3
1

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 networkの設定などをjqで出力

Last updated at Posted at 2016-11-07

ネットワーク関連の設定をバーーって出したいとき


aws ec2 describe-instances | jq '.Reservations[].Instances[].InstanceId'


ホスト名とパブリックIPの一覧を出力

 aws ec2 describe-instances | jq '.Reservations[]|.Instances[]|[.Tags[].Value ,.PublicIpAddress] |  @csv'

ホスト名とプライベートIPの一覧を出力

aws ec2 describe-instances | jq '.Reservations[]|.Instances[]|[.Tags[].Value ,.NetworkInterfaces[].PrivateIpAddresses[].PrivateIpAddress]|@csv'

一緒に出力

aws ec2 describe-instances | jq '.Reservations[]|.Instances[]|[.Tags[].Value ,.NetworkInterfaces[].PrivateIpAddresses[].PrivateIpAddress,.PublicIpAddress]|@csv'

セキュリティグループ出力

 aws ec2 describe-instances | jq '.Reservations[]|.Instances[]|[.Tags[].Value ,.NetworkInterfaces[].Groups[].GroupName]| @csv'

Inbound

 aws ec2 describe-security-groups  | jq -r '.SecurityGroups[]|{key1:.Tags[0]["Value"], key2:.IpPermissions[]}|[.key1,.key2.FromPort,.key2.ToPort,.key2.IpRanges[].CidrIp,.key2.UserIdGroupPairs[].GroupId] |@csv' > Inbound.csv


Outbound


aws ec2 describe-security-groups  | jq -r '.SecurityGroups[]|{key1:.Tags[0]["Value"], key2:.IpPermissionsEgress[]}|[.key1,.key2.FromPort,.key2.ToPort,.key2.IpRanges[].CidrIp,.key2.UserIdGroupPairs[].GroupId] |@csv' > Outbound.csv

SecurityGroup Id list

aws ec2 describe-security-groups  | jq -r '.SecurityGroups[]|[.GroupName,.GroupId]|@csv'

Volume情報

aws ec2 describe-volumes | jq  -r '.Volumes[]|[.Attachments[].InstanceId,.VolumeType , .Iops]|@csv' > vlumeinfo.csv

aws ec2 describe-instances | jq -r '.Reservations[].Instances[] | [(.Tags[] | select(.Key=="Name").Value),.InstanceId, .InstanceType, .PrivateIpAddress] | @csv'
3
1
1

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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?