Aws-sdk-js: apigateway.putIntegration type for AWS Lambda

Created on 10 Jan 2016  Â·  17Comments  Â·  Source: aws/aws-sdk-js

It appears that API Gateway does not currently allow to associate an Lambda to a an method request integration. (But maybe I'm just missing how to do it in the docs!)

Most helpful comment

For reference this is what I'm using in the putIntegration call:

{ type: 'AWS',
  httpMethod: 'POST',
  uri: 'arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:455488262213:function:begin-account-api-invite',
  credentials: 'arn:aws:iam::455488262213:role/smallwins-api-lambda'}

(again huge thx for your help in getting this working)

All 17 comments

@brianleroux
You would want to include the Lambda function as part of the uri.
The uri is probably the trickiest parameter to specify the first time around. There's clearer documentation on how to build the uri on the API Gateway docs here:
http://docs.aws.amazon.com/apigateway/api-reference/resource/integration/#uri

So, if you wanted to call a lambda function, the uri would look something like this:
arn:aws.apigateway:{region}:lambda:path/2015-03-31/functions/{lambda function arn}

See #769 for more discussion on the topic.

awesome thx. (had figured this out after looking at swagger gen … docs could use some colour!)

hmmm. still having troubles.

{ httpMethod: 'POST',
  resourceId: '6pfvuf',
  restApiId: 'afz6ejjune',
  uri: 'arn:aws.apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:455488262213:function:begin-account-api-invite',
  type: 'AWS',
  integrationHttpMethod: 'POST',
  credentials: 'smallwins-api-lambda' }

With the error:

{ [BadRequestException: Invalid ARN specified in the request]

But it looks good to me?

@brianleroux
I had a typo in my example, there should be a colon after the first aws in the arn, not a period. Please give that a try!

jeez, I didn't even see that period. (must be getting late!) unfortunately still getting an error. these params:

{ httpMethod: 'POST',
  resourceId: 'dl5emh',
  restApiId: 'lko08s3rjb',
  uri: 'arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:455488262213:function:begin-account-api-register',
  type: 'AWS',
  integrationHttpMethod: 'POST',
  credentials: 'smallwins-api-lambda' }

get this:

[BadRequestException: Invalid ARN specified in the request]

:grimacing:

@brianleroux
I suspect your credentials also need to be the full arn. I'll verify on my end if that's the case.

@brianleroux
I ran a test on my end, and an ARN should be provided for credentials as well.
Let me know if you still see errors after changing that!

Awesome! that (sort of) worked!

Wed Jan 13 23:26:16 UTC 2016 : Execution failed due to configuration error: API Gateway does not have permission to assume the provided role

guessing this means the thing in my credentials needs but struggling though that config (alas)

screen shot 2016-01-13 at 3 41 27 pm

screen shot 2016-01-13 at 3 41 36 pm

Kind of crazy. Appreciate your help!

@brianleroux
Are you seeing that message as a result of running putIntegration, or from actually testing the method?

result of actually testing (after editing the role tho / the putIntegration
works now w/ the role arn specified)

On Wed, Jan 13, 2016 at 4:10 PM, Christopher Radek <[email protected]

wrote:

@brianleroux https://github.com/brianleroux
Are you seeing that message as a result of running putIntegration, or
from actually testing the method?

—
Reply to this email directly or view it on GitHub
https://github.com/aws/aws-sdk-js/issues/868#issuecomment-171478333.

Appears the error is role/policy related <AccessDeniedException> but I have it wiiiide open.

Thu Jan 14 01:05:46 UTC 2016 : Starting execution for request: test-invoke-request
Thu Jan 14 01:05:46 UTC 2016 : API Key: test-invoke-api-key
Thu Jan 14 01:05:46 UTC 2016 : Method request path: {}
Thu Jan 14 01:05:46 UTC 2016 : Method request query string: {}
Thu Jan 14 01:05:46 UTC 2016 : Method request headers: {}
Thu Jan 14 01:05:46 UTC 2016 : Method request body before transformations: null
Thu Jan 14 01:05:46 UTC 2016 : Endpoint request URI: https://lambda.us-east-1.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-east-1:455488262213:function:begin-account-api-forgot
Thu Jan 14 01:05:46 UTC 2016 : Endpoint request headers: {Authorization=************************************************************************************************************************************************************************************************************************************************d0176d, X-Amz-Date=20160114T010546Z, Accept=application/json, User-Agent=AmazonAPIGateway_ys16lfz71c, X-Amz-Security-Token=AgoGb3JpZ2luECUaCXVzLWVhc3QtMSKAAixKX5B/DA2Ene3e/F20q8UOe9I9zxElqGKIU1AkW0EvfOMnZXtyuPdKuSd3pS7ww+6IiGh2jkgaizgzpXHHQZE9og6n2abNYo0TWM2/dKFigRiQLgMHS0rCCeXOAtFSqgsF3U52z10JM2ryGG4Xu9ACBE4wqmK8sUILJvCppwdtCJCGuaQRsh1jZHgnicj2hyPKZuz1HuWAtX/rxEL8YydIHcadn57LuGDXGCNnKUA302j0GY2Cc0lccDvlFpimIo2sGzphVObNg4mVbob0PdVGdo6YJJD//IzCkQnvX8an/S4kQFkigPJZmfjh6/ff+IjBDPsgDHHS7+GacSd45V0q/QEIOhAAGgw0NTU0ODgyNjIyMTMiDJpMEg5mPGsej0kZtiraAbNH1cjLxPO3qOY0H3ctZ8zRdQG38OJXY0+NDrqvkKtJMyZpSmxDeKwYXODiMN7CpNc8+AeX7uFCaXWz3IZSohevY8atUBUkqwAeUlbfL/fF2Jxt3kV+83aPXSgRwsjpzhUM/wHyJyJjzKyUXO5EZ9AYJMORmNLZq0BhWsz0KjKj/T7qUdI+LNyEwAdu/+BWsOb+ [TRUNCATED]
Thu Jan 14 01:05:46 UTC 2016 : Endpoint request body after transformations: 
{
  "body" : {},
  "headers": {
      },
  "method": "POST",
  "params": {
      },
  "query": {
      }  
}

Thu Jan 14 01:05:46 UTC 2016 : Endpoint response body before transformations: <AccessDeniedException>
  <Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>

For reference this is what I'm using in the putIntegration call:

{ type: 'AWS',
  httpMethod: 'POST',
  uri: 'arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:455488262213:function:begin-account-api-invite',
  credentials: 'arn:aws:iam::455488262213:role/smallwins-api-lambda'}

(again huge thx for your help in getting this working)

@brianleroux
Have you taken a look at this forum post yet? There are some suggestions related to the errors you're seeing.
https://forums.aws.amazon.com/thread.jspa?threadID=220021

@brianleroux
I'm going to close this issue since the original question is solved, and your errors appear to be related to policies and apigateway.
Feel free to comment or reopen if you're still having issues with putIntegration.

:+1:

I'll be back…!

Screen Shot 2019-05-19 at 3 57 44 PM

I'm getting Invalid ARN specified in the request error. I'm following the API Gateway example. Not sure the source of the error. see attached screenshot.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings