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

(cloudfront): Add support for ResponseHeadersPolicy #17290

Closed
1 of 2 tasks
ayush987goyal opened this issue Nov 3, 2021 · 18 comments · Fixed by #17359
Closed
1 of 2 tasks

(cloudfront): Add support for ResponseHeadersPolicy #17290

ayush987goyal opened this issue Nov 3, 2021 · 18 comments · Fixed by #17359
Labels
@aws-cdk/aws-cloudfront Related to Amazon CloudFront effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p1

Comments

@ayush987goyal
Copy link
Contributor

Description

Add support for ResponseHeadersPolicy as described in the following docs:

  1. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/creating-response-headers-policies.html
  2. https://aws.amazon.com/about-aws/whats-new/2021/11/amazon-cloudfront-supports-cors-security-custom-http-response-headers/

Use Case

We need to be able to configure response CORS, headers and security policies without using cloudfront functions or Lambda@edge.

Proposed Solution

The ResponseHeadersPolicy should be available as a new construct under the @aws-cdk/aws-cloudfront construct library.

Other information

No response

Acknowledge

  • I may be able to implement this feature request
  • This feature might incur a breaking change
@ayush987goyal ayush987goyal added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 3, 2021
@peterwoodworth peterwoodworth added effort/large Large work item – several weeks of effort needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p1 effort/medium Medium work item – several days of effort and removed effort/large Large work item – several weeks of effort p1 labels Nov 3, 2021
@peterwoodworth
Copy link
Contributor

It doesn't look like CloudFormation has made any changes to CloudFront for this, and I don't see any issues for it in the coverage roadmap.

@ayush987goyal you say you might be able to implement this, do you have any plans on how you might do that?

@ayush987goyal
Copy link
Contributor Author

ayush987goyal commented Nov 4, 2021

@peterwoodworth Sorry for jumping the gun and getting too excited too fast. I, or perhaps anyone else, would only be able to implement once the CFN support for it lands of course 😅 .

@peterwoodworth
Copy link
Contributor

Got it 😄 just wanted to make sure I wasn't missing anything

@peterwoodworth peterwoodworth added @aws-cdk/aws-cloudfront Related to Amazon CloudFront and removed needs-triage This issue or PR still needs to be triaged. labels Nov 4, 2021
@robertd
Copy link
Contributor

robertd commented Nov 5, 2021

Hot off the press: https://twitter.com/cfnupdates/status/1456452444406358019?s=21

edit: And here is the actual link to the cfn docs. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudfront-responseheaderspolicy.html

@ayush987goyal
Copy link
Contributor Author

ayush987goyal commented Nov 5, 2021

@robertd Awesome! Now waiting on the CFN autogenerated L1 constructs to get updated in the cdk modules.

How frequently does the CFN update happen in CDK @robertd ?

mergify bot pushed a commit that referenced this issue Nov 5, 2021
Generated by running `scripts/bump-cfnspec.sh`. Wanted to speed up the additions required for #17290 .

Feel free to close if this is supposed to be created by a bot like #17223 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@ayush987goyal
Copy link
Contributor Author

Well, with the #17350 merged there is AWS::CloudFront::ResponseHeadersPolicy added to the spec but the AWS::CloudFront::Distribution CacheBehavior is not updated with ResponseHeadersPolicyId. Alas, we would need to wait for it to be added in a new spec bump. But we could get started with creating a resource for the ResponseHeadersPolicy at the least

@robertd
Copy link
Contributor

robertd commented Nov 6, 2021

@ayush987goyal Sorry I was out yesterday. I’m glad you figured out how to bump the cfn specs. We’re one step closer now yay 🎉

@ayush987goyal
Copy link
Contributor Author

@robertd Thanks! Was wondering if it is common for the spec JSON cdn (https://d1uauaxba7bl26.cloudfront.net/latest/gzip/CloudFormationResourceSpecification.json) does not update even though the CFN docs are updated with all the changes?

iliapolo pushed a commit that referenced this issue Nov 7, 2021
Generated by running `scripts/bump-cfnspec.sh`. Wanted to speed up the additions required for #17290 .

Feel free to close if this is supposed to be created by a bot like #17223 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@ayush987goyal
Copy link
Contributor Author

Another spec bump PR should now address this: #17482

@dimon89ch
Copy link

Guys thanks for working on ResponseHeadersPolicy !

@y4nnick
Copy link

y4nnick commented Nov 23, 2021

Thanks for working on this! :)

In the meantime, is there a way to set the ResponseHeadersPolicy via some Escape hatches as defined here: https://docs.aws.amazon.com/cdk/latest/guide/cfn_layer.html ?

@mergify mergify bot closed this as completed in #17359 Nov 24, 2021
mergify bot pushed a commit that referenced this issue Nov 24, 2021
feat(cloudfront): Add support for response headers policy

closes #17290 

Notes:
~1. Currently the CFNSpec is not up-to-date with the latest available cloudformation changes for `ResponseHeadersPolicyId` in `AWS::CloudFront::Distribution CacheBehavior`. Some aspects of the same are added to the PR but are left commented. Would update the PR once the spec is updated.~

Refs:
1. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/adding-response-headers.html
2. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudfront-responseheaderspolicy.html
3. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-cachebehavior.html#cfn-cloudfront-distribution-cachebehavior-responseheaderspolicyid

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

beezly pushed a commit to beezly/aws-cdk that referenced this issue Nov 29, 2021
feat(cloudfront): Add support for response headers policy

closes aws#17290 

Notes:
~1. Currently the CFNSpec is not up-to-date with the latest available cloudformation changes for `ResponseHeadersPolicyId` in `AWS::CloudFront::Distribution CacheBehavior`. Some aspects of the same are added to the PR but are left commented. Would update the PR once the spec is updated.~

Refs:
1. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/adding-response-headers.html
2. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudfront-responseheaderspolicy.html
3. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-cachebehavior.html#cfn-cloudfront-distribution-cachebehavior-responseheaderspolicyid

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@mspolitaev
Copy link

mspolitaev commented Dec 9, 2021

Hi team! As i understnd it's only L1 construct? Don't want rewrite all our L2 to L1. Is it planned make available as L2 too? Or how we can combine L2 Behavior construct with this one ResponseHeaders policy? Thanks.

@robertd
Copy link
Contributor

robertd commented Dec 9, 2021

@mspolitaev It is L2 construct, but it's currently only available in v2.1.0. It should be available in v1.3.5 when it gets released.

image

@mspolitaev
Copy link

mspolitaev commented Dec 9, 2021

@robertd Oh cool, it's 1.134 now latest? Hope soon will be 1.135. We will wait then. Thanks.

@ChrsWoo
Copy link

ChrsWoo commented Jan 5, 2022

Hi all,

Can I please double check that this has been confirmed to be working as expected according to the docs here: https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-cloudfront.ResponseHeadersPolicy.html#static-security_headers

We're seeing our ResponseHeadersPolicy being created but it isn't being applied to our Cloudfront Distribution with this setup:

const responseHeadersPolicy = new ResponseHeadersPolicy(...);

const distribution = new Distribution(this, "DistName", {
    defaultBehavior: {
        origin: new S3Origin(bucket),
        cachePolicy: CachePolicy.CACHING_DISABLED,
        responseHeadersPolicy: responseHeadersPolicy,
    }
});

Just wanted to check whether others have had success with a setup like this?

@austin-payne
Copy link

We're seeing our ResponseHeadersPolicy being created but it isn't being applied to our Cloudfront Distribution

Same here, and even if set manually it's reset when the stack is deployed again

@robertd
Copy link
Contributor

robertd commented Jan 12, 2022

@ChrsWoo Can you please create new GitHub issue for better visibility.

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@kzys kzys mentioned this issue Jan 14, 2022
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
Generated by running `scripts/bump-cfnspec.sh`. Wanted to speed up the additions required for aws#17290 .

Feel free to close if this is supposed to be created by a bot like aws#17223 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
feat(cloudfront): Add support for response headers policy

closes aws#17290 

Notes:
~1. Currently the CFNSpec is not up-to-date with the latest available cloudformation changes for `ResponseHeadersPolicyId` in `AWS::CloudFront::Distribution CacheBehavior`. Some aspects of the same are added to the PR but are left commented. Would update the PR once the spec is updated.~

Refs:
1. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/adding-response-headers.html
2. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudfront-responseheaderspolicy.html
3. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-cachebehavior.html#cfn-cloudfront-distribution-cachebehavior-responseheaderspolicyid

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudfront Related to Amazon CloudFront effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants