Skip to content

Instantly share code, notes, and snippets.

@astroanu
Created April 5, 2024 21:24
Show Gist options
  • Save astroanu/d16079463ff01053b7bc4635b8e00d5d to your computer and use it in GitHub Desktop.
Save astroanu/d16079463ff01053b7bc4635b8e00d5d to your computer and use it in GitHub Desktop.
Wait for cloudfront invalidation
# creates a new invalidation and waits until it's complete
DISTRIBUTION_ID=xxx
INVALIDATION_ID=$(aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths "/" | jq -r '.Invalidation.Id')
until [[ $(aws cloudfront get-invalidation --id $INVALIDATION_ID --distribution-id $DISTRIBUTION_ID | jq -r '.Invalidation.Status') = "Completed" ]]
do
echo "Waiting for the invalidation to complete"
sleep 3
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment