goformation icon indicating copy to clipboard operation
goformation copied to clipboard

Can't use parameters of type `List<>`

Open ndeloof opened this issue 4 years ago • 4 comments

I'd like to define a template parameter as List<AWS::EC2::Subnet::Id> but I can't set directly Subnets: cloudformation.Ref("SubnetIds") as expected API type is []string while Ref return a single string.

I tried using []string{ cloudformation.Split(",", cloudformation.Ref("SubnetIds")), this produces template:

"Subnets": [
              {
                "Fn::Split": [
                  ",",
                  {
                    "Ref": "SubnetIds"
                  }
                ]
              }
]

This seems valid to me, but fail to validate : ValidationError: Template error: every Fn::Split object requires two parameters, (1) a string delimiter and (2) a string to be split or a function that returns a string to be split.

Did I miss something ? Is there a better approach to manage List<> references ?

ndeloof avatar May 12 '20 10:05 ndeloof

@ndeloof did you solved that issue maybe?

xrn avatar Jul 29 '20 06:07 xrn

nope

ndeloof avatar Jul 29 '20 07:07 ndeloof

I need also to achieve this - seems that cloudformation.Split(",", cloudformation.Ref("SubnetIds") is incorrect from the perspective of cloudformation. Second side is that goformation is expecting []string probably in this place it should be replaced to interface{}

xrn avatar Sep 22 '20 10:09 xrn

@ndeloof I solved that problem - please take a look on #309 and then use just cloudformation.Join(",", cloudformation.Ref("SubnetIds")) <- this will return String [A,B] - then you can use split, select etc

xrn avatar Sep 23 '20 17:09 xrn