Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Kotlin "hello-world" CDK example to bring it in sync with TypeScript version #72

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions kotlin/hello-world-lambda-cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ curl --json '{}' -H "Authorization: Bearer ${RESTATE_API_TOKEN}" \
https://${CLUSTER_ID}.dev.restate.cloud:8080/greeter.Greeter/Greet
```

### Useful commands
## Cleanup

* `npm run build` compile the Lambda handler and synthesize CDK deployment artifacts
* `npm run deploy` perform a CDK deployment
To tear down the stack, run:

```shell
npm run destroy
```
1 change: 1 addition & 0 deletions kotlin/hello-world-lambda-cdk/bin/lambda-jvm-cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { LambdaJvmCdkStack } from "../cdk/lambda-jvm-cdk-stack";

const app = new cdk.App();
new LambdaJvmCdkStack(app, "LambdaJvmCdkStack", {
selfHosted: Boolean(app.node.tryGetContext("selfHosted")),
clusterId: app.node.getContext("clusterId"),
authTokenSecretArn: app.node.getContext("authTokenSecretArn"),
});
36 changes: 21 additions & 15 deletions kotlin/hello-world-lambda-cdk/cdk/lambda-jvm-cdk-stack.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import * as cdk from "aws-cdk-lib";
import * as lambda from "aws-cdk-lib/aws-lambda";
import * as logs from "aws-cdk-lib/aws-logs";
import * as restate from "@restatedev/restate-cdk";
import { Construct } from "constructs";

export class LambdaJvmCdkStack extends cdk.Stack {
constructor(
scope: Construct,
id: string,
props: {
clusterId: string;
authTokenSecretArn: string;
} & cdk.StackProps,
props: (
| { selfHosted: true }
| {
selfHosted: false;
clusterId: string;
authTokenSecretArn: string;
}
) &
cdk.StackProps,
) {
super(scope, id, props);

Expand All @@ -25,17 +31,17 @@ export class LambdaJvmCdkStack extends cdk.Stack {
systemLogLevel: "DEBUG",
});

const environment = new restate.RestateCloudEnvironment(this, "RestateCloud", {
clusterId: props.clusterId,
authTokenSecretArn: props.authTokenSecretArn,
});

// Alternatively, you can deploy Restate on your own infrastructure like this. See the Restate CDK docs for more.
// const environment = new restate.SingleNodeRestateInstance(this, "Restate", {
// logGroup: new logs.LogGroup(this, "RestateLogs", {
// retention: logs.RetentionDays.THREE_MONTHS,
// }),
// });
const environment = props.selfHosted
? new restate.SingleNodeRestateDeployment(this, "Restate", {
logGroup: new logs.LogGroup(this, "RestateLogs", {
retention: logs.RetentionDays.THREE_MONTHS,
removalPolicy: cdk.RemovalPolicy.DESTROY,
}),
})
: new restate.RestateCloudEnvironment(this, "RestateCloud", {
clusterId: props.clusterId,
authTokenSecretArn: props.authTokenSecretArn,
});

new restate.LambdaServiceRegistry(this, "RestateServices", {
handlers: {
Expand Down
3 changes: 2 additions & 1 deletion kotlin/hello-world-lambda-cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"watch": "tsc -w",
"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"
"deploy": "npm run build && cdk deploy",
"destroy": "npx cdk destroy"
},
"devDependencies": {
"@restatedev/restate-cdk": "^0.7.0",
Expand Down
9 changes: 6 additions & 3 deletions typescript/hello-world-lambda-cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ curl -H "Authorization: Bearer ${RESTATE_API_TOKEN}" \
https://${CLUSTER_ID}.dev.restate.cloud:8080/Greeter/greet
```

### Useful commands
## Cleanup

* `npm run build` compile the Lambda handler and synthesize CDK deployment artifacts
* `npm run deploy` perform a CDK deployment
To tear down the stack, run:

```shell
npm run destroy
```
3 changes: 2 additions & 1 deletion typescript/hello-world-lambda-cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"build": "npx cdk synth",
"format": "prettier --ignore-path .eslintignore --write \"**/*.+(js|ts|json)\"",
"verify": "npm run format -- --check && npm run lint && npm run build",
"deploy": "npm run build && lib deploy"
"deploy": "npm run build && lib deploy",
"destroy": "npx cdk destroy"
},
"devDependencies": {
"@restatedev/restate-cdk": "^0.7.0",
Expand Down
Loading