AWS: clean up CloudFront cache

By | 09/27/2019

We have a picture in an AWS S3 bucket which updated, but AWS CloudFront still returns its old version.

To remove it from the CloudFront cache – need to create an object’s invalidation.

It can be created via AWS Console web-UI or by using AWS CLI.

In the AWS Console – go to the desired distribution and click the Create invalidation button:

And set to clear everything under the courses/images/*:

Or – create it using the AWS CLI:

aws --profile bm-backend  cloudfront create-invalidation --distribution-id E3V72S54L4XFN5 --paths "/courses/images/youthful_face.png"
"Location": "",
"Invalidation": {
"Status": "InProgress",
"CreateTime": "2019-09-27T13:16:31.089Z",
"InvalidationBatch": {
"Paths": {
"Quantity": 1,
"Items": [
"CallerReference": "cli-1569590190-500229"

Clean up process started:

By default – CloudFront will store objects in its cache during 24 hours, but this can be changed in the objects TTL settings: