diff --git a/templates/aws-stack.yml b/templates/aws-stack.yml index 6b0dd4329..67ce6dc79 100644 --- a/templates/aws-stack.yml +++ b/templates/aws-stack.yml @@ -369,7 +369,7 @@ Parameters: Default: "" RootVolumeType: - Description: Type of root volume to use + Description: Type of root volume to use. If you are specifying `io1` or `io2`, you will most likely want to specify `RootVolumeIOPS` as well. Type: String Default: "gp3" @@ -429,11 +429,13 @@ Parameters: ECRAccessPolicy: Type: String - Description: ECR access policy to give container instances + Description: ECR access policy to give instances. The `-pullthrough` variants add `ecr:CreateRepository` and `ecr:BatchImportUpstreamImage` which allows ECR pull through cache to work transparently. AllowedValues: - none - readonly + - readonly-pullthrough - poweruser + - poweruser-pullthrough - full Default: "none" @@ -640,6 +642,11 @@ Conditions: UseECR: !Not [ !Equals [ !Ref ECRAccessPolicy, "none" ] ] + AddECRPullThrough: + !Or + - !Equals [ !Ref ECRAccessPolicy, "readonly-pullthrough" ] + - !Equals [ !Ref ECRAccessPolicy, "poweruser-pullthrough" ] + UseCustomerManagedParameterPath: !Not [ !Equals [ !Ref BuildkiteAgentTokenParameterStorePath, "" ] ] UseCustomerManagedKeyForParameterStore: @@ -711,10 +718,12 @@ Conditions: Mappings: ECRManagedPolicy: - none : { Policy: '' } - readonly : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly' } - poweruser : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser' } - full : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess' } + none : { Policy: '' } + readonly : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly' } + readonly-pullthrough : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly' } + poweruser : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser' } + poweruser-pullthrough : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser' } + full : { Policy: 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess' } # Generated from Makefile via build/mappings.yml AWSRegion2AMI: { linuxamd64: !Ref ImageId, linuxarm64: !Ref ImageId, windows: !Ref ImageId } @@ -861,6 +870,17 @@ Resources: - !Ref 'AWS::NoValue' - !Ref 'AWS::NoValue' Policies: + - !If + - AddECRPullThrough + - PolicyName: ECRPullThrough + PolicyDocument: + Version: '2012-10-17' + Statement: + - Effect: Allow + Action: + - ecr:CreateRepository + - ecr:BatchImportUpstreamImage + - !Ref 'AWS::NoValue' - !If - UseCustomerManagedKeyForParameterStore - PolicyName: DecryptAgentToken