[英]Enforce AllowedPattern for parameter of type CommaDelimitedList in Cloudformation script
I'm trying to enforce an allowed pattern with regex on my parameter, but when I try to build my stack, I get the following error message:我试图在我的参数上使用正则表达式强制执行允许的模式,但是当我尝试构建我的堆栈时,我收到以下错误消息:
Template validation error: Template error: Parameter 'myParam' AllowedPattern must be on a parameter of type String
模板验证错误:模板错误:参数“myParam”AllowedPattern 必须位于字符串类型的参数上
This is my Parameter definition:这是我的参数定义:
"myParam": {
"Description": "this is my param",
"Type": "CommaDelimitedList",
"AllowedPattern": "\\+[0-9\\-\\ ]+",
"MinLength": "1"
}
I believe you can't do regex on CommaDelimitedList. 我相信你不能在CommaDelimitedList上做正则表达式。 Regex can only be applied on strings.
正则表达式只能应用于字符串。
CommaDelimitedList – An array of literal strings that are separated by commas CommaDelimitedList - 由逗号分隔的文字字符串数组
Your parameter is of type CommaDelimitedList
, not String
. 您的参数是
CommaDelimitedList
类型,而不是String
。 Attribute AllowedPattern
(also MinLength
) only applies to type String
. 属性
AllowedPattern
(也是MinLength
)仅适用于String
类型。
See eg http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html for more details. 有关详细信息,请参阅http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html 。
AllowedPattern (and AllowedValues) for CommaDelimitedLists are now supported in CloudFormation parameters. CloudFormation 参数现在支持 CommaDelimitedLists 的 AllowedPattern(和 AllowedValues)。 If you apply an AllowedPattern or AllowedValues on a CommaDelimitedList, the constraint is checked for each item in the list.
如果您在 CommaDelimitedList 上应用 AllowedPattern 或 AllowedValues,则会针对列表中的每个项目检查约束。 See the documentation here:
请参阅此处的文档:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.