Skip to content

Commit 49ea263

Browse files
authored
fix(bootstrap): rebootstrap breaks container Functions (#19446)
Container Functions automatically add a policy to an ECR repository to allow Lambda to pull from it; however, when the ECR repository is rebootstrapped and has changed, the policy might be overwritten. Add the policy to the bootstrap stack, so we don't have to rely on Lambda to add it and it will survive rebootstraps. This introduces version 11 of the bootstrap stack. You do not need to upgrade to this version unless you are affected by this issue. Fixes #18473. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 6b0cacd commit 49ea263

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/aws-cdk/lib/api/bootstrap/bootstrap-template.yaml

+15-1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,20 @@ Resources:
209209
- HasCustomContainerAssetsRepositoryName
210210
- Fn::Sub: "${ContainerAssetsRepositoryName}"
211211
- Fn::Sub: cdk-${Qualifier}-container-assets-${AWS::AccountId}-${AWS::Region}
212+
RepositoryPolicyText:
213+
Version: "2012-10-17"
214+
Statement:
215+
# Necessary for Lambda container images
216+
# https://docs.aws.amazon.com/lambda/latest/dg/configuration-images.html#configuration-images-permissions
217+
- Sid: LambdaECRImageRetrievalPolicy
218+
Effect: Allow
219+
Principal: { Service: "lambda.amazonaws.com" }
220+
Action:
221+
- ecr:BatchGetImage
222+
- ecr:GetDownloadUrlForLayer
223+
Condition:
224+
StringLike:
225+
"aws:sourceArn": { "Fn::Sub": "arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:function:*" }
212226
FilePublishingRole:
213227
Type: AWS::IAM::Role
214228
Properties:
@@ -493,7 +507,7 @@ Resources:
493507
Type: String
494508
Name:
495509
Fn::Sub: '/cdk-bootstrap/${Qualifier}/version'
496-
Value: '10'
510+
Value: '11'
497511
Outputs:
498512
BucketName:
499513
Description: The name of the S3 bucket owned by the CDK toolkit stack

0 commit comments

Comments
 (0)