500 Internal Server Error
当我尝试调用我使用 SAM 定义的 GET 端点时,我总是得到一个。
我能够定义一个有效的 POST 请求。对于 GET 请求,它向我显示:
Lambda invocation failed with status: 403
Execution failed due to configuration error:
我认为我定义 API 网关的 DefinitionBody 的地方出了点问题。
Globals:
Api:
Cors:
AllowMethods: "'GET,POST,OPTIONS'"
AllowHeaders: "'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'"
AllowOrigin: "'*'"
Resources:
getFunction:
Type: 'AWS::Serverless::Function'
Properties:
...
Events:
GetApi:
Type: Api
Properties:
Path: /tips
Method: GET
RestApiId: !Ref MyApi
MyApi:
Type: AWS::Serverless::Api
Properties:
StageName: dev
EndpointConfiguration: REGIONAL
DefinitionBody:
swagger: "2.0"
info:
title: "API"
paths:
/tips:
get:
x-amazon-apigateway-integration:
uri:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${getFunction.Arn}/invocations
responses: {}
httpMethod: "POST"
type: "aws_proxy"
我已经尝试将 x-amazon-apigateway-integration 上的 httpMethod 更改为“GET”,但这并不能解决我的问题。
在 AWS Lambda 控制台中,我看到 Lambda 和 Api Gateway 已链接,但我无法通过 API Gateway 调用 Lambda。我可以使用控制台中的测试事件成功执行我的 Lambda。这绝对是 API 网关方面的东西。
有人可以验证我做错了什么吗?