snippetMinor
How to list security groups for the specific instance via CLI?
Viewed 0 times
groupstheinstancesecurityviaforclihowlistspecific
Problem
I'm looking for syntax like:
however, the above sub-command doesn't support
I've checked and there are
What would be the easiest way to display the description of the security group of the instance?
aws ec2 describe-security-groups --instance-id i-0xyzhowever, the above sub-command doesn't support
--instance-id parameter.I've checked and there are
--filters and --query parameters, but I'm not sure about the syntax.What would be the easiest way to display the description of the security group of the instance?
Solution
The following one-liner in shell works for me:
Where
aws ec2 describe-security-groups --group-ids $(aws ec2 describe-instances --instance-id $id --query "Reservations[].Instances[].SecurityGroups[].GroupId[]" --output text) --output textWhere
$id is my instance-id.Code Snippets
aws ec2 describe-security-groups --group-ids $(aws ec2 describe-instances --instance-id $id --query "Reservations[].Instances[].SecurityGroups[].GroupId[]" --output text) --output textContext
StackExchange DevOps Q#3290, answer score: 5
Revisions (0)
No revisions yet.