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 Cloud Formation Git Syncで始める 頑張らない自動デプロイ
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
miyamo2
April 26, 2024
Programming
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
AWS Cloud Formation Git Syncで始める 頑張らない自動デプロイ
20240426 社内LT用
miyamo2
April 26, 2024
More Decks by miyamo2
See All by miyamo2
Go 1.24 tool directiveは何を変えるのか
miyamo2
1
270
Httpリクエストを自動リトライ・ポーリングするイテレータを作ってみた
miyamo2
0
200
Other Decks in Programming
See All in Programming
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
200
不幸な GC
chencmd
0
870
承認済みなのに差戻しできてしまうバグ、型で潰せます
shinchit
0
130
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
410
이 함수, 실패하면 어떻게 되나요? null부터 Rich Errors까지, Kotlin 에러 처리 15년
haeti2
0
110
自分的「カンファレンスの楽しみ方」
syumai
0
180
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
800
20260828_品質と開発生産性を両立させる、AI時代のE2Eテストの考え方
magicpod
0
110
高専キャリア LT 発表内容
crysta1221
6
5.4k
ソフトウェアラスタライザ
fadis
1
780
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
950
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
130
Featured
See All Featured
A better future with KSS
kneath
240
18k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
We Have a Design System, Now What?
morganepeng
55
8.3k
Skip the Path - Find Your Career Trail
mkilby
1
220
Paper Plane
katiecoart
PRO
2
53k
Test your architecture with Archunit
thirion
2
2.4k
Become a Pro
speakerdeck
PRO
31
6.2k
SEO for Brand Visibility & Recognition
aleyda
0
4.7k
The Spectacular Lies of Maps
axbom
PRO
1
970
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
510
The Pragmatic Product Professional
lauravandoore
37
7.4k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Transcript
AWS Cloud Formation Git Syncで始める 頑張らない自動デプロイ miyamo2
話すこと - Cloud Formation/Git Syncの概要 - Git Syncの課題と解決案 話さないこと -
Cloud Formation/Git Syncの設定手順
Cloud Formation AWSリソースをYAMLもしくはJSONで管理できるIaCサービス
AWSTemplateFormatVersion: "2010-09-09" Parameters: Env: Type: String Default: dev AllowedValues: -
dev - stage - prod Resources: UserTable: Type: AWS-:DynamoDB-:Table Properties: TableName: !Sub users-${Env} AttributeDefinitions: - AttributeName: "UserId" AttributeType: "S" KeySchema: - AttributeName: "UserId" KeyType: "HASH" ProvisionedThroughput: ReadCapacityUnits: "1" WriteCapacityUnits: "1" BillingMode: PROVISIONED Outputs: UsersTableName: Value: !Ref UserTable Parameters このテンプレートで受け取るパラメータ Resources このテンプレートで生成するリソース Outputs このテンプレートが出力するリソース Cloud Formation
Cloud Formation AWSコンソールからGUIベースでポチポチ操作することも可 CI/CD製品と組み合わせて使うのが主流?
Git Sync Cloud Formationの新機能 GitリポジトリとCFnスタック(≒デプロイの粒度)を連携させることで スクリプトレスなCDを構築できる 連携しているリポジトリに用意されたパラメータ定義用ファイルを参照
Git Sync CIワークフローが必要な場合は自前で用意する必要あり on: pull_request: branches: - "連携ブランチ" 連携ブランチへ merge
Git SyncによるCD
Git Sync 課題 ①別スタック/別手順で管理されているリソースを参照する場合、 パラメータを手修正し続けるのがツラい ②そもそもパラメータを平文で管理していいの?
パラメータは原則 SSM Parameter Storeで管理する
実装例 AWSTemplateFormatVersion: "2010-09-09" Parameters: # Resources.Somethingが依存するリソース FooArn: Type: AWS-:SSM-:Parameter-:Value<String> NoEcho:
true Default: /dev/foo/arn Env: Type: String Default: dev AllowedValues: - dev - stage - prod Resources: # なにがしかのリソース Something: --. # SomethingのArnをSSM Parameter Store SomethingArnSSMParameter: Type: "AWS-:SSM-:Parameter" Properties: Tier: "Standard" Name: !Sub /${Env}/something/arn Type: "String" Value: !GetAtt Something.Arn パラメータを AWS::SSM::Parameter::Value<T> で受け取る 生成リソースを AWS::SSM::Parameterで出力 SSM Parameterのパスだけお互いに 握っていればOK
実装例 -!/bin/sh REGISTRY=$1 REPOSITORY=$2 TAG=$(git rev-parse HEAD) docker push ${
REGISTRY }/${ REPOSITORY }:${ TAG } aws ssm put-parameter \ --name /ecr/${ REGISTRY }/${ REPOSITORY }/tag \ --value ${ TAG } \ --type String \ --overwrite \ --region ap-northeast-1 CFnで管理できないリソース → シェルスクリプトでよしなに 後々GitHub ActionsなどのCI/CD製 品に移行する場合を踏まえて、コード 資産としての引き継ぎやすさを意識し たい
まとめ CDの構築を頑張らない分、運用はちょっと煩雑になりそう 以下に当てはまる場合はおすすめ - リリース頻度が高くない - とりあえずサクッと1つの環境にデプロイしたい SPA、SSRのWebフロントエンドならAmplify Hostingの方がおすすめ
参考 Working with AWS CloudFormation Git sync https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/git-sync.html CloudFormationがCD Pipelineなしで
そのままGit連携デプロイが可能に! #AWSreInvent https://dev.classmethod.jp/articles/cloudformation-git-sync-update/ miyamo2が構築したサンプル https://github.com/miyamo2/cfn-with-gitsync-dynamodb https://github.com/miyamo2/cfn-with-gitsync-lambda