Configures an AWS Elastic Container Registry policy to allow image replication.

Terraform Template

data "aws_caller_identity" "current" {
}

data "aws_partition" "current" {
}

data "aws_region" "current" {
}

resource "aws_ecr_registry_policy" "example" {
  policy = jsonencode({
 Version = "2012-10-17",
 Statement = [
 {
 Sid = "testpolicy",
 Effect = "Allow",
 Principal = {
 "AWS" : "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:root"
 },
 Action = [
 "ecr:ReplicateImage"
 ],
 Resource = [
 "arn:${data.aws_partition.current.partition}:ecr:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:repository/*"
 ]
 }
 ]
 })
}