“由于路径 /price 中格式错误的集成,无法解析 API 定义。(服务:AmazonApiGateway;状态代码:400;
"Unable to parse API definition because of a malformed integration at path /price. (Service: AmazonApiGateway; Status Code: 400;
我为 x-amazon-apigateway-integration 添加的以下代码,如果我遗漏了什么,请告诉我。谢谢
x-amazon-apigateway-integration:
httpMethod: post
type: aws
uri:
Fn::Sub:
- arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${FunctionArn}/invocations
- { FunctionArn: !GetAtt PriceAPIFunction.Arn}
responses:
default:
statusCode: '200'
不支持 ${AWS::Region}
替换 - 只能替换函数名。见 https://github.com/awslabs/serverless-application-model/issues/79
我正在尝试为 API 创建 CFT 部署,但遇到了与 Unable to parse API definition because of a malformed integration at path / 相同的错误。
我刚刚想出解决方案,即为部署创建 AWS::Serverless-2016-10-31 模板。
您必须将 CloudFormation 模板编写为:-
1. 在Template开头添加定义Transform: AWS::Serverless-2016-10-31。
2. 对于API定义,必须将OpenApi引用为DefinitionBody:与Transform 函数,它将相应地调制 YAML。
Type: AWS::Serverless::Api
Properties:
Name: !Sub "MyRestAPI"
StageName: !Sub "dev"
DefinitionBody:
"Fn::Transform":
Name: "AWS::Include"
Parameters:
Location: !Sub "s3://${TemporaryBucket}/openapi.yaml"
我为 x-amazon-apigateway-integration 添加的以下代码,如果我遗漏了什么,请告诉我。谢谢
x-amazon-apigateway-integration:
httpMethod: post
type: aws
uri:
Fn::Sub:
- arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${FunctionArn}/invocations
- { FunctionArn: !GetAtt PriceAPIFunction.Arn}
responses:
default:
statusCode: '200'
不支持 ${AWS::Region}
替换 - 只能替换函数名。见 https://github.com/awslabs/serverless-application-model/issues/79
我正在尝试为 API 创建 CFT 部署,但遇到了与 Unable to parse API definition because of a malformed integration at path / 相同的错误。
我刚刚想出解决方案,即为部署创建 AWS::Serverless-2016-10-31 模板。
您必须将 CloudFormation 模板编写为:-
1. 在Template开头添加定义Transform: AWS::Serverless-2016-10-31。
2. 对于API定义,必须将OpenApi引用为DefinitionBody:与Transform 函数,它将相应地调制 YAML。
Type: AWS::Serverless::Api
Properties:
Name: !Sub "MyRestAPI"
StageName: !Sub "dev"
DefinitionBody:
"Fn::Transform":
Name: "AWS::Include"
Parameters:
Location: !Sub "s3://${TemporaryBucket}/openapi.yaml"