在传递CommaDelimitedList类型的参数值时看到AWS CLI Cloudformation错误 [英] Aws cli cloudformation error seen on passing parameter value of type CommaDelimitedList
本文介绍了在传递CommaDelimitedList类型的参数值时看到AWS CLI Cloudformation错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看到了CommaDelimitedList参数值的无效类型错误。 CF可以从控制台正常运行。
I am seeing an invalid-type error for a CommaDelimitedList parameter value. The CF runs without any errors from the console.
AWS CLI命令:
AWS CLI command:
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
AWS CLI version: aws-cli/1.15.75 Python/2.7.9 Windows/8 botocore/1.10.74
api_user.yaml:
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,因此您需要使用 \来转义逗号。
字符。请按照以下步骤重试。
By default, aws cli takes comma seperated value as List, hence you need to escape commas by using \
character. Please retry as per below.
aws cloudformation create-stack --stack-name agkTestUserStack --template-body file://api_user.yaml --parameters ParameterKey=CustomUserName,ParameterValue="svc_TestUser" ParameterKey=GroupAssociations,ParameterValue="Dev\,Test"
这篇关于在传递CommaDelimitedList类型的参数值时看到AWS CLI Cloudformation错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文