-
-
Save gregtaylor99/ef6f4ae67af35325d04d5eeacac8abce to your computer and use it in GitHub Desktop.
EC2 tag itself on instance launch with UserData
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
az=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone) | |
region=${az%%?} | |
instance_id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) | |
aws ec2 create-tags --resources $instance_id --region $region --tags \ | |
Key=foo,Value=bar \ | |
Key=Name,Value=myname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment