AWS Notes: Difference between revisions
From Federal Burro of Information
Jump to navigationJump to search
Line 62: | Line 62: | ||
aws ec2 --query 'Tags[*].[Value]' describe-tags --filter "Name=resource-id,Values=<id>" "Name=Key,Value=Name" --out text | aws ec2 --query 'Tags[*].[Value]' describe-tags --filter "Name=resource-id,Values=<id>" "Name=Key,Value=Name" --out text | ||
list all instance acorss all regions: | |||
<pre> | |||
for region in `aws ec2 describe-regions --output text | cut -f3`; | |||
do | |||
echo -e "\nListing Instances in region:'$region'..."; | |||
aws ec2 describe-instances \ | |||
--query 'Reservations[*].Instances[*].[PrivateIpAddress, InstanceId, ImageId, PublicIpAddress, State.Name, InstanceType]' \ | |||
--output text \ | |||
--region $region | |||
done | |||
</pre> | |||
== Also see == | == Also see == |
Revision as of 18:58, 17 March 2017
Centos 7 products:
accept lic nad choose a region -> ami id on this page.
blat keys
reference: https://alestic.com/2010/10/ec2-ssh-keys/
#!/bin/sh keypair=keyname # or some name that is meaningful to you publickeyfile=/the/file/me.pub regions=$(aws ec2 describe-regions \ --output text \ --query 'Regions[*].RegionName') for region in $regions; do echo $region aws ec2 import-key-pair \ --region "$region" \ --key-name "$keypair" \ --public-key-material "file://$publickeyfile" done
text report
be aware of your "region" set it in command line with --region
list subnets
aws ec2 --query 'Subnets[*].[SubnetId, AvailabilityZone, CidrBlock, AvailableIpAddressCount]' describe-subnets --output text
list instances by subnet
aws ec2 --query 'Subnets[*].[SubnetId, CidrBlock]' describe-subnets --output text | while read subnet cidr do echo Subnet ${subnet} ${cidr} for i in `aws ec2 --query 'Reservations[*].Instances[*].[InstanceId]' describe-instances --output text --filter "Name=subnet-id,Values=${subnet}"` do name=`aws ec2 --query 'Tags[*].[Value]' describe-tags --filter "Name=resource-id,Values=${i}" "Name=key,Values=Name" --out text` echo -n ${name} " " aws ec2 --query 'Reservations[*].Instances[*].[State.Name, InstanceId, ImageId, PrivateIpAddress, PublicIpAddress, InstanceType]' describe-instances --output text --filter "Name=subnet-id,Values=${subnet}" "Name=instance-id,Values=${i}" done done
Good ref for getting tags : http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-tags.html
getting tags example:
aws ec2 --query 'Tags[*].[Value]' describe-tags --filter "Name=resource-id,Values=<id>"
just an instance's name:
aws ec2 --query 'Tags[*].[Value]' describe-tags --filter "Name=resource-id,Values=<id>" "Name=Key,Value=Name" --out text
list all instance acorss all regions:
for region in `aws ec2 describe-regions --output text | cut -f3`; do echo -e "\nListing Instances in region:'$region'..."; aws ec2 describe-instances \ --query 'Reservations[*].Instances[*].[PrivateIpAddress, InstanceId, ImageId, PublicIpAddress, State.Name, InstanceType]' \ --output text \ --region $region done
Also see
- instance costing tool: http://www.ec2instances.info/