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
290
Httpリクエストを自動リトライ・ポーリングするイテレータを作ってみた
miyamo2
0
210
Other Decks in Programming
See All in Programming
JRuby: Past, Present, and Future
headius
0
230
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
580
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
400
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
240
phperだってパンチカードでコーディングしたい
o0h
PRO
0
280
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
110
CodeRabbitの効果検証と過ごしてみた3ヶ月
armondando
0
230
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
730
Kubernetes祭り #2 OP/ED
bells17
0
110
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
パーソナライズPodcastを作った話
repunit11
0
140
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
330
Featured
See All Featured
Visualization
eitanlees
153
17k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
350
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
470
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
530
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
400
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
590
Crafting Experiences
bethany
1
380
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
43k
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