Skip to content

Instantly share code, notes, and snippets.

@srbry
srbry / serverless.yml
Created October 2, 2018 08:46
Serverless framework multiple authorizers
service: hello-world
provider:
name: aws
runtime: go1.x
region: eu-west-1
memorySize: 128
package:
exclude:
@srbry
srbry / main_test.go
Created October 2, 2018 08:45
Golang lambda authorizer with context ginkgo tests
package main
import (
"github.com/aws/aws-lambda-go/events"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("the auth function", func() {
@srbry
srbry / main.go
Created October 2, 2018 08:44
Golang lambda authorizer with context
package main
import (
"errors"
"strings"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
@srbry
srbry / main_test.go
Created October 2, 2018 08:43
Golang lambda hello world with auth context ginkgo tests
package main
import (
"net/http"
"github.com/aws/aws-lambda-go/events"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@srbry
srbry / main.go
Created October 2, 2018 08:40
Golang lambda hello world with context
package main
import (
"fmt"
"net/http"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
@srbry
srbry / serverless.yml
Created October 2, 2018 08:36
Serverless framework authorizer config
service: hello-world
provider:
name: aws
runtime: go1.x
region: eu-west-1
memorySize: 128
package:
exclude:
@srbry
srbry / main_test.go
Created October 2, 2018 08:33
Golang lambda auth ginkgo tests
package main
import (
"github.com/aws/aws-lambda-go/events"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("the auth function", func() {
@srbry
srbry / main.go
Created October 2, 2018 08:25
Golang lambda authorizer
package main
import (
"errors"
"strings"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
@srbry
srbry / Makefile
Created October 2, 2018 08:11
Golang lambda compilation makefile
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
functions := $(shell find functions -name \*main.go | awk -F'/' '{print $$2}')
build: ## Build golang binaries
@dep ensure
@for function in $(functions) ; do \
env GOOS=linux go build -ldflags="-s -w" -o bin/$$function functions/$$function/main.go ; \
done
@srbry
srbry / main_test.go
Created October 2, 2018 08:08
Golang lambda hello world ginkgo tests
package main
import (
"net/http"
"github.com/aws/aws-lambda-go/events"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)