How to append a list in CloudFormation

痴心易碎 提交于 2020-07-22 21:34:25

问题


In CloudFormation, how can I append a list? Tried:

!Join [ ",", [ !Ref ListParam, !Ref StringParam ]]

but got an error:

A client error (ValidationError) occurred when calling the
ValidateTemplate operation: Template error: every Fn::Join object
requires two parameters, (1) a string delimiter and (2) a list of
strings to be joined or a function that returns a list of strings
(such as Fn::GetAZs) to be joined.

回答1:


First, we need to know what do you want to achieve. If you want to append new a string parameter into a list and get the output in one String you can use !Join. Because the characteristic of !Join is to appends a set of values into a single value. If you want to do that you can try the code below:

!Join [ ",", [ !Join [ ",", [ !Ref ListParam ] ], !Ref StringParam ] ]

If you want to append those values into List type, you should try another way. It will be easier if you provide the example case.




回答2:


According to the error, the second parameter can be:

  • A list of strings, OR
  • A function that returns a list of strings

You are providing a list that includes a Function and a String. That is most probably the problem.

You could try calling it first with ListParam to convert the list into a string, and then concatenate String Param to the end of it.

Meta-code:

  • If ListParam = [a,b,c] and StringParam = 'd'
  • Join(',', Join(',', ListParam), StringParam)


来源:https://stackoverflow.com/questions/46851161/how-to-append-a-list-in-cloudformation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!