Skip to content

Commit

Permalink
Add top-level verify target
Browse files Browse the repository at this point in the history
  • Loading branch information
pcholakov committed Dec 12, 2023
1 parent 6b2d89c commit e9a664c
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 67 deletions.
3 changes: 3 additions & 0 deletions kotlin/hello-world-lambda-cdk/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
cdk.out
15 changes: 15 additions & 0 deletions kotlin/hello-world-lambda-cdk/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"overrides": [],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest"
},
"plugins": ["@typescript-eslint"],
"rules": {}
}
28 changes: 19 additions & 9 deletions kotlin/hello-world-lambda-cdk/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
# Hello world - Kotlin Lambda (CDK) example

Sample project deploying a Kotlin-based Restate service to AWS Lambda using CDK. This is functionally equivalent
to the [`hello-world-lambda`](../hello-world-lambda) example but uses CDK to automate the deploy of the Lambda function
to AWS, and the registration of the handler with Restate Cloud.
to the [`hello-world-lambda`](../hello-world-lambda) example but uses CDK to automate the deployment of the Lambda
function to AWS, and the registration of the handler with Restate Cloud.

**Pre-requisites:**
Sample project configuration of a Restate service using the Kotlin coroutines interface and AWS Lambda. It contains:

* npm
* gradle
* JDK
* Restate Cloud access
* AWS account
* [CDK app entry point `lambda-jvm-cdk.ts`](bin/lambda-jvm-cdk.ts)
* [CDK stack consisting of a Lambda function and providing Restate service registration](cdk/lambda-jvm-cdk-stack.ts)
* [Kotlin Lambda handler](lambda) - based on [`hello-world-lambda`](../hello-world-lambda)

## Download the example

```shell
wget https://github.com/restatedev/examples/releases/latest/download/kotlin-hello-world-lambda-cdk.zip && unzip kotlin-hello-world-lambda-cdk.zip -d kotlin-hello-world-lambda-cdk && rm kotlin-hello-world-lambda-cdk.zip
```

## Deploy

You should have two pieces of information about your Restate Cloud: a cluster identifier and an API authentication token.
**Pre-requisites:**

* npm
* gradle
* JDK >= 11
* Restate Cloud access (cluster id + API token)
* AWS account, bootstrapped for CDK use

Create a secret in Secrets Manager to hold the authentication token. The secret name is up to you -- we suggest
using `/restate/` and an appropriate prefix to avoid confusion:
Expand Down
2 changes: 1 addition & 1 deletion kotlin/hello-world-lambda-cdk/bin/lambda-jvm-cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ const app = new cdk.App();
new LambdaJvmCdkStack(app, "LambdaJvmCdkStack", {
clusterId: app.node.getContext("clusterId"),
authTokenSecretArn: app.node.getContext("authTokenSecretArn"),
});
});
9 changes: 2 additions & 7 deletions kotlin/hello-world-lambda-cdk/cdk.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"app": "npx ts-node --prefer-ts-exts bin/lambda-jvm-cdk.ts",
"watch": {
"include": [
"**"
],
"include": ["**"],
"exclude": [
"README.md",
"cdk*.json",
Expand All @@ -19,10 +17,7 @@
"context": {
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
"@aws-cdk/core:checkSecretUsage": true,
"@aws-cdk/core:target-partitions": [
"aws",
"aws-cn"
],
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
Expand Down
38 changes: 0 additions & 38 deletions kotlin/hello-world-lambda-cdk/lambda/README.md

This file was deleted.

4 changes: 3 additions & 1 deletion kotlin/hello-world-lambda-cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
"lambda-jvm-cdk": "bin/lambda-jvm-cdk.js"
},
"scripts": {
"lint": "eslint --ignore-path .eslintignore --ext .ts .",
"build": "npm run build-lambda && npm run build-cdk",
"build-lambda": "cd lambda && ./gradlew shadowJar",
"build-cdk": "cdk synth",
"watch": "tsc -w",
"test": "jest",
"format": "prettier --ignore-path .eslintignore --write \"**/*.+(js|ts|json)\"",
"verify": "npm run format -- --check && npm run lint && npm run build",
"deploy": "npm run build && cdk deploy"
},
"devDependencies": {
Expand Down
14 changes: 3 additions & 11 deletions kotlin/hello-world-lambda-cdk/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": [
"es2020",
"dom"
],
"lib": ["es2020", "dom"],
"declaration": true,
"strict": true,
"noImplicitAny": true,
Expand All @@ -20,12 +17,7 @@
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"typeRoots": [
"./node_modules/@types"
]
"typeRoots": ["./node_modules/@types"]
},
"exclude": [
"node_modules",
"cdk.out"
]
"exclude": ["node_modules", "cdk.out"]
}

0 comments on commit e9a664c

Please sign in to comment.