-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Support include body for LambdaFunctionAssociation #7085
Comments
Is there an intermediate way to achieve this for now? |
@nitishdhar it's convoluted but the CDK provides a raw override. Here's how I got it working: const distribution = new cloudfront.CloudFrontWebDistribution(this, 'WebDistribution', {
originConfigs: [{
s3OriginSource: {
s3BucketSource: bucket
},
behaviors: [{
isDefaultBehavior: true,
compress: true
}, {
pathPattern: 'api/*',
compress: true,
allowedMethods: cloudfront.CloudFrontAllowedMethods.ALL,
minTtl: cdk.Duration.days(0),
maxTtl: cdk.Duration.days(0),
defaultTtl: cdk.Duration.days(0),
forwardedValues: {
queryString: true,
cookies: {
forward: 'all'
}
},
lambdaFunctionAssociations: [{
eventType: cloudfront.LambdaEdgeEventType.ORIGIN_REQUEST,
lambdaFunction: apiLambdaVersion
}]
}]
}]
})
// get the CloudFormation template
const distributionCfn = distribution.node.defaultChild as cloudfront.CfnDistribution
// Add IncludeBody on the first cache behavior - indexed at 0 because the default behaviour is not on the CacheBehaviors array
distributionCfn.addOverride('Properties.DistributionConfig.CacheBehaviors.0.LambdaFunctionAssociations.0.IncludeBody', true)
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
DefaultCacheBehavior:
...
CacheBehaviors:
- PathPatern: api/*
LambdaFunctionAssociations:
- EventType: origin-request
LambdaFunctionARN: arn:... The first argument in So Hopefully this will get sorted out soon, and we won't need to do this. Looks like the property in the CDK was just overlooked. |
Hi @marcgreenstock and @nitishdhar Yeap, this is just an oversight. Adding to our docket. Thanks for reporting this and thanks @marcgreenstock for the correct workaround 👍 |
@marcgreenstock Thanks!! your solution worked for me as well. |
The `includeBody` flag enables a Lambda@Edge function to receive the body of the request or response. Enabled this flag for both the `CloudFrontWebDistribution` and `Distribution` constructs. fixes #7085
The `includeBody` flag enables a Lambda@Edge function to receive the body of the request or response. Enabled this flag for both the `CloudFrontWebDistribution` and `Distribution` constructs. fixes #7085 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
When creating lambda-edge behaviours from AWS console , we can select Include Body for lambda edge association.
But the same configuration can't be done by AWS CDK because Include Body property is not available in LambdaFunctionAssociation class.
https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-cloudfront.LambdaFunctionAssociation.html
The text was updated successfully, but these errors were encountered: