Last active
February 3, 2019 21:10
-
-
Save rtancman/08a0c424a88dd801341ecc2f2d0ddc06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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