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
620
Tellus の衛星データを見てみよう #mf_fukuoka
kongmingstrap
0
590
JAWS-UG 福岡 #16 re:Invent 現地に行った人のお話 #jawsugfuk #jawsug
kongmingstrap
0
490
AppMod の開発のイマを知るために現地に潜入した私が見たものは・・・? #GoogleCloudNext
kongmingstrap
0
540
Kong Gateway から読みとく、 API統合・API連携サービスの最新情報 #devio2023
kongmingstrap
0
1.5k
Cloud Run に憧れて Google Cloud を推進している話 / CX事業本部で使われている技術
kongmingstrap
0
210
AWS / Google Cloud / Azure それぞれの推しサービス.pdf
kongmingstrap
0
1.3k
CPUブーストの話
kongmingstrap
0
53
私のAWS愛を聞け! ~ここが好きだよStep Functions~ #devio2022
kongmingstrap
0
1.1k
Other Decks in Technology
See All in Technology
Taming you application's environments
salaboy
0
190
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
220
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
2
3.2k
Amazon Personalizeのレコメンドシステム構築、実際何するの?〜大体10分で具体的なイメージをつかむ〜
kniino
1
100
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
1
110
DynamoDB でスロットリングが発生したとき_大盛りver/when_throttling_occurs_in_dynamodb_long
emiki
1
420
Lambdaと地方とコミュニティ
miu_crescent
2
370
SREによる隣接領域への越境とその先の信頼性
shonansurvivors
2
520
サイバーセキュリティと認知バイアス:対策の隙を埋める心理学的アプローチ
shumei_ito
0
390
プロダクト活用度で見えた真実 ホリゾンタルSaaSでの顧客解像度の高め方
tadaken3
0
150
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
50
7.2k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Designing for Performance
lara
604
68k
A Modern Web Designer's Workflow
chriscoyier
693
190k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Building Your Own Lightsaber
phodgson
103
6.1k
What's in a price? How to price your products and services
michaelherold
243
12k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
What's new in Ruby 2.0
geeforr
343
31k
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