Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
AWS SAM を CircleCI でデプロイさせよう #circlecijp #デプ...
Search
Takaaki Tanaka
August 05, 2019
Technology
1
130
AWS SAM を CircleCI でデプロイさせよう #circlecijp #デプロイしNight
デプロイしNight in 福岡 での発表資料です。 #circlecijp #デプロイしNight
Takaaki Tanaka
August 05, 2019
Tweet
Share
More Decks by Takaaki Tanaka
See All by Takaaki Tanaka
AWS re:Invent 2024 ふりかえり
kongmingstrap
0
170
製造の課題に立ち向かう Manufacturing Data Engine と Manufacturing Connect の ご紹介
kongmingstrap
0
700
Tellus の衛星データを見てみよう #mf_fukuoka
kongmingstrap
0
640
JAWS-UG 福岡 #16 re:Invent 現地に行った人のお話 #jawsugfuk #jawsug
kongmingstrap
0
520
AppMod の開発のイマを知るために現地に潜入した私が見たものは・・・? #GoogleCloudNext
kongmingstrap
0
570
Kong Gateway から読みとく、 API統合・API連携サービスの最新情報 #devio2023
kongmingstrap
0
1.6k
Cloud Run に憧れて Google Cloud を推進している話 / CX事業本部で使われている技術
kongmingstrap
0
230
AWS / Google Cloud / Azure それぞれの推しサービス.pdf
kongmingstrap
0
1.4k
CPUブーストの話
kongmingstrap
0
70
Other Decks in Technology
See All in Technology
#TRG24 / David Cuartielles / Post Open Source
tarugoconf
0
590
デジタルアイデンティティ技術 認可・ID連携・認証 応用 / 20250114-OIDF-J-EduWG-TechSWG
oidfj
2
700
【Oracle Cloud ウェビナー】2025年のセキュリティ脅威を読み解く:リスクに備えるためのレジリエンスとデータ保護
oracle4engineer
PRO
1
100
.NET 最新アップデート ~ AI とクラウド時代のアプリモダナイゼーション
chack411
0
200
2025年の挑戦 コーポレートエンジニアの技術広報/techpr5
nishiuma
0
150
2025年に挑戦したいこと
molmolken
0
170
EMConf JP の楽しみ方 / How to enjoy EMConf JP
pauli
2
150
When Windows Meets Kubernetes…
pichuang
0
310
なぜfreeeはハブ・アンド・スポーク型の データメッシュアーキテクチャにチャレンジするのか?
shinichiro_joya
2
510
カップ麺の待ち時間(3分)でわかるPartyRockアップデート
ryutakondo
0
140
Copilotの力を実感!3ヶ月間の生成AI研修の試行錯誤&成功事例をご紹介。果たして得たものとは・・?
ktc_shiori
0
360
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
6
55k
Featured
See All Featured
Music & Morning Musume
bryan
46
6.3k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
RailsConf 2023
tenderlove
29
970
Designing on Purpose - Digital PM Summit 2013
jponch
116
7.1k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3.1k
Practical Orchestrator
shlominoach
186
10k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
How GitHub (no longer) Works
holman
312
140k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Six Lessons from altMBA
skipperchong
27
3.6k
Become a Pro
speakerdeck
PRO
26
5.1k
Transcript
"844".Λ $JSDMF$*ͰσϓϩΠͤ͞Α͏ ݄ σϓϩΠ͠Night in Ԭ
ࣗݾհ wΫϥεϝιουגࣜձࣾ wԬΦϑΟεॴଐ w$9ࣄۀຊ෦ wϞόΠϧΞϓϦΤϯδχΞ wαʔόʔαΠυΞϓϦΤϯδχΞ ాத໌ @kongmingtrap
ࠓճͷٞ • αʔόʔϨεΞϓϦέʔγϣϯ • AWS SAM ͱαʔόʔϨεΞϓϦέʔγϣϯ •
AWS SAM ͱ CircleCI ͷΈ߹Θͤ
αʔόʔϨεΞϓϦέʔγϣϯ
αʔόʔϨεͷϝϦοτ • αʔόʔͷཧ͕ෆཁ • ॊೈੑͷ͋ΔεέʔϦϯά • Ձʹର͢Δࢧ͍ •
ߴՄ༻ੑͷࣗಈԽ https://aws.amazon.com/jp/serverless/
αʔόʔϨεΞϓϦέʔγϣϯΛߏ͢ΔͨΊͷαʔϏεʢҰ෦ʣ • AWS Lambda • Amazon API Gateway
• Amazon Kinesis • Amazon CloudWatch • Amazon S3 • Amazon DynamoDB • AWS Step Functions • Amazon Simple Queue Service • Amazon Athena • AWS Glue …etc
AWS Lambda • αʔόʔͷϓϩϏδϣχϯάɺεέʔϦϯά ཧ͕ෆཁ • ։ൃऀαʔόʔϥϯλΠϜͷཧɺૢ࡞ʹ Θ͞Εͣɺίʔυʹूத͢Δ͜ͱ͕Ͱ͖Δ
• ར༻Ͱ͖Δݴޠ͕๛ • Ruby / Node.js / Python / Java / Go / C# / PowerShell • Custom RuntimesΛར༻͢ΕɺҙͷݴޠΛ ಈ࡞ͤ͞Δ͜ͱ͕Մೳ https://aws.amazon.com/jp/lambda/
Amazon API Gateway • ಠࣗͷ REST ͓Αͼ WebSocket
API Λ࡞ɺ ެ։ɺอकɺϞχλϦϯάɺอޢͰ͖Δ • ಠࣗͷΫϥΠΞϯτΞϓϦέʔγϣϯ (ΞϓϦ) Ͱ༻͢ΔͨΊͷ API Λ࡞Ͱ͖Δ https://aws.amazon.com/jp/api-gateway/
Amazon Kinesis • ͋ΒΏΔنͷετϦʔϛϯάσʔλΛίετ ޮྑ͘ॲཧ͢ΔͨΊͷओཁػೳΛఏڙ • ετϦʔϛϯάσʔλΛϦΞϧλΠϜͰऔಘɺ όοϑΝɺॲཧ͢ΔͨΊɺ௨ৗ͔࣌ؒΒ
͔͔ΔΠϯαΠτͷੜΛඵ͔ΒͰ ྃ • ΠϯϑϥετϥΫνϟΛཧ͢Δඞཁͳ͘ɺε τϦʔϛϯάΞϓϦέʔγϣϯΛ࣮ߦͰ͖Δ https://aws.amazon.com/jp/kinesis/
Amazon CloudWatch • ओཁͳϝτϦΫεͱϩάͷϞχλϦϯάɺΞϓ Ϧέʔγϣϯ͓ΑͼΠϯϑϥετϥΫνϟελο ΫͷՄࢹԽɺΞϥʔϜͷ࡞ɺ͓ΑͼϝτϦΫ εͱϩάͷؔ࿈͚ʹΑͬͯɺύϑΥʔϚϯε ͷͷࠜຊతݪҼΛѲ
• ΞϥʔϜͷઃఆࣗಈԽ͞ΕͨΞΫγϣϯΛى ͜͢ • ϩάΛ͘͢ൃݟɺੳɺࢹ֮Խ͢Δ͜ͱͰ ӡ༻্ͷʹରॲ͘͢͢͠Δ https://aws.amazon.com/jp/cloudwatch/
αʔϏεΛΈ߹ΘͤͯΞϓϦέʔγϣϯΛߏங https://docs.aws.amazon.com/ja_jp/AmazonCloudWatch/latest/events/ WhatIsCloudWatchEvents.html • લड़ͨ͠αʔϏεΛΈΘͤͯɺػೳΛ࣮͍ͯ͘͠ AM 2:00 ʹ࣮ߦ
ͱ͋ΔҊ݅ • σόΠεʹରͯ͠ɺ֎෦API͔Βঢ়ଶΛมԽͤ͞Δ • ଟͷσόΠεͷঢ়ଶ͔Βɺঢ়ଶ͕มԽͨ͠ͷʹରͯ͠ಛ ఆͷΞΫγϣϯΛى͜͢ • σόΠεͷঢ়ଶΛมԽΛऔಘ͠ଓ͚Δ
• ͦͷͷऴྃޙͷσόΠεͷঢ়ଶΛදͨ͠σʔλΛՃ͠ɺ ՄࢹԽ͢Δ
AWS IoT • Πϯλʔωοτʹଓͨ͠σόΠεͱAWSͷ αʔϏεΛηΩϡΞʹ௨৴ͤ͞ΔΈΛఏڙ • σόΠεͷࢦྩɺσόΠε͔ΒͷσʔλΛड ͚औΓɺAWSͷαʔϏεڮ͠Λߦ͏
• ؔ࿈͢ΔαʔϏε • AWS IoT Core • AWS IoT Device Defender • AWS IoT Analytics https://docs.aws.amazon.com/ja_jp/iot/latest/developerguide/what-is-aws-iot.html
AWS IoT ϧʔϧ
AWS IoT ϧʔϧ SELECT * FROM '$aws/things/+/shadow/update' WHERE
state.reported.power = True
AWS IoT ϧʔϧ \ TUBUF\ SFQPSUFE\ QPXFSl0/ ^
^ ^ SELECT * FROM '$aws/things/+/shadow/update' WHERE state.reported.power = True ࢦఆͨ͠τϐοΫ σʔλΛૹ৴
AWS IoT ϧʔϧ \ TUBUF\ SFQPSUFE\ QPXFSl0/ ^
^ ^ SELECT * FROM '$aws/things/+/shadow/update' WHERE state.reported.power = True ϧʔϧʹϚον
AWS IoT ϧʔϧ \ TUBUF\ SFQPSUFE\ QPXFSl0/ ^
^ ^ SELECT * FROM '$aws/things/+/shadow/update' WHERE state.reported.power = True ϧʔϧʹઃఆ͞Εͨ ΞΫγϣϯΛ࣮ߦ͢Δ
AWS IoT ϧʔϧ SELECT * FROM '$aws/things/+/shadow/update/documents'
AWS IoT ϧʔϧ SELECT * FROM '$aws/things/+/shadow/update/documents'
AWS IoT ϧʔϧ SELECT * FROM '$aws/things/+/shadow/update/documents' σʔλΛ֨ೲ͢ΔΞΫγϣ
ϯΛඥ͚ͮͨผͷϧʔϧ
AWS IoT ϧʔϧ SELECT * FROM '$aws/things/+/shadow/update/documents' σʔλΛ֨ೲ͢ΔΞΫγϣ
ϯΛඥ͚ͮͨผͷϧʔϧ ෳͷτϐοΫͱϧʔϧΛΈ߹Θ ͤͯɺΞΫγϣϯΛઃఆ͍ͯ͘͠
AWS SAMͱ αʔόʔϨεΞϓϦέʔγϣϯ
։ൃͱӡ༻ͷฒߦ • ػೳ։ൃͱӡ༻։ൃऀ͕ฒߦͯ͠ߦ͏߹͕ଟ͍ • ܞΘ͍ͬͯΔҊ݅։ൃνʔϜɾӡ༻νʔϜͳͲͷׂ୲ Λ͍ͯ͠ͳ͍ • εύΠΫΞΫηεͷରԠͳͲɺϚωʔδυαʔϏεʹد͍ͤͯ
Δ෦ͷରԠෆཁ͕ͩɺͦͷ݁ՌΛ౿·͑ͯػೳΛߟྀ͢ Δ߹͋Δ • ϚΠΫϩαʔϏεΛΈ߹ΘͤΔ্Ͱͷ։ൃɾӡ༻ͷઃܭ͕؊ ཁ
AWS αʔόʔϨεΞϓϦέʔγϣϯϞσϧ (AWS SAM) ͷ༻ • αʔόʔϨεΞϓϦέʔγϣϯʹదͨ͠ॻࣜͰ AWS
CloudFromation ͷ Stack Λग़ྗͯ͘͠ΕΔ • SwaggerͷఆٛΛݩʹ Amazon API Gateway ͷઃఆ͕ߦ͑Δ • API༷ͱ࣮ͷဃΛ͙ • AWS CloudFormation ςϯϓϨʔτͱಉ༷ͰɺΈࠐΈؔ ͳͲ͕͑Δ • ผͷϦʔδϣϯผͷAWSΞΧϯτʹΞϓϦέʔγϣϯͷ σϓϩΠΛߦ͑ΔΑ͏ʹ͢Δ https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/serverless_app.html
AWS SAM sam.yml AWSΞΧϯτB AWSΞΧϯτA AWSΞΧϯτC
AWS SAM sam.yml AWSΞΧϯτB AWSΞΧϯτA AWSΞΧϯτC AWSΞΧϯτB ίϚϯυ࣮ߦ
AWS SAM sam.yml AWSΞΧϯτB AWSΞΧϯτA AWSΞΧϯτC CloudFormationͷ Stackʹม
AWS SAM sam.yml AWSΞΧϯτB AWSΞΧϯτA AWSΞΧϯτC AWSͷϦιʔεΛల։
AWS SAM sam.yml AWSΞΧϯτB AWSΞΧϯτA AWSΞΧϯτC AWSΞΧϯτA ίϚϯυ࣮ߦ
AWS SAM sam.yml AWSΞΧϯτB AWSΞΧϯτA AWSΞΧϯτC CloudFormationͷ Stackʹม
AWS SAM sam.yml AWSΞΧϯτB AWSΞΧϯτA AWSΞΧϯτC
AWS SAM sam.yml AWSΞΧϯτB AWSΞΧϯτA AWSΞΧϯτC
AWS SAM ͷه๏ͷྫ • Amazon CloudWatch Events +
AWS Lambdaͷྫ AM 2:00 ʹ࣮ߦ
AWS SAM ͷه๏ͷྫ • Amazon CloudWatch Events +
AWS Lambdaͷྫ AM 2:00 ʹ࣮ߦ TimerEventFunction: Type: AWS::Serverless::Function Properties: FunctionName: timer-event-function CodeUri: src/handlers/timer_event Handler: index.handler Runtime: python3.7 Policies: - arn:aws:iam::aws:policy/AmazonS3FullAccess Events: Schedule: Type: Schedule Properties: Schedule: cron(0 17 * * ? *) sam.yml
AWS SAM ͷه๏ͷྫ • Amazon CloudWatch Events +
AWS Lambdaͷྫ AM 2:00 ʹ࣮ߦ TimerEventFunction: Type: AWS::Serverless::Function Properties: FunctionName: timer-event-function CodeUri: src/handlers/timer_event Handler: index.handler Runtime: python3.7 Policies: - arn:aws:iam::aws:policy/AmazonS3FullAccess Events: Schedule: Type: Schedule Properties: Schedule: cron(0 17 * * ? *) sam.yml AWS LambdaΛඥ͚ͮΔ Πϕϯτͷઃఆ
AWS SAM ͷه๏ͷྫ • Amazon CloudWatch Events +
AWS Lambdaͷྫ AM 2:00 ʹ࣮ߦ TimerEventFunction: Type: AWS::Serverless::Function Properties: FunctionName: timer-event-function CodeUri: src/handlers/timer_event Handler: index.handler Runtime: python3.7 Policies: - arn:aws:iam::aws:policy/AmazonS3FullAccess Events: Schedule: Type: Schedule Properties: Schedule: cron(0 17 * * ? *) sam.yml
ʢຊʣ AWS SAM ͱ CricleCI ͷΈ߹Θͤ
CircleCIͱͷΈ߹Θͤ • AWS SAM ͱ CircleCI ΛΈ߹ΘͤͯɺϢχοτςετɹˠ σϓϩΠ
→ e2eςετ ·ͰΛҰ؏ͯ͠ߦ͏ • Approval ͳͲͷػೳΛར༻͠ɺຊ൪ڥద༻ͳͲΛҰ࿈ͷ ϫʔΫϑϩʔͰߦ͑ΔΑ͏ʹ͢Δ sam.yml
δϣϒ ͱ ϫʔΫϑϩʔ IUUQTDJSDMFDJDPNEPDTXPSLqPXT • Ϣχοτςετɺ σϓϩΠɺ e2eςετ
ͳͲΛ δϣϒ ͱ͍ ͏୯ҐͰ࡞Ͱ͖Δ • ϫʔΫϑϩʔ δϣϒ ͷॲཧͷෳࡶͳखॱʢྻɾฒߦ࣮ ߦͳͲʣΛ౿ΉΑ͏ͳϑϩʔΛදݱͰ͖Δ
αϯϓϧίʔυ IUUQTHJUIVCDPNLPOHNJOHTUSBQ4MBDL/PUJpFS4BNQMFS
.circleci/config.yml ʹ δϣϒ Λఆٛ IUUQTHJUIVCDPNLPOHNJOHTUSBQ4MBDL/PUJpFS4BNQMFSCMPCNBTUFSDJSDMFDJDPOpHZNM--
.circleci/config.yml ʹ δϣϒ Λఆٛ IUUQTHJUIVCDPNLPOHNJOHTUSBQ4MBDL/PUJpFS4BNQMFSCMPCNBTUFSDJSDMFDJDPOpHZNM--
Makefile ͳͲʹ AWS SAM ίϚϯυ Λఆٛ IUUQTHJUIVCDPNLPOHNJOHTUSBQ4MBDL/PUJpFS4BNQMFSCMPCNBTUFS.BLFpMF--
δϣϒ͔Β Makefile ͷίϚϯυΛݺͿΑ͏ʹ͢Δ IUUQTHJUIVCDPNLPOHNJOHTUSBQ4MBDL/PUJpFS4BNQMFSCMPCNBTUFSDJSDMFDJDPOpHZNM-
ϫʔΫϑϩʔͷ࡞ IUUQTHJUIVCDPNLPOHNJOHTUSBQ4MBDL/PUJpFS4BNQMFSCMPCNBTUFSDJSDMFDJDPOpHZNM- • ࡞ͨ͠ δϣϒ ΛݺͿॱ൪Λ ϫʔΫϑϩʔ ͱͯ͠࡞͢Δ
ϫʔΫϑϩʔͷ࡞ • ࡞ͨ͠ δϣϒ ΛݺͿॱ൪Λ ϫʔΫϑϩʔ ͱͯ͠࡞͢Δ IUUQTHJUIVCDPNLPOHNJOHTUSBQ4MBDL/PUJpFS4BNQMFSCMPCNBTUFSDJSDMFDJDPOpHZNM--
CircleCIͱͷΈ߹Θͤ https://circleci.com/docs/2.0/workflows/ • ϫʔΫϑϩʔͷྫ
CircleCIͱͷΈ߹Θͤ https://circleci.com/docs/2.0/workflows/ Ϣχοτςετ Λߦ͏ • ϫʔΫϑϩʔͷྫ
CircleCIͱͷΈ߹Θͤ https://circleci.com/docs/2.0/workflows/ Ϣχοτςετ Λߦ͏ • ϫʔΫϑϩʔͷྫ
CircleCIͱͷΈ߹Θͤ https://circleci.com/docs/2.0/workflows/ Ϣχοτςετ Λߦ͏ ։ൃڥͷσϓ ϩΠͱe2eςετ • ϫʔΫϑϩʔͷྫ
CircleCIͱͷΈ߹Θͤ https://circleci.com/docs/2.0/workflows/ Ϣχοτςετ Λߦ͏ ։ൃڥͷσϓ ϩΠͱe2eςετ ຊ൪ڥͷద༻ Λߦ͏
• ϫʔΫϑϩʔͷྫ
Approval Ͱຊ൪ద༻ͷ δϣϒ ΛͨͤΔ IUUQTDJSDMFDJDPNEPDTXPSLqPXT • ࣍ͷ δϣϒ
ʹਐΉલʹɺ δϣϒ ͷ खಈঝೝ ΛͭΑ͏ʹ ϫʔΫϑϩʔ ΛߏͰ͖Δ • ϦϙδτϦͷϓογϡΞΫηεݖΛ͍࣋ͬͯΔਓͳΒ୭Ͱ ঝೝϘλϯ ΛΫϦοΫͯ͠ ϫʔΫϑϩʔ Λଓ͚Δ͜ͱ͕ Ͱ͖Δ
Approval Ͱຊ൪ద༻ͷ δϣϒ ΛͨͤΔ IUUQTHJUIVCDPNLPOHNJOHTUSBQ4MBDL/PUJpFS4BNQMFSCMPCNBTUFSDJSDMFDJDPOpHZNM-
CircleCIͱͷΈ߹Θͤ https://circleci.com/docs/2.0/workflows/ ຊ൪ద༻ͷ࣮ߦ ApprovalͰͨͤΔ • ϫʔΫϑϩʔͷྫ
CircleCIͱͷΈ߹Θͤ https://circleci.com/docs/2.0/workflows/ • ϫʔΫϑϩʔͷྫ
ঝೝૢ࡞ʹΑΔຊ൪ద༻ sam.yml AWSΞΧϯτB AWSΞΧϯτA AWSΞΧϯτC
ঝೝૢ࡞ʹΑΔຊ൪ద༻ sam.yml AWSΞΧϯτB AWSΞΧϯτA AWSΞΧϯτC
࣍ੈߏ
AWS CDK ͷ׆༻ IUUQTHJUIVCDPNLPOHNJOHTUSBQ4MBDL/PUJpFS4BNQMFSCMPCNBTUFSDJSDMFDJDPOpHZNM- • AWS CDK (Cloud
Development Kit) • AWS ϦιʔεΛ ߏཁૉ(construct) ͱͯ͠ϓϩάϥϜͰॻ ͖ɺͦΕΒΛΈ߹Θ࣮ͤͯߦ͢ΔͱσϓϩΠͰ͖Δͱ͍͏ πʔϧΩοτɻ • AWSͷΠϯϑϥΛ TypeScript ͳͲͷϓϩάϥϛϯάݴޠΛ ͬͯఆٛɾσϓϩΠ͢Δɻ • CDKϓϩάϥϜΛ࣮ߦ͢Δ͜ͱͰ CloudFormation ςϯϓ ϨʔτΛੜɺͦͷςϯϓϨʔτΛͬͯσϓϩΠ͢Δɻ
·ͱΊ
·ͱΊ • CircleCI ͷ δϣϒ ͱ ϫʔΫϑϩʔ ΛΈ߹ΘͤͯαʔόʔϨ
εΞϓϦέʔγϣϯͷ Ϣχοτςετ → σϓϩΠ → e2eς ετ ΛҰ؏ͯ͠ߦ͑Δ • ຊ൪ద༻ͳͲͷঝೝ͕ඞཁͳϑϩʔʹ͍ͭͯ Approval ͱఆ ٛ͢Δ͜ͱͰՄೳͱͳΔ • ΑΓΠϯϑϥΛίʔυͰཧ͘͢͠ͳΔ
None