How do I pass a list of strings as a parameter in CloudFormation?
As @MaiKaY points out, the flaw in @Liam Mayfair's code is that Fn::Split
is preceded by -
which results in a list containing a single element which is a list. The fixed code would look like
...
Resource:
Fn::Split:
- ","
- !Ref S3Buckets
On a more general note, you must make sure to use a Parameter type of String
not CommaDelimitedList
when using Fn::Split
as it won't split a CommaDelimitedList
.
- If you use
CommaDelimitedList
withFn::Split
you'll get the errorTemplate 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
- If you use
CommaDelimitedList
with noFn::Split
you'll get the errorSyntax errors in policy
Because the return value of !Split
is A list of string values.
I would do it in the following way:
[...]
Resource: !Split [",", !Ref S3Buckets]
[...]