AWS Notes: Difference between revisions

From Federal Burro of Information
Jump to navigationJump to search
Line 44: Line 44:
  done
  done
</pre>
</pre>
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=i-01221d9d20de58b36" --out text


== Also see ==
== Also see ==

Revision as of 03:10, 4 October 2016

Centos 7 products:

https://aws.amazon.com/marketplace/fulfillment?productId=b7ee8a69-ee97-4a49-9e68-afaee216db2e&launch=oneClickLaunch

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

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}
  aws ec2 --query 'Reservations[*].Instances[*].[State.Name, InstanceId, ImageId, PrivateIpAddress, PublicIpAddress, InstanceType]' describe-instances --output text --filter "Name=subnet-id,Values=${subnet}"
  # aws ec2  describe-instances --filter "Name=subnet-id,Values=${subnet}"
 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=i-01221d9d20de58b36" --out text

Also see