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
120
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
製造の課題に立ち向かう Manufacturing Data Engine と Manufacturing Connect の ご紹介
kongmingstrap
0
590
Tellus の衛星データを見てみよう #mf_fukuoka
kongmingstrap
0
580
JAWS-UG 福岡 #16 re:Invent 現地に行った人のお話 #jawsugfuk #jawsug
kongmingstrap
0
480
AppMod の開発のイマを知るために現地に潜入した私が見たものは・・・? #GoogleCloudNext
kongmingstrap
0
530
Kong Gateway から読みとく、 API統合・API連携サービスの最新情報 #devio2023
kongmingstrap
0
1.5k
Cloud Run に憧れて Google Cloud を推進している話 / CX事業本部で使われている技術
kongmingstrap
0
200
AWS / Google Cloud / Azure それぞれの推しサービス.pdf
kongmingstrap
0
1.3k
CPUブーストの話
kongmingstrap
0
45
私のAWS愛を聞け! ~ここが好きだよStep Functions~ #devio2022
kongmingstrap
0
1.1k
Other Decks in Technology
See All in Technology
物価高なラスベガスでの過ごし方
zakky
0
380
来年もre:Invent2024 に行きたいあなたへ - “集中”と“つながり”で楽しむ -
ny7760
0
470
ガバメントクラウド先行事業中間報告を読み解く
sugiim
1
1.4k
【若手エンジニア応援LT会】AWS Security Hubの活用に苦労した話
kazushi_ohata
0
170
新卒1年目が挑む!生成AI × マルチエージェントで実現する次世代オンボーディング / operation-ai-onboarding
cyberagentdevelopers
PRO
1
170
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
290k
分布で見る効果検証入門 / ai-distributional-effect
cyberagentdevelopers
PRO
4
700
現地でMeet Upをやる場合の注意点〜反省点を添えて〜
shotashiratori
0
530
ユーザーの購買行動モデリングとその分析 / dsc-purchase-analysis
cyberagentdevelopers
PRO
2
100
急成長中のWINTICKETにおける品質と開発スピードと向き合ったQA戦略と今後の展望 / winticket-autify
cyberagentdevelopers
PRO
1
160
大規模データ基盤チームのオンプレTiDB運用への挑戦 / dpu-tidb
cyberagentdevelopers
PRO
1
110
顧客が本当に必要だったもの - パフォーマンス改善編 / Make what is needed
soudai
24
6.8k
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
243
12k
Become a Pro
speakerdeck
PRO
24
5k
Designing for Performance
lara
604
68k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Statistics for Hackers
jakevdp
796
220k
BBQ
matthewcrist
85
9.3k
Bash Introduction
62gerente
608
210k
We Have a Design System, Now What?
morganepeng
50
7.2k
Building Better People: How to give real-time feedback that sticks.
wjessup
363
19k
Learning to Love Humans: Emotional Interface Design
aarron
272
40k
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