tl;dr
ワンライナーでなんかしたいシリーズ。
今回はワンライナーで全ての AWS リージョンの VPC ID とデフォルト VPC の true or false を取得するやつ。
今日のワンライナー
for i in `aws --region ap-northeast-1 ec2 describe-regions --query 'Regions[].RegionName' --output text` do echo $i && aws --region $i ec2 describe-vpcs --query 'Vpcs[].{VPCID:VpcId, DefaultVPC:IsDefault}' --output table done
結果は以下の通り。
eu-west-1 -------------------------------- | DescribeVpcs | +-------------+----------------+ | DefaultVPC | VPCID | +-------------+----------------+ | True | vpc-xxxxxxx1 | +-------------+----------------+ ap-southeast-1 -------------------------------- | DescribeVpcs | +-------------+----------------+ | DefaultVPC | VPCID | +-------------+----------------+ | True | vpc-xxxxxxx2 | +-------------+----------------+ ap-southeast-2 -------------------------------- | DescribeVpcs | +-------------+----------------+ | DefaultVPC | VPCID | +-------------+----------------+ | True | vpc-xxxxxxx3 | +-------------+----------------+ eu-central-1 -------------------------------- | DescribeVpcs | +-------------+----------------+ | DefaultVPC | VPCID | +-------------+----------------+ | True | vpc-xxxxxxx4 | +-------------+----------------+ ap-northeast-2 -------------------------------- | DescribeVpcs | +-------------+----------------+ | DefaultVPC | VPCID | +-------------+----------------+ | True | vpc-xxxxxxx5 | +-------------+----------------+ ap-northeast-1 -------------------------------- | DescribeVpcs | +-------------+----------------+ | DefaultVPC | VPCID | +-------------+----------------+ | False | vpc-xxxxxxx6 | | True | vpc-xxxxxxx7 | | False | vpc-xxxxxxx8 | | False | vpc-xxxxxxx9 | +-------------+----------------+ us-east-1 -------------------------------- | DescribeVpcs | +-------------+----------------+ | DefaultVPC | VPCID | +-------------+----------------+ | True | vpc-xxxxxx10 | | False | vpc-xxxxxx11 | +-------------+----------------+ sa-east-1 -------------------------------- | DescribeVpcs | +-------------+----------------+ | DefaultVPC | VPCID | +-------------+----------------+ | True | vpc-xxxxxx12 | +-------------+----------------+ us-west-1 -------------------------------- | DescribeVpcs | +-------------+----------------+ | DefaultVPC | VPCID | +-------------+----------------+ | True | vpc-xxxxxx13 | +-------------+----------------+ us-west-2 -------------------------------- | DescribeVpcs | +-------------+----------------+ | DefaultVPC | VPCID | +-------------+----------------+ | True | vpc-xxxxxx14 | +-------------+----------------+
以上
メモでした。