Home > OS >  Make AWS CLI blocking during cloudfront invalidation creation
Make AWS CLI blocking during cloudfront invalidation creation

Time:02-19

I want to bust my cloudfront cache during a CI job and then run an Algolia search crawler against the busted version:

aws cloudfront create-invalidation --distribution-id $AWS_CLOUDFRONT_DISTRIBUTION_ID --paths "/*"

However, this will basically return a status response with an assigned ID I can poll, which is something I would like to avoid.

The question therefore is, whether this command can be made blocking (could not find anything in the docs). I also found this question, but is not applicable since my command always exits with 0 exit code.

CodePudding user response:

No.

What you can do is call the get-invalidation method in a loop (with a sleep in it), and only continue when the status is marked as COMPLETED

See The CLI Documentation

  • Related