In this post we will use AWS Serverless Application Model (SAM) to create and deploy a simple Lambda function written in Python. The Function get’s built and deployed with Github Actions.
sam init -r python3.8 -n pyth38-demo
Change to the newly created directory
sam build sam local invoke --event events/event.json
Create a new repository in Github. Import the project in the new repository.
Go ot the repositories Settings and add your AWS access key (AWS_ACCESS_KEY_ID) and secret (AWS_SECRET_ACCESS_KEY) as Secrets. Create a blank Github Action in your new repository with this code.
Change the S3 bucket name to an existing bucket in the same region as your Lambda. Commit your changes. The Lambda Function will be built and deployed to your AWS account.
Get the API Gateway endpoint url
aws cloudformation describe-stacks --stack-name pyth38-demo
curl endpoint url
aws cloudformation delete-stack --stack-name pyth38-demo