Skip to content

Commit e263525

Browse files
committed
adding allocmd generate command and parameterization
1 parent 85c2976 commit e263525

File tree

4 files changed

+57
-10
lines changed

4 files changed

+57
-10
lines changed

lib/allora/allora.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,9 @@ new AlloraStack(app, 'allora-single-node', {
4545
type: parseDataVolumeType(process.env.EDGE_DATA_VOL_TYPE?.toLowerCase() ? process.env.EDGE_DATA_VOL_TYPE?.toLowerCase() : "gp3"),
4646
iops: process.env.EDGE_DATA_VOL_IOPS ? parseInt(process.env.EDGE_DATA_VOL_IOPS) : 10000,
4747
throughput: process.env.EDGE_DATA_VOL_THROUGHPUT ? parseInt(process.env.EDGE_DATA_VOL_THROUGHPUT) : 700
48-
}
48+
},
49+
alloraWorkerName: process.env.ALLORA_WORKER_NAME || 'aws',
50+
alloraTopicId: process.env.ALLORA_TOPIC_ID || '3',
51+
alloraEnv: process.env.ALLORA_ENV || 'dev',
52+
alloraNetworkName: process.env.ALLORA_NETWORK_NAME || 'edgenet',
4953
});

lib/allora/lib/allora-stack.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export interface AlloraStackProps extends cdk.StackProps {
2525
resourceNamePrefix: string;
2626
dataVolume: configTypes.DataVolumeConfig;
2727
env: AlloraStackEnvironment
28+
alloraWorkerName: string;
29+
alloraTopicId: string;
30+
alloraEnv: string;
31+
alloraNetworkName: string;
2832
}
2933

3034

@@ -33,7 +37,14 @@ export class AlloraStack extends cdk.Stack {
3337
super(scope, id, props);
3438

3539
const {
36-
env, instanceType, resourceNamePrefix, dataVolume
40+
env,
41+
instanceType,
42+
resourceNamePrefix,
43+
dataVolume,
44+
alloraWorkerName,
45+
alloraTopicId,
46+
alloraEnv,
47+
alloraNetworkName
3748
} = props;
3849
const { region } = env;
3950

@@ -92,7 +103,7 @@ export class AlloraStack extends cdk.Stack {
92103
instanceType: new ec2.InstanceType(instanceType),
93104
dataVolumes: [ dataVolume ], // Define your data volumes here
94105
machineImage:new ec2.AmazonLinuxImage({
95-
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
106+
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2023,
96107
kernel:ec2.AmazonLinuxKernel.KERNEL5_X,
97108
cpuType: ec2.AmazonLinuxCpuType.X86_64,
98109
}),
@@ -117,6 +128,10 @@ export class AlloraStack extends cdk.Stack {
117128
_NODE_CF_LOGICAL_ID_: singleNode.nodeCFLogicalId,
118129
_STACK_NAME_: STACK_NAME,
119130
_STACK_ID_: STACK_ID,
131+
_ALLORA_WORKER_NAME_: alloraWorkerName,
132+
_ALLORA_TOPIC_ID_: alloraTopicId,
133+
_ALLORA_ENV_: alloraEnv,
134+
_ALLORA_NETWORK_NAME_ : alloraNetworkName
120135
});
121136

122137
// Create UserData for EC2 instance

lib/allora/lib/assets/user-data/node.sh

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,41 @@ echo "ASSETS_S3_PATH=${_ASSETS_S3_PATH_}" >> /etc/environment
88
echo "RESOURCE_ID=${_NODE_CF_LOGICAL_ID_}" >> /etc/environment
99
echo "STACK_NAME=${_STACK_NAME_}" >> /etc/environment
1010
echo "STACK_ID=${_STACK_ID_}" >> /etc/environment
11+
echo "ALLORA_WORKER_NAME=${_ALLORA_WORKER_NAME_}" >> /etc/environment
12+
echo "ALLORA_TOPIC_ID=${_ALLORA_TOPIC_ID_}" >> /etc/environment
13+
echo "ALLORA_ENV=${_ALLORA_ENV_}" >> /etc/environment
14+
echo "ALLORA_NETWORK_NAME=${_ALLORA_NETWORK_NAME_}" >> /etc/environment
1115

1216
source /etc/environment
1317

1418
echo "Updating and installing required system packages"
15-
yum update -y
19+
sudo yum update -y
1620
amazon-linux-extras install epel -y
17-
yum groupinstall "Development Tools" -y
18-
yum -y install python3-pip amazon-cloudwatch-agent collectd jq gcc10-10.5.0-1.amzn2.0.2 ncurses-devel telnet aws-cfn-bootstrap
19-
20-
cd /opt
21+
sudo yum groupinstall "Development Tools" -y
22+
sudo yum -y install python3-pip amazon-cloudwatch-agent collectd jq gcc10-10.5.0-1.amzn2.0.2 ncurses-devel telnet aws-cfn-bootstrap
2123

2224
#install Allora CLI tool with pip
23-
pip3 install allocmd --upgrade
25+
sudo pip3 install allocmd --upgrade
26+
27+
# Install Git
28+
sudo yum install git -y
29+
30+
# Install docker
31+
sudo yum install docker -y
32+
33+
# Add the current user to the docker permissions group
34+
sudo usermod -aG docker ec2-user
35+
36+
# Enable docker service at AMI boot time
37+
sudo systemctl enable docker.service
38+
39+
# Start the docker service
40+
sudo systemctl start docker.service
41+
42+
# Install docker-compose
43+
sudo pip3 install docker-compose
44+
45+
allocmd generate worker --name $ALLORA_WORKER_NAME --topic $ALLORA_TOPIC_ID --env $ALLORA_ENV --network $ALLORA_NETWORK_NAME
2446

2547
#install AWS CLI
2648
echo 'Installing AWS CLI v2'

lib/allora/sample-configs/.env-sample-full

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,10 @@ AWS_VPC_CIDR_MASK="24"
1010
EDGE_DATA_VOL_TYPE="gp3" # Other options: "io1" | "io2" | "gp3" | "instance-store" . IMPORTANT: "instance-store" NOT recommended as it is ephermal and will be reset after stopping the instance. Use "instance-store" option only with instance types that support that feature, like popular for node g4dn, d3, i3en, and i4i instance families
1111
EDGE_DATA_VOL_SIZE="256" # Current required data size to keep both snapshot archive and unarchived version of it (not applicable for "instance-store")
1212
EDGE_DATA_VOL_IOPS="3000" # Max IOPS for EBS volumes (not applicable for "instance-store")
13-
EDGE_DATA_VOL_THROUGHPUT="125" # Max throughput for EBS gp3 volumes (not applicable for "io1" | "io2" | "instance-store")
13+
EDGE_DATA_VOL_THROUGHPUT="125" # Max throughput for EBS gp3 volumes (not applicable for "io1" | "io2" | "instance-store")
14+
15+
#Allora Node Worker Generation Config
16+
ALLORA_WORKER_NAME="aws"
17+
ALLORA_TOPIC_ID="3"
18+
ALLORA_ENV="dev"
19+
ALLORA_NETWORK_NAME="edgenet"

0 commit comments

Comments
 (0)