简体   繁体   中英

AWS Lambda functions + CloudWatch

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM