Skip to content

Commit

Permalink
Expose instanceType and machineImage properties for EC2 deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
pcholakov committed Sep 2, 2024
1 parent 06b1b21 commit 5f063ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions lib/restate-constructs/single-node-restate-deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ import * as cdk from "aws-cdk-lib";
import { RemovalPolicy } from "aws-cdk-lib";

export interface SingleNodeRestateProps {
/** EC2 instance type to use. */
instanceType?: ec2.InstanceType;

/** Machine image. */
machineImage?: ec2.IMachineImage;

/** The VPC in which to launch the Restate host. */
vpc?: ec2.IVpc;

Expand Down Expand Up @@ -49,8 +55,8 @@ export interface SingleNodeRestateProps {
clusterName?: string;
/** RocksDB settings. */
rocksdb?: {
/** Defaults to `512.0 MB`. */
totalMemorySize?: string;
/** Defaults to 512 MB. */
totalMemorySize?: cdk.Size;
};
};

Expand Down Expand Up @@ -190,10 +196,12 @@ export class SingleNodeRestateDeployment extends Construct implements IRestateEn
const restateInstance = new ec2.Instance(this, "Host", {
vpc: this.vpc,
vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC },
instanceType: new ec2.InstanceType("t4g.micro"),
machineImage: ec2.MachineImage.latestAmazonLinux2023({
cpuType: ec2.AmazonLinuxCpuType.ARM_64,
}),
instanceType: props.instanceType ?? new ec2.InstanceType("t4g.micro"),
machineImage:
props.machineImage ??
ec2.MachineImage.latestAmazonLinux2023({
cpuType: ec2.AmazonLinuxCpuType.ARM_64,
}),
role: this.instanceRole,
blockDevices: [
{
Expand Down Expand Up @@ -259,7 +267,7 @@ export class SingleNodeRestateDeployment extends Construct implements IRestateEn
`default-thread-pool-size = 3`,
`storage-high-priority-bg-threads = 3`,
`storage-low-priority-bg-threads = 3`,
`rocksdb-total-memory-size = "${props.restateConfig?.rocksdb?.totalMemorySize ?? "512.0 MB"}"`,
`rocksdb-total-memory-size = "${props.restateConfig?.rocksdb?.totalMemorySize?.toMebibytes() ?? 512.0 + " MB"}"`,
`rocksdb-total-memtables-ratio = 0.6000000238418579`,
`rocksdb-bg-threads = 3`,
`rocksdb-high-priority-bg-threads = 3`,
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/restate-constructs.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ exports[`Restate constructs Create a self-hosted Restate environment deployed on
storage-low-priority-bg-threads = 3
rocksdb-total-memory-size = "512.0 MB"
rocksdb-total-memory-size = "512 MB"
rocksdb-total-memtables-ratio = 0.6000000238418579
Expand Down

0 comments on commit 5f063ca

Please sign in to comment.