Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to parameterize cloud formation resource names?

I'm trying to make AutoScalingGroup names on cloud formation templates dynamic. I was thinking if this is possible via parameters, or any other way?

"DynamicASGName": {
      "Type": "AWS::AutoScaling::AutoScalingGroup",
      "Properties": {
      ...properties here...
      }
    }
like image 921
froi Avatar asked Jun 16 '16 09:06

froi


1 Answers

CloudFormation uses two sets of names: the logical resource name, to identify a resource within the stack, and the physical name which uniquely identifies it across the whole region.

CloudFormation doesn't support setting the logical name dynamically, but with certain types, you can set the physical name in the template with the Name property. For example:

  MyUserPoolClient:
    Type: AWS::Cognito::UserPoolClient
    Properties:
      UserPoolId: !Ref MyUserPool
      ClientName: !Sub '${AppName}-userpoolclient'
      GenerateSecret: false

Unfortunately, AutoScalingGroup doesn't support this.

A better solution is probably to use Tags on your resources. Most AWS resource types (including AutoScalingGroup) support Tags and they can be set dynamically in a CloudFormation template.

like image 122
ataylor Avatar answered Oct 04 '22 07:10

ataylor