Look up Security Group names by id

How do I find the names of security groups, when I only have their id’s?


Related discussions:

The awless CLI from awless by wallix can do this pretty easily via running the command “awless list securitygroups” in the default text output mode you’ll get a nicely formatted table with columns including the sg-value, the VPC, the inbound rules, the outbound rules, and finally in the last column you will see the human readable Name value.

And the command “awless list securitygroups --columns ID,Name” will give you a nice clean list of just the Names and their associated IDs

Even better, just run “awless show ID” and it gives you all the details about that SG.

I really like the tool. It doesn’t offer everything, but it has a few simple commands that give you a lot of information. I use it in conjunction with aws-shell.

Tried that first but it crashed for me, turns out ‘awless sync’ crashes for me on a particular massive VPC with tons of resources and tens of thousands of snapshots etc.

Off the top of my head, this AWS CLI command should be close:

aws ec2 describe-security-groups --group-ids "<your sg id>" --query 'SecurityGroups[0].GroupName' --output text

I really want to ask why you need their names… Only to make sure your aren’t getting confused between EC2 classic security groups and EC2 VPC groups.

In CloudFormation for example, you only need the Id for vpc groups but the name for classic groups.