@fjall/components-infrastructure 0.86.1 → 0.87.3
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/README.md +3 -3
- package/dist/lib/app.d.ts +166 -6
- package/dist/lib/app.js +212 -20
- package/dist/lib/aspects/resourceInventory.d.ts +4 -4
- package/dist/lib/aspects/resourceInventory.js +3 -3
- package/dist/lib/config/aws/backupGlobalSettings.js +1 -2
- package/dist/lib/config/aws/identityCenter.js +1 -5
- package/dist/lib/config/aws/organisation.js +1 -4
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +7 -1
- package/dist/lib/patterns/aws/buildkite.js +3 -2
- package/dist/lib/patterns/aws/cdn.d.ts +164 -0
- package/dist/lib/patterns/aws/cdn.js +264 -0
- package/dist/lib/patterns/aws/compute.d.ts +278 -59
- package/dist/lib/patterns/aws/compute.js +384 -188
- package/dist/lib/patterns/aws/connections.d.ts +46 -0
- package/dist/lib/patterns/aws/connections.js +159 -0
- package/dist/lib/patterns/aws/database.d.ts +124 -11
- package/dist/lib/patterns/aws/database.js +188 -66
- package/dist/lib/patterns/aws/hostedZone.js +1 -1
- package/dist/lib/patterns/aws/index.d.ts +3 -0
- package/dist/lib/patterns/aws/index.js +4 -1
- package/dist/lib/patterns/aws/interfaces/compute.d.ts +121 -0
- package/dist/lib/patterns/aws/interfaces/compute.js +48 -0
- package/dist/lib/patterns/aws/interfaces/connector.d.ts +183 -0
- package/dist/lib/patterns/aws/interfaces/connector.js +117 -0
- package/dist/lib/patterns/aws/interfaces/database.d.ts +136 -0
- package/dist/lib/patterns/aws/interfaces/database.js +65 -0
- package/dist/lib/patterns/aws/interfaces/index.d.ts +12 -0
- package/dist/lib/patterns/aws/interfaces/index.js +49 -0
- package/dist/lib/patterns/aws/interfaces/messaging.d.ts +146 -0
- package/dist/lib/patterns/aws/interfaces/messaging.js +56 -0
- package/dist/lib/patterns/aws/interfaces/pattern.d.ts +403 -0
- package/dist/lib/patterns/aws/interfaces/pattern.js +36 -0
- package/dist/lib/patterns/aws/interfaces/storage.d.ts +136 -0
- package/dist/lib/patterns/aws/interfaces/storage.js +48 -0
- package/dist/lib/patterns/aws/messaging.d.ts +183 -0
- package/dist/lib/patterns/aws/messaging.js +239 -0
- package/dist/lib/patterns/aws/network.js +4 -4
- package/dist/lib/patterns/aws/pattern.d.ts +67 -0
- package/dist/lib/patterns/aws/pattern.js +69 -0
- package/dist/lib/patterns/aws/payload.d.ts +87 -0
- package/dist/lib/patterns/aws/payload.js +526 -0
- package/dist/lib/patterns/aws/storage.d.ts +127 -15
- package/dist/lib/patterns/aws/storage.js +234 -38
- package/dist/lib/resources/aws/backup/backupPlan.js +1 -6
- package/dist/lib/resources/aws/backup/backupVault.js +1 -2
- package/dist/lib/resources/aws/base/awsStack.d.ts +0 -2
- package/dist/lib/resources/aws/base/awsStack.js +1 -7
- package/dist/lib/resources/aws/cdn/cloudFront.d.ts +71 -0
- package/dist/lib/resources/aws/cdn/cloudFront.js +176 -0
- package/dist/lib/resources/aws/cdn/index.d.ts +1 -0
- package/dist/lib/resources/aws/cdn/index.js +18 -0
- package/dist/lib/resources/aws/compute/ec2.d.ts +5 -0
- package/dist/lib/resources/aws/compute/ec2.js +33 -6
- package/dist/lib/resources/aws/compute/ecs.d.ts +32 -25
- package/dist/lib/resources/aws/compute/ecs.js +31 -115
- package/dist/lib/resources/aws/compute/lambda.d.ts +94 -5
- package/dist/lib/resources/aws/compute/lambda.js +209 -32
- package/dist/lib/resources/aws/database/database.js +1 -1
- package/dist/lib/resources/aws/database/dynamodb.d.ts +70 -0
- package/dist/lib/resources/aws/database/dynamodb.js +181 -0
- package/dist/lib/resources/aws/database/index.d.ts +1 -0
- package/dist/lib/resources/aws/database/index.js +2 -1
- package/dist/lib/resources/aws/database/migrationLambda.d.ts +80 -0
- package/dist/lib/resources/aws/database/migrationLambda.js +119 -0
- package/dist/lib/resources/aws/database/rdsAurora.d.ts +15 -0
- package/dist/lib/resources/aws/database/rdsAurora.js +41 -18
- package/dist/lib/resources/aws/database/rdsAuroraGlobal.js +12 -8
- package/dist/lib/resources/aws/database/rdsInstance.js +2 -2
- package/dist/lib/resources/aws/index.d.ts +2 -0
- package/dist/lib/resources/aws/index.js +3 -1
- package/dist/lib/resources/aws/messaging/eventbridge.d.ts +28 -0
- package/dist/lib/resources/aws/messaging/eventbridge.js +53 -0
- package/dist/lib/resources/aws/messaging/index.d.ts +3 -0
- package/dist/lib/resources/aws/messaging/index.js +20 -0
- package/dist/lib/resources/aws/messaging/sns.d.ts +35 -0
- package/dist/lib/resources/aws/messaging/sns.js +70 -0
- package/dist/lib/resources/aws/messaging/sqs.d.ts +105 -0
- package/dist/lib/resources/aws/messaging/sqs.js +231 -0
- package/dist/lib/resources/aws/messaging/utils.d.ts +3 -0
- package/dist/lib/resources/aws/messaging/utils.js +7 -0
- package/dist/lib/resources/aws/networking/ipam.js +1 -2
- package/dist/lib/resources/aws/networking/ipamPool.js +3 -2
- package/dist/lib/resources/aws/networking/vpc.js +1 -2
- package/dist/lib/resources/aws/storage/ecr.js +8 -5
- package/dist/lib/resources/aws/storage/s3.js +1 -2
- package/dist/lib/resources/aws/utilities/awsCustomResource.js +1 -1
- package/dist/lib/resources/aws/utilities/customResource.js +1 -1
- package/dist/lib/utils/getConfig.js +3 -2
- package/dist/lib/utils/index.d.ts +1 -0
- package/dist/lib/utils/index.js +2 -1
- package/dist/lib/utils/manifestWriter.d.ts +174 -0
- package/dist/lib/utils/manifestWriter.js +233 -0
- package/dist/lib/utils/standardTagsAspect.js +1 -8
- package/dist/lib/utils/validationLogger.d.ts +34 -0
- package/dist/lib/utils/validationLogger.js +83 -0
- package/package.json +3 -3
- package/dist/lib/__tests__/setup.d.ts +0 -48
- package/dist/lib/__tests__/setup.js +0 -1
- package/dist/lib/patterns/aws/cicdRole.d.ts +0 -67
- package/dist/lib/patterns/aws/cicdRole.js +0 -68
- package/dist/lib/resources/aws/cicd/cicdRole.d.ts +0 -65
- package/dist/lib/resources/aws/cicd/cicdRole.js +0 -191
- package/dist/lib/resources/aws/compute/ecsFreeTier.d.ts +0 -75
- package/dist/lib/resources/aws/compute/ecsFreeTier.js +0 -1
- package/dist/lib/resources/aws/compute/ecsSpot.d.ts +0 -75
- package/dist/lib/resources/aws/compute/ecsSpot.js +0 -1
- package/dist/lib/resources/aws/compute/utilities/capacityProviderDrainWaiter.d.ts +0 -20
- package/dist/lib/resources/aws/compute/utilities/capacityProviderDrainWaiter.js +0 -1
- package/dist/lib/resources/aws/utilities/cfnOutput.d.ts +0 -5
- package/dist/lib/resources/aws/utilities/cfnOutput.js +0 -1
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import { type RepositoryImage } from "aws-cdk-lib/aws-ecs";
|
|
1
|
+
import { type RepositoryImage, type ICluster, type IBaseService } from "aws-cdk-lib/aws-ecs";
|
|
2
2
|
import { Repository } from "aws-cdk-lib/aws-ecr";
|
|
3
|
-
import { type Connections, type
|
|
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";
|
|
3
|
+
import { type Connections, type IVpc, type UserData, type IMachineImage, type ISecurityGroup } from "aws-cdk-lib/aws-ec2";
|
|
4
|
+
import { Code, Runtime, type Architecture, type FunctionUrlAuthType, type FunctionUrlCorsOptions, type IFunction, type InvokeMode } from "aws-cdk-lib/aws-lambda";
|
|
5
|
+
import { type PolicyStatement, type PolicyDocument, type IManagedPolicy, type IGrantable, Grant } from "aws-cdk-lib/aws-iam";
|
|
6
|
+
import { type IApplicationLoadBalancer, type ApplicationListener } from "aws-cdk-lib/aws-elasticloadbalancingv2";
|
|
7
|
+
import { type IAutoScalingGroup } from "aws-cdk-lib/aws-autoscaling";
|
|
6
8
|
import { Construct } from "constructs";
|
|
9
|
+
import { type IEcsCompute, type ILambdaCompute, type IEc2Compute, type AnyCompute, isCompute, isEcsCompute, isLambdaCompute, isEc2Compute } from "./interfaces/compute.js";
|
|
10
|
+
import { type ConnectionSpec } from "./interfaces/connector.js";
|
|
7
11
|
import type App from "../../app";
|
|
8
|
-
import { ScalingType, type DomainConfig, type EcsCapacityProvider, type Ec2CapacityConfig } from "../../resources/aws/compute/ecs";
|
|
12
|
+
import EcsCluster, { type EcsClusterProps, ScalingType, type DomainConfig, type EcsCapacityProvider, type Ec2CapacityConfig } from "../../resources/aws/compute/ecs";
|
|
13
|
+
import { Ec2Instance } from "../../resources/aws/compute/ec2";
|
|
14
|
+
import { LambdaFunction } from "../../resources/aws/compute/lambda";
|
|
9
15
|
import { type SecretImport } from "../../resources/aws/secrets";
|
|
10
16
|
export type ComputeType = "ecs" | "ec2" | "lambda";
|
|
17
|
+
export { ScalingType };
|
|
11
18
|
export type { EcsCapacityProvider, Ec2CapacityConfig };
|
|
12
19
|
/**
|
|
13
20
|
* Configuration defaults for each compute type.
|
|
@@ -36,9 +43,30 @@ export interface EcsCapacityProviderConfig {
|
|
|
36
43
|
usesEc2Instances: boolean;
|
|
37
44
|
}
|
|
38
45
|
export declare const ECS_CAPACITY_PROVIDER_CONFIG: Record<EcsCapacityProvider, EcsCapacityProviderConfig>;
|
|
46
|
+
/**
|
|
47
|
+
* Default values for compute resource configuration.
|
|
48
|
+
* Centralised constants to ensure consistency across the codebase.
|
|
49
|
+
*/
|
|
50
|
+
export declare const COMPUTE_DEFAULTS: {
|
|
51
|
+
readonly EC2: {
|
|
52
|
+
readonly INSTANCE_TYPE: "t3.micro";
|
|
53
|
+
readonly MIN_CAPACITY: 1;
|
|
54
|
+
readonly MAX_CAPACITY: 1;
|
|
55
|
+
};
|
|
56
|
+
readonly ECS: {
|
|
57
|
+
/** AWS sample image used when no ECR repository is provided */
|
|
58
|
+
readonly FALLBACK_IMAGE: "amazon/amazon-ecs-sample";
|
|
59
|
+
/** Default tag for ECR images */
|
|
60
|
+
readonly IMAGE_TAG: "latest";
|
|
61
|
+
};
|
|
62
|
+
readonly LAMBDA: {
|
|
63
|
+
readonly HANDLER: "index.handler";
|
|
64
|
+
readonly RUNTIME: Runtime;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
39
67
|
export declare function getComputeTypeConfig(type: ComputeType): ComputeTypeConfig;
|
|
40
68
|
export declare function getEcsCapacityProviderConfig(provider: EcsCapacityProvider): EcsCapacityProviderConfig;
|
|
41
|
-
export { HttpMethod, type FunctionUrlCorsOptions } from "aws-cdk-lib/aws-lambda";
|
|
69
|
+
export { Architecture, HttpMethod, InvokeMode, type FunctionUrlCorsOptions } from "aws-cdk-lib/aws-lambda";
|
|
42
70
|
/**
|
|
43
71
|
* Configuration for a container in an ECS task.
|
|
44
72
|
*
|
|
@@ -75,8 +103,6 @@ export interface EcsContainerConfig {
|
|
|
75
103
|
port?: number;
|
|
76
104
|
/** Environment variables */
|
|
77
105
|
environment?: Record<string, string>;
|
|
78
|
-
/** Secrets imported from other resources (AWS Secrets Manager) */
|
|
79
|
-
secretsImport?: Record<string, SecretImport>;
|
|
80
106
|
/**
|
|
81
107
|
* Secrets from AWS SSM Parameter Store.
|
|
82
108
|
* Array of secret names that will be fetched from the service's SSM namespace.
|
|
@@ -84,9 +110,11 @@ export interface EcsContainerConfig {
|
|
|
84
110
|
*
|
|
85
111
|
* @example
|
|
86
112
|
* // Secrets at /myapp/api-cluster/users/API_KEY and /myapp/api-cluster/users/DB_PASSWORD
|
|
87
|
-
*
|
|
113
|
+
* secrets: ["API_KEY", "DB_PASSWORD"]
|
|
88
114
|
*/
|
|
89
|
-
|
|
115
|
+
secrets?: string[];
|
|
116
|
+
/** Secrets imported from other CDK resources (AWS Secrets Manager) */
|
|
117
|
+
secretsImport?: Record<string, SecretImport>;
|
|
90
118
|
/** Command to run in the container */
|
|
91
119
|
command?: string[];
|
|
92
120
|
/** Entry point for the container */
|
|
@@ -243,11 +271,13 @@ export interface EcsServiceConfig {
|
|
|
243
271
|
dockerfilePath?: string;
|
|
244
272
|
/**
|
|
245
273
|
* Docker build target stage for multi-stage Dockerfiles.
|
|
246
|
-
*
|
|
274
|
+
* When specified, the CLI builds with `--target <dockerTarget>`.
|
|
275
|
+
* The image tag suffix is also updated: `<service>-<target>-latest`.
|
|
247
276
|
*
|
|
248
277
|
* @example
|
|
249
|
-
* //
|
|
250
|
-
* dockerTarget: "api"
|
|
278
|
+
* // Dockerfile: FROM node AS base ... FROM base AS api ... FROM base AS worker
|
|
279
|
+
* { name: "api", dockerTarget: "api" } // builds: myapp-api-api-latest
|
|
280
|
+
* { name: "worker", dockerTarget: "worker" } // builds: myapp-worker-worker-latest
|
|
251
281
|
*/
|
|
252
282
|
dockerTarget?: string;
|
|
253
283
|
/**
|
|
@@ -262,18 +292,31 @@ export interface EcsServiceConfig {
|
|
|
262
292
|
*/
|
|
263
293
|
taskRoleManagedPolicies?: IManagedPolicy[];
|
|
264
294
|
/**
|
|
265
|
-
* Resources this service needs to connect to (e.g., databases).
|
|
266
|
-
* Creates security group rules
|
|
295
|
+
* Resources this service needs to connect to (e.g., databases, S3 buckets, SQS queues).
|
|
296
|
+
* Creates security group rules for IConnectable resources and IAM grants for IAM resources.
|
|
267
297
|
* Follows least-privilege - only this service gets access, not all services in the cluster.
|
|
268
298
|
*
|
|
299
|
+
* Supports:
|
|
300
|
+
* - IConnectable: Security group resources (RDS, ECS, etc.)
|
|
301
|
+
* - IStorageConnector: S3 buckets (IAM grants)
|
|
302
|
+
* - IDynamoDBConnector: DynamoDB tables (IAM grants)
|
|
303
|
+
* - IQueueConnector: SQS queues (IAM grants)
|
|
304
|
+
* - ConnectionConfig: Explicit access level configuration
|
|
305
|
+
*
|
|
269
306
|
* @example
|
|
270
|
-
* //
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
307
|
+
* // Simple connections (default permissions)
|
|
308
|
+
* connections: [database, bucket, cache, queue]
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* // Explicit access levels
|
|
312
|
+
* connections: [
|
|
313
|
+
* database, // Security group (RDS)
|
|
314
|
+
* { resource: cache, access: "read" }, // Read-only DynamoDB
|
|
315
|
+
* { resource: bucket, access: "write" }, // Write-only S3
|
|
316
|
+
* { resource: queue, access: "consume" } // Consume-only SQS
|
|
274
317
|
* ]
|
|
275
318
|
*/
|
|
276
|
-
connections?:
|
|
319
|
+
connections?: ConnectionSpec[];
|
|
277
320
|
/**
|
|
278
321
|
* Capacity provider for this service. REQUIRED.
|
|
279
322
|
* Each service specifies its own capacity provider.
|
|
@@ -330,6 +373,8 @@ export interface FunctionUrlConfig {
|
|
|
330
373
|
authType?: FunctionUrlAuthType;
|
|
331
374
|
/** CORS configuration */
|
|
332
375
|
cors?: FunctionUrlCorsOptions;
|
|
376
|
+
/** Invoke mode. Use RESPONSE_STREAM for Lambda streaming. Default: BUFFERED */
|
|
377
|
+
invokeMode?: InvokeMode;
|
|
333
378
|
}
|
|
334
379
|
interface BaseComputeProps {
|
|
335
380
|
vpc?: IVpc;
|
|
@@ -369,7 +414,7 @@ export interface EcsComputeProps extends BaseComputeProps {
|
|
|
369
414
|
type: "ecs";
|
|
370
415
|
/**
|
|
371
416
|
* Application name for SSM secrets namespace.
|
|
372
|
-
* When containers use
|
|
417
|
+
* When containers use secrets, the path is derived as: /<appName>/<clusterName>/<serviceName>
|
|
373
418
|
* Auto-derived from App.getName() if not specified.
|
|
374
419
|
*/
|
|
375
420
|
appName?: string;
|
|
@@ -419,6 +464,16 @@ export interface Ec2ComputeProps extends BaseComputeProps {
|
|
|
419
464
|
minCapacity?: number;
|
|
420
465
|
/** Maximum number of instances. Default: 1 */
|
|
421
466
|
maxCapacity?: number;
|
|
467
|
+
/**
|
|
468
|
+
* Percentage of capacity to run on Spot instances (0-100).
|
|
469
|
+
* - Omit or 0: All On-Demand instances (default)
|
|
470
|
+
* - 100: All Spot instances
|
|
471
|
+
* - 50: Half Spot, half On-Demand
|
|
472
|
+
*
|
|
473
|
+
* Spot instances can reduce costs by up to 90% but may be interrupted.
|
|
474
|
+
* Use for fault-tolerant workloads.
|
|
475
|
+
*/
|
|
476
|
+
spotCapacityPercentage?: number;
|
|
422
477
|
}
|
|
423
478
|
/**
|
|
424
479
|
* Base Lambda configuration shared by both container and code deployments.
|
|
@@ -430,6 +485,8 @@ interface BaseLambdaProps extends BaseComputeProps {
|
|
|
430
485
|
/** Memory size in MB. Default: 128 */
|
|
431
486
|
memorySize?: number;
|
|
432
487
|
ephemeralStorageSize?: number;
|
|
488
|
+
/** CPU architecture. Default: x86_64. Use Architecture.ARM_64 for Graviton2. */
|
|
489
|
+
architecture?: Architecture;
|
|
433
490
|
/** Lambda function description */
|
|
434
491
|
description?: string;
|
|
435
492
|
/** IAM role description */
|
|
@@ -446,15 +503,64 @@ interface BaseLambdaProps extends BaseComputeProps {
|
|
|
446
503
|
functionUrl?: FunctionUrlConfig | false;
|
|
447
504
|
/** Environment variables */
|
|
448
505
|
environment?: Record<string, string>;
|
|
449
|
-
/** Container secrets import (key: env var, value: SecretImport) */
|
|
450
|
-
containerSecretsImport?: {
|
|
451
|
-
[key: string]: SecretImport;
|
|
452
|
-
};
|
|
453
506
|
/**
|
|
454
|
-
*
|
|
455
|
-
*
|
|
507
|
+
* Secrets from AWS SSM Parameter Store.
|
|
508
|
+
* Array of secret names that will be fetched from the Lambda's SSM namespace.
|
|
509
|
+
* The namespace path is auto-determined as: /<appName>/lambda/<functionName>
|
|
510
|
+
*
|
|
511
|
+
* @example
|
|
512
|
+
* secrets: ["API_KEY", "STRIPE_SECRET"]
|
|
513
|
+
*/
|
|
514
|
+
secrets?: string[];
|
|
515
|
+
/**
|
|
516
|
+
* SSM Parameter Store path for secrets.
|
|
517
|
+
* If secrets are defined, this path is used as the base path.
|
|
518
|
+
* If not specified, uses: /<appName>/lambda/<functionName>
|
|
519
|
+
*
|
|
520
|
+
* @example
|
|
521
|
+
* ssmSecretsPath: "/myapp/custom/path"
|
|
522
|
+
*/
|
|
523
|
+
ssmSecretsPath?: string;
|
|
524
|
+
/**
|
|
525
|
+
* Secrets imported from other CDK resources (AWS Secrets Manager).
|
|
526
|
+
* Used for CDK-managed secrets like database credentials.
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* secretsImport: {
|
|
530
|
+
* DATABASE_USERNAME: database.getCredentials().getImport("username"),
|
|
531
|
+
* DATABASE_PASSWORD: database.getCredentials().getImport("password")
|
|
532
|
+
* }
|
|
533
|
+
*/
|
|
534
|
+
secretsImport?: Record<string, SecretImport>;
|
|
535
|
+
/**
|
|
536
|
+
* Application name for SSM secrets path derivation.
|
|
537
|
+
* Auto-derived from App instance when using ComputeFactory.
|
|
538
|
+
* Only specify for advanced use cases.
|
|
539
|
+
*/
|
|
540
|
+
appName?: string;
|
|
541
|
+
/**
|
|
542
|
+
* Resources this Lambda needs to connect to (e.g., databases, S3 buckets, SQS queues).
|
|
543
|
+
* Creates security group rules for IConnectable resources and IAM grants for IAM resources.
|
|
544
|
+
*
|
|
545
|
+
* Supports:
|
|
546
|
+
* - IConnectable: Security group resources (RDS, ECS, etc.)
|
|
547
|
+
* - IStorageConnector: S3 buckets (IAM grants)
|
|
548
|
+
* - IDynamoDBConnector: DynamoDB tables (IAM grants)
|
|
549
|
+
* - IQueueConnector: SQS queues (IAM grants)
|
|
550
|
+
* - ConnectionConfig: Explicit access level configuration
|
|
551
|
+
*
|
|
552
|
+
* @example
|
|
553
|
+
* connections: [
|
|
554
|
+
* database,
|
|
555
|
+
* { resource: queue, access: "send" }
|
|
556
|
+
* ]
|
|
557
|
+
*/
|
|
558
|
+
connections?: ConnectionSpec[];
|
|
559
|
+
/**
|
|
560
|
+
* EventBridge schedule expression for scheduled Lambda invocations.
|
|
561
|
+
* Uses cron or rate syntax: "rate(1 hour)" or "cron(0 12 * * ? *)".
|
|
456
562
|
*/
|
|
457
|
-
|
|
563
|
+
scheduleExpression?: string;
|
|
458
564
|
}
|
|
459
565
|
/**
|
|
460
566
|
* Container-based Lambda using ECR image.
|
|
@@ -515,51 +621,164 @@ export interface CodeLambdaProps extends BaseLambdaProps {
|
|
|
515
621
|
* { type: "lambda", deployment: "code", code: Code.fromAsset("./lambda") }
|
|
516
622
|
*/
|
|
517
623
|
export type LambdaComputeProps = ContainerLambdaProps | CodeLambdaProps;
|
|
518
|
-
export type
|
|
624
|
+
export type IEcsComputeProps = EcsComputeProps;
|
|
625
|
+
export type ILambdaComputeProps = LambdaComputeProps;
|
|
626
|
+
export type IEc2ComputeProps = Ec2ComputeProps;
|
|
627
|
+
export type IComputeProps = IEcsComputeProps | ILambdaComputeProps | IEc2ComputeProps;
|
|
628
|
+
/**
|
|
629
|
+
* Build container configurations for an ECS service.
|
|
630
|
+
* Converts user-facing EcsContainerConfig to internal EcsClusterProps format.
|
|
631
|
+
* @internal Exported for testing only
|
|
632
|
+
*/
|
|
633
|
+
export declare function buildContainerConfigs(service: EcsServiceConfig): EcsClusterProps["services"][number]["containers"];
|
|
634
|
+
/**
|
|
635
|
+
* Resolved scaling configuration for an ECS service.
|
|
636
|
+
* @internal Exported for testing only
|
|
637
|
+
*/
|
|
638
|
+
export interface ResolvedScalingConfig {
|
|
639
|
+
scalingType: ScalingType | undefined;
|
|
640
|
+
minCapacity: number | undefined;
|
|
641
|
+
maxCapacity: number | undefined;
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Resolve scaling configuration from service props.
|
|
645
|
+
* Handles the three cases: explicit config, disabled (false), or default (undefined).
|
|
646
|
+
* @internal Exported for testing only
|
|
647
|
+
*/
|
|
648
|
+
export declare function resolveScalingConfig(scaling: EcsScalingConfig | false | undefined): ResolvedScalingConfig;
|
|
519
649
|
/**
|
|
520
|
-
*
|
|
650
|
+
* Resolved Lambda deployment configuration.
|
|
651
|
+
*/
|
|
652
|
+
export interface ResolvedLambdaDeployment {
|
|
653
|
+
code: Code;
|
|
654
|
+
handler: string;
|
|
655
|
+
runtime: Runtime;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Resolve Lambda deployment configuration from props.
|
|
659
|
+
* Handles container vs code deployment types.
|
|
660
|
+
*/
|
|
661
|
+
export declare function resolveLambdaDeployment(props: ILambdaComputeProps): ResolvedLambdaDeployment;
|
|
662
|
+
/**
|
|
663
|
+
* Factory for creating compute resources with type-safe return types.
|
|
664
|
+
*
|
|
665
|
+
* The factory uses overloads to infer the specific compute type from props,
|
|
666
|
+
* ensuring TypeScript provides only the relevant methods for each compute type.
|
|
521
667
|
*
|
|
522
668
|
* @example
|
|
523
|
-
* //
|
|
524
|
-
* app.addCompute(ComputeFactory.build("WebApp", {
|
|
669
|
+
* // ECS compute - returns EcsCompute with ECS-specific methods
|
|
670
|
+
* const ecs = app.addCompute(ComputeFactory.build("WebApp", {
|
|
525
671
|
* type: "ecs",
|
|
526
672
|
* cluster: { domain: "app.example.com" },
|
|
527
673
|
* services: [{ name: "web", containers: [{ port: 3000 }] }]
|
|
528
674
|
* }));
|
|
675
|
+
* ecs.getLoadBalancer(); // Available on EcsCompute
|
|
529
676
|
*
|
|
530
677
|
* @example
|
|
531
|
-
* //
|
|
532
|
-
* app.addCompute(ComputeFactory.build("
|
|
533
|
-
* type: "
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
* { name: "users", containers: [{ port: 3000 }], routing: { path: "/users/*" } },
|
|
537
|
-
* { name: "orders", containers: [{ port: 3001 }], routing: { path: "/orders/*" } }
|
|
538
|
-
* ]
|
|
678
|
+
* // Lambda compute - returns LambdaCompute with Lambda-specific methods
|
|
679
|
+
* const lambda = app.addCompute(ComputeFactory.build("Fn", {
|
|
680
|
+
* type: "lambda",
|
|
681
|
+
* deployment: "code",
|
|
682
|
+
* code: Code.fromAsset("./lambda")
|
|
539
683
|
* }));
|
|
684
|
+
* lambda.getFunctionUrl(); // Available on LambdaCompute
|
|
540
685
|
*
|
|
541
686
|
* @example
|
|
542
|
-
* //
|
|
543
|
-
* app.addCompute(ComputeFactory.build("
|
|
544
|
-
* type: "
|
|
545
|
-
*
|
|
546
|
-
* services: [
|
|
547
|
-
* { name: "processor", containers: [{ command: ["node", "worker.js"] }] }
|
|
548
|
-
* ]
|
|
687
|
+
* // EC2 compute - returns Ec2Compute with EC2-specific methods
|
|
688
|
+
* const ec2 = app.addCompute(ComputeFactory.build("Instance", {
|
|
689
|
+
* type: "ec2",
|
|
690
|
+
* instanceType: "t3.micro"
|
|
549
691
|
* }));
|
|
692
|
+
* ec2.getAutoScalingGroup(); // Available on Ec2Compute
|
|
550
693
|
*/
|
|
551
694
|
export declare class ComputeFactory {
|
|
552
|
-
static build(id: string, props:
|
|
695
|
+
static build(id: string, props: IEcsComputeProps): (app: App, scope: Construct) => EcsCompute;
|
|
696
|
+
static build(id: string, props: ILambdaComputeProps): (app: App, scope: Construct) => LambdaCompute;
|
|
697
|
+
static build(id: string, props: IEc2ComputeProps): (app: App, scope: Construct) => Ec2Compute;
|
|
553
698
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
699
|
+
/**
|
|
700
|
+
* ECS compute wrapper implementing IEcsCompute.
|
|
701
|
+
* Provides type-safe access to ECS-specific resources.
|
|
702
|
+
*/
|
|
703
|
+
export declare class EcsCompute extends Construct implements IEcsCompute {
|
|
704
|
+
readonly computeType: "ecs";
|
|
705
|
+
readonly connections: Connections;
|
|
706
|
+
private readonly ecsCluster;
|
|
707
|
+
constructor(scope: Construct, id: string, props: IEcsComputeProps);
|
|
708
|
+
/** Get the ECS cluster. */
|
|
709
|
+
getCluster(): ICluster;
|
|
710
|
+
/** Get the Application Load Balancer if one was created. */
|
|
711
|
+
getLoadBalancer(): IApplicationLoadBalancer | undefined;
|
|
712
|
+
/** Get a specific service by name. */
|
|
713
|
+
getService(name: string): IBaseService | undefined;
|
|
714
|
+
/** Get all services in the cluster. */
|
|
715
|
+
getAllServices(): IBaseService[];
|
|
716
|
+
/** Get the security group for the cluster. */
|
|
717
|
+
getSecurityGroup(): ISecurityGroup;
|
|
718
|
+
/**
|
|
719
|
+
* Get the ALB listener if this is an ECS compute with ALB.
|
|
720
|
+
*/
|
|
721
|
+
getListener(): ApplicationListener | undefined;
|
|
722
|
+
/**
|
|
723
|
+
* Get the underlying ECS cluster construct.
|
|
724
|
+
*/
|
|
725
|
+
getEcsCluster(): EcsCluster;
|
|
726
|
+
/**
|
|
727
|
+
* Grants ecs:ExecuteCommand permission for ECS services.
|
|
728
|
+
*/
|
|
729
|
+
grantExecuteCommand(grantee: IGrantable): Grant;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Lambda compute wrapper implementing ILambdaCompute.
|
|
733
|
+
* Provides type-safe access to Lambda-specific resources.
|
|
734
|
+
*/
|
|
735
|
+
export declare class LambdaCompute extends Construct implements ILambdaCompute {
|
|
736
|
+
readonly computeType: "lambda";
|
|
737
|
+
readonly connections: Connections;
|
|
738
|
+
private readonly lambdaFunction;
|
|
739
|
+
constructor(scope: Construct, id: string, props: ILambdaComputeProps);
|
|
740
|
+
/**
|
|
741
|
+
* Get a Lambda function by name.
|
|
742
|
+
* Since we only have one function, name is ignored.
|
|
743
|
+
*/
|
|
744
|
+
getFunction(_name?: string): IFunction | undefined;
|
|
745
|
+
/** Get all Lambda functions. */
|
|
746
|
+
getAllFunctions(): IFunction[];
|
|
747
|
+
/**
|
|
748
|
+
* Get the function URL for a Lambda function.
|
|
749
|
+
*/
|
|
750
|
+
getFunctionUrl(_name?: string): string | undefined;
|
|
751
|
+
/**
|
|
752
|
+
* Grant invoke permissions to a grantee.
|
|
753
|
+
*/
|
|
754
|
+
grantInvoke(grantee: IGrantable, _functionName?: string): Grant;
|
|
755
|
+
/**
|
|
756
|
+
* Get the security group for VPC-enabled Lambda functions.
|
|
757
|
+
* Returns undefined if the Lambda is not VPC-enabled.
|
|
758
|
+
*/
|
|
759
|
+
getSecurityGroup(): ISecurityGroup | undefined;
|
|
760
|
+
/**
|
|
761
|
+
* Get the underlying Lambda function construct.
|
|
762
|
+
*/
|
|
763
|
+
getLambdaFunction(): LambdaFunction;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* EC2 compute wrapper implementing IEc2Compute.
|
|
767
|
+
* Provides type-safe access to EC2-specific resources.
|
|
768
|
+
*/
|
|
769
|
+
export declare class Ec2Compute extends Construct implements IEc2Compute {
|
|
770
|
+
readonly computeType: "ec2";
|
|
771
|
+
readonly connections: Connections;
|
|
772
|
+
private readonly ec2Instance;
|
|
773
|
+
constructor(scope: Construct, id: string, props: IEc2ComputeProps);
|
|
774
|
+
/** Get the Auto Scaling Group. */
|
|
775
|
+
getAutoScalingGroup(): IAutoScalingGroup;
|
|
776
|
+
/** Get the security group. */
|
|
777
|
+
getSecurityGroup(): ISecurityGroup;
|
|
778
|
+
/**
|
|
779
|
+
* Get the underlying EC2 instance construct.
|
|
780
|
+
*/
|
|
781
|
+
getEc2Instance(): Ec2Instance;
|
|
565
782
|
}
|
|
783
|
+
export { isCompute, isEcsCompute, isLambdaCompute, isEc2Compute };
|
|
784
|
+
export type { IEcsCompute, ILambdaCompute, IEc2Compute, AnyCompute };
|