Skip to content

Commit

Permalink
feat(bootstrap): Add ECR resource policy for emr-serverless containers (
Browse files Browse the repository at this point in the history
#112)

This PR modifies the default bootstrap template to support EMR
Serverless containers.

Without this policy, containers created using the `DockerImageAsset`
construct cannot be used with EMR Serverless applications.

There is precedence for this pattern to support Lambda function
containers, so I don't think this should be too controversial of a
change.

Relevant documentation on using custom images in EMR Serverless:
-
https://docs.aws.amazon.com/emr/latest/EMR-Serverless-UserGuide/application-custom-image.html

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license
  • Loading branch information
graydenshand authored Mar 3, 2025
1 parent a48d3db commit 478113d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/aws-cdk/lib/api/bootstrap/bootstrap-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,19 @@ Resources:
Condition:
StringLike:
"aws:sourceArn": { "Fn::Sub": "arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:function:*" }
# Necessary for EMR Serverless container images
# https://docs.aws.amazon.com/emr/latest/EMR-Serverless-UserGuide/application-custom-image.html#access-repo
- Sid: EmrServerlessImageRetrievalPolicy
Effect: Allow
Principal:
Service: emr-serverless.amazonaws.com
Action:
- ecr:BatchGetImage
- ecr:GetDownloadUrlForLayer
- ecr:DescribeImages
Condition:
StringLike:
"aws:sourceArn": { "Fn::Sub": "arn:${AWS::Partition}:emr-serverless:${AWS::Region}:${AWS::AccountId}:/applications/*" }
FilePublishingRole:
Type: AWS::IAM::Role
Properties:
Expand Down Expand Up @@ -659,7 +672,7 @@ Resources:
Type: String
Name:
Fn::Sub: '/cdk-bootstrap/${Qualifier}/version'
Value: '26'
Value: '27'
Outputs:
BucketName:
Description: The name of the S3 bucket owned by the CDK toolkit stack
Expand Down

0 comments on commit 478113d

Please sign in to comment.