3

I am using s3 bucket as origin in cloudfront to cache and host my reactjs website.

After every deployment on s3 i want to invalidate the cache of my cloudfront distribution so that the user can get the latest build deployed..

Moreover, while reading the pricing of cloudfront invalidation, i want to make sure i don't exceed the free tier which is 1000 paths per month. Plus we don't have more then 10 or 20 deployments to production in a month.. and each deployment has around 500 files in directories:

enter image description here

So my question is: if i use "/*" as a invalidation query would it be considered as a 1 path ? or it would be 500 paths ?

Murtaza Hussain
  • 3,851
  • 24
  • 30

2 Answers2

4

I think the answer is the same link you provided in your question. Your question is whether wildcard is considered as 1 path or multiple part, so here is the screenshot for the same :

enter image description here

EDIT : For your confirmation, you can find the number of invalidations for a period of time by filtering the "Cost & Usage Report" (AWS console) by service="CloudFront" and usageType="Invalidations".

Hope this answers your question. Feel free to comment for any question.

Vipulw
  • 1,253
  • 5
  • 12
  • have you tried invalidate root folder /*, was it considered single path ? – Murtaza Hussain Jan 15 '22 at 10:14
  • 1
    Yes, I have used root folder wildcard, but didn't check myself for single path and relied on the docs I put in answer. For your confirmation, you can find the number of invalidations for a period of time by filtering the "Cost & Usage Report" (AWS console) by service="CloudFront" and usageType="Invalidations". – Vipulw Jan 15 '22 at 10:28
  • I tried as you informed for checking the usage after creating a `/*` **invalidation**, downloading the csv file i found that is `UsageValue: 1` . so i hope it means paths is also 1 ... thanks :D – Murtaza Hussain Jan 15 '22 at 11:15
  • I edited original answer with steps to check usage. Please accept the answer if you think this helped you. – Vipulw Jan 15 '22 at 13:17
  • its still not sure that usage 1 means 1 path or 500 paths, i have created support ticket at aws.. once verified will do it. – Murtaza Hussain Jan 15 '22 at 13:25
1

The below excerpt which clarifies regarding the paths:

The charge to submit an invalidation path is the same regardless of the number of files you're invalidating: a single file (/images/logo.jpg) or all of the files that are associated with a distribution (/*). For more information, see Amazon CloudFront Pricing.

The text is taken from docs mentioned in the link below: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#invalidation-specifying-objects-paths

which means that the "/*" is a single path.

Murtaza Hussain
  • 3,851
  • 24
  • 30