Last active
May 5, 2016 16:39
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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