Skip to content

krakend/krakend-lambda

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"

About

consume lambda functions through a KrakenD API Gateway

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •