我正在与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'
我一直在尝试这一切的可能性,但它总是给我一个错误。
发布于 2019-09-02 06:59:55
只需通过aws创建所需的一切:
我使用的是相同的yaml文件和参数的json模板,没有任何错误。下面是我在param.json中所做的唯一更改:
[
{
"ParameterKey": "FunctionName",
"ParameterValue": "taskaplambda"
},
{
"ParameterKey": "MemorySize",
"ParameterValue": "512"
},
{
"ParameterKey": "Timeout",
"ParameterValue": "5"
}
]
您需要将Number转换为 string ,这是因为CloudFormation参数类型不映射到JSON类型,因此CLI希望将所有内容都作为字符串传递。
https://stackoverflow.com/questions/57751982
复制相似问题