Skip to content

Commit f5b7cbd

Browse files
committed
Implement IAM permissions required for pull through cache with ECR
1 parent cc8a7fc commit f5b7cbd

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

templates/aws-stack.yml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ Parameters:
575575
Default: ""
576576

577577
RootVolumeType:
578-
Description: Type of root volume to use
578+
Description: Type of root volume to use. If you are specifying `io1` or `io2`, you will most likely want to specify `RootVolumeIOPS` as well.
579579
Type: String
580580
Default: "gp3"
581581

@@ -651,11 +651,13 @@ Parameters:
651651

652652
ECRAccessPolicy:
653653
Type: String
654-
Description: ECR access policy to give container instances
654+
Description: ECR access policy to give instances. The `-pullthrough` variants add ECR pull-through cache permissions (including `ecr:CreateRepository`, `ecr:BatchImportUpstreamImage`, `ecr:GetImageCopyStatus`, and upload permissions) to enable transparent upstream registry caching.
655655
AllowedValues:
656656
- none
657657
- readonly
658+
- readonly-pullthrough
658659
- poweruser
660+
- poweruser-pullthrough
659661
- full
660662
Default: "none"
661663

@@ -1015,6 +1017,11 @@ Conditions:
10151017
UseECR:
10161018
!Not [ !Equals [ !Ref ECRAccessPolicy, "none" ] ]
10171019

1020+
AddECRPullThrough:
1021+
!Or
1022+
- !Equals [ !Ref ECRAccessPolicy, "readonly-pullthrough" ]
1023+
- !Equals [ !Ref ECRAccessPolicy, "poweruser-pullthrough" ]
1024+
10181025
UseCustomerManagedParameterPath:
10191026
!Not [ !Equals [ !Ref BuildkiteAgentTokenParameterStorePath, "" ] ]
10201027
UseCustomerManagedKeyForParameterStore:
@@ -1116,10 +1123,12 @@ Conditions:
11161123

11171124
Mappings:
11181125
ECRManagedPolicy:
1119-
none : { Policy: '' }
1120-
readonly : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly' }
1121-
poweruser : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser' }
1122-
full : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess' }
1126+
none : { Policy: '' }
1127+
readonly : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly' }
1128+
readonly-pullthrough : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly' }
1129+
poweruser : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser' }
1130+
poweruser-pullthrough : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser' }
1131+
full : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess' }
11231132

11241133
# Generated from Makefile via build/mappings.yml
11251134
AWSRegion2AMI: { linuxamd64: !Ref ImageId, linuxarm64: !Ref ImageId, windows: !Ref ImageId }
@@ -1283,6 +1292,23 @@ Resources:
12831292
- !Ref 'AWS::NoValue'
12841293
- !Ref 'AWS::NoValue'
12851294
Policies:
1295+
- !If
1296+
- AddECRPullThrough
1297+
- PolicyName: ECRPullThrough
1298+
PolicyDocument:
1299+
Version: '2012-10-17'
1300+
Statement:
1301+
- Effect: Allow
1302+
Action:
1303+
- ecr:CreateRepository
1304+
- ecr:BatchImportUpstreamImage
1305+
- ecr:GetImageCopyStatus
1306+
- ecr:InitiateLayerUpload
1307+
- ecr:UploadLayerPart
1308+
- ecr:CompleteLayerUpload
1309+
- ecr:PutImage
1310+
Resource: "*"
1311+
- !Ref 'AWS::NoValue'
12861312
- !If
12871313
- HasPipelineSigningKMSKey
12881314
- PolicyName: PipelineSigningKMSKeyAccess

0 commit comments

Comments
 (0)