lambda

package module
v2.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

README

krakend-lambda

consume lambda functions through a KrakenD API Gateway

Local test

Set up the localstack container

docker run --rm --name localstack -it \
  -p 4566:4566 \
  -p 4510-4559:4510-4559 \
  -p 8080:8080 \
  -e HOSTNAME_EXTERNAL=$(docker-machine ip localstack) \
  -e SERVICES=serverless \
  -e DEFAULT_REGION=us-east-1 \
  -e LAMBDA_EXECUTOR=local \
  -e DATA_DIR=/tmp/localstack/data \
  -v /tmp/localstack:/tmp/localstack \
  localstack/localstack

build and zip your sample lambdas

$ cd ./test/lambda1 && zip lambda1.zip handler.py && cd ../../ && mv ./test/lambda1/lambda1.zip .

register your lambda

$ aws --endpoint-url=http://$(docker-machine ip localstack):4566 --no-verify-ssl \
	lambda create-function \
	    --region us-east-1 \
	    --memory-size 128 \
	    --zip-file fileb://lambda1.zip \
	    --role arn:aws:iam::123456:role/irrelevant \
	    --function-name python37 \
	    --runtime python37 \
	    --handler handler.my_handler

test it

aws  --endpoint-url=http://$(docker-machine ip localstack):4566 --no-verify-ssl \
    lambda invoke \
        --function-name python37 \
        --invocation-type "RequestResponse" \
        --payload '{"first_name":"foo","last_name":"bar"}' \
        response.txt

test the backend

cd test
go test -tags integration -aws_endpoint=http://192.168.99.100:4566"

Documentation

Index

Constants

View Source
const (
	Namespace = "github.com/davron112/krakend-lambda"
)

Variables

This section is empty.

Functions

func BackendFactory

func BackendFactory(logger logging.Logger, bf proxy.BackendFactory) proxy.BackendFactory

func BackendFactoryWithInvoker

func BackendFactoryWithInvoker(logger logging.Logger, bf proxy.BackendFactory, invokerFactory func(*Options) Invoker) proxy.BackendFactory

Types

type Invoker

type Invoker interface {
	InvokeWithContext(aws.Context, *lambda.InvokeInput, ...request.Option) (*lambda.InvokeOutput, error)
}

type Options

type Options struct {
	PayloadExtractor  payloadExtractor
	FunctionExtractor functionExtractor
	Config            *aws.Config
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL