I am trying upload my python code into AWS Lambda. I have been following this guide to create the deployment package (https://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html).
I have created a folder 'project-dir' on my desktop and moved my python file 'Twilio_Alerts_AWS.py' into the folder. I have used the command:
pip install module-name -t /path/to/project-dir
to install all my libraries into the folder. Next I highlighted everything and hit 'compress' by right clicking on the highlighted files in the folder. This produces one zipped file called 'archive'
I put the 'archive.zip'
in a S3 bucket on AWS and called it into AWS Lambda. I keep getting error Unable to import module 'Twilio_Alerts_AWS': Missing required dependencies ['numpy']
even though I have installed numpy into the folder.
Not sure what I am doing wrong.
Code I am trying to upload:
from twilio.rest import Client
import time
import datetime
import requests
import pandas as pd
from pandas.io.json import json_normalize
def lambda_handler(event, context):
# Your Account SID from twilio.com/console
account_sid = "xxx"
# Your Auth Token from twilio.com/console
auth_token = "xxx"
client = Client(account_sid, auth_token)
current_datetime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'x-api-key': 'xxx',
'x-organization-id': 'xxx',
'x-facility-id': 'xxx',
'x-user-id': 'xxx',
}
orders_staging_api_call = requests.get('URL', headers=headers, verify=False)
consumers_staging_api_call = requests.get('URL', headers=headers, verify=False)
inventory_staging_api_call = requests.get('URL', headers=headers, verify=False)
lst = ["+1234567890"]
##Consumers API Alert
if consumers_staging_api_call.status_code !=200:
for i in lst:
message = client.messages.create(
to=i,
from_="+1234567890",
body="API connection between A and B has failed for: Consumers.Datetime of check:{}".format(current_datetime))
time.sleep(5)
print(message.sid)
else:
print('done')
edit: using osx machine.