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 },
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.
A value that you specify to uniquely identify an invalidation request. CloudFront uses the value to prevent you from accidentally resubmitting an identical request.
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.
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.
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.
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:
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.
That's your shell doing expansion of local filenames.
That's what you're essentially asking for since the *
isn't quoted.
Either Specifying --paths '*'
or--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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With