Category: AWS


aws – iterate instances across all regions

By polfilm,

describe_all_instances.sh

for region in `aws ec2 describe-regions --output text | cut -f3`
do
     echo -e "\nListing Instances in region:'$region'..."
     aws ec2 describe-instances --region $region | jq '.Reservations[] | ( .Instances[] | {state: .State.Name, name: .KeyName, type: .InstanceType, key: .KeyName})'
done

describe_all_stacks.sh

for region in `aws ec2 describe-regions --output text | cut -f3`
do
     echo -e "\nListing Stacks in region:'$region'..."
     aws cloudformation describe-stacks --region $region | jq '( .Stacks[] | {stackid: .StackId, status: .StackStatus})'
done

AWS SSH Fingerprint

By polfilm,

IF SHORT

root@ubuntu:~/.ssh/mac$ openssl pkey -in id_rsa -pubout -outform DER | openssl md5 -c
(stdin)= 6a:96:26:bd:fd:41:4f:53:77:67:78:13:01:c9:9c:12

IF LONG

openssl pkcs8 -in aws_private.pem -nocrypt -topk8 -outform DER | openssl sha1 -c

Fedora 20. Set hostname permanently.

By polfilm,

1.Set the hostname in /etc/hostname

2. Edit /etc/cloud/cloud.cfg (which is a YAML file) and set preserve_hostname: true at the toplevel (one can also pass this option in with the user data)

Knife EC2 [official]

By polfilm,

This is the official Opscode Knife plugin for EC2. This plugin gives knife the ability to create, bootstrap, and manage EC2 instances.

https://github.com/opscode/knife-ec2

knife ec2 server create -r "role[ubuntu]" -I ami-399ca94d -f m1.small -S knife -i ~/.ssh/knife.pem --ssh-user ubuntu --region eu-west-1 -Z eu-west-1a

knife ec2 server list --region eu-west-1