Reputation: 641
I'm trying to find security group ID in metadata, but there is only a name of the group.
The get the name with curl
like this:
curl http://169.254.169.254/latest/meta-data/security-groups/
RESULT
some-secgroup-name
I need the ID like this one sg-1234567911
Any Idea how to I find in metadata (whitout CLI)?
Upvotes: 2
Views: 1327
Reputation: 21275
You'll need the MAC address of the instance. To obtain that you can do a curl
using the metadata url:
http://169.254.169.254/latest/meta-data/mac
Once you have that, you can get the security groups from the network
section:
http://169.254.169.254/latest/meta-data/network/interfaces/macs/<your_mac>/security-group-ids
Upvotes: 6