gpt4 book ai didi

amazon-web-services - 解析参数 '--parameters' : Expected: '=' , 时出错: 'P'

转载 作者:行者123 更新时间:2023-12-04 17:33:20 24 4
gpt4 key购买 nike

我正在使用 aws cli cloudformation。在使用 JSON 参数文件和 yml 模板时,我不断收到错误。我尝试使用创建堆栈更新堆栈以及更改集。

Error parsing parameter '--parameters': Expected: '=', received: 'P' for input: 
- ParameterKey: FunctionName
^
ParameterValue: taskaplambda
- ParameterKey: MemorySize
ParameterValue: 512
- ParameterKey: Timeout
ParameterValue: 5

我的命令在哪里:

aws cloudformation update-stack --stack-name apstack --template-body file://templates/cflambdatemplate.yaml --parameters file://params/param.json

我的 param.json 是:

[
{
"ParameterKey": "FunctionName",
"ParameterValue": "taskaplambda"
},
{
"ParameterKey": "MemorySize",
"ParameterValue": 512
},
{
"ParameterKey": "Timeout",
"ParameterValue": 5
}
]

这是我的 YAML 文件

cflambdatemplate.yaml

Transform: AWS::Serverless-2016-10-31
Resources:
tasklambda:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Ref FunctionName
Handler: lambda_function.lambda_handler
MemorySize: !Ref MemorySize
Role:
Fn::GetAtt:
- "tasklambdarole"
- "Arn"
Runtime: python3.7
Timeout: !Ref Timeout
CodeUri:
Bucket: taskapbucket
Key: apbuild/lambda_function.zip

tasklambdarole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Principal:
Service:
- "lambda.amazonaws.com"
Action:
- "sts:AssumeRole"
Path: "/"
taskPolicies:
Type: "AWS::IAM::Policy"
Properties:
PolicyName: "root"
PolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Action: "*"
Resource: "*"
Roles:
-
Ref: "tasklambdarole"

Parameters:
FunctionName:
Type: String
MinLength: '3'
MaxLength: '18'
MemorySize:
Type: Number
MinValue: '128'
MaxValue: '1024'
Timeout:
Type: Number
MinValue: '1'
MaxValue: '15'

我一直在尝试这种可能性,但它总是给我一个错误。

最佳答案

只需通过 aws CLI 创建您需要的一切:

CLoudformation Stack

我使用相同的 yaml 文件和 json 参数模板,但没有收到任何错误。以下是我在 param.json 中所做的唯一更改:

[
{
"ParameterKey": "FunctionName",
"ParameterValue": "taskaplambda"
},
{
"ParameterKey": "MemorySize",
"ParameterValue": "512"
},
{
"ParameterKey": "Timeout",
"ParameterValue": "5"
}
]

您需要将数字转换为字符串,这是因为CloudFormation参数类型不映射到JSON类型,因此CLI期望所有内容都作为字符串传递。

关于amazon-web-services - 解析参数 '--parameters' : Expected: '=' , 时出错: 'P',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57751982/

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