Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(s3-deployment): added property outputObjectKeys for BucketDeployment #30944

Closed
wants to merge 17 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def cfn_error(message=None):
exclude = props.get('Exclude', [])
include = props.get('Include', [])
sign_content = props.get('SignContent', 'false').lower() == 'true'
output_object_keys = props.get('OutputObjectKeys', 'true') == 'true'

# backwards compatibility - if "SourceMarkers" is not specified,
# assume all sources have an empty market map
Expand Down Expand Up @@ -135,7 +136,7 @@ def cfn_error(message=None):
cfn_send(event, context, CFN_SUCCESS, physicalResourceId=physical_id, responseData={
# Passing through the ARN sequences dependencees on the deployment
'DestinationBucketArn': props.get('DestinationBucketArn'),
'SourceObjectKeys': props.get('SourceObjectKeys'),
**({'SourceObjectKeys': props.get('SourceObjectKeys')} if output_object_keys else {})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too familiar on what the ** operator does in this context?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This operator is to merge the content of that dictionary with the parent dictionary

})
except KeyError as e:
cfn_error("invalid request. Missing key %s" % str(e))
Expand Down
13 changes: 12 additions & 1 deletion packages/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,16 @@ export interface BucketDeploymentProps {
* @default - `x-amz-content-sha256` will not be computed
*/
readonly signContent?: boolean;

/**
* If set to false, the custom resource will not send back the SourceObjectKeys.
* This is useful when you are facing the error `Response object is too long`
*
* See https://github.com/aws/aws-cdk/issues/28579
*
* @default true
*/
readonly outputObjectKeys?: boolean;
}

/**
Expand Down Expand Up @@ -422,6 +432,7 @@ export class BucketDeployment extends Construct {
DistributionId: props.distribution?.distributionId,
DistributionPaths: props.distributionPaths,
SignContent: props.signContent,
OutputObjectKeys: props.outputObjectKeys,
// Passing through the ARN sequences dependency on the deployment
DestinationBucketArn: cdk.Lazy.string({ produce: () => this.requestDestinationArn ? this.destinationBucket.bucketArn : undefined }),
},
Expand Down Expand Up @@ -519,7 +530,7 @@ export class BucketDeployment extends Construct {
* first source file in your bucket deployment.
*/
public get objectKeys(): string[] {
const objectKeys = cdk.Token.asList(this.cr.getAtt('SourceObjectKeys'));
const objectKeys = cdk.Lazy.uncachedList({ produce: () => this.sources.map(source => source.zipObjectKey) });
return objectKeys;
}

Expand Down
Loading