Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
AWS Cloud Formation Git Syncで始める 頑張らない自動デプロイ
Search
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
210
Other Decks in Programming
See All in Programming
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
250
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
0
1.2k
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
100
AGENTS.md Is Not Enough:Build Skills, Don't Download Them
lx_t
0
110
LoopHub - ローカルで動く GitHub で、AI と共同開発
jugyo
1
550
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
110
Webの地図
yosuke_furukawa
PRO
6
4.5k
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
1
450
FreeBSDでZabbixを動かす.pdf
kenkino
0
250
アクセシビリティから考える情報設計
high_g_engineer
0
370
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
240
Family mrubyの進捗
kishima
1
120
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
55
10k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
450
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Google's AI Overviews - The New Search
badams
0
1.6k
How to Talk to Developers About Accessibility
jct
2
550
30 Presentation Tips
portentint
PRO
1
390
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
The Invisible Side of Design
smashingmag
301
52k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
420
Into the Great Unknown - MozCon
thekraken
41
2.7k
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