ec2-get-tag

ec2-get-tag is a one-liner that retrieves the value of a tag you set on your EC2 instance.

1. First add the following IAM policy to your EC2 instance:

{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Effect": "Allow",
			"Action": "ec2:DescribeTags",
			"Resource": "*"
		}
	]
}

2. Now you can execute the following

curl -s https://raw.githubusercontent.com/saoudrizwan/ec2-get-tag/1.0/ec2-get-tag.sh | bash -s TAGNAME

Sources