Skip to content

Instantly share code, notes, and snippets.

@DerPauli
Created April 25, 2020 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DerPauli/bbdd7eb437b77e94cc07a8b08435665e to your computer and use it in GitHub Desktop.
Save DerPauli/bbdd7eb437b77e94cc07a8b08435665e to your computer and use it in GitHub Desktop.
IAM ECR
resource "aws_iam_access_key" "iam-key-ecr-deploy" {
user = aws_iam_user.iam-ecr-deploy.name
pgp_key = var.iam_pgp_ecr_deploy
}
resource "aws_iam_user" "iam-ecr-deploy" {
name = var.iam_user_name_ecr_auth
}
resource "aws_iam_user_policy" "iam-policy-ecr-deploy" {
name = var.iam_policy_ecr_deploy_name
user = aws_iam_user.iam-ecr-deploy.name
policy = <<EOF
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"ListImagesInRepository",
"Effect":"Allow",
"Action":[
"ecr:ListImages"
],
"Resource":"${var.ecr_auth_ms.arn}"
},
{
"Sid":"GetAuthorizationToken",
"Effect":"Allow",
"Action":[
"ecr:GetAuthorizationToken"
],
"Resource":"*"
},
{
"Sid":"ManageRepositoryContents",
"Effect":"Allow",
"Action":[
"ecr:GetAuthorizationToken",
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:GetRepositoryPolicy",
"ecr:DescribeRepositories",
"ecr:ListImages",
"ecr:DescribeImages",
"ecr:BatchGetImage",
"ecr:InitiateLayerUpload",
"ecr:UploadLayerPart",
"ecr:CompleteLayerUpload",
"ecr:PutImage"
],
"Resource":"${var.ecr_auth_ms.arn}"
}
]
}
EOF
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment