Chris T
Chris T

Reputation: 483

What is the standard way of making REST API calls in an AWS Lambda function?

I normally use javascript fetch or python requests to make REST API calls. I want to interact with an amazon lex chatbot I'm writing for a calls from within my lambda function, but apparently fetch and requests aren't available within AWS Lambda. Is there some other way I can make an REST API call to lex from within a lambda function?

On a separate note, does anyone know if Lex requires some kind of authentication process to accept a REST API request?

Upvotes: 0

Views: 501

Answers (1)

Sébastien Stormacq
Sébastien Stormacq

Reputation: 14915

AWS Lambda execution environments does not include language specific dependencies. If your code relies on third party libraries such as Python's requests, you need to include them in your ZIP file. AWS Lambda will not install these for your automatically.

About the second question : YES, Lex requires correct permission to be called. See documentation at https://docs.aws.amazon.com/lex/latest/dg/lex-api-permissions-ref.html

If you are calling Lex through the AWS SDK for Python (boto3), the SDK will pass the correct signature to the LEX call. Your lambda function will require an execution role that authorise it to invoke Lex.

If you want to use requests, you will need to compute and to include the signature in your request. This is a lot of code to write and I cam't think of a valid reason to not use the AWS SDK for python instead.

Upvotes: 1

Related Questions