![](/img/trans.png)
[英]Enforce AllowedPattern for parameter of type CommaDelimitedList in Cloudformation script
[英]Aws cli cloudformation error seen on passing parameter value of type CommaDelimitedList
我看到CommaDelimitedList参数值的无效类型错误。 CF运行成功,控制台没有任何错误。
AWS CLI命令:
aws cloudformation create-stack --stack-name agkTestUserStack --template-body file://api_user.yaml --parameters ParameterKey=CustomUserName,ParameterValue="svc_TestUser" ParameterKey=GroupAssociations,ParameterValue="Dev,Test"
输出:
Parameter validation failed:
Invalid type for parameter Parameters[1].ParameterValue, value: [u'Dev', u'Test'], type: <type 'list'>, valid types: <type 'basestring'>
AWS CLI版本:aws-cli / 1.15.75 Python / 2.7.9 Windows / 8 botocore / 1.10.74
api_user.yaml:
AWSTemplateFormatVersion: 2010-09-09
Parameters:
CustomUserName:
Type: String
Description: Custom user name
Default: ''
GroupAssociations:
Type: CommaDelimitedList
Description: Comma-delimited list of groups to associate the user
Default: ''
Conditions:
NoGroups: !Equals
- !Join
- ''
- !Ref GroupAssociations
- ''
NoUserName: !Equals
- !Ref CustomUserName
- ''
Resources:
CustomUser:
Type: 'AWS::IAM::User'
Properties:
UserName: !If
- NoUserName
- !Ref AWS::NoValue
- !Ref CustomUserName
Groups: !If
- NoGroups
- !Ref AWS::NoValue
- !Ref GroupAssociations
Outputs:
UserName:
Description: User instance name
Value: !Ref CustomUser
Export:
Name: UserName
UserArn:
Description: User instance ARN
Value: !GetAtt CustomUser.Arn
Export:
Name: UserArn
默认情况下,aws cli将逗号分隔的值用作List,因此您需要使用\\
字符对逗号进行转义。 请按照以下步骤重试。
aws cloudformation create-stack --stack-name agkTestUserStack --template-body file://api_user.yaml --parameters ParameterKey=CustomUserName,ParameterValue="svc_TestUser" ParameterKey=GroupAssociations,ParameterValue="Dev\,Test"
我也看到了错误
参数验证失败:无效类型参数的参数[2] .ParameterValue,值:[U ' 的http://本地主机:3000 ',U ' https://subdomain.example.business.com '],类型:,有效类型:
...当我尝试不正确地将以逗号分隔的URL列表作为参数传递给模板时,例如:
aws cloudformation create-stack --stack-name STACKNAME --template-body file://cognito-idp-saml.yaml --parameters ParameterKey=CallbackURLs,ParameterValue=http://localhost:3000,https://subdomain.example.business.com
对我来说,解决方法是将ParameterValue
的值括在双引号中(如下所示)。
当我提供URL的CommaDelimetedList时\\,
转义逗号\\,
的建议对我不起作用。 某些参数验证引发错误。 我想\\
不是URL中的有效字符,但是String属性(GroupAssociation)可能不在乎它的值是否带有\\
字符,尽管我认为应用程序代码可能会这样。
示例模板:
Parameters:
CallbackURLs:
Type: CommaDelimitedList
Resources:
blahblah:
Properties:
SomeListProp: !Ref CallbackURLs
示例正确地传递列表参数:
aws cloudformation create-stack --stack-name STACKNAME --template-body file://cognito-idp-saml.yaml --parameters ParameterKey=CallbackURLs,ParameterValue="http://localhost:3000,https://subdomain.example.business.com"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.