amazon-web-services - 在传递 CommaDelimitedList 类型的参数值时看到 Aws cli cloudformation 错误
问题描述
我看到 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"
推荐阅读
- c# - 给定属性名称,是否有返回对象属性值的 C# 函数?
- javascript - 如何将动态值传递给@Html.Action()
- mysql - PGChameleon 复制错误,没有记录
- python - 如何在 matplotlib 中的 NonUniformImage 中反转轴?
- redmine - 通过电子邮件在 Redmine 中生成票证
- python - 如何在 pandas DataFrame 中迭代字符串对象
- php - MySql - 使用 FIFO 逻辑更新行的状态
- python - 如何使用 BeautifulSoup 从 Python 网站中未加载的选项卡中抓取表数据
- python - 求解数独的回溯算法
- python - 递归树搜索以获取节点级别