Chris Williams
Chris Williams

Reputation: 11

Pre-populate Keys (but not Values) Tags when creating cloudformation template

I'm trying to create a cloudformation template that, during the "Options" phase, has a list of tags pre-populated... but not the values. The thinking here is that the user will fill in the Values for a set list of Keys before proceeding with the creation of the stack. Pic of Options section

Upvotes: 0

Views: 286

Answers (2)

maafk
maafk

Reputation: 6876

One option would be to create a main CloudFormation stack (or parent stack), that has Parameter values for all the keys you'd like for the Stack tags, then use those parameters to create a child stack, which would be tagged appropriately contain all the resources you'd need.

For example:

AWSTemplateFormatVersion: 2010-09-09
Parameters:
  MyFirstStackKey:
    Type: String
    Default: some default value
  MySecondStackKey:
    Type: String
    Default: some other default value
  AnotherStackKey:
    Type: String
    Default: checkout this other default value
Resources:
  SomeChildStack:
  Type: AWS::CloudFormation::Stack
  Properties:
    Parameters:
      SomeParam: AWS CloudFormation Stack Parameters
    TemplateURL: !Ref SomeTemplateUrl
    Tags:
      - Key: MyFirstStackKey
        Value: !Ref MyFirstStackKey
      - Key: MySecondStackKey
        Value: !Ref MySecondStackKey
      - Key: AnotherStackKey
        Value: !Ref AnotherStackKey

Upvotes: 0

cementblocks
cementblocks

Reputation: 4606

Those tags are not controlled by the cloudformation template, only the parameters are.

Upvotes: 1

Related Questions