Skip to content

Commit 526c1ba

Browse files
author
Pedro Aceves
committed
missed commits and minor cleanup
1 parent 6ec18bc commit 526c1ba

File tree

8 files changed

+126
-39
lines changed

8 files changed

+126
-39
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ ha-nodes-deploy*.json
3838
.env
3939
.idea
4040
.vscode
41+
.venv

lib/xrp/app.ts

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env node
2+
import "dotenv/config";
3+
import * as cdk from "aws-cdk-lib";
4+
import * as nag from "cdk-nag";
5+
import * as config from "./lib/config/XRPConfig";
6+
7+
import { XRPSingleNodeStack } from "./lib/single-node-stack";
8+
import { XRPCommonStack } from "./lib/common-stack";
9+
import { XRPHANodesStack } from "./lib/ha-nodes-stack";
10+
11+
const app = new cdk.App();
12+
cdk.Tags.of(app).add("Project", "AWSXRP");
13+
14+
const commonStack = new XRPCommonStack(app, "XRP-common", {
15+
stackName: `XRP-nodes-common`,
16+
env: { account: config.baseConfig.accountId, region: config.baseConfig.region },
17+
});
18+
19+
new XRPSingleNodeStack(app, "XRP-single-node", {
20+
env: { account: config.baseConfig.accountId, region: config.baseConfig.region },
21+
stackName: `XRP-single-node`,
22+
instanceType: config.baseNodeConfig.instanceType,
23+
instanceCpuType: config.baseNodeConfig.instanceCpuType,
24+
dataVolume: config.baseNodeConfig.dataVolume,
25+
hubNetworkID: config.baseNodeConfig.hubNetworkID,
26+
instanceRole: commonStack.instanceRole,
27+
});
28+
29+
new XRPHANodesStack(app, "XRP-ha-nodes", {
30+
stackName: "xrp-ha-nodes",
31+
env: { account: config.baseConfig.accountId, region: config.baseConfig.region },
32+
instanceType: config.baseNodeConfig.instanceType,
33+
instanceCpuType: config.baseNodeConfig.instanceCpuType,
34+
dataVolume: config.baseNodeConfig.dataVolume,
35+
hubNetworkID: config.baseNodeConfig.hubNetworkID,
36+
instanceRole: commonStack.instanceRole,
37+
albHealthCheckGracePeriodMin: config.haNodeConfig.albHealthCheckGracePeriodMin,
38+
heartBeatDelayMin: config.haNodeConfig.heartBeatDelayMin,
39+
numberOfNodes: config.haNodeConfig.numberOfNodes,
40+
});
41+
42+
// Security Check
43+
cdk.Aspects.of(app).add(
44+
new nag.AwsSolutionsChecks({
45+
verbose: false,
46+
reports: true,
47+
logIgnores: false,
48+
})
49+
);

lib/xrp/lib/config/XRPConfig.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import * as ec2 from "aws-cdk-lib/aws-ec2";
22
import * as configTypes from "../../../constructs/config.interface";
33
import * as constants from "../../../constructs/constants";
4-
import * as xrp from "./XRPConfig.interface"
5-
import { BaseNodeConfig } from "../../../constructs/config.interface";
4+
import * as xrp from "./XRPConfig.interface";
65

76

87
const parseDataVolumeType = (dataVolumeType: string) => {
@@ -36,13 +35,7 @@ export const baseNodeConfig: xrp.XRPBaseNodeConfig = {
3635
iops: process.env.DATA_VOL_IOPS ? parseInt(process.env.DATA_VOL_IOPS): 12000,
3736
throughput: process.env.DATA_VOL_THROUGHPUT ? parseInt(process.env.DATA_VOL_THROUGHPUT): 700,
3837
},
39-
// hubNetworkIP: process.env.HUB_NETWORK_IP || "s.altnet.rippletest.net 51235", //testnet
40-
hubNetworkID: process.env.HUB_NETWORK_ID || "testnet",
41-
// onlineDelete: process.env.ONLINE_DELETE || "512",
42-
// advisoryDelete: process.env.ADVISORY_DELETE || "1",
43-
// validatorListSites: process.env.VALIDATOR_LIST_SITES || "https://vl.altnet.rippletest.net", //testnet
44-
// validatorListKeys: process.env.VALIDATOR_LIST_KEYS || "https://vl.altnet.rippletest.net" //testnet
45-
38+
hubNetworkID: process.env.HUB_NETWORK_ID || "testnet"
4639
};
4740

4841

lib/xrp/lib/ha-nodes-stack.ts

+13-26
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import { HANodesConstruct } from "../../constructs/ha-rpc-nodes-with-alb";
99
import * as constants from "../../constructs/constants";
1010
import { XRPSingleNodeStackProps } from "./single-node-stack";
1111
import { XRPNodeSecurityGroupConstruct } from "./constructs/xrp-node-security-group";
12-
import { SingleNodeCWDashboardJSON } from "./constructs/node-cw-dashboard";
13-
import * as cw from 'aws-cdk-lib/aws-cloudwatch';
1412

1513
export interface XRPHANodesStackProps extends XRPSingleNodeStackProps {
1614
albHealthCheckGracePeriodMin: number;
@@ -36,33 +34,25 @@ export class XRPHANodesStack extends cdk.Stack {
3634
dataVolume: dataVolume,
3735
stackName,
3836
hubNetworkID,
39-
// hubNetworkIP,
40-
// validatorListSites,
41-
// validatorListKeys,
42-
// onlineDelete,
43-
// advisoryDelete,
4437
albHealthCheckGracePeriodMin,
4538
heartBeatDelayMin,
46-
numberOfNodes,
39+
numberOfNodes
4740
} = props;
4841

4942
// Using default VPC
5043
const vpc = ec2.Vpc.fromLookup(this, "vpc", { isDefault: true });
5144

5245
// Setting up the security group for the node from Solana-specific construct
5346
const instanceSG = new XRPNodeSecurityGroupConstruct(this, "security-group", {
54-
vpc: vpc,
47+
vpc: vpc
5548
});
5649

5750
// Making our scripts and configis from the local "assets" directory available for instance to download
5851
const asset = new s3Assets.Asset(this, "assets", {
59-
path: path.join(__dirname, "assets"),
52+
path: path.join(__dirname, "assets")
6053
});
6154

62-
// Getting the IAM role ARN from the common stack
63-
const importedInstanceRoleArn = cdk.Fn.importValue("SolanaNodeInstanceRoleArn");
64-
65-
const instanceRole = props.instanceRole; //iam.Role.fromRoleArn(this, "iam-role", importedInstanceRoleArn);
55+
const instanceRole = props.instanceRole;
6656

6757
// Making sure our instance will be able to read the assets
6858
asset.bucket.grantRead(instanceRole);
@@ -90,7 +80,7 @@ export class XRPHANodesStack extends cdk.Stack {
9080
.replace("_HUB_NETWORK_ID_", hubNetworkID)
9181
.replace("_LIFECYCLE_HOOK_NAME_", lifecycleHookName)
9282
.replace("_ASG_NAME_", autoScalingGroupName);
93-
},
83+
}
9484
})
9585
);
9686

@@ -101,7 +91,7 @@ export class XRPHANodesStack extends cdk.Stack {
10191
rootDataVolumeDeviceName: "/dev/xvda",
10292
machineImage: new ec2.AmazonLinuxImage({
10393
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
104-
cpuType: ec2.AmazonLinuxCpuType.X86_64,
94+
cpuType: ec2.AmazonLinuxCpuType.X86_64
10595
}),
10696
vpc,
10797
role: instanceRole,
@@ -113,16 +103,13 @@ export class XRPHANodesStack extends cdk.Stack {
113103
heartBeatDelayMin,
114104
lifecycleHookName: lifecycleHookName,
115105
autoScalingGroupName: autoScalingGroupName,
116-
rpcPortForALB: 6005,
106+
rpcPortForALB: 6005
117107
});
118108

119-
120-
121-
122109

123110
// Making sure we output the URL of our Applicaiton Load Balancer
124111
new cdk.CfnOutput(this, "alb-url", {
125-
value: nodeASG.loadBalancerDnsName,
112+
value: nodeASG.loadBalancerDnsName
126113
});
127114

128115
// Adding suppressions to the stack
@@ -131,20 +118,20 @@ export class XRPHANodesStack extends cdk.Stack {
131118
[
132119
{
133120
id: "AwsSolutions-AS3",
134-
reason: "No notifications needed",
121+
reason: "No notifications needed"
135122
},
136123
{
137124
id: "AwsSolutions-S1",
138-
reason: "No access log needed for ALB logs bucket",
125+
reason: "No access log needed for ALB logs bucket"
139126
},
140127
{
141128
id: "AwsSolutions-EC28",
142-
reason: "Using basic monitoring to save costs",
129+
reason: "Using basic monitoring to save costs"
143130
},
144131
{
145132
id: "AwsSolutions-IAM5",
146-
reason: "Need read access to the S3 bucket with assets",
147-
},
133+
reason: "Need read access to the S3 bucket with assets"
134+
}
148135
],
149136
true
150137
);

lib/xrp/lib/single-node-stack.ts

-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { XRPNodeSecurityGroupConstruct } from "./constructs/xrp-node-security-gr
1212
import { SingleNodeCWDashboardJSON } from "./constructs/node-cw-dashboard";
1313
import { DataVolumeConfig } from "../../constructs/config.interface";
1414
import * as constants from "../../constructs/constants";
15-
import { parseRippledConfig } from "./config/createIniFile";
1615

1716

1817
export interface XRPSingleNodeStackProps extends cdk.StackProps {
@@ -58,9 +57,6 @@ export class XRPSingleNodeStack extends cdk.Stack {
5857
path: path.join(__dirname, "assets")
5958
});
6059

61-
// Getting the IAM role ARN from the common stack
62-
const importedInstanceRoleArn = cdk.Fn.importValue("XRPNodeInstanceRoleArn");
63-
6460
const instanceRole = props.instanceRole; //iam.Role.fromRoleArn(this, "iam-role", importedInstanceRoleArn);
6561

6662
// Making sure our instance will be able to read the assets

lib/xrp/package.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "aws-blockchain-node-runners-xrp",
3+
"version": "0.2.0",
4+
"scripts": {
5+
"build": "npx tsc",
6+
"watch": "npx tsc -w",
7+
"test": "npx jest --detectOpenHandles",
8+
"cdk": "npx cdk",
9+
"scan-cdk": "npx cdk synth"
10+
},
11+
"dependencies": {
12+
"ini": "^4.1.1"
13+
},
14+
"devDependencies": {
15+
"@types/ini": "^4.1.1"
16+
}
17+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
AWS_ACCOUNT_ID="xxxxxxxxxxx"
2+
AWS_REGION="xxxxxxxxxx"
3+
XRP_INSTANCE_TYPE="r7a.12xlarge"
4+
XRP_CPU_TYPE="x86_64" # All options: "x86_64". ARM currently not supported
5+
DATA_VOL_TYPE="gp3" # Other options: "io1" | "io2" | "gp3" | "instance-store" . IMPORTANT: Use "instance-store" option only with instance types that support that feature, like popular for node im4gn, d3, i3en, and i4i instance families
6+
DATA_VOL_SIZE="2000" # Current required data size to keep both smapshot archive and unarchived version of it
7+
DATA_VOL_IOPS="12000" # Max IOPS for EBS volumes (not applicable for "instance-store")
8+
DATA_VOL_THROUGHPUT="700"
9+
XRP_HA_ALB_HEALTHCHECK_GRACE_PERIOD_MIN="60"
10+
XRP_HA_NODES_HEARTBEAT_DELAY_MIN="5"
11+
XRP_HA_NUMBER_OF_NODES="2"
12+
HUB_NETWORK_ID="testnet"
13+

lib/xrp/tsconfig.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"module": "commonjs",
5+
"lib": [
6+
"es2020",
7+
"dom"
8+
],
9+
"declaration": true,
10+
"strict": true,
11+
"noImplicitAny": true,
12+
"strictNullChecks": true,
13+
"noImplicitThis": true,
14+
"alwaysStrict": true,
15+
"noUnusedLocals": false,
16+
"noUnusedParameters": false,
17+
"noImplicitReturns": true,
18+
"noFallthroughCasesInSwitch": false,
19+
"inlineSourceMap": true,
20+
"inlineSources": true,
21+
"experimentalDecorators": true,
22+
"strictPropertyInitialization": false,
23+
"typeRoots": [
24+
"../../node_modules/@types"
25+
]
26+
},
27+
"exclude": [
28+
"node_modules",
29+
"cdk.out"
30+
]
31+
}

0 commit comments

Comments
 (0)