Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solana #11

Merged
merged 13 commits into from
Oct 26, 2023
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ data-volume-snpashot*.json
sync-node-deploy*.json
instance-image*.json
rpc-node-deploy*.json
single-node-deploy*.json
ha-nodes-deploy*.json

*.OLD
.env
63 changes: 31 additions & 32 deletions docs/setup-cloud9.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AWS Cloud9 Setup

Most steps in this repository will need to be performed from a Linux command prompt. An especially convenient way of doing this is to use AWS Cloud9, a cloud-based Integrated Development Environment (IDE). Cloud9 allows you to edit source files and execute commands from an easy-to-use web interface. It comes preconfigured with many of the tools needed for software development, and because it runs in the AWS Cloud, it can be an especially easy way to access other cloud services. One other handy feature is that your Cloud9 instances automatically stop running after a configurable period of inactivity, which helps reduce costs.
Most steps in this repository will need to be performed from a Linux command prompt. An especially convenient way of doing this is to use AWS Cloud9, a cloud-based Integrated Development Environment (IDE). Cloud9 allows you to edit source files and execute commands from an easy-to-use web interface. It comes pre-configured with many of the tools needed for software development, and because it runs in the AWS Cloud, it can be an especially easy way to access other cloud services. One other handy feature is that your Cloud9 instances automatically stop running after a configurable period of inactivity, which helps reduce costs.

## Create a Cloud9 environment

Expand All @@ -14,10 +14,10 @@ Create an instance profile called **Cloud9-Developer-Access**

1. Create role policy definition file

```bash
cat <<EOF > ec2-trust-policy.json
```bash
cat > ec2-trust-policy.json <<EOF
{
"Version": "2012-10-17",
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
Expand All @@ -28,38 +28,38 @@ Create an instance profile called **Cloud9-Developer-Access**
}
]
}
EOF
```
EOF
```

2. Create new IAM role called "Cloud9-Developer-Access" and assign the new role policy

```bash
aws iam create-role \
--role-name Cloud9-Developer-Access \
--assume-role-policy-document file://ec2-trust-policy.json
```
```bash
aws iam create-role \
--role-name Cloud9-Developer-Access \
--assume-role-policy-document file://ec2-trust-policy.json
```

3. Attach AWS Managed policy with AdministratorAccess to the new role

```bash
aws iam attach-role-policy \
--role-name Cloud9-Developer-Access \
--policy-arn arn:aws:iam::aws:policy/AdministratorAccess
```
```bash
aws iam attach-role-policy \
--role-name Cloud9-Developer-Access \
--policy-arn arn:aws:iam::aws:policy/AdministratorAccess
```

4. Create EC2 instance profile

```bash
aws iam create-instance-profile --instance-profile-name Cloud9-Developer-Access
```
```bash
aws iam create-instance-profile --instance-profile-name Cloud9-Developer-Access
```

5. Add the new role to the instance profile

```bash
aws iam add-role-to-instance-profile \
--instance-profile-name Cloud9-Developer-Access \
--role-name Cloud9-Developer-Access
```
```bash
aws iam add-role-to-instance-profile \
--instance-profile-name Cloud9-Developer-Access \
--role-name Cloud9-Developer-Access
```

## Modify Cloud9 IAM role

Expand Down Expand Up @@ -90,15 +90,14 @@ aws configure set default.region us-east-2
Install NodeJS v18 and set as the default version

```bash
nvm install 18
nvm use 18
nvm alias default 18
nvm install 16
nvm use 16
nvm alias default 16
```

The AWS CDK includes the CDK Toolkit (also called the CLI), a command line tool for working with your AWS CDK apps and stacks. Install the CDK toolkit

```bash

npm install -g aws-cdk
cdk --version
```
Expand All @@ -125,7 +124,7 @@ cdk bootstrap aws://<INSERT_YOUR_AWS_ACCOUNT_NUMBER>/<INSERT_YOUR_AWS_REGION>

2. Delete the instance profile and IAM role

```bash
aws iam delete-instance-profile --instance-profile-name Cloud9-Developer-Access
aws iam delete-role --role-name Cloud9-Developer-Access
```
```bash
aws iam delete-instance-profile --instance-profile-name Cloud9-Developer-Access
aws iam delete-role --role-name Cloud9-Developer-Access
```
2 changes: 1 addition & 1 deletion lib/constructs/config.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface DataVolumeConfig {
throughput: number;
}

interface BaseNodeConfig {
export interface BaseNodeConfig {
instanceType: ec2.InstanceType;
instanceCpuType: ec2.AmazonLinuxCpuType;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/constructs/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const InstanceStoreageDeviceVolumeType = "instance-store";
export const NoneValue = "none";
export const VolumeDeviceNames = ["/dev/sdf", "/dev/sdg", "/dev/sdh", "/dev/sdi", "/dev/sdj", "/dev/sdk"]
export const VolumeDeviceNames = ["/dev/sdf", "/dev/sdg", "/dev/sdh", "/dev/sdi", "/dev/sdj", "/dev/sdk"]
export const GibibytesToBytesConversionCoefficient = 1073741824;
9 changes: 7 additions & 2 deletions lib/constructs/ha-rpc-nodes-with-alb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import * as albv2 from "aws-cdk-lib/aws-elasticloadbalancingv2";
import * as configTypes from "./config.interface";
import * as constants from "./constants";
import * as nag from "cdk-nag";
import { HealthCheck } from "aws-cdk-lib/aws-appmesh";

export interface HANodesConstructCustomProps {
instanceType: ec2.InstanceType,
dataVolumes: configTypes.DataVolumeConfig[],
rootDataVolumeDeviceName?: string,
machineImage: cdk.aws_ec2.IMachineImage,
role: cdk.aws_iam.IRole,
vpc: cdk.aws_ec2.IVpc,
Expand All @@ -19,6 +21,7 @@ export interface HANodesConstructCustomProps {
numberOfNodes: number;
rpcPortForALB: number,
albHealthCheckGracePeriodMin: number;
healthCheckPath? : string;
heartBeatDelayMin: number;
lifecycleHookName: string;
autoScalingGroupName: string;
Expand All @@ -35,6 +38,7 @@ export class HANodesConstruct extends cdkContructs.Construct {
const {
instanceType,
dataVolumes,
rootDataVolumeDeviceName,
machineImage,
role,
vpc,
Expand All @@ -43,6 +47,7 @@ export class HANodesConstruct extends cdkContructs.Construct {
numberOfNodes,
rpcPortForALB,
albHealthCheckGracePeriodMin,
healthCheckPath,
heartBeatDelayMin,
lifecycleHookName,
autoScalingGroupName,
Expand All @@ -51,7 +56,7 @@ export class HANodesConstruct extends cdkContructs.Construct {
let blockDevices: ec2.BlockDevice[] = [
{
// ROOT VOLUME
deviceName: "/dev/xvda",
deviceName: rootDataVolumeDeviceName ? rootDataVolumeDeviceName : "/dev/xvda",
volume: autoscaling.BlockDeviceVolume.ebs(46, {
deleteOnTermination: true,
throughput: 125,
Expand Down Expand Up @@ -172,7 +177,7 @@ export class HANodesConstruct extends cdkContructs.Construct {
healthCheck: {
enabled: true,
healthyHttpCodes: "200-299",
path: "/",
path: healthCheckPath ? healthCheckPath : "/",
// In the future, can create a separate service to have a more reliable health check
port: rpcPortForALB.toString(),
unhealthyThresholdCount: 2,
Expand Down
4 changes: 3 additions & 1 deletion lib/constructs/single-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface SingleNodeConstructCustomProps {
instanceName: string,
instanceType: ec2.InstanceType,
dataVolumes: configTypes.DataVolumeConfig[],
rootDataVolumeDeviceName?: string,
machineImage: cdk.aws_ec2.IMachineImage,
role: cdk.aws_iam.IRole,
vpc: cdk.aws_ec2.IVpc,
Expand All @@ -28,6 +29,7 @@ export class SingleNodeConstruct extends cdkContructs.Construct {
instanceName,
instanceType,
dataVolumes,
rootDataVolumeDeviceName,
machineImage,
role,
vpc,
Expand All @@ -45,7 +47,7 @@ export class SingleNodeConstruct extends cdkContructs.Construct {
blockDevices: [
{
// ROOT VOLUME
deviceName: "/dev/xvda",
deviceName: rootDataVolumeDeviceName ? rootDataVolumeDeviceName :"/dev/xvda",
volume: ec2.BlockDeviceVolume.ebs(46, {
deleteOnTermination: true,
encrypted: true,
Expand Down
15 changes: 0 additions & 15 deletions lib/ethereum/lib/assets/cw-agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,6 @@
"metrics_collection_interval": 60,
"run_as_user": "root"
},
"logs": {
"logs_collected": {
"files": {
"collect_list": [{
"file_path": "/var/log/cloud-init-output.log",
"log_group_name": "cloud-init-output.log",
"log_stream_name": "{instance_id}"
}, {
"file_path": "/var/log/initial-sync.log",
"log_group_name": "initial-sync.log",
"log_stream_name": "{instance_id}"
}]
}
}
},
"metrics": {
"aggregation_dimensions": [
[
Expand Down
Loading
Loading