0

I have a list of CloudFront distributions that need to be invalidated. I have made the list using this command:-

dist_id=$(aws cloudfront list-distributions --query "DistributionList.Items[*].{id:Id,origin:Aliases.Items[0]}[?origin=='website1.com'||origin=='website2.com'||origin=='website3.com'].id" --output text)

Now the create-invalidation command expects only one string value for the distribution ID. How do I make it run for all of my distributions? When I run aws cloudfront create-invalidation --distribution-id $dist_id --paths "/*" it says that distributions 2 and 3 are unknown options.

I am using these commands from inside a buildspec.yml file in my React project.

Sh4dy
  • 143
  • 2
  • 15

1 Answers1

0

I ended up using a plain for-do loop:-

for varname in $dist_id; do aws cloudfront create-invalidation --distribution-id  $varname --paths "/*"; done
Sh4dy
  • 143
  • 2
  • 15