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
130
製造の課題に立ち向かう Manufacturing Data Engine と Manufacturing Connect の ご紹介
kongmingstrap
0
660
Tellus の衛星データを見てみよう #mf_fukuoka
kongmingstrap
0
610
JAWS-UG 福岡 #16 re:Invent 現地に行った人のお話 #jawsugfuk #jawsug
kongmingstrap
0
510
AppMod の開発のイマを知るために現地に潜入した私が見たものは・・・? #GoogleCloudNext
kongmingstrap
0
560
Kong Gateway から読みとく、 API統合・API連携サービスの最新情報 #devio2023
kongmingstrap
0
1.6k
Cloud Run に憧れて Google Cloud を推進している話 / CX事業本部で使われている技術
kongmingstrap
0
220
AWS / Google Cloud / Azure それぞれの推しサービス.pdf
kongmingstrap
0
1.3k
CPUブーストの話
kongmingstrap
0
62
Other Decks in Technology
See All in Technology
10個のフィルタをAXI4-Streamでつなげてみた
marsee101
0
170
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
270
ハイテク休憩
sat
PRO
2
160
podman_update_2024-12
orimanabu
1
280
20241214_WACATE2024冬_テスト設計技法をチョット俯瞰してみよう
kzsuzuki
3
530
社外コミュニティで学び社内に活かす共に学ぶプロジェクトの実践/backlogworld2024
nishiuma
0
270
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
17
15k
非機能品質を作り込むための実践アーキテクチャ
knih
5
1.5k
なぜCodeceptJSを選んだか
goataka
0
160
GitHub Copilot のテクニック集/GitHub Copilot Techniques
rayuron
37
15k
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
590
バクラクのドキュメント解析技術と実データにおける課題 / layerx-ccc-winter-2024
shimacos
2
1.1k
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
We Have a Design System, Now What?
morganepeng
51
7.3k
Statistics for Hackers
jakevdp
796
220k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Speed Design
sergeychernyshev
25
670
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Building an army of robots
kneath
302
44k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
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