繁体   English   中英

在 Cloudformation 脚本中为 CommaDelimitedList 类型的参数强制执行 AllowedPattern

[英]Enforce AllowedPattern for parameter of type CommaDelimitedList in Cloudformation script

我试图在我的参数上使用正则表达式强制执行允许的模式,但是当我尝试构建我的堆栈时,我收到以下错误消息:

模板验证错误:模板错误:参数“myParam”AllowedPattern 必须位于字符串类型的参数上

这是我的参数定义:

"myParam": {
   "Description": "this is my param",
   "Type": "CommaDelimitedList",
   "AllowedPattern": "\\+[0-9\\-\\ ]+",
   "MinLength": "1"
 }

我相信你不能在CommaDelimitedList上做正则表达式。 正则表达式只能应用于字符串。

CommaDelimitedList - 由逗号分隔的文字字符串数组

您的参数是CommaDelimitedList类型,而不是String 属性AllowedPattern (也是MinLength )仅适用于String类型。

有关详细信息,请参阅http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html

CloudFormation 参数现在支持 CommaDelimitedLists 的 AllowedPattern(和 AllowedValues)。 如果您在 CommaDelimitedList 上应用 AllowedPattern 或 AllowedValues,则会针对列表中的每个项目检查约束。 请参阅此处的文档:

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM