Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
mkdir lambda_com_pacotes && cd lambda_com_pacotes
#criando o arquivo main.py
echo -e "
import requests
def handle(event, context):
r = requests.get('https://api.github.com/events')
return {
'texto': r.text,
}
" >> main.py
#criando o requirements.txt
echo -e "requests" >> requirements.txt
#instalando as dependencias para o lambda
pip install -r requirements.txt -t .
# zipando
zip -qr hellorequests.zip .
# criar a nossa função via awscli.
aws lambda create-function \
--region us-east-1 \
--handler main.handle \
--runtime python3.7 \
--function-name 'hellorequests' \
--zip-file fileb://./hellorequests.zip \
--role 'PEGUE_SUA_ARN'
aws lambda invoke \
--region us-east-1 \
--function-name 'hellorequests' \
--payload '{}' \
hellorequests.output
cat hellorequests.output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.