ApiGateway REST not respecting Lambda alias

0

Hi. I've connected my an ApiGateway REST resource to a lambda function. It works correctly when I use only the lambda function name (not the alias or the version) in the "Lambda Function" field of my REST resource's "Integration Request" page. However, when I add an alias to my lambda function, and set the "Lambda Function" to use the ":alias" at the end of the lambda function, and then set the correct permissions on my lambda alias, the requests do not make it through.

I have CloudWatch logs from my ApiGateway from one of these requests. Here is the relevant bit:

(57980943-e0ee-4556-a70d-477ea10f0b43) Sending request to https://lambda.us-west-2.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-west-2:**************:function:interact/invocations
(57980943-e0ee-4556-a70d-477ea10f0b43) Execution failed due to configuration error: Invalid permissions on Lambda function

You can see that ApiGateway is attempting to post to the unaliased function name, instead of the aliased one. I only have LambdaInvoke permissions on the aliased function, not the unaliased one, so the error message makes sense. What doesn't make sense is why ApiGateway is not using the alias that I specify in the "Integration Request" page of my resource.

Can anyone shed some light on this please?

  • It would be helpful to see the actual uri that is returned for the integration, using get-integration

  • @Farski

    {
        "type": "AWS_PROXY",
        "httpMethod": "POST",
        "uri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:*******************:function:interact:prod/invocations",
        "passthroughBehavior": "WHEN_NO_MATCH",
        "contentHandling": "CONVERT_TO_TEXT",
        "timeoutInMillis": 29000,
        "cacheNamespace": "333zfp",
        "cacheKeyParameters": [],
        "integrationResponses": {
            "200": {
                "statusCode": "200",
                "responseTemplates": {
                    "application/json": null
                }
            }
        }
    }
    

    And here's a CloudWatch entry for the ApiGateway api:

    (2215a781-0b95-45ce-9769-ac60a93f52ab) Sending request to https://lambda.us-west-2.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-west-2:*******************:function:interact/invocations
    

    You can see that the alias is not included in the request.

2개 답변
0
수락된 답변

I figured it out. From the "Resources" page of your ApiGateway, you need to click "Actions" -> "Deploy API" for any api changes that you make, even if they appear to persist in the UI. The issue was that my api changes were undeployed, and there is no visual indication that I have pending undeployed changes. Deploying the api resolves the issue.

amoffat
답변함 2년 전
0
amoffat
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠