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
180
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
260
Httpリクエストを自動リトライ・ポーリングするイテレータを作ってみた
miyamo2
0
180
Other Decks in Programming
See All in Programming
AI駆動開発を妨げる技術的負債の解消アプローチ / ai-refactoring-approach
minodriven
17
8.9k
【やさしく解説 設計編・中級 #1】一つの車に、運転手は一人 ~ある倉庫システムの事例から~
panda728
PRO
0
170
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
180
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.4k
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
220
Contextとはなにか
chiroruxx
1
390
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
260
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
240
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
260
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
170
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
360
技術記事、 専門家としてのプログラマ、 言語化
mizchi
14
7.4k
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
410
Skip the Path - Find Your Career Trail
mkilby
1
170
Utilizing Notion as your number one productivity tool
mfonobong
4
380
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
320
Mobile First: as difficult as doing things right
swwweet
225
10k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
220
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1k
The Limits of Empathy - UXLibs8
cassininazir
1
460
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
350
Embracing the Ebb and Flow
colly
88
5.1k
First, design no harm
axbom
PRO
2
1.2k
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