【发布时间】:2021-10-08 05:24:46
【问题描述】:
大家好,我创建了一个 lambda 函数,然后使用 cloudformation 将其部署到 API 网关。为了进行身份验证,我使用 cognito 用户池。在标头中,我传递了一个适用于其他功能的授权令牌。当我尝试访问 API 时,我得到“IncompleteSignatureException”。我不知道如何解决这个问题......我以为我将 cloudformation 模板设置为类似于我手动附加 lambda 函数时,但我显然错过了一些东西。任何想法将不胜感激!
谢谢!
顺便说一句,当我从 api 网关控制台“测试”它时它确实有效
CreateMethod:
Type: AWS::ApiGateway::Method
Properties:
RestApiId: !Ref baseApi
ResourceId: !Ref NewResource
HttpMethod: POST
AuthorizationType: COGNITO_USER_POOLS
AuthorizerId: !Ref cogId
Integration:
Type: AWS_PROXY
IntegrationHttpMethod: POST
Uri: !Sub
- arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${lambdaArn}/invocations
- lambdaArn: !GetAtt TheLambda.Arn
MethodResponses:
- StatusCode: 200
ResponseModels:
application/json : Empty
LambdaApiGatewayInvoke:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:InvokeFunction
FunctionName: !GetAtt TheLambda.Arn
Principal: apigateway.amazonaws.com
SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${baseApi}/*/POST/${basePath}/ChosenPath
【问题讨论】:
标签: amazon-web-services amazon-cloudformation aws-api-gateway