cloudmason 2.1.38 → 2.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,6 +27,7 @@ exports.main = async function(args){
27
27
  throw new Error('Version not found:' + pubArgs.version);
28
28
  }
29
29
  pubArgs.amiId = instanceVersion.baseAMI_Id;
30
+ const arch = instanceVersion.arch || 'x86_64';
30
31
  console.log('Publishing AMI:\n\t',Object.entries(pubArgs).map(([k,v])=>{return `${k}:${v}`}).join('\n\t'));
31
32
  console.log('----------')
32
33
 
@@ -88,10 +89,12 @@ const updateAmiVersion = async ({productId, amiId, version, changeDescription})
88
89
  "AccessRoleArn": "arn:aws:iam::590183947985:role/Theorim_MarketPlaceRole",
89
90
  "UserName": "ec2-user",
90
91
  "OperatingSystemName": "AMAZONLINUX",
91
- "OperatingSystemVersion": "Amazon Linux 2 AMI 2.0.20220207.1 x86_64 HVM gp2"
92
+ "OperatingSystemVersion": arch === 'arm'
93
+ ? "Amazon Linux 2023 arm64 HVM"
94
+ : "Amazon Linux 2 AMI 2.0.20220207.1 x86_64 HVM gp2"
92
95
  },
93
96
  "UsageInstructions": "Visit Theorim.ai/install for installation instructions",
94
- "RecommendedInstanceType": "m6a.large",
97
+ "RecommendedInstanceType": arch === 'arm' ? "r8g.medium" : "m6a.large",
95
98
  "SecurityGroups":
96
99
  [
97
100
  {
@@ -40,7 +40,7 @@ const SETUP_COMMANDS = [
40
40
 
41
41
 
42
42
  class EC2AMIBuilder {
43
- constructor(amiName, instanceType = 'm6a.large', localZipPath) {
43
+ constructor(amiName, instanceType = 'm6a.large', localZipPath, arch = 'x86_64') {
44
44
  if (!amiName || !localZipPath) {
45
45
  throw new Error('amiName and localZipPath are required parameters');
46
46
  }
@@ -48,6 +48,7 @@ class EC2AMIBuilder {
48
48
  this.amiName = amiName;
49
49
  this.instanceType = instanceType;
50
50
  this.localZipPath = localZipPath;
51
+ this.arch = arch;
51
52
 
52
53
  // AWS clients
53
54
  const region = process.env.orgRegion || process.env.AWS_REGION || 'us-east-1';
@@ -77,7 +78,7 @@ class EC2AMIBuilder {
77
78
  Filters: [
78
79
  {
79
80
  Name: 'name',
80
- Values: ['al2023-ami-*-x86_64']
81
+ Values: [this.arch === 'arm' ? 'al2023-ami-*-arm64' : 'al2023-ami-*-x86_64']
81
82
  },
82
83
  {
83
84
  Name: 'owner-alias',
@@ -586,8 +587,8 @@ class EC2AMIBuilder {
586
587
  }
587
588
  }
588
589
 
589
- async function sshAMI(amiName, localZipPath, instanceType){
590
- const builder = new EC2AMIBuilder(amiName, instanceType, localZipPath);
590
+ async function sshAMI(amiName, localZipPath, instanceType, arch){
591
+ const builder = new EC2AMIBuilder(amiName, instanceType, localZipPath, arch);
591
592
  const result = await builder.build();
592
593
  console.log('AMI ID:', result);
593
594
  return result;
@@ -50,12 +50,15 @@ exports.main = async function(args){
50
50
  const buildNumber = (app.versions[args.v]?.currentBuild || 0) + 1;
51
51
  const appVID = `${app.name.toLowerCase()}-v${args.v}.${buildNumber}`;
52
52
 
53
- console.log(`Building AMI: ${appVID}`);
53
+ const arch = args.arch || 'x86_64';
54
+ const buildInstanceType = arch === 'arm' ? 'r8g.medium' : 'm6a.large';
55
+
56
+ console.log(`Building AMI: ${appVID} (${arch}, ${buildInstanceType})`);
54
57
  console.log(`Using local zip: ${zipFilePath}`);
55
58
 
56
59
  let ami_id;
57
60
  try {
58
- ami_id = await buildAMI(appVID, zipFilePath);
61
+ ami_id = await buildAMI(appVID, zipFilePath, buildInstanceType, arch);
59
62
  } catch(e) {
60
63
  console.log("Error Creating AMI:" + e);
61
64
  throw new Error("Error - Build Not Complete");
@@ -68,7 +71,8 @@ exports.main = async function(args){
68
71
  stackURL: `https://s3.${process.env.orgRegion}.amazonaws.com/${process.env.orgBucket}/apps/${args.app.toLowerCase()}/${args.v}/stack.yaml`,
69
72
  baseAMI_Id: ami_id,
70
73
  currentBuild: buildNumber,
71
- updated: Date.now()
74
+ updated: Date.now(),
75
+ arch: arch
72
76
  }
73
77
  await Params.updateAppV(app.name,args.v,versionInfo);
74
78
 
package/main.js CHANGED
@@ -67,7 +67,8 @@ const Commands = {
67
67
  {n: 'app', desc: 'Name of existing app', pattern: `[A-Za-z]{2,20}`, r: true},
68
68
  {n: 'v', desc: 'Version to update', pattern: `[0-9]{1,20}`, r: true},
69
69
  {n: 'path', desc: 'Path to app zip file or folder', r: true},
70
- {n: 'stack', desc: 'Path to updated JSON or YML stack', r: false}
70
+ {n: 'stack', desc: 'Path to updated JSON or YML stack', r: false},
71
+ {n: 'arch', desc: 'CPU architecture: x86_64 (default) or arm', r: false, pattern: '^(x86_64|arm)$'}
71
72
  ]
72
73
  },
73
74
  'update-stack': {
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"cloudmason","version":"2.1.38","description":"","main":"main.js","scripts":{"build":"node build.js"},"bin":{"mason":"./main.js"},"repository":{"type":"git","url":"https://github.com/kai-harvey/cloudmason.git"},"author":"Kai Harvey","license":"ISC","dependencies":{"@aws-sdk/client-acm":"^3.418.0","@aws-sdk/client-auto-scaling":"^3.470.0","@aws-sdk/client-cloudformation":"^3.418.0","@aws-sdk/client-ec2":"^3.864.0","@aws-sdk/client-iam":"^3.864.0","@aws-sdk/client-marketplace-catalog":"^3.716.0","@aws-sdk/client-route-53":"^3.425.0","@aws-sdk/client-s3":"^3.418.0","@aws-sdk/client-ssm":"^3.421.0","adm-zip":"^0.5.10","ssh2":"^1.16.0","yaml":"^2.6.1"}}
1
+ {"name":"cloudmason","version":"2.1.39","description":"","main":"main.js","scripts":{"build":"node build.js"},"bin":{"mason":"./main.js"},"repository":{"type":"git","url":"https://github.com/kai-harvey/cloudmason.git"},"author":"Kai Harvey","license":"ISC","dependencies":{"@aws-sdk/client-acm":"^3.418.0","@aws-sdk/client-auto-scaling":"^3.470.0","@aws-sdk/client-cloudformation":"^3.418.0","@aws-sdk/client-ec2":"^3.864.0","@aws-sdk/client-iam":"^3.864.0","@aws-sdk/client-marketplace-catalog":"^3.716.0","@aws-sdk/client-route-53":"^3.425.0","@aws-sdk/client-s3":"^3.418.0","@aws-sdk/client-ssm":"^3.421.0","adm-zip":"^0.5.10","ssh2":"^1.16.0","yaml":"^2.6.1"}}