Skip to content

Instantly share code, notes, and snippets.

@dansalias
Last active October 6, 2023 11:32
Show Gist options
  • Save dansalias/6ead9805f72da9aff1201d775e695152 to your computer and use it in GitHub Desktop.
Save dansalias/6ead9805f72da9aff1201d775e695152 to your computer and use it in GitHub Desktop.
Invalidate an AWS CloudFront Distribution by domain name
#!/bin/bash
# get the CloudFront Id
CF_DISTRIBUTION_ID=$(aws cloudfront list-distributions \
--query "DistributionList.Items[?contains(Aliases.Items[0], "example.com")] | [0].Id" \
--output text
)
# invalidate all paths
aws cloudfront create-invalidation --distribution-id ${CF_DISTRIBUTION_ID} --paths "/*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment