Sample project deploying a Java-based Restate service to AWS Lambda using the AWS Cloud Development Kit (CDK). The stack uses the Restate CDK constructs library to register the service with against a Restate Cloud environment.
For more information on CDK, please see Getting started with the AWS CDK.
- CDK app entry point
lambda-jvm-cdk.ts - CDK stack consisting of a Lambda function and providing Restate service registration
- Java Lambda handler - based on
hello-world-java
-
Via the CLI:
restate example java-hello-world-lambda-cdk && cd java-hello-world-lambda-cdk
-
Via git clone:
git clone git@github.com:restatedev/examples.git cd examples/java/integrations/java-gradle-lambda-cdk -
Via
wget:wget https://github.com/restatedev/examples/releases/latest/download/java-hello-world-lambda-cdk.zip && unzip java-hello-world-lambda-cdk.zip -d java-hello-world-lambda-cdk && rm java-hello-world-lambda-cdk.zip
Pre-requisites:
- npm
- gradle
- JDK >= 21
- AWS account, bootstrapped for CDK use
- valid AWS credentials with sufficient privileges to create the necessary resources
- an existing Restate Cloud environment (environment id + API key)
Install npm dependencies:
npm installTo deploy the stack, export the Restate Cloud environment id and API key, and run cdk deploy:
export RESTATE_ENV_ID=env_... RESTATE_API_KEY=key_...
npx cdk deployThe stack output will print out the Restate server ingress URL.
You can send a test request to the Restate ingress endpoint to call the newly deployed service:
curl -k ${restateIngressUrl}/Greeter/greet \
-H "Authorization: Bearer $RESTATE_API_KEY" \
-H 'content-type: application/json' -d '"Restate"'npm run buildcompile the Lambda handler and synthesize CDK deployment artifactsnpm run deployperform a CDK deploymentnpm run destroydelete the stack and all its resources