Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
pcholakov committed Dec 12, 2023
1 parent f91a8aa commit 6633b4f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 10 deletions.
46 changes: 42 additions & 4 deletions kotlin/hello-world-lambda-cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,60 @@ Sample project deploying a Kotlin-based Restate service to AWS Lambda using CDK.
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.

## Deploy

Pre-requisites:
**Pre-requisites:**

* npm
* gradle
* JDK
* Restate Cloud access
* AWS account

Run:
## Deploy

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

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:

```shell
export AUTH_TOKEN_ARN=$(aws secretsmanager create-secret \
--name /restate/${CLUSTER_ID}/auth-token --secret-string ${RESTATE_AUTH_TOKEN} \
--query ARN --output text
)
```

Once you have the ARN for the auth token secret, you can deploy the stack using:

```shell
npx cdk deploy \
--context clusterId=${CLUSTER_ID} \
--context authTokenSecretArn=${AUTH_TOKEN_ARN}
```

Alternatively, you can save this information in the `cdk.context.json` file:

```json
{
"clusterId": "...",
"authTokenSecretArn": "arn:aws:secretsmanager:us-east-1:123456789012:secret:/restate/.../auth-token-abc123"
}
```

In that case, you can simply run:

```shell
npm run deploy
```

### Test

You can send a test request to the Restate cluster ingress endpoint to call the newly deployed service:

```shell
curl --json '{}' -H "Authorization: Bearer ${RESTATE_API_TOKEN}" \
https://${CLUSTER_ID}.dev.restate.cloud:8080/greeter.Greeter/Greet
```

### Useful commands

* `npm run build` compile the Lambda handler and synthesize CDK deployment artifacts
Expand Down
12 changes: 6 additions & 6 deletions kotlin/hello-world-lambda-cdk/lambda/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import com.google.protobuf.gradle.id

val restateSdkVersion = "0.0.1-SNAPSHOT"

plugins {
kotlin("jvm") version "1.9.10"

Expand All @@ -16,14 +18,12 @@ repositories {
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") }
}

val restateVersion = "0.0.1-SNAPSHOT"

dependencies {
// Restate SDK
implementation("dev.restate:sdk-api-kotlin:$restateVersion")
implementation("dev.restate:sdk-lambda:$restateVersion")
implementation("dev.restate:sdk-api-kotlin:$restateSdkVersion")
implementation("dev.restate:sdk-lambda:$restateSdkVersion")
// To use Jackson to read/write state entries (optional)
implementation("dev.restate:sdk-serde-jackson:$restateVersion")
implementation("dev.restate:sdk-serde-jackson:$restateSdkVersion")

// Protobuf and grpc dependencies (we need the Java dependencies as well because the Kotlin dependencies rely on Java)
implementation("com.google.protobuf:protobuf-java:3.24.3")
Expand All @@ -44,7 +44,7 @@ dependencies {
// Testing (optional)
testImplementation("org.junit.jupiter:junit-jupiter:5.9.1")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
testImplementation("dev.restate:sdk-testing:$restateVersion")
testImplementation("dev.restate:sdk-testing:$restateSdkVersion")
}

// Setup Java/Kotlin compiler target
Expand Down

0 comments on commit 6633b4f

Please sign in to comment.