@shogomuranushi さんが拙作の j2y で CloudFormation のテンプレートを作る話を書いてくれたので、なんか他の使い方ないかなーと思って書いてみます。
AWS CLIの表示形式は json
, table
, text
が選べますが、 yaml
は選択肢にありません。
そこで、 j2y を使ってAWS CLIの出力をYAMLにしてみます。
$ j2y -e "$(aws ec2 describe-regions)"
Regions:
- Endpoint: ec2.eu-west-1.amazonaws.com
RegionName: eu-west-1
- Endpoint: ec2.ap-southeast-1.amazonaws.com
RegionName: ap-southeast-1
- Endpoint: ec2.ap-southeast-2.amazonaws.com
RegionName: ap-southeast-2
- Endpoint: ec2.eu-central-1.amazonaws.com
RegionName: eu-central-1
- Endpoint: ec2.ap-northeast-2.amazonaws.com
RegionName: ap-northeast-2
- Endpoint: ec2.ap-northeast-1.amazonaws.com
RegionName: ap-northeast-1
- Endpoint: ec2.us-east-1.amazonaws.com
RegionName: us-east-1
- Endpoint: ec2.sa-east-1.amazonaws.com
RegionName: sa-east-1
- Endpoint: ec2.us-west-1.amazonaws.com
RegionName: us-west-1
- Endpoint: ec2.us-west-2.amazonaws.com
RegionName: us-west-2
おお。これなら describe-instances
とかの出力結果も少しは見やすいかもですね。
標準入力できるようになりました(from v0.0.8)
$ aws ec2 describe-regions | j2y
Regions:
- Endpoint: ec2.eu-west-1.amazonaws.com
RegionName: eu-west-1
- Endpoint: ec2.ap-southeast-1.amazonaws.com
RegionName: ap-southeast-1
- Endpoint: ec2.ap-southeast-2.amazonaws.com
RegionName: ap-southeast-2
- Endpoint: ec2.eu-central-1.amazonaws.com
RegionName: eu-central-1
- Endpoint: ec2.ap-northeast-2.amazonaws.com
RegionName: ap-northeast-2
- Endpoint: ec2.ap-northeast-1.amazonaws.com
RegionName: ap-northeast-1
- Endpoint: ec2.us-east-1.amazonaws.com
RegionName: us-east-1
- Endpoint: ec2.sa-east-1.amazonaws.com
RegionName: sa-east-1
- Endpoint: ec2.us-west-1.amazonaws.com
RegionName: us-west-1
- Endpoint: ec2.us-west-2.amazonaws.com
RegionName: us-west-2