Accessing AWS instance metadata in Chef

Your AWS instance metadata is available by sending an HTTP GET request to the IP 169.254.169.254. Say you wanted to get the availability zone of the instance you’re provisioning in Chef, you could simply use Chef::HTTP::Simple.new('http://169.254.169.254').get('/latest/meta-data/placement/availability-zone').

For Ansible you should use the ec2_facts module.

 
3
Kudos
 
3
Kudos

Now read this

Getting the tags of an EC2 instance in Ansible

Say you are working on some Ansible for a client and they say to you “Hey, I really like the stuff you did but it’d be helpful if I knew what box I was SSH’d into.” since EC2 hostnames default to a dashed notation of their private IP... Continue →