- Notifications
You must be signed in to change notification settings - Fork0
tayron/serverless-api-python
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Exemplo de uma API Serverless usando Serverless Framework e deploy no AWS utilizando os serviços:
- AWS Lambda
- API Gateway
- DynamoDB
- https://solvimm.com/blog/como-construir-sua-primeira-api-na-nuvem-com-o-serverless-framework
- https://solvimm.com/blog/como-adicionar-uma-chave-de-autorizacao-de-api-com-o-serverless-framework
- https://solvimm.com/blog/como-usar-variaveis-com-o-serverless-framework
- https://solvimm.com/blog/integracao-de-api-com-dynamodb-utilizando-o-serverless-framework
serverless config credentials \--provider aws \--key apiKeyAqui \--secret chaveSecretaAqui \--profile my-aws-profile
npm install serverless-iam-roles-per-function
Para fazer deploy e manter o stage padrão:devserverless deploy --aws-profile my-aws-profile
Para fazer deploy e alterar o stage padrão:dev paraprodserverless deploy --aws-profile my-aws-profile --stage prod
O resultado do comando será algo parecido com
....Serverless: Stack update finished...Service Informationservice: api-python-hello-worldstage: devregion: us-east-1stack: api-python-hello-world-devresources: 16api keys: myKey: CCJZsdfgzrbxi0shwR8e2Yasdfaz0bOG6A5hlJc7Uiendpoints: GET - https://aaa.execute-api.aa-aa-1.amazonaws.com/dev/api/python/hello-worldfunctions: hello: api-python-hello-world-dev-hellolayers: None
Chave da API se encontra na reposta
api keys: myKey: CCJZsdfgzrbxi0shwR8e2Yasdfaz0bOG6A5hlJc7Ui
Chave da API deve ser passado no header da requisição:
x-api-key: CCJZsdfgzrbxi0shwR8e2Yasdfaz0bOG6A5hlJc7Ui
serverless remove --aws-profile my-aws-profile --stage dev
curl --request GET \ --url https://7cq8ind2me.execute-api.us-east-1.amazonaws.com/dev/api/python/hello-world \ --header 'x-api-key: CCJZsdfgzrbxi0shwR8e2Yasdfaz0bOG6A5hlJc7Ui'
curl -X GET-H "x-api-key: CCJZsdfgzrbxi0shwR8e2Yasdfaz0bOG6A5hlJc7Ui" \https://8nncm9w4p5.execute-api.us-east-1.amazonaws.com/dev/contact
curl -X POST-H "x-api-key: CCJZsdfgzrbxi0shwR8e2Yasdfaz0bOG6A5hlJc7Ui" \-H "Content-Type: application/json" \-d '{"name":"Lina Nathan", "phone":"90000-0000"}' \https://8nncm9w4p5.execute-api.us-east-1.amazonaws.com/dev/contact
curl -X DELETE-H "x-api-key: CCJZsdfgzrbxi0shwR8e2Yasdfaz0bOG6A5hlJc7Ui" \-H "Content-Type: application/json" \-d '{"id":"29a64dab-b77a-4b5f-9e82-222950c3b5ff"}' \https://8nncm9w4p5.execute-api.us-east-1.amazonaws.com/dev/contact
About
API feita em Python para estudo do Serveless Framework e deploy na AWS usando Lambda e API Gateway
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.