Skip to content

Instantly share code, notes, and snippets.

View SarahFrench's full-sized avatar
💭
PTO, I won't respond to @ mentions

Sarah French SarahFrench

💭
PTO, I won't respond to @ mentions
View GitHub Profile
@SarahFrench
SarahFrench / ec2_self_tagging.sh
Created May 29, 2024 15:24 — forked from pahud/ec2_self_tagging.sh
EC2 tag itself on instance launch with UserData
#!/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