Skip to content

Instantly share code, notes, and snippets.

@kenzo0107
Created October 28, 2019 12:43
Show Gist options
  • Save kenzo0107/5427f609fb61a948f6474d4ba16b11db to your computer and use it in GitHub Desktop.
Save kenzo0107/5427f609fb61a948f6474d4ba16b11db to your computer and use it in GitHub Desktop.
AWS Serverless Application Model with Go

environment

  • go version go1.13.3 darwin/amd64

Preparation

$ pip install awscli
$ pip install aws-sam-cli
$ aws configure --profile <profile>

Step by step

$ sam init --runtime go --name sam-test
$ cd sam-test
$ export AWS_PROFILE=<profile>
$ go mod init
$ make deps

Unit Testing

$ go test ./hello-world

ok  	github.com/medpeer-dev/ri-utilization-plotter/hello-world	0.381s

Build

$ make build

execute Local Lambda Function

$ sam local start-api

Mounting HelloWorldFunction at http://127.0.0.1:3000/hello [GET]
...

open other terminal:

$ curl http://127.0.0.1:3000/hello

Hello, 221.117.173.167

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment