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

Add CDK reference page #234

Merged
merged 13 commits into from
Dec 19, 2023
132 changes: 132 additions & 0 deletions docs/services/deployment/cdk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
sidebar_position: 3
label: "cdk"
description: "Deploy Restate services on AWS Lambda using CDK."
---

# AWS Cloud Development Kit + Restate

Check warning on line 7 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L7

[Google.Headings] 'AWS Cloud Development Kit + Restate' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] 'AWS Cloud Development Kit + Restate' should use sentence-style capitalization.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 7, "column": 3}}}, "severity": "WARNING"}

Check warning on line 7 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L7

[Google.WordList] Use 'Google Cloud Platform' or 'GCP' instead of 'Cloud'.
Raw output
{"message": "[Google.WordList] Use 'Google Cloud Platform' or 'GCP' instead of 'Cloud'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 7, "column": 7}}}, "severity": "WARNING"}

## Deploying Restate services as AWS Lambda functions

You can run your Restate services as serverless functions on [AWS Lambda](https://aws.amazon.com/lambda/).
The [Restate CDK support library](https://www.npmjs.com/package/@restatedev/restate-cdk) provides convenient constructs

Check notice on line 12 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L12

[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 12, "column": 14}}}, "severity": "INFO"}
for deploying Restate services on AWS Lambda.

[CDK](https://aws.amazon.com/cdk/) provides an elegant way to define your cloud application infrastructure in a familiar

Check notice on line 15 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L15

[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 15, "column": 2}}}, "severity": "INFO"}
programming language. Currently, we support CDK projects built in TypeScript, but you can deploy Restate handlers in any

Check warning on line 16 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L16

[write-good.Weasel] 'Currently' is a weasel word!
Raw output
{"message": "[write-good.Weasel] 'Currently' is a weasel word!", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 16, "column": 23}}}, "severity": "WARNING"}

Check warning on line 16 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L16

[Google.We] Try to avoid using first-person plural like 'we'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'we'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 16, "column": 34}}}, "severity": "WARNING"}

Check notice on line 16 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L16

[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 16, "column": 45}}}, "severity": "INFO"}
language supported by a Restate SDK. CDK is often used to manage serverless application stacks, and the Restate CDK

Check notice on line 17 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L17

[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 17, "column": 38}}}, "severity": "INFO"}

Check notice on line 17 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L17

[write-good.E-Prime] Try to avoid using 'is'.
Raw output
{"message": "[write-good.E-Prime] Try to avoid using 'is'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 17, "column": 42}}}, "severity": "INFO"}

Check notice on line 17 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L17

[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 17, "column": 113}}}, "severity": "INFO"}
constructs are the easiest method to deploy and manage Restate services on AWS Lambda.

Check notice on line 18 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L18

[write-good.E-Prime] Try to avoid using 'are'.
Raw output
{"message": "[write-good.E-Prime] Try to avoid using 'are'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 18, "column": 12}}}, "severity": "INFO"}

If you don't have an existing CDK project, follow the CDK [Getting started](https://docs.aws.amazon.com/cdk/v2/guide/hello_world.html)

Check notice on line 20 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L20

[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 20, "column": 31}}}, "severity": "INFO"}

Check notice on line 20 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L20

[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 20, "column": 55}}}, "severity": "INFO"}
page to set one up.

### Adding the Restate CDK support library

Check notice on line 23 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L23

[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 23, "column": 24}}}, "severity": "INFO"}

Add the Restate CDK support library to your project:

Check notice on line 25 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L25

[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 25, "column": 17}}}, "severity": "INFO"}

```shell
npm install @restatedev/restate-cdk
```

### Deploy your handler code to AWS Lambda

Define one or more Lambda functions in your CDK stack to deploy the service handlers in your chosen language. Depending

Check notice on line 33 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L33

[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 33, "column": 45}}}, "severity": "INFO"}
on the SDK and programming language, you may need an additional build process such as Gradle, to bundle your business

Check warning on line 34 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L34

[write-good.TooWordy] 'additional' is too wordy.
Raw output
{"message": "[write-good.TooWordy] 'additional' is too wordy.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 34, "column": 54}}}, "severity": "WARNING"}

Check failure on line 34 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L34

[Vale.Spelling] Did you really mean 'Gradle'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Gradle'?", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 34, "column": 87}}}, "severity": "ERROR"}
logic in a Lambda-deployable artifact.

For example, to deploy a Java or Kotlin service handler to Lambda, you might use the following CDK construct:

Check notice on line 37 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L37

[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 37, "column": 96}}}, "severity": "INFO"}

```typescript
import * as lambda from "aws-cdk-lib/aws-lambda";

const service: lambda.Function = new lambda.Function(scope, "RestateService", {
runtime: lambda.Runtime.JAVA_21,
architecture: lambda.Architecture.ARM_64,
code: lambda.Code.fromAsset(".../lambda-all.jar"), // use the path of your JAR file artifact
handler: "com.example.service.package.LambdaHandler", // use the fully qualified name of your handler class
timeout: cdk.Duration.seconds(10),
pcholakov marked this conversation as resolved.
Show resolved Hide resolved
});
```

For TypeScript/JavaScript services, you can use the [`NodejsFunction`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda_nodejs-readme.html)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put this behind tabs? One for TS, one for Java?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, on a second thought, the code itself is always Typescript... So not sure if tabs would make sense

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're onto something though! I'll play with tabs - I hadn't thought of that in this context. Ditto for self-hosted / managed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It came out much nicer, thank you for the suggestion!

construct to transpile and bundle all the required dependencies.

Check failure on line 52 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L52

[Vale.Spelling] Did you really mean 'transpile'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'transpile'?", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 52, "column": 14}}}, "severity": "ERROR"}

```typescript
import * as lambda from "aws-cdk-lib/aws-lambda";
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";

const service = new NodejsFunction(scope, "RestateService", {
runtime: lambda.Runtime.NODEJS_18_X,
architecture: lambda.Architecture.ARM_64,
entry: "handler", // use the path to your service handler
});
```

These definitions are no different to how you might deploy any other Lambda handler.

Check notice on line 65 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L65

[write-good.E-Prime] Try to avoid using 'are'.
Raw output
{"message": "[write-good.E-Prime] Try to avoid using 'are'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 65, "column": 19}}}, "severity": "INFO"}

### Register Lambda-based services with Restate

To enable our Lambda-deployed handlers to receive Restate requests, we need to register them with a Restate instance.

Check warning on line 69 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L69

[Google.We] Try to avoid using first-person plural like 'our'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'our'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 69, "column": 11}}}, "severity": "WARNING"}

Check warning on line 69 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L69

[Google.We] Try to avoid using first-person plural like 'we'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'we'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 69, "column": 69}}}, "severity": "WARNING"}
pcholakov marked this conversation as resolved.
Show resolved Hide resolved
We can model existing Restate Cloud instance using the `RestateCloudEndpoint` construct:

Check warning on line 70 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L70

[Google.We] Try to avoid using first-person plural like 'We'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'We'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 70, "column": 1}}}, "severity": "WARNING"}

Check warning on line 70 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L70

[Google.WordList] Use 'Google Cloud Platform' or 'GCP' instead of 'Cloud'.
Raw output
{"message": "[Google.WordList] Use 'Google Cloud Platform' or 'GCP' instead of 'Cloud'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 70, "column": 31}}}, "severity": "WARNING"}
pcholakov marked this conversation as resolved.
Show resolved Hide resolved

```typescript
import * as restate from "@restatedev/restate-cdk";

const restateInstance = new restate.RestateCloudEndpoint(scope, "RestateCloud", {
clusterId: "restate-cluster-id",
authTokenSecretArn: restateAuthToken.secretFullArn,
});
```

Automatically register service handlers with Restate on deployment:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this sentence might need a bit more context and explanation on how it differs from the normal registration practices.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the primary way this differs is in the same way how Lambda deployments differ – they always refer to an explicit version of the function, and every function update generates a new deployment revision. Is that what you had in mind?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've expanded the text to cover this - let me know if you can think of something more to add!


```typescript
import * as restate from "@restatedev/restate-cdk";

const handlers = new restate.LambdaServiceRegistry(scope, "RestateServiceRegistry", {
serviceHandlers: {
"namespace.Service": service,
},
restate: restateInstance,
});
handlers.register({
metaEndpoint: restateInstance.metaEndpoint,
invokerRoleArn: restateInstance.invokerRole.roleArn,
authTokenSecretArn: restateInstance.authToken.secretArn,
});
```

### Deploy a single-node development Restate instance

Restate is [very easy to deploy](https://docs.restate.dev/restate/deployment), and we provide a CDK construct to take

Check notice on line 101 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L101

[write-good.E-Prime] Try to avoid using 'is'.
Raw output
{"message": "[write-good.E-Prime] Try to avoid using 'is'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 101, "column": 9}}}, "severity": "INFO"}

Check warning on line 101 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L101

[write-good.Weasel] 'very' is a weasel word!
Raw output
{"message": "[write-good.Weasel] 'very' is a weasel word!", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 101, "column": 13}}}, "severity": "WARNING"}

Check failure on line 101 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L101

[proselint.Very] Remove 'very'.
Raw output
{"message": "[proselint.Very] Remove 'very'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 101, "column": 13}}}, "severity": "ERROR"}

Check warning on line 101 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L101

[Google.We] Try to avoid using first-person plural like 'we'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'we'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 101, "column": 84}}}, "severity": "WARNING"}

Check notice on line 101 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L101

[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 101, "column": 97}}}, "severity": "INFO"}
advantage of this to deploy a standalone self-hosted instance running on Amazon EC2. The `SingleNodeRestateInstance`
construct deploys a single-node server and creates a new role that can be assumed by the Restate managed service with

Check notice on line 103 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L103

[write-good.E-Prime] Try to avoid using 'be'.
Raw output
{"message": "[write-good.E-Prime] Try to avoid using 'be'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 103, "column": 72}}}, "severity": "INFO"}

Check notice on line 103 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L103

[Google.Passive] In general, use active voice instead of passive voice ('be assumed').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('be assumed').", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 103, "column": 72}}}, "severity": "INFO"}

Check warning on line 103 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L103

[write-good.Passive] 'be assumed' may be passive voice. Use active voice if you can.
Raw output
{"message": "[write-good.Passive] 'be assumed' may be passive voice. Use active voice if you can.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 103, "column": 72}}}, "severity": "WARNING"}
pcholakov marked this conversation as resolved.
Show resolved Hide resolved
permission to invoke service handlers in your account. The instance will be deployed in a new internet-connected VPC,

Check warning on line 104 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L104

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 104, "column": 69}}}, "severity": "WARNING"}

Check notice on line 104 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L104

[Google.Passive] In general, use active voice instead of passive voice ('be deployed').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('be deployed').", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 104, "column": 74}}}, "severity": "INFO"}

Check warning on line 104 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L104

[write-good.Passive] 'be deployed' may be passive voice. Use active voice if you can.
Raw output
{"message": "[write-good.Passive] 'be deployed' may be passive voice. Use active voice if you can.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 104, "column": 74}}}, "severity": "WARNING"}

Check notice on line 104 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L104

[write-good.E-Prime] Try to avoid using 'be'.
Raw output
{"message": "[write-good.E-Prime] Try to avoid using 'be'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 104, "column": 74}}}, "severity": "INFO"}

Check notice on line 104 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L104

[Google.Acronyms] Spell out 'VPC', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'VPC', if it's unfamiliar to the audience.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 104, "column": 114}}}, "severity": "INFO"}
unless you provide one explicitly. You can also optionally enable tracing integration, which will grant the instance

Check warning on line 105 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L105

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 105, "column": 94}}}, "severity": "WARNING"}
role permission to send traces to AWS X-Ray.

```typescript
import * as restate from "@restatedev/restate-cdk";

const restateInstance = new restate.SingleNodeRestateInstance(scope, "RestateServer", {
restateTag: "latest",
tracing: restate.TracingMode.AWS_XRAY,
logGroup: new logs.LogGroup(scope, "RestateLogs", {
logGroupName: "/restate/server-logs",
retention: logs.RetentionDays.ONE_MONTH,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also add how to define a specific VPC for deployment here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left it out because I think it's a better default to deploy Restate in its own VPC. Advanced customers who know what they're doing can easily define their own or connect it to an existing VPC.

A related question is whether we should similarly auto-create a log group for Restate server logs if the user doesn't supply one. Right now that's a required property.

}),
});
```

Note that you still need to register your service handlers with the Restate instance as described earlier.

For a complete working project, please refer to one of the examples below.

## Complete examples

You can use the following examples as references for your own CDK projects:

Check notice on line 127 in docs/services/deployment/cdk.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/deployment/cdk.md#L127

[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CDK', if it's unfamiliar to the audience.", "location": {"path": "docs/services/deployment/cdk.md", "range": {"start": {"line": 127, "column": 63}}}, "severity": "INFO"}

- [hello-world-lambda-cdk](https://github.com/restatedev/examples/tree/main/kotlin/hello-world-lambda-cdk) - provides a
simple example of a Lambda-deployed Kotlin handler
- [Restate Holiday](https://github.com/restatedev/restate-holiday) - a more complex example of a fictional reservation
service demonstrating the Saga orchestration pattern