Design a site like this with
Get started

Call ELASTIC Beanstalk rest service from lambda

If you use request library from boto then most of time it will give error in aws lambda as this is excluded in newer version of aws python packages.

If you use below import in your lambda in latest python package you will get below mentioned error

from botocore.vendored import requests

No module named 'requests'

so in new python module below library is provided which you can use for rest api communication.


I was facing problem while calling api with botocore.vendored.request so i have used below code to solve my issue with urllib3

def callApi():
   print('calling service')
   import callApi

   http = urllib3.PoolManager()

   response = http.request('POST',
                        body = json.dumps({    "to":"",    "from":"",    "subject":"AWS micro service testing",    "name":"Sagar",    "product":"Debit card",    "link":"",    "templateType":"thankyou.ftl"}),
                        headers = {'Content-Type': 'application/json'},
                        retries = False)
   data = json.loads('utf-8'))
   print('data' , data)
def lambda_handler(event, context):

Here lambda_handler is entry point for your lambda and then it will call callApi() method and using urllib3 it will give call to rest webservice.

For more details please refer