7
7

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でdescribe-instances

Last updated at Posted at 2014-03-06

#EC2インスタンス情報取得

aws ec2 describe-instances 

#タグ名でフィルタリング:relで前方一致

aws ec2 describe-instances \
  --filters "Name=tag:Name,Values=rel*" 

#テーブル形式

aws ec2 describe-instances \
  --filters "Name=tag:Name,Values=rel*" \
  --output table

#特定項目をテキスト出力:インスタンスIDとグローバルIP

aws ec2 describe-instances \
  --filters "Name=tag:Name,Values=rel*" \
  --query "Reservations[*].Instances[*].[InstanceId,PublicIpAddress]"  \
  --output table

jq版

aws ec2 describe-instances | jq ".Reservations[].Instances[]" \
 | jq ". | select(.Tags[].Key==\"Name\") | select(.Tags[].Value|contains(\"rel\"))" \
 | jq --raw-output '"\(.InstanceId) \(.PublicIpAddress)"'
7
7
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
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?