Serverless Api in Go with AWS Lambda
Here we are going to use AWS Lambda
to build serverless applications in golang.
Prerequisites
-
You’ll need an AWS account for this. If you don’t yet have one, sign up for a free account here.
-
If you don’t have Go installed yet, you can either download an installer from the official website or use your favorite package manager to install it.
-
For building and deploying your functions, you’ll be using the
Serverless Framework
. Assuming you have a recent version of Node.js installed, you can install theServerless CLI
with the following npm command$ npm install -g serverless
Once you have the Serverless CLI installed, you must configure it to use the AWS access keys of your account
$ serverless config credentials --provider aws --key <access key ID> --secret <secret access key>
Build
$ GOOS=linux GOARCH=amd64 go build -o bin/lambda-time .
Deploy
$ serverless deploy