This is a basic template repo for deploying an AWS Lambda function in Go. It uses AWS Lambda, S3, and Cloudformation for automating storage and deployment of Go lambda functions.
You can either fork or use as template through Github.
- Go Lang
- AWS CLI
- AWS SAM CLI
- Proper
aws configuresettings that will allow you to connect to AWS Lambda, S3, IAM, and CloudFormation
First, make sure you have all the required CLI tools installed!
Begin by installing all go dependencies, run: make install
Once all dependencies are installed, you can start the API by running: make api. Visit http://127.0.0.1:3000/ in your browser to see your Lambda execution!
Finally, update main.go to fit your needs!
Most of the commands have been extracted into a make file. To run any of the the following commands type make COMMAND_GOES_HERE
List of commands:
test- runs tests usinggo testinstall- installs all go dependenciesmain- builds the app for environmentlambda- builds app for environment AWS uses in the cloudapi- starts local API using Docker environment provided bySAM CLI(runsbuild)package- usessam-clito createpackaged.yamlfile for CloudFormation. (Runstestandbuildbefore)deploy- usessam-clito deploy the app on AWS (Runstestandpackage)clean- cleans up app by removing oldpackaged.yamlfile.
In order to run the make deploy command successfully, you will need to supply the S3_BUCKET and STACK_NAME variables. Example usage below:
S3_BUCKET=YOUR_BUCKET_NAME STACK_NAME=YOUR_STACK_NAME make deploy