0

I am trying to use a Lambda Function with CloudWatch as trigger to simulate a cron job.

I am having problem with the Lambda Function.

Here is my function:

import requests

URL = 'www.somesite.com/SchedulerEmail'
def lambda_handler(event, context):
    requests.get(URL)

The lambda function is called "SchedulerEmail"

When I created it I choose python as language and pasted the code on aws "edit code inline" tab.

1 Answer 1

2

Only builtin libraries are available in Lambda environment. requests library is not available by default in Python. You have to create a deployment package that includes the requests library along with your lambda code and upload the package as .zip file either to S3 or directly to the Lambda function.

Follow the instructions here on how to create a deployment package for lambda.

Sign up to request clarification or add additional context in comments.

6 Comments

I see, is there anyway I can achieve my goal by using the "Edit code inline" tool, without deploying a package? If not I will probably use JAVA for that, l don't have python set up.
Nope, unless you are planning to use only the builtin python2 libraries.
Ok, I will either use java or c#, thought something as simple as that wouldn't need that kind of commitment. Thanks
Yea, if building a deployment package for python is a problem, It is better to switch. But for simpler cases like the one you have, you can find alternatives among the builtins. If the functionality gets bigger you might end up with the need for external modules.
It shouldn't get any bigger than just calling a scheduler URL, do you know where I can find information on how to achieve that by using the builtins?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.