Skip to content

Instantly share code, notes, and snippets.

@rtancman
Last active February 3, 2019 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtancman/08a0c424a88dd801341ecc2f2d0ddc06 to your computer and use it in GitHub Desktop.
Save rtancman/08a0c424a88dd801341ecc2f2d0ddc06 to your computer and use it in GitHub Desktop.
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