Skip to content

Latest commit

 

History

History
92 lines (66 loc) · 2.34 KB

README.rst

File metadata and controls

92 lines (66 loc) · 2.34 KB

Serverless Golang

Feedback? Questions? Do not hesitate to send me an email. Helpful? Give a LIKE to a LinkedIn post about this talk or a STAR to this github repo.

Golang AWS Lambda with Serverless and SAM

Hello-worder:

brew tap aws/tap
brew install aws-sam-cli
mkidr $GOPATH/github.com/wojciech12/planning-poker
cd $GOPATH/github.com/wojciech12/planning-poker
npm install -g serverless
serverless create -t aws-go-dep
cat > template.yml <<EOF

AWSTemplateFormatVersion : '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: A hello world application. Resources: HelloWorldFunction: Type: AWS::Serverless::Function Properties: Handler: bin/hello Runtime: go1.x Events: Vote: Type: Api Properties: Path: / Method: get

EOF

Test locally:

sam local start-api
sam local start-api --env-vars env.json
sam local generate-event apigateway authorizer > event.json
sam local invoke "HelloWorldFunction" -e event.json
sam local generate-event apigateway authorize

see:

curl  http://127.0.0.1:3000/hello
curl  http://127.0.0.1:3000/hello/wojtek
curl  http://127.0.0.1:3000/hello?name=wojtek
python3 -m venv .venv
source .venv/bin/activate
pip install localstack