@fjall/components-infrastructure 0.77.4 → 0.78.5
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/lib/app.d.ts +8 -5
- package/dist/lib/app.js +19 -7
- package/dist/lib/patterns/aws/buildkite.js +4 -7
- package/dist/lib/patterns/aws/compute.d.ts +479 -48
- package/dist/lib/patterns/aws/compute.js +307 -94
- package/dist/lib/patterns/aws/database.d.ts +1 -0
- package/dist/lib/patterns/aws/database.js +4 -1
- package/dist/lib/patterns/aws/hostedZone.js +4 -7
- package/dist/lib/patterns/aws/loadBalancer.d.ts +163 -0
- package/dist/lib/patterns/aws/loadBalancer.js +278 -0
- package/dist/lib/patterns/aws/network.d.ts +1 -0
- package/dist/lib/patterns/aws/network.js +2 -1
- package/dist/lib/resources/aws/compute/capacityProviderDrainWaiter.d.ts +20 -0
- package/dist/lib/resources/aws/compute/capacityProviderDrainWaiter.js +180 -0
- package/dist/lib/resources/aws/compute/ecs.d.ts +294 -57
- package/dist/lib/resources/aws/compute/ecs.js +745 -261
- package/dist/lib/resources/aws/compute/ecsFreeTier.js +1 -1
- package/dist/lib/resources/aws/compute/ecsSpot.js +1 -1
- package/dist/lib/resources/aws/compute/utilities/capacityProviderDrainWaiter.d.ts +20 -0
- package/dist/lib/resources/aws/compute/utilities/capacityProviderDrainWaiter.js +180 -0
- package/dist/lib/resources/aws/database/rdsAurora.d.ts +1 -0
- package/dist/lib/resources/aws/database/rdsAurora.js +2 -2
- package/dist/lib/resources/aws/database/rdsAuroraGlobal.d.ts +1 -0
- package/dist/lib/resources/aws/database/rdsAuroraGlobal.js +2 -1
- package/dist/lib/resources/aws/database/rdsDeletionWaiter.d.ts +33 -0
- package/dist/lib/resources/aws/database/rdsDeletionWaiter.js +74 -0
- package/dist/lib/resources/aws/database/rdsInstance.d.ts +1 -0
- package/dist/lib/resources/aws/database/rdsInstance.js +3 -3
- package/dist/lib/resources/aws/networking/vpc.d.ts +1 -0
- package/dist/lib/resources/aws/networking/vpc.js +4 -3
- package/dist/lib/resources/aws/networking/vpcEndpoint.d.ts +2 -2
- package/dist/lib/resources/aws/networking/vpcEndpoint.js +1 -1
- package/dist/lib/resources/aws/networking/vpcEndpoints.d.ts +71 -0
- package/dist/lib/resources/aws/networking/vpcEndpoints.js +125 -0
- package/dist/lib/resources/aws/secrets/kms.d.ts +14 -0
- package/dist/lib/resources/aws/secrets/kms.js +5 -2
- package/dist/lib/resources/aws/secrets/secret.js +1 -1
- package/dist/lib/utils/standardTagsAspect.d.ts +26 -12
- package/dist/lib/utils/standardTagsAspect.js +67 -477
- package/dist/lib/utils/tagResource.d.ts +18 -3
- package/dist/lib/utils/tagResource.js +23 -6
- package/package.json +3 -3
- package/dist/lib/aspects/resourceInventory.d.ts +0 -41
- package/dist/lib/aspects/resourceInventory.js +0 -56
- package/dist/lib/config/audit.d.ts +0 -18
- package/dist/lib/config/audit.js +0 -22
- package/dist/lib/patterns/aws/auditRole.d.ts +0 -44
- package/dist/lib/patterns/aws/auditRole.js +0 -58
- package/dist/lib/patterns/aws/basicApp.d.ts +0 -0
- package/dist/lib/patterns/aws/basicApp.js +0 -150
- package/dist/lib/patterns/aws/ec2.d.ts +0 -43
- package/dist/lib/patterns/aws/ec2.js +0 -123
- package/dist/lib/patterns/aws/freeTierApp.d.ts +0 -44
- package/dist/lib/patterns/aws/freeTierApp.js +0 -83
- package/dist/lib/patterns/aws/spotInstanceApp.d.ts +0 -45
- package/dist/lib/patterns/aws/spotInstanceApp.js +0 -85
- package/dist/lib/resources/aws/audit/auditRole.d.ts +0 -32
- package/dist/lib/resources/aws/audit/auditRole.js +0 -46
- package/dist/lib/resources/aws/database/databaseFreeTier.d.ts +0 -15
- package/dist/lib/resources/aws/database/databaseFreeTier.js +0 -29
- package/dist/lib/resources/aws/database/rdsFreeTier.d.ts +0 -37
- package/dist/lib/resources/aws/database/rdsFreeTier.js +0 -84
- package/dist/lib/utils/getCidr.d.ts +0 -8
- package/dist/lib/utils/getCidr.js +0 -40
|
@@ -1,79 +1,511 @@
|
|
|
1
1
|
import { type RepositoryImage } from "aws-cdk-lib/aws-ecs";
|
|
2
2
|
import { Repository } from "aws-cdk-lib/aws-ecr";
|
|
3
3
|
import { Connections, type IConnectable, type IVpc, type UserData, type IMachineImage } from "aws-cdk-lib/aws-ec2";
|
|
4
|
-
import { Code, Runtime, type FunctionUrlAuthType } from "aws-cdk-lib/aws-lambda";
|
|
5
|
-
import { type
|
|
6
|
-
import { type PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
4
|
+
import { Code, Runtime, type FunctionUrlAuthType, type FunctionUrlCorsOptions } from "aws-cdk-lib/aws-lambda";
|
|
5
|
+
import { type PolicyStatement, type PolicyDocument, type IManagedPolicy } from "aws-cdk-lib/aws-iam";
|
|
7
6
|
import { Construct } from "constructs";
|
|
8
7
|
import type App from "../../app";
|
|
9
|
-
import {
|
|
8
|
+
import { ScalingType } from "../../resources/aws/compute/ecs";
|
|
10
9
|
import { type SecretImport } from "../../resources/aws/secrets";
|
|
11
|
-
export type
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
10
|
+
export type ComputeType = "ecs" | "ec2" | "lambda";
|
|
11
|
+
export type EcsCapacityProvider = "FARGATE" | "FARGATE_SPOT" | "EC2";
|
|
12
|
+
/**
|
|
13
|
+
* Configuration defaults for each compute type.
|
|
14
|
+
*/
|
|
15
|
+
export interface ComputeTypeConfig {
|
|
16
|
+
/** Default port for the compute type. ECS: 80, EC2: 22, Lambda: 0 (no port) */
|
|
17
|
+
defaultPort: number;
|
|
18
|
+
/** Default scaling limits */
|
|
19
|
+
defaultScaling: {
|
|
20
|
+
minCapacity: number;
|
|
21
|
+
maxCapacity: number;
|
|
22
|
+
};
|
|
23
|
+
/** Whether this compute type supports security group connections */
|
|
24
|
+
supportsConnections: boolean;
|
|
25
|
+
/** Whether this compute type requires a VPC */
|
|
26
|
+
requiresVpc: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare const COMPUTE_TYPE_CONFIG: Record<ComputeType, ComputeTypeConfig>;
|
|
29
|
+
/**
|
|
30
|
+
* Configuration for ECS capacity providers.
|
|
31
|
+
*/
|
|
32
|
+
export interface EcsCapacityProviderConfig {
|
|
33
|
+
/** Whether this uses Spot pricing */
|
|
34
|
+
usesSpot: boolean;
|
|
35
|
+
/** Whether this runs on EC2 instances (vs serverless Fargate) */
|
|
36
|
+
usesEc2Instances: boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare const ECS_CAPACITY_PROVIDER_CONFIG: Record<EcsCapacityProvider, EcsCapacityProviderConfig>;
|
|
39
|
+
export declare function getComputeTypeConfig(type: ComputeType): ComputeTypeConfig;
|
|
40
|
+
export declare function getEcsCapacityProviderConfig(provider: EcsCapacityProvider): EcsCapacityProviderConfig;
|
|
41
|
+
export { HttpMethod, type FunctionUrlCorsOptions } from "aws-cdk-lib/aws-lambda";
|
|
42
|
+
/**
|
|
43
|
+
* Configuration for a container in an ECS task.
|
|
44
|
+
*
|
|
45
|
+
* For single-container services, `name` is optional and defaults to `${serviceName}Container`.
|
|
46
|
+
* For multi-container tasks, the first container with a `port` is the **primary container**
|
|
47
|
+
* that receives load balancer traffic.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* // Single container (name auto-generated)
|
|
51
|
+
* containers: [{ port: 3000 }]
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* // Multi-container with sidecars
|
|
55
|
+
* containers: [
|
|
56
|
+
* { name: "app", port: 3000 }, // Primary - receives ALB traffic
|
|
57
|
+
* { name: "datadog", image: "datadog/agent" } // Sidecar - monitoring
|
|
58
|
+
* ]
|
|
59
|
+
*/
|
|
60
|
+
export interface EcsContainerConfig {
|
|
61
|
+
/** Container name. Optional for single-container services. */
|
|
62
|
+
name?: string;
|
|
27
63
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
64
|
+
* Container image. Options:
|
|
65
|
+
* - Omit: Uses app's default ECR repository (primary container only)
|
|
66
|
+
* - string: ECR repository name or public image URL
|
|
67
|
+
* - Repository: CDK ECR Repository construct
|
|
31
68
|
*/
|
|
32
|
-
|
|
69
|
+
image?: string | Repository;
|
|
33
70
|
/**
|
|
34
|
-
* Port the container listens on
|
|
71
|
+
* Port the container listens on.
|
|
72
|
+
* The first container with a port becomes the **primary container**
|
|
73
|
+
* and is registered with the load balancer.
|
|
35
74
|
*/
|
|
36
|
-
|
|
75
|
+
port?: number;
|
|
76
|
+
/** Environment variables */
|
|
77
|
+
environment?: Record<string, string>;
|
|
78
|
+
/** Secrets imported from other resources */
|
|
79
|
+
secretsImport?: Record<string, SecretImport>;
|
|
80
|
+
/** Command to run in the container */
|
|
81
|
+
command?: string[];
|
|
82
|
+
/** Entry point for the container */
|
|
83
|
+
entryPoint?: string[];
|
|
37
84
|
/**
|
|
38
|
-
*
|
|
85
|
+
* Whether this container is essential.
|
|
86
|
+
* If an essential container stops, all containers in the task stop.
|
|
87
|
+
* Default: true
|
|
39
88
|
*/
|
|
40
|
-
|
|
89
|
+
essential?: boolean;
|
|
41
90
|
/**
|
|
42
|
-
*
|
|
91
|
+
* Health check configuration.
|
|
92
|
+
* Default: For primary container with port, uses curl health check.
|
|
43
93
|
*/
|
|
94
|
+
healthCheck?: {
|
|
95
|
+
command: string[];
|
|
96
|
+
interval?: number;
|
|
97
|
+
timeout?: number;
|
|
98
|
+
retries?: number;
|
|
99
|
+
startPeriod?: number;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* ECS scaling configuration.
|
|
104
|
+
* - Omit: enabled with defaults
|
|
105
|
+
* - `{}`: enabled with defaults
|
|
106
|
+
* - `{ minCapacity: 2, maxCapacity: 10 }`: custom scaling
|
|
107
|
+
* - `false`: explicitly disabled
|
|
108
|
+
*/
|
|
109
|
+
export interface EcsScalingConfig {
|
|
110
|
+
minCapacity?: number;
|
|
111
|
+
maxCapacity?: number;
|
|
112
|
+
scalingType?: ScalingType;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* EC2 capacity configuration for ECS EC2-backed clusters.
|
|
116
|
+
* Only used when capacityProvider is "EC2".
|
|
117
|
+
*/
|
|
118
|
+
export interface Ec2CapacityConfig {
|
|
119
|
+
/** EC2 instance type. Default: "t3.micro" */
|
|
120
|
+
instanceType?: string;
|
|
121
|
+
/** AMI hardware type. Default: "ARM" (Graviton - better cost/performance) */
|
|
122
|
+
amiHardwareType?: "ARM" | "STANDARD";
|
|
123
|
+
/** Minimum number of instances. Default: 1 */
|
|
124
|
+
minCapacity?: number;
|
|
125
|
+
/** Maximum number of instances. Default: 3 */
|
|
126
|
+
maxCapacity?: number;
|
|
127
|
+
/** Desired number of EC2 instances. Default: 2 (for availability) */
|
|
128
|
+
desiredCount?: number;
|
|
129
|
+
/** Memory limit in MiB for the container. Default: 1024 */
|
|
44
130
|
memoryLimitMiB?: number;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Cluster-level configuration.
|
|
134
|
+
* Controls the shared ALB for all services in this cluster.
|
|
135
|
+
*/
|
|
136
|
+
export interface EcsClusterConfig {
|
|
45
137
|
/**
|
|
46
|
-
*
|
|
138
|
+
* Domain for HTTPS access.
|
|
139
|
+
* - Omit: ALB created with default DNS (*.elb.amazonaws.com)
|
|
140
|
+
* - Specified: Creates ACM certificate + Route53 DNS A record
|
|
47
141
|
*/
|
|
48
|
-
|
|
49
|
-
[key: string]: string;
|
|
50
|
-
};
|
|
142
|
+
domain?: string;
|
|
51
143
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
144
|
+
* Load balancer configuration.
|
|
145
|
+
* - Omit or "public": Internet-facing ALB (default)
|
|
146
|
+
* - "internal": VPC-only ALB
|
|
147
|
+
* - false: No ALB (for workers/background processors)
|
|
54
148
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
149
|
+
loadBalancer?: false | "public" | "internal";
|
|
150
|
+
/**
|
|
151
|
+
* Enable direct EC2 access without ALB.
|
|
152
|
+
* Uses host network mode for predictable ports.
|
|
153
|
+
* Access via EC2 public IP at container port.
|
|
154
|
+
*/
|
|
155
|
+
directAccess?: boolean;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Routing configuration for path/host-based routing on the ALB.
|
|
159
|
+
* Required when cluster has multiple services with ports.
|
|
160
|
+
* Optional for single service (gets all traffic automatically).
|
|
161
|
+
*/
|
|
162
|
+
export interface EcsRoutingConfig {
|
|
163
|
+
/**
|
|
164
|
+
* Path pattern for routing (e.g., "/api/*", "/users/*").
|
|
165
|
+
* Uses ALB path-based routing.
|
|
166
|
+
*/
|
|
167
|
+
path?: string;
|
|
168
|
+
/**
|
|
169
|
+
* Host header for routing (e.g., "api.example.com").
|
|
170
|
+
* Uses ALB host-based routing.
|
|
171
|
+
*/
|
|
172
|
+
host?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Priority for this routing rule (1-50000).
|
|
175
|
+
* Lower number = higher priority.
|
|
176
|
+
* Auto-assigned if omitted.
|
|
177
|
+
*/
|
|
178
|
+
priority?: number;
|
|
179
|
+
/**
|
|
180
|
+
* Health check path for this service's target group.
|
|
181
|
+
* Default: "/"
|
|
182
|
+
*/
|
|
183
|
+
healthCheckPath?: string;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Configuration for a service in an ECS cluster.
|
|
187
|
+
* Each service gets its own task definition, scaling config, and target group.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* // Simple service
|
|
191
|
+
* { name: "api", containers: [{ port: 3000 }] }
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* // Service with routing (for multi-service clusters)
|
|
195
|
+
* { name: "users", containers: [{ port: 3000 }], routing: { path: "/users/*", priority: 100 } }
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* // Service with sidecars
|
|
199
|
+
* {
|
|
200
|
+
* name: "api",
|
|
201
|
+
* containers: [
|
|
202
|
+
* { name: "app", port: 3000 },
|
|
203
|
+
* { name: "datadog", image: "datadog/agent" }
|
|
204
|
+
* ]
|
|
205
|
+
* }
|
|
206
|
+
*/
|
|
207
|
+
export interface EcsServiceConfig {
|
|
208
|
+
/** Service name (unique within cluster) */
|
|
209
|
+
name: string;
|
|
210
|
+
/**
|
|
211
|
+
* Container image for this service (applies to first container without explicit image).
|
|
212
|
+
* - Omit: Uses app's default ECR repository
|
|
213
|
+
* - string: ECR repository name or public image URL
|
|
214
|
+
* - Repository: CDK ECR Repository construct
|
|
215
|
+
*/
|
|
216
|
+
image?: string | Repository;
|
|
217
|
+
/**
|
|
218
|
+
* Container configuration(s) for this service.
|
|
219
|
+
* For single-container services, container name is optional and auto-generated.
|
|
220
|
+
* For multi-container services, the first container with a port is the primary container.
|
|
221
|
+
*/
|
|
222
|
+
containers?: EcsContainerConfig[];
|
|
223
|
+
/**
|
|
224
|
+
* Routing rules for this service on the cluster's ALB.
|
|
225
|
+
* Required when cluster has multiple services with ports.
|
|
226
|
+
* Optional for single service (gets /* automatically).
|
|
227
|
+
*/
|
|
228
|
+
routing?: EcsRoutingConfig;
|
|
229
|
+
/** CPU units for this service's tasks (256-4096) */
|
|
230
|
+
cpu?: number;
|
|
231
|
+
/** Memory in MiB for this service's tasks (512-30720) */
|
|
232
|
+
memoryLimitMiB?: number;
|
|
233
|
+
/** Desired number of tasks. Default: 2 */
|
|
234
|
+
desiredCount?: number;
|
|
235
|
+
/**
|
|
236
|
+
* Scaling configuration.
|
|
237
|
+
* - Omit: enabled with defaults
|
|
238
|
+
* - false: disabled
|
|
239
|
+
*/
|
|
240
|
+
scaling?: EcsScalingConfig | false;
|
|
241
|
+
/**
|
|
242
|
+
* Path to Dockerfile for building this service's image.
|
|
243
|
+
* Metadata for CLI build process, not used during CDK synthesis.
|
|
244
|
+
*/
|
|
245
|
+
dockerfilePath?: string;
|
|
246
|
+
/**
|
|
247
|
+
* Additional inline policies for this service's task role.
|
|
248
|
+
* Added on top of the default ECS Exec permissions.
|
|
249
|
+
* Use for service-specific AWS permissions (S3, DynamoDB, SQS, etc.).
|
|
250
|
+
*/
|
|
251
|
+
taskRoleInlinePolicies?: Record<string, PolicyDocument>;
|
|
252
|
+
/**
|
|
253
|
+
* Additional managed policies for this service's task role.
|
|
254
|
+
* Added on top of the default ECS Exec permissions.
|
|
255
|
+
*/
|
|
256
|
+
taskRoleManagedPolicies?: IManagedPolicy[];
|
|
257
|
+
/**
|
|
258
|
+
* Resources this service needs to connect to (e.g., databases).
|
|
259
|
+
* Creates security group rules to allow traffic from this service.
|
|
260
|
+
* Follows least-privilege - only this service gets access, not all services in the cluster.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* // Only backend service connects to database
|
|
264
|
+
* services: [
|
|
265
|
+
* { name: "frontend" },
|
|
266
|
+
* { name: "backend", connections: [appDatabase] }
|
|
267
|
+
* ]
|
|
268
|
+
*/
|
|
269
|
+
connections?: IConnectable[];
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* SSH access configuration for EC2 instances.
|
|
273
|
+
* - Omit: disabled (default)
|
|
274
|
+
* - `{}`: enabled with auto-generated key
|
|
275
|
+
* - `{ keyName: "my-key" }`: enabled with existing key
|
|
276
|
+
* - `false`: explicitly disabled
|
|
277
|
+
*/
|
|
278
|
+
export interface SshConfig {
|
|
279
|
+
/** SSH key pair name */
|
|
280
|
+
keyName?: string;
|
|
281
|
+
/** Allowed CIDR blocks for SSH access */
|
|
282
|
+
allowedCidrs?: string[];
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Lambda function URL configuration.
|
|
286
|
+
* - Omit: disabled (default)
|
|
287
|
+
* - `{}`: enabled with IAM auth
|
|
288
|
+
* - `{ authType: "NONE", cors: {...} }`: public with CORS
|
|
289
|
+
* - `false`: explicitly disabled
|
|
290
|
+
*/
|
|
291
|
+
export interface FunctionUrlConfig {
|
|
292
|
+
/** Authentication type. Default: AWS_IAM */
|
|
293
|
+
authType?: FunctionUrlAuthType;
|
|
294
|
+
/** CORS configuration */
|
|
295
|
+
cors?: FunctionUrlCorsOptions;
|
|
296
|
+
}
|
|
297
|
+
interface BaseComputeProps {
|
|
298
|
+
vpc?: IVpc;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* ECS compute configuration.
|
|
302
|
+
* Creates an ECS cluster with one or more services sharing a load balancer.
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* // Single service
|
|
306
|
+
* app.addCompute(ComputeFactory.build("WebApp", {
|
|
307
|
+
* type: "ecs",
|
|
308
|
+
* cluster: { domain: "app.example.com" },
|
|
309
|
+
* services: [{ name: "web", containers: [{ port: 3000 }] }]
|
|
310
|
+
* }));
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* // Multi-service cluster with routing
|
|
314
|
+
* app.addCompute(ComputeFactory.build("ApiCluster", {
|
|
315
|
+
* type: "ecs",
|
|
316
|
+
* cluster: { domain: "api.example.com" },
|
|
317
|
+
* services: [
|
|
318
|
+
* { name: "users", containers: [{ port: 3000 }], routing: { path: "/users/*" } },
|
|
319
|
+
* { name: "orders", containers: [{ port: 3001 }], routing: { path: "/orders/*" } }
|
|
320
|
+
* ]
|
|
321
|
+
* }));
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* // Internal workers (no ALB)
|
|
325
|
+
* app.addCompute(ComputeFactory.build("Workers", {
|
|
326
|
+
* type: "ecs",
|
|
327
|
+
* cluster: { loadBalancer: false },
|
|
328
|
+
* services: [{ name: "processor" }, { name: "emailer" }]
|
|
329
|
+
* }));
|
|
330
|
+
*/
|
|
331
|
+
export interface EcsComputeProps extends BaseComputeProps {
|
|
332
|
+
type: "ecs";
|
|
333
|
+
/**
|
|
334
|
+
* Cluster configuration.
|
|
335
|
+
* Controls the shared ALB for all services in this cluster.
|
|
336
|
+
* - Omit: ALB created with default settings
|
|
337
|
+
* - `{ domain: "..." }`: ALB with HTTPS + DNS
|
|
338
|
+
* - `{ loadBalancer: false }`: No ALB (internal workers)
|
|
339
|
+
*/
|
|
340
|
+
cluster?: EcsClusterConfig;
|
|
341
|
+
/**
|
|
342
|
+
* Services in this cluster.
|
|
343
|
+
* Each service gets its own task definition, scaling, and target group.
|
|
344
|
+
* All services share the cluster's ALB (unless disabled).
|
|
345
|
+
*/
|
|
346
|
+
services: EcsServiceConfig[];
|
|
347
|
+
/**
|
|
348
|
+
* Capacity provider determines infrastructure type.
|
|
349
|
+
* - "FARGATE": Serverless containers (default)
|
|
350
|
+
* - "FARGATE_SPOT": Serverless with Spot pricing
|
|
351
|
+
* - "EC2": EC2-backed containers
|
|
352
|
+
*/
|
|
353
|
+
capacityProvider?: EcsCapacityProvider;
|
|
354
|
+
/**
|
|
355
|
+
* EC2 capacity configuration.
|
|
356
|
+
* Only used when capacityProvider is "EC2".
|
|
357
|
+
*/
|
|
358
|
+
ec2Config?: Ec2CapacityConfig;
|
|
359
|
+
/**
|
|
360
|
+
* ECR repository for all services (default image).
|
|
361
|
+
* Individual services can override with their own `image` property.
|
|
362
|
+
*/
|
|
363
|
+
ecrRepository?: Repository | RepositoryImage;
|
|
364
|
+
/**
|
|
365
|
+
* Path to Dockerfile for building custom image.
|
|
366
|
+
* Note: This is metadata for the CLI build process,
|
|
367
|
+
* not used during CDK synthesis.
|
|
368
|
+
*/
|
|
369
|
+
dockerfilePath?: string;
|
|
370
|
+
}
|
|
371
|
+
export interface Ec2ComputeProps extends BaseComputeProps {
|
|
372
|
+
type: "ec2";
|
|
373
|
+
/** EC2 instance type. Default: "t3.micro" */
|
|
58
374
|
instanceType?: string;
|
|
59
|
-
|
|
375
|
+
/**
|
|
376
|
+
* SSH access configuration.
|
|
377
|
+
* - Omit: disabled (default)
|
|
378
|
+
* - `{}`: enabled with defaults
|
|
379
|
+
* - `false`: explicitly disabled
|
|
380
|
+
*/
|
|
381
|
+
ssh?: SshConfig | false;
|
|
382
|
+
/** User data script */
|
|
60
383
|
userData?: UserData;
|
|
384
|
+
/** Machine image (AMI) */
|
|
61
385
|
machineImage?: IMachineImage;
|
|
386
|
+
/** Minimum number of instances. Default: 1 */
|
|
62
387
|
minCapacity?: number;
|
|
388
|
+
/** Maximum number of instances. Default: 1 */
|
|
63
389
|
maxCapacity?: number;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Base Lambda configuration shared by both container and code deployments.
|
|
393
|
+
*/
|
|
394
|
+
interface BaseLambdaProps extends BaseComputeProps {
|
|
395
|
+
type: "lambda";
|
|
396
|
+
/** Timeout in seconds. Default: 3 */
|
|
67
397
|
timeout?: number;
|
|
398
|
+
/** Memory size in MB. Default: 128 */
|
|
68
399
|
memorySize?: number;
|
|
69
|
-
|
|
400
|
+
/** Lambda function description */
|
|
401
|
+
description?: string;
|
|
402
|
+
/** IAM role description */
|
|
70
403
|
roleDescription?: string;
|
|
404
|
+
/** Inline IAM policy statements */
|
|
71
405
|
inlinePolicy?: PolicyStatement[];
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
406
|
+
/**
|
|
407
|
+
* Function URL configuration.
|
|
408
|
+
* - Omit: disabled (default)
|
|
409
|
+
* - `{}`: enabled with IAM auth
|
|
410
|
+
* - `{ authType: "NONE" }`: public access
|
|
411
|
+
* - `false`: explicitly disabled
|
|
412
|
+
*/
|
|
413
|
+
functionUrl?: FunctionUrlConfig | false;
|
|
414
|
+
/** Environment variables */
|
|
415
|
+
environment?: Record<string, string>;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Container-based Lambda using ECR image.
|
|
419
|
+
*
|
|
420
|
+
* Uses Docker image from ECR repository. Handler and runtime are
|
|
421
|
+
* automatically set to FROM_IMAGE.
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* app.addCompute(ComputeFactory.build("ImageLambda", {
|
|
425
|
+
* type: "lambda",
|
|
426
|
+
* deployment: "container",
|
|
427
|
+
* ecrRepository: app.getDefaultContainerRegistry()
|
|
428
|
+
* }));
|
|
429
|
+
*/
|
|
430
|
+
export interface ContainerLambdaProps extends BaseLambdaProps {
|
|
431
|
+
/** Container-based deployment using ECR image */
|
|
432
|
+
deployment: "container";
|
|
433
|
+
/** ECR repository containing the Lambda container image */
|
|
434
|
+
ecrRepository: Repository | RepositoryImage;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Code-based Lambda using inline code or S3.
|
|
438
|
+
*
|
|
439
|
+
* Uses traditional Lambda deployment with code, handler, and runtime.
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* app.addCompute(ComputeFactory.build("CodeLambda", {
|
|
443
|
+
* type: "lambda",
|
|
444
|
+
* deployment: "code",
|
|
445
|
+
* code: Code.fromAsset("./lambda"),
|
|
446
|
+
* handler: "index.handler",
|
|
447
|
+
* runtime: Runtime.NODEJS_20_X
|
|
448
|
+
* }));
|
|
449
|
+
*/
|
|
450
|
+
export interface CodeLambdaProps extends BaseLambdaProps {
|
|
451
|
+
/** Code-based deployment */
|
|
452
|
+
deployment: "code";
|
|
453
|
+
/** Lambda code (from asset, S3, or inline) */
|
|
454
|
+
code: Code;
|
|
455
|
+
/** Handler function. Default: "index.handler" */
|
|
456
|
+
handler?: string;
|
|
457
|
+
/** Lambda runtime. Default: NODEJS_18_X */
|
|
458
|
+
runtime?: Runtime;
|
|
76
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* Lambda compute configuration.
|
|
462
|
+
*
|
|
463
|
+
* Discriminated union ensuring type-safe Lambda configuration:
|
|
464
|
+
* - `deployment: "container"` requires `ecrRepository`
|
|
465
|
+
* - `deployment: "code"` requires `code` and allows `handler`/`runtime`
|
|
466
|
+
*
|
|
467
|
+
* @example
|
|
468
|
+
* // Container-based Lambda
|
|
469
|
+
* { type: "lambda", deployment: "container", ecrRepository: ecr }
|
|
470
|
+
*
|
|
471
|
+
* @example
|
|
472
|
+
* // Code-based Lambda
|
|
473
|
+
* { type: "lambda", deployment: "code", code: Code.fromAsset("./lambda") }
|
|
474
|
+
*/
|
|
475
|
+
export type LambdaComputeProps = ContainerLambdaProps | CodeLambdaProps;
|
|
476
|
+
export type IComputeProps = EcsComputeProps | Ec2ComputeProps | LambdaComputeProps;
|
|
477
|
+
/**
|
|
478
|
+
* Factory for creating compute resources.
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* // Single service cluster
|
|
482
|
+
* app.addCompute(ComputeFactory.build("WebApp", {
|
|
483
|
+
* type: "ecs",
|
|
484
|
+
* cluster: { domain: "app.example.com" },
|
|
485
|
+
* services: [{ name: "web", containers: [{ port: 3000 }] }]
|
|
486
|
+
* }));
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* // Multi-service cluster with routing
|
|
490
|
+
* app.addCompute(ComputeFactory.build("ApiCluster", {
|
|
491
|
+
* type: "ecs",
|
|
492
|
+
* cluster: { domain: "api.example.com" },
|
|
493
|
+
* services: [
|
|
494
|
+
* { name: "users", containers: [{ port: 3000 }], routing: { path: "/users/*" } },
|
|
495
|
+
* { name: "orders", containers: [{ port: 3001 }], routing: { path: "/orders/*" } }
|
|
496
|
+
* ]
|
|
497
|
+
* }));
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* // Worker cluster (no ALB)
|
|
501
|
+
* app.addCompute(ComputeFactory.build("Workers", {
|
|
502
|
+
* type: "ecs",
|
|
503
|
+
* cluster: { loadBalancer: false },
|
|
504
|
+
* services: [
|
|
505
|
+
* { name: "processor", containers: [{ command: ["node", "worker.js"] }] }
|
|
506
|
+
* ]
|
|
507
|
+
* }));
|
|
508
|
+
*/
|
|
77
509
|
export declare class ComputeFactory {
|
|
78
510
|
static build(id: string, props: IComputeProps): (app: App, scope: Construct) => Compute;
|
|
79
511
|
}
|
|
@@ -89,4 +521,3 @@ export declare class Compute extends Construct implements IConnectable {
|
|
|
89
521
|
private addEcsCompute;
|
|
90
522
|
private addLambdaCompute;
|
|
91
523
|
}
|
|
92
|
-
export {};
|