Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloudformation security group set group name

Using cloudformation SecurityGroup is possible set the GroupName or has to be provide by cloudformation?.

The final name format it´s pretty long and does not look nice, also is not a good match to use it for find it by command line.

I know I can use tags, but still don't understand why AWS don't allow us to add it, I guess because they´re lazy and they don't want to implement a validation.

Regards.

like image 350
paul Avatar asked Jun 29 '16 09:06

paul


2 Answers

You can set the name for a SecurityGroup by adding a Tag with the key "Name", like this:

"MySecurityGroup": {
  "Type": "AWS::EC2::SecurityGroup",
  "Properties": {
    "GroupDescription": "Allow http",
    "SecurityGroupIngress": [
      {"IpProtocol": "tcp", "FromPort": "80", "ToPort": "80", "CidrIp": "0.0.0.0/0"}
    ],
    "Tags": [
      {"Key": "Name", "Value": "MySecurityGroup"},
    ]
  }
},
like image 196
Markus Herzog Avatar answered Oct 17 '22 22:10

Markus Herzog


[Updated Jun 26 2017] As of Apr 28 2017, it is now possible to specify a custom name for an EC2 Security Group using CloudFormation, using the GroupName property on the AWS::EC2::SecurityGroup resource.

Thanks surenyonjan for the comment on this update.


[Original answer Dec. 23 2016] - No, it is not currently possible to provide a custom name for an EC2 Security Group using CloudFormation.

According to the AWS::EC2::SecurityGroup resource documentation, there is no Name or GroupName property available. You can provide tags using the Tags property as an alternative, as you pointed out.

Recently, some CloudFormation resources have started supporting custom names via a Name property. A full list of supported resources is in the Name Type section of the documentation.

AWS::EC2::SecurityGroup is not one of the resources supporting custom names. As for why, presumably this is because this CloudFormation resource is an earlier implementation, created before custom names were supported by the service.

It's possible that AWS will eventually go back and update all of its existing CloudFormation resources with custom name support at some point, if enough users ask them to do so. If this is an important/critical feature for your use case, I'd recommend contacting their product/support teams with a feature request to help them make it higher priority.

like image 34
wjordan Avatar answered Oct 18 '22 00:10

wjordan