Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CLI CloudFront Invalidate All Files

I am attempting to invalidate an entire static website. The following command does not seem to invalidate /index.html and gives an odd output of items to be invalided, as shown below. Is this AWS CLI behaviour normal or am I missing something? Thanks!

aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths /* 

Output:

{     "Invalidation": {     "Status": "InProgress",      "InvalidationBatch": {         "Paths": {             "Items": [                 "/lib32",                  "/home",                  "/vmlinuz",                  "/core",                  "/proc",                  "/var",                  "/dev",                  "/usr",                  "/etc",                  "/initrd.img",                  "/cdrom",                  "/lost+found",                  "/root",                  "/tmp",                  "/lib",                  "/dead.letter",                  "/lib64",                  "/boot",                  "/sys",                  "/run",                  "/bin",                  "/sbin",                  "/mnt",                  "/opt",                  "/snap",                  "/media",                  "/copyright",                  "/srv"             ],              "Quantity": 28         },  
like image 437
neutreno Avatar asked Jun 11 '16 04:06

neutreno


People also ask

How do I automatically invalidate CloudFront cache?

Bynder can automatically invalidate your CloudFront CDN URLs when you upload a new version to an existing asset. No longer will you have to wait for its cache to expire. The assets you integrated externally using CloudFront will now always reflect the latest version.

What is create invalidation?

A value that you specify to uniquely identify an invalidation request. CloudFront uses the value to prevent you from accidentally resubmitting an identical request.

What is the use of invalidation in CloudFront?

Amazon CloudFront's invalidation feature, which allows you to remove an object from the CloudFront cache before it expires, now supports the * wildcard character. You can add a * wildcard character at the end of an invalidation path to remove all objects that match this path.

How do I invalidate multiple objects in Amazon CloudFront?

Amazon CloudFront Makes it Easier to Invalidate Multiple Objects. Amazon CloudFront’s invalidation feature, which allows you to remove an object from the CloudFront cache before it expires, now supports the * wildcard character. You can add a * wildcard character at the end of an invalidation path to remove all objects that match this path.

How do I cancel an invalidation request in CloudFront?

Choose Invalidate. When you submit an invalidation request to CloudFront, CloudFront forwards the request to all edge locations within a few seconds, and each edge location starts processing the invalidation immediately. As a result, you can’t cancel an invalidation after you submit it.

How do I invalidate a directory with a wildcard in AWS?

Also, if you use the AWS Command Line Interface (AWS CLI) for invalidating files and you specify a path that includes the * wildcard, you must use quotes ( ") around the path (like this: "/*" ). To invalidate a directory, all of its subdirectories, and all of the files in the directory and subdirectories:

Is it possible to invalidate a directory in CloudFront?

At the time, this was also true, and again, to a certain extent, it still is: The cloudfront documentation mentions "invalidating directories," but this refers to web sites that actually allow a directory listing [when] the listing is what you want to invalidate, so this won't help you either.


1 Answers

That's your shell doing expansion of local filenames.

That's what you're essentially asking for since the * isn't quoted.

Either --paths '*' or Specifying --paths '/*'¹ will do what you intend. Quoting the wildcard keeps it as a literal string rather than what you're seeing.


¹The CloudFront console allows you to specify either * or /* to invalidate the entire distribution; by contrast, the CLI expects /*. This, in turn, is because the underlying API also expects /*. When you use * in the console, the leading slash is silently added by the console before the console makes the request to the CloudFront API.

like image 111
Michael - sqlbot Avatar answered Sep 19 '22 22:09

Michael - sqlbot