This repo holds a basic template to deploy python codes to AWS lambda function.
Please create an IAM bot-user in AWS. A default policy for Singapore region can be found in serverless-aws-py-dev-ap-southeast-1-policy.json. You can also generate your own policy with yeoman:
npm run policyPlease ensure your AWS credentials are exported as your current environment variables AWS_KEY and AWS_SECRET respectively. Otherwise you can create an .env file of the form:
AWS_KEY=SOMERANDOMIDKEY
AWS_SECRET=SOMERANDOMSECRETVALUE
Run the following command once to setup your credentials:
npm run initnpm ior
yarnnpm run deploynpm run deployf -- <name of the function>npm run removenpm run function -- <name of the function>
npm run function -- echo --data hello!npm run api -- <name of the function>
npm run api -- echo --data hello!You will see the api endpoint after deploying to AWS
curl -d [DATA] -X POST [API_ENDPOINT]
# example
curl -d "hello!" -X POST https://abcdef.execute-api.ap-southeast-1.amazonaws.com/dev/echoPlease look at serverless cli documentation for more details.
As serverless is installed locally, please prefix the command with a npx:
npx serverless