@fjall/generator 0.88.4
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.
- package/dist/src/ast/astComputeParser.d.ts +4 -0
- package/dist/src/ast/astComputeParser.js +427 -0
- package/dist/src/ast/astInfrastructureParser.d.ts +357 -0
- package/dist/src/ast/astInfrastructureParser.js +1925 -0
- package/dist/src/ast/astSurgicalModification.d.ts +47 -0
- package/dist/src/ast/astSurgicalModification.js +400 -0
- package/dist/src/ast/index.d.ts +2 -0
- package/dist/src/ast/index.js +2 -0
- package/dist/src/aws/regions.d.ts +30 -0
- package/dist/src/aws/regions.js +254 -0
- package/dist/src/generation/common.d.ts +86 -0
- package/dist/src/generation/common.js +187 -0
- package/dist/src/generation/compute.d.ts +6 -0
- package/dist/src/generation/compute.js +547 -0
- package/dist/src/generation/database.d.ts +54 -0
- package/dist/src/generation/database.js +201 -0
- package/dist/src/generation/index.d.ts +12 -0
- package/dist/src/generation/index.js +18 -0
- package/dist/src/generation/infrastructure.d.ts +44 -0
- package/dist/src/generation/infrastructure.js +389 -0
- package/dist/src/generation/storage.d.ts +23 -0
- package/dist/src/generation/storage.js +174 -0
- package/dist/src/generation/storageConnections.d.ts +37 -0
- package/dist/src/generation/storageConnections.js +71 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.js +19 -0
- package/dist/src/planning/index.d.ts +1 -0
- package/dist/src/planning/index.js +1 -0
- package/dist/src/planning/resourcePlanning.d.ts +58 -0
- package/dist/src/planning/resourcePlanning.js +216 -0
- package/dist/src/presets/index.d.ts +3 -0
- package/dist/src/presets/index.js +3 -0
- package/dist/src/presets/patternTierPresets.d.ts +93 -0
- package/dist/src/presets/patternTierPresets.js +131 -0
- package/dist/src/presets/storagePresets.d.ts +11 -0
- package/dist/src/presets/storagePresets.js +36 -0
- package/dist/src/presets/tierPresets.d.ts +59 -0
- package/dist/src/presets/tierPresets.js +384 -0
- package/dist/src/presets/tierTypes.d.ts +301 -0
- package/dist/src/presets/tierTypes.js +7 -0
- package/dist/src/schemas/constants.d.ts +74 -0
- package/dist/src/schemas/constants.js +208 -0
- package/dist/src/schemas/index.d.ts +3 -0
- package/dist/src/schemas/index.js +3 -0
- package/dist/src/schemas/instanceTypeArchitecture.d.ts +35 -0
- package/dist/src/schemas/instanceTypeArchitecture.js +75 -0
- package/dist/src/schemas/resourceSchemas.d.ts +3534 -0
- package/dist/src/schemas/resourceSchemas.js +2015 -0
- package/dist/src/types/Result.d.ts +19 -0
- package/dist/src/types/Result.js +31 -0
- package/dist/src/util/errorUtils.d.ts +2 -0
- package/dist/src/util/errorUtils.js +15 -0
- package/dist/src/validation/patterns.d.ts +300 -0
- package/dist/src/validation/patterns.js +360 -0
- package/dist/src/version.d.ts +1 -0
- package/dist/src/version.js +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared constants for Fjall CLI generators
|
|
3
|
+
* These defaults are designed to draw attention when not properly configured
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULTS: Readonly<{
|
|
6
|
+
RESOURCE_SUFFIXES: {
|
|
7
|
+
storage: string;
|
|
8
|
+
database: string;
|
|
9
|
+
cluster: string;
|
|
10
|
+
function: string;
|
|
11
|
+
instance: string;
|
|
12
|
+
compute: string;
|
|
13
|
+
};
|
|
14
|
+
}>;
|
|
15
|
+
export declare const DATABASE_TYPES: readonly ["Aurora", "Instance", "GlobalAurora"];
|
|
16
|
+
export type DatabaseType = (typeof DATABASE_TYPES)[number];
|
|
17
|
+
export declare const COMPUTE_TYPES: readonly ["ecs", "lambda", "ec2"];
|
|
18
|
+
export type ComputeType = (typeof COMPUTE_TYPES)[number];
|
|
19
|
+
export declare const COMPUTE_TYPE: Readonly<{
|
|
20
|
+
readonly ECS: "ecs";
|
|
21
|
+
readonly LAMBDA: "lambda";
|
|
22
|
+
readonly EC2: "ec2";
|
|
23
|
+
}>;
|
|
24
|
+
export declare const DEPLOYMENT_TYPES: readonly ["code", "container"];
|
|
25
|
+
export type DeploymentType = (typeof DEPLOYMENT_TYPES)[number];
|
|
26
|
+
export declare const DEPLOYMENT_TYPE: Readonly<{
|
|
27
|
+
readonly CODE: "code";
|
|
28
|
+
readonly CONTAINER: "container";
|
|
29
|
+
}>;
|
|
30
|
+
export declare const COMPUTE_ARCHITECTURES: readonly ["ARM_64", "X86_64"];
|
|
31
|
+
export type ComputeArchitecture = (typeof COMPUTE_ARCHITECTURES)[number];
|
|
32
|
+
export declare const DEFAULT_COMPUTE_ARCHITECTURE: ComputeArchitecture;
|
|
33
|
+
export declare const ECS_CAPACITY_PROVIDERS: readonly ["FARGATE", "FARGATE_SPOT", "EC2"];
|
|
34
|
+
export type EcsCapacityProvider = (typeof ECS_CAPACITY_PROVIDERS)[number];
|
|
35
|
+
export declare const DEFAULT_CAPACITY_PROVIDER: EcsCapacityProvider;
|
|
36
|
+
/**
|
|
37
|
+
* OpenNext deployment patterns.
|
|
38
|
+
* - payload: Payload CMS (always has database + migrations)
|
|
39
|
+
* - nextjs: Pure Next.js (optional database)
|
|
40
|
+
*/
|
|
41
|
+
export declare const PATTERN_TYPE_VALUES: readonly ["payload", "nextjs"];
|
|
42
|
+
export type PatternType = (typeof PATTERN_TYPE_VALUES)[number];
|
|
43
|
+
export declare const PATTERN_TYPES: ReadonlySet<string>;
|
|
44
|
+
export { APP_TYPES, CUSTOM_TIER, type AppType, } from "../presets/tierPresets.js";
|
|
45
|
+
export declare const EC2_INSTANCE_TYPES: readonly ["t3.nano", "t3.micro", "t3.small", "t3.medium", "t3.large", "t3.xlarge", "t3.2xlarge", "t3a.nano", "t3a.micro", "t3a.small", "t3a.medium", "t3a.large", "t3a.xlarge", "t3a.2xlarge", "t4g.nano", "t4g.micro", "t4g.small", "t4g.medium", "t4g.large", "t4g.xlarge", "t4g.2xlarge", "c5.large", "c5.xlarge", "c5.2xlarge", "c5.4xlarge", "c5.9xlarge", "c5.12xlarge", "c5.18xlarge", "c5.24xlarge", "c5a.large", "c5a.xlarge", "c5a.2xlarge", "c5a.4xlarge", "c5a.8xlarge", "c5a.12xlarge", "c5a.16xlarge", "c5a.24xlarge", "c6g.medium", "c6g.large", "c6g.xlarge", "c6g.2xlarge", "c6g.4xlarge", "c6g.8xlarge", "c6g.12xlarge", "c6g.16xlarge", "r5.large", "r5.xlarge", "r5.2xlarge", "r5.4xlarge", "r5.8xlarge", "r5.12xlarge", "r5.16xlarge", "r5.24xlarge", "r5a.large", "r5a.xlarge", "r5a.2xlarge", "r5a.4xlarge", "r5a.8xlarge", "r5a.12xlarge", "r5a.16xlarge", "r5a.24xlarge", "r6g.medium", "r6g.large", "r6g.xlarge", "r6g.2xlarge", "r6g.4xlarge", "r6g.8xlarge", "r6g.12xlarge", "r6g.16xlarge", "i3.large", "i3.xlarge", "i3.2xlarge", "i3.4xlarge", "i3.8xlarge", "i3.16xlarge", "p3.2xlarge", "p3.8xlarge", "p3.16xlarge", "g4dn.xlarge", "g4dn.2xlarge", "g4dn.4xlarge", "g4dn.8xlarge", "g4dn.12xlarge", "g4dn.16xlarge", "m5.large", "m5.xlarge", "m5.2xlarge", "m5.4xlarge", "m5.8xlarge", "m5.12xlarge", "m5.16xlarge", "m5.24xlarge", "m5a.large", "m5a.xlarge", "m5a.2xlarge", "m5a.4xlarge", "m5a.8xlarge", "m5a.12xlarge", "m5a.16xlarge", "m5a.24xlarge"];
|
|
46
|
+
export type EC2InstanceType = (typeof EC2_INSTANCE_TYPES)[number];
|
|
47
|
+
export declare const VALID_MONITORING_INTERVALS: readonly [0, 1, 5, 10, 15, 30, 60];
|
|
48
|
+
/** Includes check for `as const` arrays (centralises the widening cast) */
|
|
49
|
+
export declare function constIncludes<T extends ReadonlyArray<string | number>>(arr: T, value: string | number): boolean;
|
|
50
|
+
export declare const MIN_PORT = 1;
|
|
51
|
+
export declare const MAX_PORT = 65535;
|
|
52
|
+
/**
|
|
53
|
+
* Default database port: 35255 (FJALL on phone keypad)
|
|
54
|
+
* Used when no explicit port is specified in tier presets or configuration.
|
|
55
|
+
*/
|
|
56
|
+
export declare const DEFAULT_DATABASE_PORT = 35255;
|
|
57
|
+
export declare const MIN_LAMBDA_MEMORY = 128;
|
|
58
|
+
export declare const MAX_LAMBDA_MEMORY = 10240;
|
|
59
|
+
export declare const MIN_LAMBDA_TIMEOUT = 1;
|
|
60
|
+
export declare const MAX_LAMBDA_TIMEOUT = 900;
|
|
61
|
+
export declare const MIN_ECS_CAPACITY = 1;
|
|
62
|
+
export declare const MAX_ECS_CAPACITY = 1000;
|
|
63
|
+
export declare const DEFAULT_CONTAINER_PORT = 3000;
|
|
64
|
+
export declare const DEFAULT_EC2_INSTANCE_TYPE: "t4g.micro";
|
|
65
|
+
/** AWS Secrets Manager recommended rotation interval (days) */
|
|
66
|
+
export declare const DEFAULT_SECRET_ROTATION_DAYS = 30;
|
|
67
|
+
export declare const HTTP_METHODS: readonly ["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "PATCH"];
|
|
68
|
+
export type HttpMethod = (typeof HTTP_METHODS)[number];
|
|
69
|
+
export declare const STORAGE_PRESET_TYPES: readonly ["standard", "assets", "upload", "website"];
|
|
70
|
+
export type StoragePresetType = (typeof STORAGE_PRESET_TYPES)[number];
|
|
71
|
+
export declare const S3_ENCRYPTION_TYPES: readonly ["AES256", "KMS"];
|
|
72
|
+
export type S3EncryptionType = (typeof S3_ENCRYPTION_TYPES)[number];
|
|
73
|
+
export declare const BACKUP_VAULT_TIERS: readonly ["standard", "resilient", "enterprise"];
|
|
74
|
+
export type BackupVaultTier = (typeof BACKUP_VAULT_TIERS)[number];
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared constants for Fjall CLI generators
|
|
3
|
+
* These defaults are designed to draw attention when not properly configured
|
|
4
|
+
*/
|
|
5
|
+
export const DEFAULTS = Object.freeze({
|
|
6
|
+
// Resource naming conventions
|
|
7
|
+
RESOURCE_SUFFIXES: {
|
|
8
|
+
storage: "Storage",
|
|
9
|
+
database: "Database",
|
|
10
|
+
cluster: "Cluster",
|
|
11
|
+
function: "Function",
|
|
12
|
+
instance: "Instance",
|
|
13
|
+
compute: "Compute",
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
// Resource type constants for validation
|
|
17
|
+
export const DATABASE_TYPES = ["Aurora", "Instance", "GlobalAurora"];
|
|
18
|
+
export const COMPUTE_TYPES = ["ecs", "lambda", "ec2"];
|
|
19
|
+
// Object form for cleaner comparisons: COMPUTE_TYPE.ECS, COMPUTE_TYPE.LAMBDA, etc.
|
|
20
|
+
export const COMPUTE_TYPE = Object.freeze({
|
|
21
|
+
ECS: "ecs",
|
|
22
|
+
LAMBDA: "lambda",
|
|
23
|
+
EC2: "ec2",
|
|
24
|
+
});
|
|
25
|
+
// Deployment types for Lambda compute resources
|
|
26
|
+
export const DEPLOYMENT_TYPES = ["code", "container"];
|
|
27
|
+
export const DEPLOYMENT_TYPE = Object.freeze({
|
|
28
|
+
CODE: "code",
|
|
29
|
+
CONTAINER: "container",
|
|
30
|
+
});
|
|
31
|
+
export const COMPUTE_ARCHITECTURES = ["ARM_64", "X86_64"];
|
|
32
|
+
export const DEFAULT_COMPUTE_ARCHITECTURE = "ARM_64";
|
|
33
|
+
export const ECS_CAPACITY_PROVIDERS = [
|
|
34
|
+
"FARGATE",
|
|
35
|
+
"FARGATE_SPOT",
|
|
36
|
+
"EC2",
|
|
37
|
+
];
|
|
38
|
+
export const DEFAULT_CAPACITY_PROVIDER = "FARGATE";
|
|
39
|
+
/**
|
|
40
|
+
* OpenNext deployment patterns.
|
|
41
|
+
* - payload: Payload CMS (always has database + migrations)
|
|
42
|
+
* - nextjs: Pure Next.js (optional database)
|
|
43
|
+
*/
|
|
44
|
+
export const PATTERN_TYPE_VALUES = ["payload", "nextjs"];
|
|
45
|
+
export const PATTERN_TYPES = new Set(PATTERN_TYPE_VALUES);
|
|
46
|
+
export { APP_TYPES, CUSTOM_TIER, } from "../presets/tierPresets.js";
|
|
47
|
+
// Common EC2 instance types (not exhaustive, but covers common cases)
|
|
48
|
+
export const EC2_INSTANCE_TYPES = [
|
|
49
|
+
// General purpose
|
|
50
|
+
"t3.nano",
|
|
51
|
+
"t3.micro",
|
|
52
|
+
"t3.small",
|
|
53
|
+
"t3.medium",
|
|
54
|
+
"t3.large",
|
|
55
|
+
"t3.xlarge",
|
|
56
|
+
"t3.2xlarge",
|
|
57
|
+
"t3a.nano",
|
|
58
|
+
"t3a.micro",
|
|
59
|
+
"t3a.small",
|
|
60
|
+
"t3a.medium",
|
|
61
|
+
"t3a.large",
|
|
62
|
+
"t3a.xlarge",
|
|
63
|
+
"t3a.2xlarge",
|
|
64
|
+
"t4g.nano",
|
|
65
|
+
"t4g.micro",
|
|
66
|
+
"t4g.small",
|
|
67
|
+
"t4g.medium",
|
|
68
|
+
"t4g.large",
|
|
69
|
+
"t4g.xlarge",
|
|
70
|
+
"t4g.2xlarge",
|
|
71
|
+
// Compute optimised
|
|
72
|
+
"c5.large",
|
|
73
|
+
"c5.xlarge",
|
|
74
|
+
"c5.2xlarge",
|
|
75
|
+
"c5.4xlarge",
|
|
76
|
+
"c5.9xlarge",
|
|
77
|
+
"c5.12xlarge",
|
|
78
|
+
"c5.18xlarge",
|
|
79
|
+
"c5.24xlarge",
|
|
80
|
+
"c5a.large",
|
|
81
|
+
"c5a.xlarge",
|
|
82
|
+
"c5a.2xlarge",
|
|
83
|
+
"c5a.4xlarge",
|
|
84
|
+
"c5a.8xlarge",
|
|
85
|
+
"c5a.12xlarge",
|
|
86
|
+
"c5a.16xlarge",
|
|
87
|
+
"c5a.24xlarge",
|
|
88
|
+
"c6g.medium",
|
|
89
|
+
"c6g.large",
|
|
90
|
+
"c6g.xlarge",
|
|
91
|
+
"c6g.2xlarge",
|
|
92
|
+
"c6g.4xlarge",
|
|
93
|
+
"c6g.8xlarge",
|
|
94
|
+
"c6g.12xlarge",
|
|
95
|
+
"c6g.16xlarge",
|
|
96
|
+
// Memory optimised
|
|
97
|
+
"r5.large",
|
|
98
|
+
"r5.xlarge",
|
|
99
|
+
"r5.2xlarge",
|
|
100
|
+
"r5.4xlarge",
|
|
101
|
+
"r5.8xlarge",
|
|
102
|
+
"r5.12xlarge",
|
|
103
|
+
"r5.16xlarge",
|
|
104
|
+
"r5.24xlarge",
|
|
105
|
+
"r5a.large",
|
|
106
|
+
"r5a.xlarge",
|
|
107
|
+
"r5a.2xlarge",
|
|
108
|
+
"r5a.4xlarge",
|
|
109
|
+
"r5a.8xlarge",
|
|
110
|
+
"r5a.12xlarge",
|
|
111
|
+
"r5a.16xlarge",
|
|
112
|
+
"r5a.24xlarge",
|
|
113
|
+
"r6g.medium",
|
|
114
|
+
"r6g.large",
|
|
115
|
+
"r6g.xlarge",
|
|
116
|
+
"r6g.2xlarge",
|
|
117
|
+
"r6g.4xlarge",
|
|
118
|
+
"r6g.8xlarge",
|
|
119
|
+
"r6g.12xlarge",
|
|
120
|
+
"r6g.16xlarge",
|
|
121
|
+
// Storage optimised
|
|
122
|
+
"i3.large",
|
|
123
|
+
"i3.xlarge",
|
|
124
|
+
"i3.2xlarge",
|
|
125
|
+
"i3.4xlarge",
|
|
126
|
+
"i3.8xlarge",
|
|
127
|
+
"i3.16xlarge",
|
|
128
|
+
// Accelerated computing
|
|
129
|
+
"p3.2xlarge",
|
|
130
|
+
"p3.8xlarge",
|
|
131
|
+
"p3.16xlarge",
|
|
132
|
+
"g4dn.xlarge",
|
|
133
|
+
"g4dn.2xlarge",
|
|
134
|
+
"g4dn.4xlarge",
|
|
135
|
+
"g4dn.8xlarge",
|
|
136
|
+
"g4dn.12xlarge",
|
|
137
|
+
"g4dn.16xlarge",
|
|
138
|
+
// Previous generation (still common)
|
|
139
|
+
"m5.large",
|
|
140
|
+
"m5.xlarge",
|
|
141
|
+
"m5.2xlarge",
|
|
142
|
+
"m5.4xlarge",
|
|
143
|
+
"m5.8xlarge",
|
|
144
|
+
"m5.12xlarge",
|
|
145
|
+
"m5.16xlarge",
|
|
146
|
+
"m5.24xlarge",
|
|
147
|
+
"m5a.large",
|
|
148
|
+
"m5a.xlarge",
|
|
149
|
+
"m5a.2xlarge",
|
|
150
|
+
"m5a.4xlarge",
|
|
151
|
+
"m5a.8xlarge",
|
|
152
|
+
"m5a.12xlarge",
|
|
153
|
+
"m5a.16xlarge",
|
|
154
|
+
"m5a.24xlarge",
|
|
155
|
+
];
|
|
156
|
+
// Valid monitoring intervals for enhanced monitoring (in seconds)
|
|
157
|
+
export const VALID_MONITORING_INTERVALS = [0, 1, 5, 10, 15, 30, 60];
|
|
158
|
+
/** Includes check for `as const` arrays (centralises the widening cast) */
|
|
159
|
+
export function constIncludes(arr, value) {
|
|
160
|
+
return arr.includes(value);
|
|
161
|
+
}
|
|
162
|
+
// Port constraints
|
|
163
|
+
export const MIN_PORT = 1;
|
|
164
|
+
export const MAX_PORT = 65535;
|
|
165
|
+
/**
|
|
166
|
+
* Default database port: 35255 (FJALL on phone keypad)
|
|
167
|
+
* Used when no explicit port is specified in tier presets or configuration.
|
|
168
|
+
*/
|
|
169
|
+
export const DEFAULT_DATABASE_PORT = 35255;
|
|
170
|
+
// Lambda constraints — AWS service hard limits
|
|
171
|
+
export const MIN_LAMBDA_MEMORY = 128;
|
|
172
|
+
export const MAX_LAMBDA_MEMORY = 10240;
|
|
173
|
+
export const MIN_LAMBDA_TIMEOUT = 1;
|
|
174
|
+
export const MAX_LAMBDA_TIMEOUT = 900;
|
|
175
|
+
// ECS constraints — AWS service hard limits
|
|
176
|
+
export const MIN_ECS_CAPACITY = 1;
|
|
177
|
+
export const MAX_ECS_CAPACITY = 1000;
|
|
178
|
+
// Default container port for ECS clusters and services
|
|
179
|
+
export const DEFAULT_CONTAINER_PORT = 3000;
|
|
180
|
+
// Default EC2 instance type — Graviton-based, free-tier eligible
|
|
181
|
+
export const DEFAULT_EC2_INSTANCE_TYPE = "t4g.micro";
|
|
182
|
+
/** AWS Secrets Manager recommended rotation interval (days) */
|
|
183
|
+
export const DEFAULT_SECRET_ROTATION_DAYS = 30;
|
|
184
|
+
// Valid HTTP methods for Lambda CORS
|
|
185
|
+
export const HTTP_METHODS = [
|
|
186
|
+
"GET",
|
|
187
|
+
"POST",
|
|
188
|
+
"PUT",
|
|
189
|
+
"DELETE",
|
|
190
|
+
"HEAD",
|
|
191
|
+
"OPTIONS",
|
|
192
|
+
"PATCH",
|
|
193
|
+
];
|
|
194
|
+
// S3 storage preset types (generator-level concept, resolved to params before plan creation)
|
|
195
|
+
export const STORAGE_PRESET_TYPES = [
|
|
196
|
+
"standard",
|
|
197
|
+
"assets",
|
|
198
|
+
"upload",
|
|
199
|
+
"website",
|
|
200
|
+
];
|
|
201
|
+
// S3 encryption types
|
|
202
|
+
export const S3_ENCRYPTION_TYPES = ["AES256", "KMS"];
|
|
203
|
+
// Backup vault tiers for disaster recovery
|
|
204
|
+
export const BACKUP_VAULT_TIERS = [
|
|
205
|
+
"standard",
|
|
206
|
+
"resilient",
|
|
207
|
+
"enterprise",
|
|
208
|
+
];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EC2 Instance Type Architecture Mapping
|
|
3
|
+
*
|
|
4
|
+
* Maps EC2 instance type prefixes to their required CPU architecture.
|
|
5
|
+
* Used for early validation to prevent architecture mismatches between
|
|
6
|
+
* instance types and AMI hardware types.
|
|
7
|
+
*/
|
|
8
|
+
export type AmiHardwareType = "ARM" | "STANDARD";
|
|
9
|
+
/**
|
|
10
|
+
* Get the required architecture for an EC2 instance type.
|
|
11
|
+
*
|
|
12
|
+
* @param instanceType - EC2 instance type (e.g., "t4g.micro", "t3.small")
|
|
13
|
+
* @returns "ARM" for Graviton instances, "STANDARD" for Intel/AMD
|
|
14
|
+
*/
|
|
15
|
+
export declare function getArchitectureForInstanceType(instanceType: string): AmiHardwareType;
|
|
16
|
+
/**
|
|
17
|
+
* Validate that an EC2 instance type is compatible with the specified AMI hardware type.
|
|
18
|
+
*
|
|
19
|
+
* @param instanceType - EC2 instance type (e.g., "t4g.micro")
|
|
20
|
+
* @param amiHardwareType - AMI hardware type ("ARM" or "STANDARD")
|
|
21
|
+
* @returns Validation result with optional error message
|
|
22
|
+
*/
|
|
23
|
+
export declare function validateArchitectureMatch(instanceType: string, amiHardwareType: AmiHardwareType): {
|
|
24
|
+
valid: boolean;
|
|
25
|
+
message?: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Check if an instance type is compatible with a given AMI hardware type.
|
|
29
|
+
* Simpler boolean version of validateArchitectureMatch.
|
|
30
|
+
*
|
|
31
|
+
* @param instanceType - EC2 instance type
|
|
32
|
+
* @param amiHardwareType - AMI hardware type
|
|
33
|
+
* @returns true if compatible, false otherwise
|
|
34
|
+
*/
|
|
35
|
+
export declare function isArchitectureCompatible(instanceType: string, amiHardwareType: AmiHardwareType): boolean;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EC2 Instance Type Architecture Mapping
|
|
3
|
+
*
|
|
4
|
+
* Maps EC2 instance type prefixes to their required CPU architecture.
|
|
5
|
+
* Used for early validation to prevent architecture mismatches between
|
|
6
|
+
* instance types and AMI hardware types.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Instance type prefixes that use ARM64 architecture (Graviton processors).
|
|
10
|
+
* All other prefixes are assumed to be x86-64 (STANDARD).
|
|
11
|
+
*/
|
|
12
|
+
const ARM_INSTANCE_PREFIXES = new Set([
|
|
13
|
+
"t4g",
|
|
14
|
+
"c6g",
|
|
15
|
+
"c6gd",
|
|
16
|
+
"c6gn",
|
|
17
|
+
"c7g",
|
|
18
|
+
"c7gd",
|
|
19
|
+
"c7gn",
|
|
20
|
+
"r6g",
|
|
21
|
+
"r6gd",
|
|
22
|
+
"r7g",
|
|
23
|
+
"r7gd",
|
|
24
|
+
"m6g",
|
|
25
|
+
"m6gd",
|
|
26
|
+
"m7g",
|
|
27
|
+
"m7gd",
|
|
28
|
+
"a1",
|
|
29
|
+
"x2gd",
|
|
30
|
+
"im4gn",
|
|
31
|
+
"is4gen",
|
|
32
|
+
"i4g",
|
|
33
|
+
"hpc7g",
|
|
34
|
+
]);
|
|
35
|
+
/**
|
|
36
|
+
* Get the required architecture for an EC2 instance type.
|
|
37
|
+
*
|
|
38
|
+
* @param instanceType - EC2 instance type (e.g., "t4g.micro", "t3.small")
|
|
39
|
+
* @returns "ARM" for Graviton instances, "STANDARD" for Intel/AMD
|
|
40
|
+
*/
|
|
41
|
+
export function getArchitectureForInstanceType(instanceType) {
|
|
42
|
+
const prefix = instanceType.split(".")[0];
|
|
43
|
+
return ARM_INSTANCE_PREFIXES.has(prefix) ? "ARM" : "STANDARD";
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Validate that an EC2 instance type is compatible with the specified AMI hardware type.
|
|
47
|
+
*
|
|
48
|
+
* @param instanceType - EC2 instance type (e.g., "t4g.micro")
|
|
49
|
+
* @param amiHardwareType - AMI hardware type ("ARM" or "STANDARD")
|
|
50
|
+
* @returns Validation result with optional error message
|
|
51
|
+
*/
|
|
52
|
+
export function validateArchitectureMatch(instanceType, amiHardwareType) {
|
|
53
|
+
const required = getArchitectureForInstanceType(instanceType);
|
|
54
|
+
if (required !== amiHardwareType) {
|
|
55
|
+
const suggestion = required === "ARM"
|
|
56
|
+
? "Graviton instance (t4g, c6g, r6g, m6g, etc.)"
|
|
57
|
+
: "Intel/AMD instance (t3, c5, r5, m5, etc.)";
|
|
58
|
+
return {
|
|
59
|
+
valid: false,
|
|
60
|
+
message: `Instance type '${instanceType}' requires ${required} architecture, but '${amiHardwareType}' AMI was specified. Use a ${suggestion} instead.`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return { valid: true };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check if an instance type is compatible with a given AMI hardware type.
|
|
67
|
+
* Simpler boolean version of validateArchitectureMatch.
|
|
68
|
+
*
|
|
69
|
+
* @param instanceType - EC2 instance type
|
|
70
|
+
* @param amiHardwareType - AMI hardware type
|
|
71
|
+
* @returns true if compatible, false otherwise
|
|
72
|
+
*/
|
|
73
|
+
export function isArchitectureCompatible(instanceType, amiHardwareType) {
|
|
74
|
+
return getArchitectureForInstanceType(instanceType) === amiHardwareType;
|
|
75
|
+
}
|