aws-cloudformation / cfn-language-discussion

Language discussions for CloudFormation template language
https://aws.amazon.com/cloudformation/
Apache License 2.0
142 stars 13 forks source link

Allow CommaDelimitedList stack parameters to be passed to CommaDelimitedList parameters in nested stacks. #115

Open josb opened 1 year ago

josb commented 1 year ago

Community Note

Tell us about your request

Allow CommaDelimitedList stack parameters to be passed to CommaDelimitedList parameters in nested stacks.

Tell us about the problem you are trying to solve. What are you trying to do, and why is it hard?

I am trying to lower the cognitive burden of dealing with CloudFormation CommaDelimitedList parameters by making them adhere to the Principle Of Least Surprise more. Coming from other programming languages, it is surprising that one cannot pass a parameter of a given data type to a receiving parameter of the same data type.

Are you currently working around this issue?

One has to define the parameter in the calling stack as a String.

What is the expect behavior with this new feature

Main stack:

Parameters:
  Foo:
    Type: CommaDelimitedList
...
  S3Bucket:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: "nested/stack.yaml"
      Parameters:
        Foo: !Ref Foo

Nested stack:

Parameters:
  Foo:
    Type: CommaDelimitedList

Resources:
  # Use !Ref Foo

Additional context

Don't break existing behavior. But since this is currently prohibited this should not be a problem. The current error one sees is:

Value of property Parameters must be an object with String (or simple type) properties

Attachments

None.

josb commented 1 year ago

The CommaDelimited type is really a String that upon assignment turns its value into a list. This seems to be the problematic part of the data type - it's a list that can only be initialized with a String.

Perhaps it makes more sense to make List<String> work.

MalikAtalla-AWS commented 1 year ago

Thanks @josb for raising this issue. We'll triage this issue internally.