diff --git a/lib/solana/app.ts b/lib/solana/app.ts index c666c53..681939a 100644 --- a/lib/solana/app.ts +++ b/lib/solana/app.ts @@ -34,23 +34,28 @@ new SolanaSingleNodeStack(app, "solana-single-node", { registrationTransactionFundingAccountSecretARN: config.baseNodeConfig.registrationTransactionFundingAccountSecretARN, }); -new SolanaHANodesStack(app, "solana-ha-nodes", { - stackName: `solana-ha-nodes-${config.baseNodeConfig.nodeConfiguration}`, - env: { account: config.baseConfig.accountId, region: config.baseConfig.region }, - - instanceType: config.baseNodeConfig.instanceType, - instanceCpuType: config.baseNodeConfig.instanceCpuType, - solanaCluster: config.baseNodeConfig.solanaCluster, - solanaVersion: config.baseNodeConfig.solanaVersion, - nodeConfiguration: config.baseNodeConfig.nodeConfiguration, - dataVolume: config.baseNodeConfig.dataVolume, - accountsVolume: config.baseNodeConfig.accountsVolume, +if (app.node.tryGetContext('deployHA') === 'true') { + if (config.baseNodeConfig.nodeConfiguration !== "consensus") { + new SolanaHANodesStack(app, "solana-ha-nodes", { + stackName: `solana-ha-nodes-${config.baseNodeConfig.nodeConfiguration}`, + env: { account: config.baseConfig.accountId, region: config.baseConfig.region }, - albHealthCheckGracePeriodMin: config.haNodeConfig.albHealthCheckGracePeriodMin, - heartBeatDelayMin: config.haNodeConfig.heartBeatDelayMin, - numberOfNodes: config.haNodeConfig.numberOfNodes, -}); + instanceType: config.baseNodeConfig.instanceType, + instanceCpuType: config.baseNodeConfig.instanceCpuType, + solanaCluster: config.baseNodeConfig.solanaCluster, + solanaVersion: config.baseNodeConfig.solanaVersion, + nodeConfiguration: config.baseNodeConfig.nodeConfiguration, + dataVolume: config.baseNodeConfig.dataVolume, + accountsVolume: config.baseNodeConfig.accountsVolume, + albHealthCheckGracePeriodMin: config.haNodeConfig.albHealthCheckGracePeriodMin, + heartBeatDelayMin: config.haNodeConfig.heartBeatDelayMin, + numberOfNodes: config.haNodeConfig.numberOfNodes, + }); + } else { + throw new Error("Consensus node configuration is not yet supported for HA setup"); + } +} // Security Check cdk.Aspects.of(app).add( diff --git a/lib/solana/lib/ha-nodes-stack.ts b/lib/solana/lib/ha-nodes-stack.ts index 0b5abd4..03ddcb3 100644 --- a/lib/solana/lib/ha-nodes-stack.ts +++ b/lib/solana/lib/ha-nodes-stack.ts @@ -53,7 +53,7 @@ export class SolanaHANodesStack extends cdk.Stack { const vpc = ec2.Vpc.fromLookup(this, "vpc", { isDefault: true }); // Setting up the security group for the node from Solana-specific construct - const instanceSG = new SolanaNodeSecurityGroupConstruct (this, "security-group", { + const instanceSG = new SolanaNodeSecurityGroupConstruct(this, "security-group", { vpc: vpc, }) @@ -75,10 +75,6 @@ export class SolanaHANodesStack extends cdk.Stack { throw new Error("ARM_64 is not yet supported"); } - if (nodeConfiguration === "consensus") { - throw new Error("Consensus node configuration is not yet supported for HA setup"); - } - // Use Ubuntu 20.04 LTS image for amd64. Find more: https://discourse.ubuntu.com/t/finding-ubuntu-images-with-the-aws-ssm-parameter-store/15507 const ubuntu204stableImageSsmName = "/aws/service/canonical/ubuntu/server/20.04/stable/current/amd64/hvm/ebs-gp2/ami-id" @@ -110,7 +106,7 @@ export class SolanaHANodesStack extends cdk.Stack { // Setting up the nodse using generic High Availability (HA) Node constract const healthCheckPath = "/health"; - const rpcNodes = new HANodesConstruct (this, "rpc-nodes", { + const rpcNodes = new HANodesConstruct(this, "rpc-nodes", { instanceType, dataVolumes: [accountsVolume, dataVolume], rootDataVolumeDeviceName: "/dev/sda1",