gpt4 book ai didi

amazon-web-services - 在传递 CommaDelimitedList 类型的参数值时出现 AWS cli cloudformation 错误

转载 作者:行者123 更新时间:2023-12-02 23:46:08 24 4
gpt4 key购买 nike

我发现 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 将逗号分隔值作为列表,因此您需要使用 \ 字符转义逗号。请按照以下方式重试。

aws cloudformation create-stack --stack-name agkTestUserStack --template-body file://api_user.yaml --parameters ParameterKey=CustomUserName,ParameterValue="svc_TestUser" ParameterKey=GroupAssociations,ParameterValue="Dev\,Test"

关于amazon-web-services - 在传递 CommaDelimitedList 类型的参数值时出现 AWS cli cloudformation 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52394889/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com