【CloudFormation】ECR クロスリージョンレプリケーションを一発で作成する
本記事では、CloudFormationによるECR クロスリージョンレプリケーションのデプロイについて具体例付き解説する。

前提
リソースの名前は下記。
・ECRレジストリ:test-registory
説明
スタック作成は東京リージョンのみ。
実際のコード
レプリ先へログイン
AWSTemplateFormatVersion: 2010-09-09
##########################################################
#
# Parameter
#
##########################################################
Parameters:
AccountID:
Type: String
Default: <Account ID>
##########################################################
#
# ECR Replication
#
##########################################################
Resources:
ECRRepository:
Type: 'AWS::ECR::Repository'
Properties:
EncryptionConfiguration:
EncryptionType: KMS #KMS暗号化
ImageScanningConfiguration:
ScanOnPush: true #プッシュ時にイメージをスキャンする
ImageTagMutability: IMMUTABLE #イメージのタグを変更させない
RepositoryName: test-repository
DependsOn:
- ECRReplicationConfiguration
ECRReplicationConfiguration:
Type: 'AWS::ECR::ReplicationConfiguration'
Properties:
ReplicationConfiguration:
Rules:
- Destinations:
- Region: ap-northeast-3
RegistryId: !Sub ${AccountID}