ããã«ã¡ã¯ãAWS CLIã好ããªç¦å³¶ã§ãã
ä»åã¯ãEC2ã®ãªã½ã¼ã¹æ
å ±ãåå¾ããã³ãã³ãããç´¹ä»ãããã¾ãã
ãã®ä»ã®AWS CLIé¢é£ã®è¨äº
ç§ã¯ããqueryã使ããããqueryã®ä½¿ãæ¹ãåãããªãæ¹ã¯ããã¡ããåç §ãã¦ããã ãã¾ãã¨å¹¸ãã§ãã
- å®è¡ç°å¢
- å©ç¨ããã³ãã³ã,ãµãã³ãã³ã
- åºæ¬æ å ±ã®åå¾
- 詳細æ å ±ã®åå¾
- ã¤ã³ã¹ã¿ã³ã¹ãããã¡ã¤ã«ä¸è¦§
- åé¤ä¿è·ãã§ãã¯
- çµäºæã®åä½
- ã¹ãã¼ã¿ã¹ãã§ãã¯
- ENIæ å ±ã®åå¾
- ããªã¥ã¼ã æ å ±ã®åå¾
- ããªã¥ã¼ã ã®è©³ç´°æ å ±åå¾
- ã»ãã¥ãªãã£ã°ã«ã¼ãæ å ±ã®åå¾
- ã¿ã°æ å ±ã®åå¾
- ãããã«
å®è¡ç°å¢
ä»åãã³ãã³ããå®è¡ããç°å¢ã¯ã以ä¸ã®éãã¨ãªãã¾ãã
ï¼æ¬è¨äºã§ãç´¹ä»ãã¦ããã³ãã³ãã®ä¸ã«ã¯ãLinuxã®ã³ãã³ããå©ç¨ãã¦ããç®æãããã¾ããï¼
# uname -a Linux LAPTOP-CNM26HN6 4.4.0-18362-Microsoft #1049-Microsoft Thu Aug 14 12:01:00 PST 2020 x86_64 x86_64 x86_64 GNU/Linux #
å©ç¨ããã³ãã³ã,ãµãã³ãã³ã
ã¾ããAWS CLIã®æ§é ã¯ä»¥ä¸ã®éãã§ãã
aws <command> <subcommand> [options and parameters]
ä¸è¨ãåæã«ä»å使ã <command>,<subcommand>
ã¯ã以ä¸ã®éãã§ãã
<command>
- ec2
<subcommand>
- â describe-instances
âEC2ã®æ å ±ãåå¾ã§ãã¾ãã - â¡describe-iam-instance-profile-associations
â EC2ã®ã¤ã³ã¹ã¿ã³ã¹ãããã¡ã¤ã«ã®æ å ±ãåå¾ã§ãã¾ãã - â¢describe-tags
âTagã®æ å ±ãåå¾ã§ãã¾ãã - â£describe-instance-attribute
âEC2ã®è©³ç´°è¨å®ã®æ å ±ãåå¾ã§ãã¾ãã - â¤describe-instance-status
âEC2ã®ã¹ãã¼ã¿ã¹ãåå¾ã§ãã¾ãã - â¥describe-volumes
âEBSã®æ å ±ãåå¾ã§ãã¾ãã
åºæ¬æ å ±ã®åå¾
ã³ãã³ã(ãããã¼ç¡ã)
aws ec2 describe-instances --query "Reservations[].Instances[].[Tags[?Key=='Name'] | [0].Value,InstanceId,InstanceType,ImageId,KeyName,Placement.AvailabilityZone,PrivateIpAddress,State.Name,VpcId,SubnetId]" --output text
- å®è¡çµæ
fk-linux-jira i-0f6126b7aeedfabd6 t2.medium ami-041581098aa702a3b fk-test-key ap-northeast-1c 10.88.1.83 stopped vpc-0fee138d3e0deef81 subnet-03fbedc39e6211234 fk-test-vyos i-050536efdd9dc1126 t3.large ami-0bcd9399d3bfa0a0e fk-test-key ap-northeast-1c 10.88.1.249 stopped vpc-0fee138d3e0deef81 subnet-03fbedc39e6211234 fk-test-smtp i-0807173c03bac7939 t4g.micro ami-0ff2715db3ddfcaf5 fk-test-key ap-northeast-1c 10.88.1.46 stopped vpc-0fee138d3e0deef81 subnet-03fbedc39e6211234
ã³ãã³ã(ãããã¼æã)
echo "NameTag InstanceId ImageId InstanceType AvailabilityZone KeyName PrivateIpAddress State VpcId SubnetId" > /tmp/awscli.tmp;\ aws ec2 describe-instances --query "Reservations[].Instances[].[Tags[?Key=='Name'] | [0].Value,InstanceId,ImageId,InstanceType,Placement.AvailabilityZone,KeyName,PrivateIpAddress,State.Name,VpcId,SubnetId]" --output text >> /tmp/awscli.tmp;\ column -t /tmp/awscli.tmp;\ rm /tmp/awscli.tmp
- å®è¡çµæ
NameTag InstanceId ImageId InstanceType AvailabilityZone KeyName PrivateIpAddress State VpcId SubnetId fk-test-asav i-xxxxxxxxxxxxxxxxx ami-xxxxxxxxxxxxxxxxx m4.large ap-northeast-1c fk-test-key 10.88.1.127 stopped vpc-xxxxxxxxxxxxxxxxx subnet-xxxxxxxxxxxxxxxxx fk-win-ad i-xxxxxxxxxxxxxxxxx ami-xxxxxxxxxxxxxxxxx t2.medium ap-northeast-1a fk-test-key 10.88.0.240 stopped vpc-xxxxxxxxxxxxxxxxx subnet-xxxxxxxxxxxxxxxxx fk-test-jwin2016 i-xxxxxxxxxxxxxxxxx ami-xxxxxxxxxxxxxxxxx t2.medium ap-northeast-1a fk-test-key 10.88.0.241 stopped vpc-xxxxxxxxxxxxxxxxx subnet-xxxxxxxxxxxxxxxxx
詳細æ å ±ã®åå¾
ã³ãã³ã ãããã¼ç¡ã
aws ec2 describe-instances --query "Reservations[].Instances[].[Tags[?Key=='Name'] | [0].Value,InstanceId,ImageId,InstanceType,CpuOptions.CoreCount,CpuOptions.ThreadsPerCore,KeyName,Placement.AvailabilityZone,State.Name,VpcId,SubnetId,Architecture,EbsOptimized,EnaSupport,Hypervisor,SourceDestCheck,VirtualizationType,Monitoring.State,HibernationOptions.Configured]" --output text
- å®è¡çµæ
fk-linux-jira i-0f6126b7aeedfabd6 ami-041581098aa702a3b t2.medium 2 1 fk-test-key ap-northeast-1c stopped vpc-0fee138d3e0deef81 subnet-03fbedc39e6211234 x86_64 False True xen True hvm disabled False fk-test-vyos i-050536efdd9dc1126 ami-0bcd9399d3bfa0a0e t3.large 1 2 fk-test-key ap-northeast-1c stopped vpc-0fee138d3e0deef81 subnet-03fbedc39e6211234 x86_64 True True xen False hvm disabled False fk-test-smtp i-0807173c03bac7939 ami-0ff2715db3ddfcaf5 t4g.micro 2 1 fk-test-key ap-northeast-1c stopped vpc-0fee138d3e0deef81 subnet-03fbedc39e6211234 arm64 True True xen True hvm disabled False
ã³ãã³ã ãããã¼æã
echo "NameTag InstanceId ImageId InstanceType CoreCount ThreadsPerCore KeyName AvailabilityZone Name VpcId SubnetId Architecture EbsOptimized EnaSupport Hypervisor SourceDestCheck VirtualizationType Monitoring.State Hibernation" > /tmp/awscli.tmp;\ aws ec2 describe-instances --query "Reservations[].Instances[].[Tags[?Key=='Name'] | [0].Value,InstanceId,ImageId,InstanceType,CpuOptions.CoreCount,CpuOptions.ThreadsPerCore,KeyName,Placement.AvailabilityZone,State.Name,VpcId,SubnetId,Architecture,EbsOptimized,EnaSupport,Hypervisor,SourceDestCheck,VirtualizationType,Monitoring.State,HibernationOptions.Configured]" --output text | sort >> /tmp/awscli.tmp;\ column -t /tmp/awscli.tmp;\ rm /tmp/awscli.tmp
- å®è¡çµæ
NameTag InstanceId ImageId InstanceType CoreCount ThreadsPerCore KeyName AvailabilityZone Name VpcId SubnetId Architecture EbsOptimized EnaSupport Hypervisor SourceDestCheck VirtualizationType Monitoring.State Hibernation aws-cloud9-aws-code-hands-on-0f7eeec411fd49be880ebf5a4791df17 i-03767ce5637a45a1a ami-0ea42ac15b5216c72 t2.micro 1 1 None ap-northeast-1a stopped vpc-0fee138d3e0deef81 subnet-0093d7475de79313b x86_64 False True xen True hvm disabled False fk-linux i-0808672558492fde8 ami-052652af12b58691f t3.micro 1 2 fk-test-key ap-northeast-1a stopped vpc-0fee138d3e0deef81 subnet-0093d7475de79313b x86_64 True True xen True hvm disabled False fk-linux-jira i-0f6126b7aeedfabd6 ami-041581098aa702a3b t2.medium 2 1 fk-test-key ap-northeast-1c stopped vpc-0fee138d3e0deef81 subnet-03fbedc39e6211234 x86_64 False True xen True hvm disabled False
ã¤ã³ã¹ã¿ã³ã¹ãããã¡ã¤ã«ä¸è¦§
ã³ãã³ã ãããã¼ç¡ã
aws ec2 describe-iam-instance-profile-associations --query "IamInstanceProfileAssociations[].[InstanceId,IamInstanceProfile.Arn]" --output text | sort
- å®è¡çµæ
i-xxxxxxxxxxxxxxxxx arn:aws:iam::xxxxxxxxxxxx:instance-profile/base-ec2-ap-northeast-1 i-xxxxxxxxxxxxxxxxx arn:aws:iam::xxxxxxxxxxxx:instance-profile/ec2-s3
ã³ãã³ã ãããã¼æã(NameTagä»ã)
echo "InstanceId NameTag IamInstanceProfile" > /tmp/awscli.tmp;\ aws ec2 describe-iam-instance-profile-associations --query "IamInstanceProfileAssociations[].[InstanceId,IamInstanceProfile.Arn]" --output text | sort > /tmp/awscli-tag-jonn1.tmp;\ aws ec2 describe-tags --filters "Name=key,Values=Name" "Name=resource-type,Values=instance" --query "Tags[].[ResourceId,Value]" --output text | sort > /tmp/awscli-tag-jonn2.tmp;\ join /tmp/awscli-tag-jonn2.tmp /tmp/awscli-tag-jonn1.tmp >> /tmp/awscli.tmp ;\ join -v 1 /tmp/awscli-tag-jonn1.tmp /tmp/awscli-tag-jonn2.tmp | sed 's/arn/ None arn/g' | sort >> /tmp/awscli.tmp ;\ column -t /tmp/awscli.tmp;\ rm /tmp/awscli.tmp /tmp/awscli-tag-jonn1.tmp /tmp/awscli-tag-jonn2.tmp
- å®è¡çµæ
InstanceId NameTag IamInstanceProfile i-xxxxxxxxxxxxxxxxx fk-test-jwin2019 arn:aws:iam::xxxxxxxxxxxx:instance-profile/base-ec2-ap-northeast-1 i-xxxxxxxxxxxxxxxxx fk-linux arn:aws:iam::xxxxxxxxxxxx:instance-profile/ec2-s3
åé¤ä¿è·ãã§ãã¯
ã³ãã³ã ãããã¼ç¡ã(1å°ã ã)
INSTNACEID="" â ã¤ã³ã¹ã¿ã³ã¹IDãè¨å®ãã¦ãã ããã aws ec2 describe-instance-attribute --instance-id ${INSTNACEID} --attribute disableApiTermination --query "[InstanceId,DisableApiTermination.Value]" --output text
- å®è¡çµæ
i-xxxxxxxxxxxxxxxxx False
ã³ãã³ã ãããã¼æã(NameTagä»ã)
â»ã¤ã³ã¹ã¿ã³ã¹ã®å°æ°åã³ãã³ããå®è¡ãããããå°ãæéããããã¾ãã ã¾ããNameTagãä»ä¸ããã¦ããªãã¤ã³ã¹ã¿ã³ã¹ã¯ãåãããã¾ãã
echo "InstanceId NameTag disableApiTermination" > /tmp/awscli.tmp;\ aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId" --output text | tr "\t" "\n" | while read line; do aws ec2 describe-instance-attribute --instance-id ${line} --attribute disableApiTermination --query "[InstanceId,DisableApiTermination.Value]" --output text; done | sort > /tmp/awscli-tag-jonn1.tmp;\ aws ec2 describe-tags --filters "Name=key,Values=Name" "Name=resource-type,Values=instance" --query "Tags[].[ResourceId,Value]" --output text | sort > /tmp/awscli-tag-jonn2.tmp;\ join /tmp/awscli-tag-jonn2.tmp /tmp/awscli-tag-jonn1.tmp >> /tmp/awscli.tmp ;\ join -v 1 /tmp/awscli-tag-jonn1.tmp /tmp/awscli-tag-jonn2.tmp >> /tmp/awscli.tmp ;\ column -t /tmp/awscli.tmp;\ rm /tmp/awscli.tmp /tmp/awscli-tag-jonn1.tmp /tmp/awscli-tag-jonn2.tmp
- å®è¡çµæ
InstanceId NameTag disableApiTermination i-xxxxxxxxxxxxxxxxx fk-win-ad False i-xxxxxxxxxxxxxxxxx fk-test-jwin2019 False i-xxxxxxxxxxxxxxxxx fk-test-vyos False
çµäºæã®åä½
ã³ãã³ã ãããã¼ç¡ã(1å°ã ã)
INSTNACEID="" aws ec2 describe-instance-attribute --instance-id ${INSTNACEID} --attribute instanceInitiatedShutdownBehavior --query "[InstanceId,InstanceInitiatedShutdownBehavior.Value]" --output text
- å®è¡çµæ
i-xxxxxxxxxxxxxxxxx stop
ã³ãã³ã ãããã¼æã(NameTagä»ã)
â»ã¤ã³ã¹ã¿ã³ã¹ã®å°æ°åã³ãã³ããå®è¡ãããããå°ãæéããããã¾ãã ã¾ããNameTagãä»ä¸ããã¦ããªãã¤ã³ã¹ã¿ã³ã¹ã¯ãåãããã¾ãã
echo "InstanceId NameTag instanceInitiatedShutdownBehavior" > /tmp/awscli.tmp;\ aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId" --output text | tr "\t" "\n" | while read line; do aws ec2 describe-instance-attribute --instance-id ${line} --attribute instanceInitiatedShutdownBehavior --query "[InstanceId,InstanceInitiatedShutdownBehavior.Value]" --output text; done | sort > /tmp/awscli-tag-jonn1.tmp;\ aws ec2 describe-tags --filters "Name=key,Values=Name" "Name=resource-type,Values=instance" --query "Tags[].[ResourceId,Value]" --output text | sort > /tmp/awscli-tag-jonn2.tmp;\ join /tmp/awscli-tag-jonn2.tmp /tmp/awscli-tag-jonn1.tmp >> /tmp/awscli.tmp ;\ join -v 1 /tmp/awscli-tag-jonn1.tmp /tmp/awscli-tag-jonn2.tmp >> /tmp/awscli.tmp ;\ column -t /tmp/awscli.tmp;\ rm /tmp/awscli.tmp /tmp/awscli-tag-jonn1.tmp /tmp/awscli-tag-jonn2.tmp
- å®è¡çµæ
InstanceId NameTag instanceInitiatedShutdownBehavior i-xxxxxxxxxxxxxxxxx fk-win-ad stop i-xxxxxxxxxxxxxxxxx fk-test-jwin2019 stop i-xxxxxxxxxxxxxxxxx fk-test-vyos stop
ã¹ãã¼ã¿ã¹ãã§ãã¯
ã³ãã³ã ãããã¼ç¡ã
aws ec2 describe-instance-status --query "InstanceStatuses[].[InstanceId,InstanceState.Name,InstanceStatus.Status,SystemStatus.Status]" --output text | sort
- å®è¡çµæ
i-xxxxxxxxxxxxxxxxx running ok ok
ã³ãã³ã ãããã¼æã(NameTagä»ã)
â»NameTagãä»ä¸ããã¦ããªãã¤ã³ã¹ã¿ã³ã¹ã¯ãåãããã¾ãã
echo "InstanceId NameTag State InstanceStatus SystemStatus" > /tmp/awscli.tmp;\ aws ec2 describe-instance-status --query "InstanceStatuses[].[Tags[?Key=='Name'] | [0].Value,InstanceId,InstanceState.Name,InstanceStatus.Status,SystemStatus.Status]" --output text | sort > /tmp/awscli-tag-jonn1.tmp;\ aws ec2 describe-tags --filters "Name=key,Values=Name" "Name=resource-type,Values=instance" --query "Tags[].[ResourceId,Value]" --output text | sort > /tmp/awscli-tag-jonn2.tmp;\ join /tmp/awscli-tag-jonn2.tmp /tmp/awscli-tag-jonn1.tmp >> /tmp/awscli.tmp ;\ join -v 1 /tmp/awscli-tag-jonn1.tmp /tmp/awscli-tag-jonn2.tmp >> /tmp/awscli.tmp ;\ column -t /tmp/awscli.tmp;\ rm /tmp/awscli.tmp /tmp/awscli-tag-jonn1.tmp /tmp/awscli-tag-jonn2.tmp
- å®è¡çµæ
InstanceId NameTag State InstanceStatus SystemStatus i-xxxxxxxxxxxxxxxxx fk-linux running ok ok
ENIæ å ±ã®åå¾
â»ãã©ã¤ããªã¨ã»ã«ã³ããªENIã®ã¿åºåã
ã³ãã³ã ãããã¼ç¡ã
aws ec2 describe-instances --query "Reservations[].Instances[].\ [InstanceId,VpcId,SubnetId,\ NetworkInterfaces[0].Association.PublicIp,\ NetworkInterfaces[0].NetworkInterfaceId,NetworkInterfaces[0].PrivateIpAddresses[0].PrivateIpAddress,\ NetworkInterfaces[1].NetworkInterfaceId,NetworkInterfaces[0].PrivateIpAddresses[1].PrivateIpAddress]" --output text
- å®è¡çµæ
i-xxxxxxxxxxxxxxxxx vpc-xxxxxxxxxxxxxxxxx subnet-xxxxxxxxxxxxxxxxx None eni-xxxxxxxxxxxxxxxxx 10.88.1.83 None None i-xxxxxxxxxxxxxxxxx vpc-xxxxxxxxxxxxxxxxx subnet-xxxxxxxxxxxxxxxxx None eni-xxxxxxxxxxxxxxxxx 10.88.1.153 None None i-xxxxxxxxxxxxxxxxx vpc-xxxxxxxxxxxxxxxxx subnet-xxxxxxxxxxxxxxxxx None eni-xxxxxxxxxxxxxxxxx 10.88.1.249 None None
ã³ãã³ã ãããã¼æã(NameTagä»ã)
echo "NameTag InstanceId VpcId SubnetId PublicIP PrimaryENI PrimaryPrivateIpAddress SeconderyENI SseconderyPrivateIpAddress" > /tmp/awscli.tmp;\ aws ec2 describe-instances --query "Reservations[].Instances[].[Tags[?Key=='Name'] | [0].Value,InstanceId,VpcId,SubnetId,\ NetworkInterfaces[0].Association.PublicIp,\ NetworkInterfaces[0].NetworkInterfaceId,NetworkInterfaces[0].PrivateIpAddresses[0].PrivateIpAddress,\ NetworkInterfaces[1].NetworkInterfaceId,NetworkInterfaces[1].PrivateIpAddresses[0].PrivateIpAddress]" \ --output text | sort >>/tmp/awscli.tmp;\ column -t /tmp/awscli.tmp;\ rm /tmp/awscli.tmp
- å®è¡çµæ
InstanceId NameTag VpcId SubnetId PublicIP PrimaryENI PrimaryPrivateIpAddress SeconderyENI SseconderyPrivateIpAddress i-xxxxxxxxxxxxxxxxx fk-win-ad vpc-xxxxxxxxxxxxxxxxx subnet-xxxxxxxxxxxxxxxxx None eni-xxxxxxxxxxxxxxxxx 10.88.0.240 eni-xxxxxxxxxxxxxxxxx 10.88.0.220 i-xxxxxxxxxxxxxxxxx fk-test-jwin2019 vpc-xxxxxxxxxxxxxxxxx subnet-xxxxxxxxxxxxxxxxx None eni-xxxxxxxxxxxxxxxxx 10.88.0.150 None None i-xxxxxxxxxxxxxxxxx fk-test-vyos vpc-xxxxxxxxxxxxxxxxx subnet-xxxxxxxxxxxxxxxxx None eni-xxxxxxxxxxxxxxxxx 10.88.1.249 None None
ããªã¥ã¼ã æ å ±ã®åå¾
â»3ã¤ã®ããªã¥ã¼ã ã ãåºåã
ã³ãã³ã ãããã¼ç¡ã
aws ec2 describe-instances --query "Reservations[].Instances[].\ [InstanceId,\ BlockDeviceMappings[0].DeviceName,BlockDeviceMappings[0].Ebs.DeleteOnTermination,BlockDeviceMappings[0].Ebs.VolumeId, \ BlockDeviceMappings[1].DeviceName,BlockDeviceMappings[1].Ebs.DeleteOnTermination,BlockDeviceMappings[1].Ebs.VolumeId, \ BlockDeviceMappings[2].DeviceName,BlockDeviceMappings[2].Ebs.DeleteOnTermination,BlockDeviceMappings[2].Ebs.VolumeId]" \ --output text
- å®è¡çµæ
i-xxxxxxxxxxxxxxxxx /dev/xvda True vol-0a6092980c505e7ca None None None None None None i-xxxxxxxxxxxxxxxxx /dev/sda1 True vol-0f9005c084d48a632 None None None None None None i-xxxxxxxxxxxxxxxxx /dev/xvda True vol-0e0f2f0c98bf36694 None None None None None None
ã³ãã³ã ãããã¼æã(NameTagä»ã)
echo "NameTag InstanceId DeviceName[1] DeleteOnTermination[1] VolumeId[1] DeviceName[2] DeleteOnTermination[2] VolumeId[2] DeviceName[3] DeleteOnTermination[3] VolumeId[3]" > /tmp/awscli.tmp;\ aws ec2 describe-instances --query "Reservations[].Instances[].[Tags[?Key=='Name'] | [0].Value,InstanceId,BlockDeviceMappings[0].DeviceName,BlockDeviceMappings[0].Ebs.DeleteOnTermination,BlockDeviceMappings[0].Ebs.VolumeId,BlockDeviceMappings[1].DeviceName,BlockDeviceMappings[1].Ebs.DeleteOnTermination,BlockDeviceMappings[1].Ebs.VolumeId,BlockDeviceMappings[2].DeviceName,BlockDeviceMappings[2].Ebs.DeleteOnTermination,BlockDeviceMappings[2].Ebs.VolumeId]" --output text | sort >> /tmp/awscli.tmp;\ column -t /tmp/awscli.tmp;\ rm /tmp/awscli.tmp
- å®è¡çµæ
InstanceId NameTag DeviceName[1] DeleteOnTermination[1] VolumeId[1] DeviceName[2] DeleteOnTermination[2] VolumeId[2] DeviceName[3] DeleteOnTermination[3] VolumeId[3] i-xxxxxxxxxxxxxxxxx fk-win-ad /dev/sda1 True vol-0ed26b83c38d909c8 None None None None None None i-xxxxxxxxxxxxxxxxx fk-test-jwin2019 /dev/sda1 True vol-085a475bc6367330e None None None None None None i-xxxxxxxxxxxxxxxxx fk-linux /dev/xvda True vol-0172865e01b54cad9 /dev/sdb True vol-03a8f440ea016b119 None None None
ããªã¥ã¼ã ã®è©³ç´°æ å ±åå¾
ã³ãã³ã ãããã¼ç¡ã
aws ec2 describe-volumes --query "Volumes[].[Attachments[0].InstanceId,AvailabilityZone,Encrypted,Size,State,VolumeId,Iops,VolumeType]" --output text
- å®è¡çµæ
i-xxxxxxxxxxxxxxxxxxx ap-northeast-1a False 8 in-use vol-xxxxxxxxxxxxxxxxxxxx 100 gp2 i-xxxxxxxxxxxxxxxxxxx ap-northeast-1a False 8 in-use vol-xxxxxxxxxxxxxxxxxxxx 100 gp2 None ap-northeast-1a False 10 available vol-xxxxxxxxxxxxxxxxxxxx 100 gp2
ã³ãã³ã ãããã¼æã(NameTagä»ã)
echo "InstanceId NameTag VolumeId AvailabilityZone Encrypted State Size Iops VolumeType" > /tmp/awscli.tmp;\ aws ec2 describe-volumes --query "Volumes[].[Tags[?Key=='Name'] | [0].Value,Attachments[0].InstanceId,VolumeId,AvailabilityZone,Encrypted,Size,State,Iops,VolumeType]" --output text | sort >> /tmp/awscli.tmp;\ column -t /tmp/awscli.tmp;\ rm /tmp/awscli.tmp
- å®è¡çµæ
InstanceId NameTag VolumeId AvailabilityZone Encrypted State Size Iops VolumeType i-xxxxxxxxxxxxxxxxxxx yamazon-win-2019-english vol-xxxxxxxxxxxxxxxxxxx ap-northeast-1a False 30 in-use 100 gp2 i-xxxxxxxxxxxxxxxxxxx fk-test-jwin2019 vol-xxxxxxxxxxxxxxxxxxx ap-northeast-1a False 30 in-use 100 gp2 i-xxxxxxxxxxxxxxxxxxx fk-test-vyos vol-xxxxxxxxxxxxxxxxxxx ap-northeast-1c False 4 in-use 100 gp2
ã»ãã¥ãªãã£ã°ã«ã¼ãæ å ±ã®åå¾
â»5åã ãåºåã
ã³ãã³ã ãããã¼ç¡ã
aws ec2 describe-instances --query "Reservations[].Instances[].\ [InstanceId,PrivateIpAddress,\ SecurityGroups[0].GroupName,SecurityGroups[0].GroupId,\ SecurityGroups[1].GroupName,SecurityGroups[1].GroupId,\ SecurityGroups[2].GroupName,SecurityGroups[2].GroupId,\ SecurityGroups[3].GroupName,SecurityGroups[3].GroupId,\ SecurityGroups[4].GroupName,SecurityGroups[4].GroupId]" --output text
- å®è¡çµæ
i-xxxxxxxxxxxxxxxxx 10.88.1.83 jira-t-5569 sg-024ecbe396a3b1803 fk-test-public-sg sg-00c78fbf089ace674 fk-test-redis-sg sg-01d8e3364ff438d84 None None None None i-xxxxxxxxxxxxxxxxx 10.88.1.153 fk-test-public-sg sg-00c78fbf089ace674 None None None None None None None None i-xxxxxxxxxxxxxxxxx 10.88.1.249 fk-test-vpn-sg sg-0bf94f91d38a95edf None None None None None None None None
ã³ãã³ã ãããã¼æã(NameTagä»ã)
echo "NameTag InstanceId PrivateIpAddress GroupName[1] GroupId[1] GroupName[2] GroupId[2] GroupName[3] GroupId[3] GroupName[4] GroupId[4] GroupName[5] GroupId[5]" > /tmp/awscli.tmp;\ aws ec2 describe-instances --query "Reservations[].Instances[].[Tags[?Key=='Name'] | [0].Value,InstanceId,PrivateIpAddress,SecurityGroups[0].GroupName,SecurityGroups[0].GroupId,SecurityGroups[1].GroupName,SecurityGroups[1].GroupId,SecurityGroups[2].GroupName,SecurityGroups[2].GroupId,SecurityGroups[3].GroupName,SecurityGroups[3].GroupId,SecurityGroups[4].GroupName,SecurityGroups[4].GroupId]" --output text | sort >> /tmp/awscli.tmp;\ column -t /tmp/awscli.tmp;\ rm /tmp/awscli.tmp
- å®è¡çµæ
InstanceId NameTag PrivateIpAddress GroupName[1] GroupId[1] GroupName[2] GroupId[2] GroupName[3] GroupId[3] GroupName[4] GroupId[4] GroupName[5] GroupId[5] i-xxxxxxxxxxxxxxxxx fk-win-ad 10.88.0.240 fk-test-ad-sg sg-0754867b9033b3199 None None None None None None None None i-xxxxxxxxxxxxxxxxx fk-test-jwin2019 10.88.0.150 fk-test-public-sg sg-00c78fbf089ace674 None None None None None None None None i-xxxxxxxxxxxxxxxxx fk-test-vyos 10.88.1.249 fk-test-vpn-sg sg-0bf94f91d38a95edf None None None None None None None None
ã¿ã°æ å ±ã®åå¾
ã³ãã³ã ãããã¼ç¡ã
aws ec2 describe-instances --query "Reservations[].Instances[].\ [InstanceId,\ Tags[0].Key,Tags[0].Value,\ Tags[1].Key,Tags[1].Value,\ Tags[2].Key,Tags[2].Value,\ Tags[3].Key,Tags[3].Value,\ Tags[4].Key,Tags[4].Value,\ Tags[5].Key,Tags[5].Value,\ Tags[6].Key,Tags[6].Value,\ Tags[7].Key,Tags[7].Value,\ Tags[8].Key,Tags[8].Value,\ Tags[9].Key,Tags[9].Value]" --output text
- å®è¡çµæ
i-xxxxxxxxxxxxxxxxx Name fk-linux-jira None None None None None None None None None None None None None None None None None None i-xxxxxxxxxxxxxxxxx Name fk-test-jwin2019-02 None None None None None None None None None None None None None None None None None None i-xxxxxxxxxxxxxxxxx Name fk-test-vyos None None None None None None None None None None None None None None None None None None i-xxxxxxxxxxxxxxxxx Name fk-linux Inspector True None None None None None None None None None None None None None None None None
ã³ãã³ã ãããã¼æã
echo "InstanceId \ Tag-Key[1] Tag-Value[1] \ Tag-Key[2] Tag-Value[2] \ Tag-Key[3] Tag-Value[3] \ Tag-Key[4] Tag-Value[4] \ Tag-Key[5] Tag-Value[5] \ Tag-Key[6] Tag-Value[6] \ Tag-Key[7] Tag-Value[7] \ Tag-Key[8] Tag-Value[8] \ Tag-Key[9] Tag-Value[9] \ Tag-Key[10] Tag-Value[10]" > /tmp/awscli.tmp;\ aws ec2 describe-instances --query "Reservations[].Instances[].\ [InstanceId,\ Tags[0].Key,Tags[0].Value,\ Tags[1].Key,Tags[1].Value,\ Tags[2].Key,Tags[2].Value,\ Tags[3].Key,Tags[3].Value,\ Tags[4].Key,Tags[4].Value,\ Tags[5].Key,Tags[5].Value,\ Tags[6].Key,Tags[6].Value,\ Tags[7].Key,Tags[7].Value,\ Tags[8].Key,Tags[8].Value,\ Tags[9].Key,Tags[9].Value]" --output text >> /tmp/awscli.tmp;\ column -t /tmp/awscli.tmp;\ rm /tmp/awscli.tmp
- å®è¡çµæ
InstanceId Tag-Key[1] Tag-Value[1] Tag-Key[2] Tag-Value[2] Tag-Key[3] Tag-Value[3] Tag-Key[4] Tag-Value[4] Tag-Key[5] Tag-Value[5] Tag-Key[6] Tag-Value[6] Tag-Key[7] Tag-Value[7] Tag-Key[8] Tag-Value[8] Tag-Key[9] Tag-Value[9] Tag-Key[10] Tag-Value[10] i-xxxxxxxxxxxxxxxxx Name fk-linux-jira None None None None None None None None None None None None None None None None None None i-xxxxxxxxxxxxxxxxx Name fk-test-jwin2019-02 None None None None None None None None None None None None None None None None None None i-xxxxxxxxxxxxxxxxx Name fk-linux Inspector True None None None None None None None None None None None None None None None None
ãããã«
ä»åã¯ãEC2é¢é£ã®ãªã½ã¼ã¹ãä¸è¦§åå¾ããã³ãã³ãããç´¹ä»ãããã¾ããã
次åã¯ããããæ
å ±ãCSVå½¢å¼ã§åºåããæ¹æ³ããç´¹ä»ãããã¨æãã¾ãã