5
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS CLIの出力をYAMLにする

Last updated at Posted at 2016-04-16

@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
5
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?