How to do cache purge of Amazon cloudfront through AWS-CLI

AWS CLI support for this service that we can purge cache of Cloudfront. When we configured AWS cli on our system, we need aws_access_key_id, aws_secret_access_key and region of particular user that we have entered in “config” file in “.aws” directory.

STEP 1 : [default]
output = text
aws_access_key_id = **********************
aws_secret_access_key = **********************************
region = us-west-2


STEP 2: Go to AWS console and IAM tab and attach policy “CloudFrontFullAccess” to user.

STEP 3: create a “invaliate.json” script for it.

“Paths”: {
“Quantity”: 1,
“Items”: [“/*”]
“CallerReference”: “my-invalidation-2015-09-01”

STEP 4: We need distribution id of that particular CDN. We can execute final command for cache purging.
aws cloudfront create-invalidation –invalidation-batch file://invalidate.json –distribution-id ************

Like This (3)
Dislike This (0)

Leave a Comment


Your email address will not be published. Required fields are marked *