我正在使用 CloudFormation
在API网关中创建API . 我的每个 endpoints 都指向一个Lambda函数 . 我需要为每个 endpoints 打开"Lambda Proxy integration" .
这是我的`CloudFormation模板的片段:
method1:
Type: "AWS::ApiGateway::Method"
Properties:
ApiKeyRequired: true
AuthorizationType: None
HttpMethod: POST
Integration:
Type: AWS_PROXY
IntegrationHttpMethod: POST
IntegrationResponses:
- ResponseTemplates:
application/json: Empty
StatusCode: 200
Uri:
Fn::ImportValue: !Sub '${ProjectName}-${Environment}-method1'
MethodResponses:
- ResponseModels:
application/json: Empty
StatusCode: 200
RequestValidatorId: !Ref validateBodyValidator
ResourceId: !Ref method1Resource
RestApiId: !Ref RestApi
我已将集成类型设置为 AWS_PROXY
. 当我运行这个模板时,一切似乎都是 . 我得到以下结果:
如您所见, Use Lambda Proxy integration
选项显示为已选中 . 但是,当我进行API调用时,我收到以下错误 .
[
"Internal Server Error"
]
经过一天试图找到问题后,我发现了以下内容:
If I uncheck the Use Lambda Proxy integration option, re-check it, and deploy - it starts working.
它几乎就像 - 它看起来被选中但它没有被选中 . 我必须手动取消选中并重新检查每个方法 .
有什么想法吗?
1 回答
我能够解决这个问题,感谢上面的评论congbaoguier .
我在以下模板中添加了
Method1Permission
部分,我创建了Lambda函数:这允许API网关访问我的Lambda函数 .