DEV Community

KenjiGoh
KenjiGoh

Posted on

Automate CloudFront Cache Invalidation

If you are using CloudFront distribution to serve your users, it will be good to be able to automate cache invalidation by using this command:

Replace stackName with the name of your Cloudformation stack.

distributionId=$(aws cloudformation describe-stacks --stack-name stackName --query "Stacks[0].Outputs[?OutputKey=='DistributionId'].OutputValue" --output text)

echo distributionId

aws cloudfront create-invalidation --distribution-id $distributionId --paths "/*"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay