Skip to content

Instantly share code, notes, and snippets.

@daviddyball
Forked from ianmas-aws/gist:8840850
Created February 20, 2014 08:31
Show Gist options
  • Save daviddyball/9109202 to your computer and use it in GitHub Desktop.
Save daviddyball/9109202 to your computer and use it in GitHub Desktop.
Try this - it requires that you have the AWS command line tools installed and that your instance has either been assigned an IAM role with sufficent permissions, or that your AWS command line tools have been set up with the right credentials. You should use IAM roles if you want to get this info at first boot, which I suspect is what you want to use this for?
aws ec2 describe-instances --region eu-west-1 --output text --instance-ids `curl -s http://169.254.169.254/latest/meta-data/instance-id` | grep TAGS
If you create an IAM role called AllowDescribeInstances with the following policy this and assign it to your instances, this is the minimum permissions set that is required.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1391694313000",
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances"
],
"Resource": [
"*"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment