我创建了一个参数:
Parameters:
..
list:
Description: "Provide a list .."
Type: CommaDelimitedList
Default: "test1, test2"
现在我想引用这个列表(将在我的cloudformation中的文件中解析" test1"," test2",..),如下所示:
configure_xx:
files:
/etc/file.conf:
content: !Sub |
input {
logs {
log_group => [ "${list}" ]
access_key_id => "${logstashUserKey}"
secret_access_key => "${logstashUserKey.SecretAccessKey}"
region => "eu-west-1"
}
}
如何使这个参数列表工作? (钥匙工作)。
错误:Fn::Sub expression does not resolve to a string
答案 0 :(得分:1)
只需切换" String"
的参数类型Parameters:
..
list:
Description: "Provide a list .."
Type: String
Default: "test1, test2"
如果由于某种原因,您无法控制此参数类型,则可以使用Fn::Join
将列表转换为字符串。例如:
configure_xx:
files:
/etc/file.conf:
content:
Fn::Sub:
- |-
input {
logs {
log_group => [ "${joinedlist}" ]
access_key_id => "${logstashUserKey}"
secret_access_key => "${logstashUserKey.SecretAccessKey}"
region => "eu-west-1"
}
}
- joinedlist:
Fn::Join:
- ', '
- !Ref list