Example AWS Lambda function in Go and SAM
Switch branches/tags
Nothing to show
Clone or download
Latest commit 040194f Feb 14, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Update CircleCI config Feb 3, 2018
handler Update CircleCI config Feb 3, 2018
repository Update CircleCI config Feb 3, 2018
.gitignore Update CircleCI config Feb 3, 2018
Makefile Update CircleCI config Feb 3, 2018
README.md Updated API Feb 3, 2018
template.yml Updated API Feb 3, 2018

README.md

Lambda Go Example

Dependecies

$ > go get github.com/aws/aws-lambda-go/events
$ > go get github.com/aws/aws-lambda-go/lambda
$ > go get github.com/stretchr/testify/assert

Build

# Build binary
$ > make build

# Test Go Code
$ > make test

Deploy

Create .env

AWS_ACCOUNT_ID=1234567890
AWS_BUCKET_NAME=your-bucket-name-for-cloudformation-package-data
AWS_STACK_NAME=your-cloudformation-stack-name
AWS_REGION=us-west-1

Install AWS CLI

$ > brew install awscli

Command

# Create S3 Bucket
$ > make configure

# Upload data to S3 Bucket
$ > make package

# Deploy CloudFormation Stack
$ > make deploy

Usage

$ > make outputs

[
  {
    "OutputKey": "URL",
    "OutputValue": "https://random-id.execute-api.us-west-1.amazonaws.com/Prod",
    "Description": "URL for HTTPS Endpoint"
  }
]

$ > curl https://random-id.execute-api.us-west-1.amazonaws.com/Stage/people

{"data":[{"id":"d1","name":"Anton","age":31},{"id":"c2","name":"Frank","age":28},{"id":"b1","name":"Horst","age":42}]}

$ > curl https://random-id.execute-api.us-west-1.amazonaws.com/Stage/person/b1

{"data":{"id":"b1","name":"Horst","age":42}}