AWS lambda to gRPC demonstration
- Lambda and gRPC server must route (i.e. same VPC, etc)
- Security group must allow gRPC (in this case port 50053)
- LambdaBasicExecution (i.e. CloudWatch logs) is enough after installation.
- Developed on AWS EC2 (ubuntu server 20.04 LTS)
- python 3.8 runtime
- proto (directory)
- gRPC protobuf definitions
- Invoke "proto.sh" to regenerate
- server (directory)
- gRPC server, "go build" to create
- Invoke "run.sh" to run (use a dedicated terminal for the server)
- go-client (directory)
- gRPC client in go, configured for localhost
- Invoke "go run" for diagnostic (with server from previous step)
- py-client (directory)
- gRPC client in python, configured for localhost
- Uses virtualenv
- Invoke "proto.sh" to generate gRPC stubs
- Invoke "python client.py" to run
- py-lambda (directory)
- gRPC client as a AWS python lambda
- Uses virtualenv
- Invoke "lambda-build.sh" to create deployment zip
- Two zip files: grpc-layer.zip and elder-mixer.zip
- Deploys from s3 (because gRPC libraries are large)
- Upload both zip files to s3 bucket
- From AWS console
- Create python lambda function "elder-mixer" using python 3.8 runtime
- Select VPC, subnet and security group to match server EC2 instance
- Upload elder-mixer.zip as lambda function (from s3 bucket)
- Upload grpc-layer.zip as lambda layer (from s3 bucket)
- Configure elder-mixer to use grpc-layer
- Invoke "test" on elder-mixer lambda, the "hello, world" test is OK
- The lambda does not care, but need an event which causes gRPC write to server
- Success means the lambda ran without errors and the server wrote a log message
- Create python lambda function "elder-mixer" using python 3.8 runtime