Skip to content

Instantly share code, notes, and snippets.

@skatsuta
Last active May 5, 2016 16:39
Show Gist options
  • Save skatsuta/4ba1cf06a149499523f9341be4f8472f to your computer and use it in GitHub Desktop.
Save skatsuta/4ba1cf06a149499523f9341be4f8472f to your computer and use it in GitHub Desktop.
Enable to use EC2 longer ID format for all resources in all regions by using AWS CLI.
#!/bin/bash
set -eu
# Change this as you want
PROFILE=default
# Check user ARN of the profile
USER_ARN=$(aws --profile $PROFILE sts get-caller-identity --query 'Arn' --output text)
echo "User ARN: '$USER_ARN'"
# Enable longer ID format for all resources in all regions
RESOURCES=(reservation instance volume snapshot)
for region in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do
for resource in ${RESOURCES[@]}; do
echo "[$region] $resource"
aws --profile $PROFILE --region $region ec2 modify-id-format --resource $resource --use-long-ids
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment