William Ross
William Ross

Reputation: 3910

AWS using groupName rather than groupId for security group?

I have a Cloud Formation Template which specifies VPC security group ids in JSON like this:

"SecurityGroupIds": ["sg-abcd1234","sg-efjh6789"]

I would like to replace these security group ids with the name of the security group themselves like:

"SecurityGroupIds": ["MySecurityGroupName1","MySecurityGroupName2"]

How can I switch from using the security group ID, to using the security group name?

Upvotes: 0

Views: 1283

Answers (1)

helloV
helloV

Reputation: 52393

Use SecurityGroups but it is valid only for Amazon EC2 security groups. I assume you are using VPC security groups in which case you can use only the security group ids.

Valid only for Amazon EC2 security groups.

"SecurityGroups": ["MySecurityGroupName1","MySecurityGroupName2"]

But if you are creating the security groups in the same CF, then refer to it by name:

"SecurityGroupIds" : [ { "Ref" : "MyAWSSecurityGroup" } ],

Upvotes: 1

Related Questions