Skip to content

Commit 0771b73

Browse files
committed
using amazon AMI
1 parent 71423d8 commit 0771b73

File tree

5 files changed

+27
-71
lines changed

5 files changed

+27
-71
lines changed

lib/allora/allora.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ new AlloraStack(app, 'allora-single-node', {
3535
account: process.env.AWS_ACCOUNT_ID || "xxxxxxxxxxx",
3636
region: process.env.AWS_REGION || 'us-east-1',
3737
},
38-
amiId: process.env.AWS_AMI_ID || 'ami-04b70fa74e45c3917',
39-
instanceType: process.env.AWS_INSTANCE_TYPE || 'ami-04b70fa74e45c3917',
38+
instanceType: process.env.AWS_INSTANCE_TYPE || 't3.medium',
4039
vpcMaxAzs: Number(process.env.AWS_VPC_MAX_AZS || 1),
4140
vpcNatGateways: Number(process.env.AWS_VPC_NAT_GATEWAYS || 0),
4241
vpcSubnetCidrMask: Number(process.env.AWS_VPC_CIDR_MASK),

lib/allora/lib/allora-stack.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ interface AlloraStackEnvironment extends cdk.Environment {
1818
}
1919

2020
export interface AlloraStackProps extends cdk.StackProps {
21-
amiId: string;
2221
instanceType: string;
2322
vpcMaxAzs: number;
2423
vpcNatGateways: number
@@ -34,7 +33,7 @@ export class AlloraStack extends cdk.Stack {
3433
super(scope, id, props);
3534

3635
const {
37-
env, amiId, instanceType, resourceNamePrefix, dataVolume
36+
env, instanceType, resourceNamePrefix, dataVolume
3837
} = props;
3938
const { region } = env;
4039

@@ -92,7 +91,11 @@ export class AlloraStack extends cdk.Stack {
9291
instanceName: `${resourceNamePrefix}Instance`,
9392
instanceType: new ec2.InstanceType(instanceType),
9493
dataVolumes: [ dataVolume ], // Define your data volumes here
95-
machineImage: ec2.MachineImage.genericLinux({ [region]: amiId }),
94+
machineImage:new ec2.AmazonLinuxImage({
95+
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
96+
kernel:ec2.AmazonLinuxKernel.KERNEL5_X,
97+
cpuType: ec2.AmazonLinuxCpuType.X86_64,
98+
}),
9699
role: instanceRole,
97100
vpc: vpc,
98101
rootDataVolumeDeviceName: '/dev/sda1',

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

Lines changed: 15 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -11,67 +11,21 @@ echo "STACK_ID=${_STACK_ID_}" >> /etc/environment
1111

1212
source /etc/environment
1313

14-
#############################
15-
# Prerequisites
16-
# Pip
17-
# Pipx
18-
# Go
19-
#############################
20-
21-
22-
23-
24-
# Update Ubuntu, answer yes to all prompts non-interactively
25-
echo "[user-data] Update Ubuntu package list"
26-
sudo add-apt-repository ppa:deadsnakes/ppa
27-
sudo apt-get update --yes
28-
29-
30-
# Install pip
31-
echo "[user-data] Pip"
32-
sudo apt-get install -y python3-pip
33-
34-
35-
# Install Pipx
36-
echo "[user-data] Install Pipx"
37-
sudo apt-get install pipx --yes
38-
pipx ensurepath
39-
40-
# Install Go
41-
echo "[user-data] Install Go"
42-
sudo apt-get install golang-go --yes
43-
44-
# Install ca-certificates, a certificate authority package for verifying third-party identities, and curl, a data transfer tool:
45-
echo "[user-data] Install ca-certificates"
46-
sudo apt-get install ca-certificates --yes
47-
48-
echo "[user-data] Install curl"
49-
sudo apt-get install curl --yes
50-
51-
# Set ownership permissions for the /etc/apt/keyrings directory:
52-
echo "[user-data] Set ownership perms for /etc/apt/keyrings"
53-
sudo install -m 0755 -d /etc/apt/keyrings
54-
55-
# Download the key with curl:
56-
echo "[user-data] Downloading key with curl"
57-
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
58-
59-
# Set read permissions for the key:
60-
echo "[user-data] set read permissions for key"
61-
sudo chmod a+r /etc/apt/keyrings/docker.asc
62-
63-
# install cfn
64-
65-
# install python 3.11
66-
sudo apt-get install python3.11 --yes
67-
68-
sudo apt-get install python3.11-venv
69-
sudo python3.11 -m venv env
70-
source env/bin/activate
71-
72-
sudo apt-get install heat-cfntools --yes
73-
74-
cfn-init --stack $STACK_NAME --resource $RESOURCE_ID --region $AWS_REGION --configsets setup
14+
echo "Updating and installing required system packages"
15+
yum update -y
16+
amazon-linux-extras install epel -y
17+
yum groupinstall "Development Tools" -y
18+
yum -y install amazon-cloudwatch-agent collectd jq gcc10-10.5.0-1.amzn2.0.2 ncurses-devel telnet aws-cfn-bootstrap
19+
20+
cd /opt
21+
22+
#install AWS CLI
23+
echo 'Installing AWS CLI v2'
24+
curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o "awscliv2.zip"
25+
unzip -q awscliv2.zip
26+
./aws/install
27+
rm /usr/bin/aws
28+
ln /usr/local/bin/aws /usr/bin/aws
7529

7630
cfn-signal -e $? --stack $STACK_NAME --resource $RESOURCE_ID --region $AWS_REGION
7731

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
AWS_ACCOUNT_ID="xxxxxxxxxxx"
22
AWS_RESOURCE_NAME_PREFIX="AlloraWorkerx"
33
AWS_REGION="us-east-1"
4-
AWS_AMI_ID="ami-04b70fa74e45c3917"
54
AWS_INSTANCE_TYPE="t3.medium"
65
AWS_VPC_MAX_AZS="1"
76
AWS_VPC_NAT_GATEWAYS="0"

lib/allora/test/allora.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ describe("AlloranodeStack", () => {
88
const app = new cdk.App();
99
const stack = new AlloraStack(app, 'TestStack', {
1010
env: { account: 'xxxxxxxxxxx', region: 'us-east-1' },
11-
amiId: 'ami-04b70fa74e45c3917',
12-
instanceType: 't2.medium',
11+
instanceType: 't3.medium',
1312
vpcMaxAzs: 1,
1413
vpcNatGateways: 0,
1514
vpcSubnetCidrMask: 24,
@@ -44,8 +43,10 @@ describe("AlloranodeStack", () => {
4443

4544
// Check for EC2 Instance
4645
template.hasResourceProperties('AWS::EC2::Instance', {
47-
InstanceType: 't2.medium',
48-
ImageId: 'ami-04b70fa74e45c3917',
46+
InstanceType: 't3.medium',
47+
ImageId: {
48+
"Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amikernel510hvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter"
49+
},
4950
BlockDeviceMappings: [
5051
{
5152
DeviceName: '/dev/sda1',

0 commit comments

Comments
 (0)