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

[s3-deployment] Validate leading slash in cloudfront invalidation paths. #9317

Closed
1 of 2 tasks
Gaelan opened this issue Jul 29, 2020 · 5 comments · Fixed by #15865
Closed
1 of 2 tasks

[s3-deployment] Validate leading slash in cloudfront invalidation paths. #9317

Gaelan opened this issue Jul 29, 2020 · 5 comments · Fixed by #15865
Labels
@aws-cdk/aws-s3-deployment effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@Gaelan
Copy link

Gaelan commented Jul 29, 2020

Before deploying, validate that each element of distributionPaths starts with a slash.

Use Case

The following code results in a CloudFormation failure:

new BucketDeployment(this, "DeployPublic", {
  sources: [Source.asset(`${app}/public`)],
  destinationBucket: assetsBucket,
  destinationKeyPrefix: "",
  distribution: dist,
  distributionPaths: ["images/*"],
})

The issue is that distributionPaths should have a leading slash, i.e. /images/*. Cloudfront errors are slow and frustrating, so should be avoided where possible.

Proposed Solution

Make sure the paths have a leading slash before attempting to deploy.

Other

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@Gaelan Gaelan added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 29, 2020
@iliapolo
Copy link
Contributor

iliapolo commented Aug 3, 2020

@Gaelan Thanks for this. Any chance you can also attach the specific error that happens? Or a link to a documentation page that explains this behavior?

@iliapolo iliapolo added effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Aug 3, 2020
@Gaelan
Copy link
Author

Gaelan commented Aug 3, 2020

Sure. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#invalidation-specifying-objects-paths:

In the CloudFront console, you can omit the leading slash in the path, like this: images/image2.jpg. When you use the CloudFront API directly, invalidation paths must begin with a leading slash.

@iliapolo
Copy link
Contributor

iliapolo commented Aug 3, 2020

@Gaelan Cool. Thanks!

@peterwoodworth
Copy link
Contributor

Hey @Gaelan, thanks again for submitting this issue! I see you said you might be able to implement this, any chance you still want to implement this yourself? I'd be happy to take a look at the pr you would submit for this

@iliapolo iliapolo removed their assignment Jun 27, 2021
@mergify mergify bot closed this as completed in #15865 Aug 13, 2021
mergify bot pushed a commit that referenced this issue Aug 13, 2021
…on paths start with "/" (#15865)

Cloudfront invalidation paths must start with a leading "/". This pull requests adds a corresponding validation to fail during build instead of during the Cloudformation deployment.

closes #9317

----

*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.

hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Aug 26, 2021
…on paths start with "/" (aws#15865)

Cloudfront invalidation paths must start with a leading "/". This pull requests adds a corresponding validation to fail during build instead of during the Cloudformation deployment.

closes aws#9317

----

*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 Sep 6, 2021
…on paths start with "/" (aws#15865)

Cloudfront invalidation paths must start with a leading "/". This pull requests adds a corresponding validation to fail during build instead of during the Cloudformation deployment.

closes aws#9317

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
david-doyle-as24 pushed a commit to david-doyle-as24/aws-cdk that referenced this issue Sep 7, 2021
…on paths start with "/" (aws#15865)

Cloudfront invalidation paths must start with a leading "/". This pull requests adds a corresponding validation to fail during build instead of during the Cloudformation deployment.

closes aws#9317

----

*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-s3-deployment effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
3 participants