Skip to content

Instantly share code, notes, and snippets.

@amosshapira
Created December 2, 2015 03:54
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amosshapira/21022bd5481f4e31ca16 to your computer and use it in GitHub Desktop.
Save amosshapira/21022bd5481f4e31ca16 to your computer and use it in GitHub Desktop.
Fetch the S3 prefix list ID's for S3 in all AWS regions. These are can then be used as destinations in route tables
#!/bin/bash
# Fetch the S3 prefix list ID's for S3 in all AWS regions.
# These are can then be used as destinations in route tables
aws ec2 describe-regions --query 'Regions[*].RegionName' | \
jq -r '.[]' | \
while read REGION
do
echo ==== $REGION ====
aws ec2 describe-prefix-lists \
--region $REGION \
--filters Name=prefix-list-name,Values=com.amazonaws.$REGION.s3 \
--query 'PrefixLists[0].PrefixListId'
done
@yangmillstheory
Copy link

Need to wrap https://gist.github.com/amosshapira/21022bd5481f4e31ca16#file-get-all-s3-prefix-lists-L10 in double-quotes, else

zsh: === not found

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment