Skip to content

Instantly share code, notes, and snippets.

@labrute974
Created October 1, 2016 21:49
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 labrute974/52da3f0273e62c6ced5bbafccee044d6 to your computer and use it in GitHub Desktop.
Save labrute974/52da3f0273e62c6ced5bbafccee044d6 to your computer and use it in GitHub Desktop.
Cloudformation_ecr_role_working
AWSTemplateFormatVersion: '2010-09-09'
Resources:
Repository:
Type: "AWS::ECR::Repository"
Properties:
RepositoryPolicyText:
Version: "2012-10-17"
Statement:
-
Sid: AllowPushPull
Effect: Allow
Principal:
AWS:
- !GetAtt [ "PushRole", "Arn" ]
Action:
- "ecr:GetDownloadUrlForLayer"
- "ecr:BatchGetImage"
- "ecr:BatchCheckLayerAvailability"
- "ecr:PutImage"
- "ecr:InitiateLayerUpload"
- "ecr:UploadLayerPart"
- "ecr:CompleteLayerUpload"
PushRole:
Type: "AWS::IAM::Role"
Properties:
Path: "/application/"
RoleName: "registry-push"
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Principal:
Service:
- "ec2.amazonaws.com"
Action:
- "sts:AssumeRole"
PushPolicy:
Type: "AWS::IAM::Policy"
Properties:
PolicyName: "registry_push"
Roles:
- !Ref PushRole
PolicyDocument:
Version: "2012-10-17"
Statement:
-
Resource: !Join [ "", [ "arn:aws:ecr:", !Ref "AWS::Region", ":", !Ref "AWS::AccountId", ":repository/", !Ref Repository ] ]
Effect: "Allow"
Action:
- "ecr:BatchDeleteImage"
- "ecr:CompleteLayerUpload"
- "ecr:InitiateLayerUpload"
- "ecr:ListImages"
- "ecr:PutImage"
- "ecr:UploadLayerPart"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment