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
AI時代のデータセンターネットワーク
lycorptech_jp
PRO
1
290
Wantedly での Datadog 活用事例
bgpat
1
530
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
620
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
190
Opcodeを読んでいたら何故かphp-srcを読んでいた話
murashotaro
0
280
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
210
サイバー攻撃を想定したセキュリティガイドライン 策定とASM及びCNAPPの活用方法
syoshie
3
1.3k
バクラクのドキュメント解析技術と実データにおける課題 / layerx-ccc-winter-2024
shimacos
2
1.1k
20241220_S3 tablesの使い方を検証してみた
handy
4
640
ハイテク休憩
sat
PRO
2
170
pg_bigmをRustで実装する(第50回PostgreSQLアンカンファレンス@オンライン 発表資料)
shinyakato_
0
100
PHPからGoへのマイグレーション for DMMアフィリエイト
yabakokobayashi
1
170
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Designing for Performance
lara
604
68k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
99
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Gamification - CAS2011
davidbonilla
80
5.1k
Making Projects Easy
brettharned
116
5.9k
Documentation Writing (for coders)
carmenintech
66
4.5k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Designing Experiences People Love
moore
138
23k
Writing Fast Ruby
sferik
628
61k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
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