-
Notifications
You must be signed in to change notification settings - Fork 4
/
restate-cloud.e2e.ts
50 lines (40 loc) · 1.85 KB
/
restate-cloud.e2e.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* Copyright (c) 2024 - Restate Software, Inc., Restate GmbH
*
* This file is part of the Restate SDK for Node.js/TypeScript,
* which is released under the MIT license.
*
* You can find a copy of the license in file LICENSE in the root
* directory of this repository or package, or at
* https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
*/
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 secrets from "aws-cdk-lib/aws-secretsmanager";
import "source-map-support/register";
import { EnvironmentId, RestateCloudEnvironment, ServiceDeployer } from "../../lib/restate-constructs";
// Deploy with: RESTATE_ENV_ID=env_... RESTATE_API_KEY=key_... npx cdk --app 'npx tsx restate-cloud.e2e.ts' deploy
const app = new cdk.App();
const stack = new cdk.Stack(app, "e2e-RestateCloud");
if (!process.env.RESTATE_ENV_ID || !process.env.RESTATE_API_KEY) {
throw new Error("Please set RESTATE_ENV_ID and RESTATE_API_KEY");
}
const handler: lambda.Function = new lambda.Function(stack, "Service", {
runtime: lambda.Runtime.NODEJS_LATEST,
code: lambda.Code.fromAsset("../handlers/dist/"),
handler: "bundle.handler",
});
const environment = new RestateCloudEnvironment(stack, "CloudEnv", {
environmentId: process.env.RESTATE_ENV_ID! as EnvironmentId,
apiKey: new secrets.Secret(stack, "RestateCloudApiKey", {
secretStringValue: cdk.SecretValue.unsafePlainText(process.env.RESTATE_API_KEY!),
}),
});
const deployer = new ServiceDeployer(stack, "ServiceDeployer", {
removalPolicy: cdk.RemovalPolicy.DESTROY,
entry: "../../dist/register-service-handler/index.js", // only needed for in-tree tests
});
deployer.deployService("Greeter", handler.currentVersion, environment);
new cdk.CfnOutput(stack, "RestateIngressUrl", { value: environment.ingressUrl });
app.synth();