@fjall/components-infrastructure 0.88.3 → 0.89.2
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/LICENSE +21 -0
- package/dist/lib/app.d.ts +33 -10
- package/dist/lib/app.js +79 -36
- package/dist/lib/aspects/index.d.ts +1 -0
- package/dist/lib/aspects/index.js +6 -0
- package/dist/lib/config/aws/accountAuditRole.d.ts +20 -0
- package/dist/lib/config/aws/accountAuditRole.js +38 -0
- package/dist/lib/config/aws/accountMonitoringRole.d.ts +22 -0
- package/dist/lib/config/aws/accountMonitoringRole.js +133 -0
- package/dist/lib/config/aws/cloudTrail.d.ts +0 -3
- package/dist/lib/config/aws/cloudTrail.js +2 -2
- package/dist/lib/config/aws/disasterRecovery.js +53 -20
- package/dist/lib/config/aws/ecrDefaultImage.js +4 -3
- package/dist/lib/config/aws/index.d.ts +4 -0
- package/dist/lib/config/aws/index.js +5 -1
- package/dist/lib/config/aws/oidcConnector.d.ts +8 -0
- package/dist/lib/config/aws/oidcConnector.js +46 -0
- package/dist/lib/config/aws/platform.d.ts +2 -0
- package/dist/lib/config/aws/platform.js +6 -0
- package/dist/lib/config/index.d.ts +2 -0
- package/dist/lib/config/index.js +21 -0
- package/dist/lib/patterns/aws/account.js +22 -10
- package/dist/lib/patterns/aws/cdn.d.ts +19 -40
- package/dist/lib/patterns/aws/cdn.js +21 -17
- package/dist/lib/patterns/aws/compute.d.ts +9 -720
- package/dist/lib/patterns/aws/compute.js +27 -432
- package/dist/lib/patterns/aws/computeEc2.d.ts +67 -0
- package/dist/lib/patterns/aws/computeEc2.js +46 -0
- package/dist/lib/patterns/aws/computeEcs.d.ts +446 -0
- package/dist/lib/patterns/aws/computeEcs.js +246 -0
- package/dist/lib/patterns/aws/computeLambda.d.ts +220 -0
- package/dist/lib/patterns/aws/computeLambda.js +147 -0
- package/dist/lib/patterns/aws/database.d.ts +7 -87
- package/dist/lib/patterns/aws/database.js +15 -38
- package/dist/lib/patterns/aws/domainDelegation.d.ts +8 -0
- package/dist/lib/patterns/aws/domainDelegation.js +54 -0
- package/dist/lib/patterns/aws/domainFactory.d.ts +8 -0
- package/dist/lib/patterns/aws/domainFactory.js +23 -0
- package/dist/lib/patterns/aws/index.d.ts +4 -1
- package/dist/lib/patterns/aws/index.js +6 -2
- package/dist/lib/patterns/aws/interfaces/cdn.d.ts +26 -0
- package/dist/lib/patterns/aws/interfaces/cdn.js +14 -0
- package/dist/lib/patterns/aws/interfaces/connector.d.ts +4 -181
- package/dist/lib/patterns/aws/interfaces/connector.js +16 -113
- package/dist/lib/patterns/aws/interfaces/domain.d.ts +2 -0
- package/dist/lib/patterns/aws/interfaces/domain.js +6 -0
- package/dist/lib/patterns/aws/interfaces/index.d.ts +2 -0
- package/dist/lib/patterns/aws/interfaces/index.js +5 -2
- package/dist/lib/patterns/aws/interfaces/pattern.d.ts +9 -6
- package/dist/lib/patterns/aws/interfaces/pattern.js +1 -1
- package/dist/lib/patterns/aws/network.js +6 -9
- package/dist/lib/patterns/aws/organisation.d.ts +4 -2
- package/dist/lib/patterns/aws/organisation.js +21 -8
- package/dist/lib/patterns/aws/payload.js +21 -12
- package/dist/lib/patterns/aws/storage.d.ts +3 -2
- package/dist/lib/patterns/aws/storage.js +1 -1
- package/dist/lib/resources/aws/audit/auditRole.js +4 -4
- package/dist/lib/resources/aws/audit/index.d.ts +1 -0
- package/dist/lib/resources/aws/audit/index.js +6 -0
- package/dist/lib/resources/aws/backup/backupPlan.js +3 -2
- package/dist/lib/resources/aws/backup/backupVault.js +5 -3
- package/dist/lib/resources/aws/base/awsStack.d.ts +4 -2
- package/dist/lib/resources/aws/base/awsStack.js +8 -2
- package/dist/lib/resources/aws/cdn/cloudFront.d.ts +14 -0
- package/dist/lib/resources/aws/cdn/cloudFront.js +52 -18
- package/dist/lib/resources/aws/compute/ec2.js +18 -22
- package/dist/lib/resources/aws/compute/ecs.d.ts +23 -10
- package/dist/lib/resources/aws/compute/ecs.js +121 -64
- package/dist/lib/resources/aws/compute/index.d.ts +1 -0
- package/dist/lib/resources/aws/compute/index.js +2 -1
- package/dist/lib/resources/aws/compute/lambda.d.ts +0 -2
- package/dist/lib/resources/aws/compute/lambda.js +12 -27
- package/dist/lib/resources/aws/database/dynamodb.js +3 -13
- package/dist/lib/resources/aws/database/index.d.ts +8 -2
- package/dist/lib/resources/aws/database/index.js +19 -3
- package/dist/lib/resources/aws/database/rdsAurora.d.ts +2 -3
- package/dist/lib/resources/aws/database/rdsAurora.js +32 -68
- package/dist/lib/resources/aws/database/rdsAuroraGlobal.d.ts +6 -6
- package/dist/lib/resources/aws/database/rdsAuroraGlobal.js +25 -29
- package/dist/lib/resources/aws/database/rdsDefaults.d.ts +11 -0
- package/dist/lib/resources/aws/database/rdsDefaults.js +15 -0
- package/dist/lib/resources/aws/database/rdsHelpers.d.ts +39 -0
- package/dist/lib/resources/aws/database/rdsHelpers.js +75 -0
- package/dist/lib/resources/aws/database/rdsInstance.d.ts +7 -8
- package/dist/lib/resources/aws/database/rdsInstance.js +40 -84
- package/dist/lib/resources/aws/database/rdsProxyOutput.d.ts +7 -0
- package/dist/lib/resources/aws/database/rdsProxyOutput.js +18 -0
- package/dist/lib/resources/aws/iam/index.d.ts +0 -1
- package/dist/lib/resources/aws/iam/index.js +1 -2
- package/dist/lib/resources/aws/index.d.ts +0 -1
- package/dist/lib/resources/aws/index.js +1 -2
- package/dist/lib/resources/aws/logging/cloudTrail.js +13 -3
- package/dist/lib/resources/aws/logging/index.d.ts +2 -0
- package/dist/lib/resources/aws/logging/index.js +19 -0
- package/dist/lib/resources/aws/messaging/index.d.ts +3 -2
- package/dist/lib/resources/aws/messaging/index.js +4 -3
- package/dist/lib/resources/aws/messaging/sqs.js +14 -11
- package/dist/lib/resources/aws/messaging/utils.d.ts +1 -2
- package/dist/lib/resources/aws/messaging/utils.js +3 -4
- package/dist/lib/resources/aws/monitoring/index.d.ts +0 -1
- package/dist/lib/resources/aws/monitoring/index.js +4 -17
- package/dist/lib/resources/aws/networking/domain.d.ts +13 -0
- package/dist/lib/resources/aws/networking/domain.js +102 -0
- package/dist/lib/resources/aws/networking/domainCertificate.d.ts +13 -0
- package/dist/lib/resources/aws/networking/domainCertificate.js +28 -0
- package/dist/lib/resources/aws/networking/hostedZone.d.ts +28 -0
- package/dist/lib/resources/aws/networking/hostedZone.js +150 -0
- package/dist/lib/resources/aws/networking/index.d.ts +4 -0
- package/dist/lib/resources/aws/networking/index.js +5 -1
- package/dist/lib/resources/aws/networking/ipamPool.js +57 -31
- package/dist/lib/resources/aws/networking/securityGroup.d.ts +5 -0
- package/dist/lib/resources/aws/networking/securityGroup.js +14 -0
- package/dist/lib/resources/aws/networking/vpc.js +9 -4
- package/dist/lib/resources/aws/organisation/costAllocationTagActivator.d.ts +17 -0
- package/dist/lib/resources/aws/organisation/costAllocationTagActivator.js +66 -0
- package/dist/lib/resources/aws/organisation/index.d.ts +1 -0
- package/dist/lib/resources/aws/organisation/index.js +4 -2
- package/dist/lib/resources/aws/secrets/index.d.ts +0 -1
- package/dist/lib/resources/aws/secrets/index.js +1 -2
- package/dist/lib/resources/aws/storage/ecr.d.ts +0 -1
- package/dist/lib/resources/aws/storage/ecr.js +5 -5
- package/dist/lib/resources/aws/storage/s3.d.ts +3 -3
- package/dist/lib/resources/aws/storage/s3.js +1 -1
- package/dist/lib/resources/aws/utilities/index.d.ts +5 -0
- package/dist/lib/resources/aws/utilities/index.js +22 -0
- package/dist/lib/utils/backupTierMapping.d.ts +11 -0
- package/dist/lib/utils/backupTierMapping.js +17 -0
- package/dist/lib/utils/capitaliseString.d.ts +1 -12
- package/dist/lib/utils/capitaliseString.js +8 -28
- package/dist/lib/utils/connections.d.ts +46 -0
- package/dist/lib/utils/connections.js +159 -0
- package/dist/lib/utils/connector.d.ts +183 -0
- package/dist/lib/utils/connector.js +117 -0
- package/dist/lib/utils/databaseTypes.d.ts +85 -0
- package/dist/lib/utils/databaseTypes.js +34 -0
- package/dist/lib/utils/dnsRecords.d.ts +4 -0
- package/dist/lib/utils/dnsRecords.js +108 -0
- package/dist/lib/utils/domainTypes.d.ts +37 -0
- package/dist/lib/utils/domainTypes.js +10 -0
- package/dist/lib/utils/env.d.ts +42 -0
- package/dist/lib/utils/env.js +122 -0
- package/dist/lib/utils/getConfig.d.ts +0 -5
- package/dist/lib/utils/getConfig.js +42 -19
- package/dist/lib/utils/index.d.ts +7 -0
- package/dist/lib/utils/index.js +8 -1
- package/dist/lib/utils/removalPolicy.d.ts +2 -0
- package/dist/lib/utils/removalPolicy.js +16 -0
- package/dist/lib/utils/standardTagsAspect.d.ts +4 -0
- package/dist/lib/utils/standardTagsAspect.js +8 -8
- package/dist/lib/utils/vpcUtils.d.ts +14 -0
- package/dist/lib/utils/vpcUtils.js +28 -0
- package/package.json +7 -6
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type Connections, type IVpc, type UserData, type IMachineImage, type ISecurityGroup } from "aws-cdk-lib/aws-ec2";
|
|
2
|
+
import { type IAutoScalingGroup } from "aws-cdk-lib/aws-autoscaling";
|
|
3
|
+
import { Construct } from "constructs";
|
|
4
|
+
import { type IEc2Compute } from "./interfaces/compute.js";
|
|
5
|
+
import { Ec2Instance } from "../../resources/aws/compute/ec2";
|
|
6
|
+
/**
|
|
7
|
+
* SSH access configuration for EC2 instances.
|
|
8
|
+
* - Omit: disabled (default)
|
|
9
|
+
* - `{}`: enabled with auto-generated key
|
|
10
|
+
* - `{ keyName: "my-key" }`: enabled with existing key
|
|
11
|
+
* - `false`: explicitly disabled
|
|
12
|
+
*/
|
|
13
|
+
export interface SshConfig {
|
|
14
|
+
/** SSH key pair name */
|
|
15
|
+
keyName?: string;
|
|
16
|
+
/** Allowed CIDR blocks for SSH access */
|
|
17
|
+
allowedCidrs?: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface Ec2ComputeProps {
|
|
20
|
+
type: "ec2";
|
|
21
|
+
vpc?: IVpc;
|
|
22
|
+
/** EC2 instance type. Default: "t4g.micro" */
|
|
23
|
+
instanceType?: string;
|
|
24
|
+
/**
|
|
25
|
+
* SSH access configuration.
|
|
26
|
+
* - Omit: disabled (default)
|
|
27
|
+
* - `{}`: enabled with defaults
|
|
28
|
+
* - `false`: explicitly disabled
|
|
29
|
+
*/
|
|
30
|
+
ssh?: SshConfig | false;
|
|
31
|
+
/** User data script */
|
|
32
|
+
userData?: UserData;
|
|
33
|
+
/** Machine image (AMI) */
|
|
34
|
+
machineImage?: IMachineImage;
|
|
35
|
+
/** Minimum number of instances. Default: 1 */
|
|
36
|
+
minCapacity?: number;
|
|
37
|
+
/** Maximum number of instances. Default: 1 */
|
|
38
|
+
maxCapacity?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Percentage of capacity to run on Spot instances (0-100).
|
|
41
|
+
* - Omit or 0: All On-Demand instances (default)
|
|
42
|
+
* - 100: All Spot instances
|
|
43
|
+
* - 50: Half Spot, half On-Demand
|
|
44
|
+
*
|
|
45
|
+
* Spot instances can reduce costs by up to 90% but may be interrupted.
|
|
46
|
+
* Use for fault-tolerant workloads.
|
|
47
|
+
*/
|
|
48
|
+
spotCapacityPercentage?: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* EC2 compute wrapper implementing IEc2Compute.
|
|
52
|
+
* Provides type-safe access to EC2-specific resources.
|
|
53
|
+
*/
|
|
54
|
+
export declare class Ec2Compute extends Construct implements IEc2Compute {
|
|
55
|
+
readonly computeType: "ec2";
|
|
56
|
+
readonly connections: Connections;
|
|
57
|
+
private readonly ec2Instance;
|
|
58
|
+
constructor(scope: Construct, id: string, props: Ec2ComputeProps);
|
|
59
|
+
/** Get the Auto Scaling Group. */
|
|
60
|
+
getAutoScalingGroup(): IAutoScalingGroup;
|
|
61
|
+
/** Get the security group. */
|
|
62
|
+
getSecurityGroup(): ISecurityGroup;
|
|
63
|
+
/**
|
|
64
|
+
* Get the underlying EC2 instance construct.
|
|
65
|
+
*/
|
|
66
|
+
getEc2Instance(): Ec2Instance;
|
|
67
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Ec2Compute = void 0;
|
|
4
|
+
const constructs_1 = require("constructs");
|
|
5
|
+
const ec2_1 = require("../../resources/aws/compute/ec2");
|
|
6
|
+
const compute_js_1 = require("./compute.js");
|
|
7
|
+
/**
|
|
8
|
+
* EC2 compute wrapper implementing IEc2Compute.
|
|
9
|
+
* Provides type-safe access to EC2-specific resources.
|
|
10
|
+
*/
|
|
11
|
+
class Ec2Compute extends constructs_1.Construct {
|
|
12
|
+
constructor(scope, id, props) {
|
|
13
|
+
super(scope, id);
|
|
14
|
+
this.computeType = "ec2";
|
|
15
|
+
const enableSSH = props.ssh !== undefined && props.ssh !== false;
|
|
16
|
+
const ec2Props = {
|
|
17
|
+
serviceName: `${id}Service`,
|
|
18
|
+
instanceType: props.instanceType || compute_js_1.COMPUTE_DEFAULTS.EC2.INSTANCE_TYPE,
|
|
19
|
+
enableSSH,
|
|
20
|
+
userData: props.userData,
|
|
21
|
+
machineImage: props.machineImage,
|
|
22
|
+
minCapacity: props.minCapacity || compute_js_1.COMPUTE_DEFAULTS.EC2.MIN_CAPACITY,
|
|
23
|
+
maxCapacity: props.maxCapacity || compute_js_1.COMPUTE_DEFAULTS.EC2.MAX_CAPACITY,
|
|
24
|
+
vpc: props.vpc,
|
|
25
|
+
spotCapacityPercentage: props.spotCapacityPercentage
|
|
26
|
+
};
|
|
27
|
+
this.ec2Instance = new ec2_1.Ec2Instance(scope, `${id}Ec2`, ec2Props);
|
|
28
|
+
this.connections = this.ec2Instance.connections;
|
|
29
|
+
}
|
|
30
|
+
/** Get the Auto Scaling Group. */
|
|
31
|
+
getAutoScalingGroup() {
|
|
32
|
+
return this.ec2Instance.getAutoScalingGroup();
|
|
33
|
+
}
|
|
34
|
+
/** Get the security group. */
|
|
35
|
+
getSecurityGroup() {
|
|
36
|
+
return this.ec2Instance.asgSecurityGroup;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get the underlying EC2 instance construct.
|
|
40
|
+
*/
|
|
41
|
+
getEc2Instance() {
|
|
42
|
+
return this.ec2Instance;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.Ec2Compute = Ec2Compute;
|
|
46
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcHV0ZUVjMi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL2xpYi9wYXR0ZXJucy9hd3MvY29tcHV0ZUVjMi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFTQSwyQ0FBdUM7QUFJdkMseURBQThEO0FBRTlELDZDQUFnRDtBQWtEaEQ7OztHQUdHO0FBQ0gsTUFBYSxVQUFXLFNBQVEsc0JBQVM7SUFNdkMsWUFBWSxLQUFnQixFQUFFLEVBQVUsRUFBRSxLQUFzQjtRQUM5RCxLQUFLLENBQUMsS0FBSyxFQUFFLEVBQUUsQ0FBQyxDQUFDO1FBTkgsZ0JBQVcsR0FBRyxLQUFjLENBQUM7UUFRM0MsTUFBTSxTQUFTLEdBQUcsS0FBSyxDQUFDLEdBQUcsS0FBSyxTQUFTLElBQUksS0FBSyxDQUFDLEdBQUcsS0FBSyxLQUFLLENBQUM7UUFFakUsTUFBTSxRQUFRLEdBQUc7WUFDZixXQUFXLEVBQUUsR0FBRyxFQUFFLFNBQVM7WUFDM0IsWUFBWSxFQUFFLEtBQUssQ0FBQyxZQUFZLElBQUksNkJBQWdCLENBQUMsR0FBRyxDQUFDLGFBQWE7WUFDdEUsU0FBUztZQUNULFFBQVEsRUFBRSxLQUFLLENBQUMsUUFBUTtZQUN4QixZQUFZLEVBQUUsS0FBSyxDQUFDLFlBQVk7WUFDaEMsV0FBVyxFQUFFLEtBQUssQ0FBQyxXQUFXLElBQUksNkJBQWdCLENBQUMsR0FB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CBDT01QVVRFX0RFRkFVTFRTLkVDMi5NQVhfQ0FQQUNJVFksXG4gICAgICB2cGM6IHByb3BzLnZwYyxcbiAgICAgIHNwb3RDYXBhY2l0eVBlcmNlbnRhZ2U6IHByb3BzLnNwb3RDYXBhY2l0eVBlcmNlbnRhZ2VcbiAgICB9O1xuXG4gICAgdGhpcy5lYzJJbnN0YW5jZSA9IG5ldyBFYzJJbnN0YW5jZShzY29wZSwgYCR7aWR9RWMyYCwgZWMyUHJvcHMpO1xuICAgIHRoaXMuY29ubmVjdGlvbnMgPSB0aGlzLmVjMkluc3RhbmNlLmNvbm5lY3Rpb25zO1xuICB9XG5cbiAgLyoqIEdldCB0aGUgQXV0byBTY2FsaW5nIEdyb3VwLiAqL1xuICBnZXRBdXRvU2NhbGluZ0dyb3VwKCk6IElBdXRvU2NhbGluZ0dyb3VwIHtcbiAgICByZXR1cm4gdGhpcy5lYzJJbnN0YW5jZS5nZXRBdXRvU2NhbGluZ0dyb3VwKCk7XG4gIH1cblxuICAvKiogR2V0IHRoZSBzZWN1cml0eSBncm91cC4gKi9cbiAgZ2V0U2VjdXJpdHlHcm91cCgpOiBJU2VjdXJpdHlHcm91cCB7XG4gICAgcmV0dXJuIHRoaXMuZWMySW5zdGFuY2UuYXNnU2VjdXJpdHlHcm91cDtcbiAgfVxuXG4gIC8qKlxuICAgKiBHZXQgdGhlIHVuZGVybHlpbmcgRUMyIGluc3RhbmNlIGNvbnN0cnVjdC5cbiAgICovXG4gIGdldEVjMkluc3RhbmNlKCk6IEVjMkluc3RhbmNlIHtcbiAgICByZXR1cm4gdGhpcy5lYzJJbnN0YW5jZTtcbiAgfVxufVxuIl19
|
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
import { type RepositoryImage, type ICluster, type IBaseService } from "aws-cdk-lib/aws-ecs";
|
|
2
|
+
import { type Repository } from "aws-cdk-lib/aws-ecr";
|
|
3
|
+
import { type Connections, type IVpc, type ISecurityGroup } from "aws-cdk-lib/aws-ec2";
|
|
4
|
+
import { type PolicyDocument, type IManagedPolicy, type IGrantable, Grant } from "aws-cdk-lib/aws-iam";
|
|
5
|
+
import { type IApplicationLoadBalancer, type ApplicationListener } from "aws-cdk-lib/aws-elasticloadbalancingv2";
|
|
6
|
+
import { Construct } from "constructs";
|
|
7
|
+
import { type IEcsCompute } from "./interfaces/compute.js";
|
|
8
|
+
import { type ConnectionSpec } from "./interfaces/connector.js";
|
|
9
|
+
import EcsCluster, { type EcsClusterProps, ScalingType, type DomainConfig, type EcsCapacityProvider, type Ec2CapacityConfig } from "../../resources/aws/compute/ecs";
|
|
10
|
+
import { type SecretImport } from "../../resources/aws/secrets";
|
|
11
|
+
export { ScalingType };
|
|
12
|
+
export type { EcsCapacityProvider, Ec2CapacityConfig };
|
|
13
|
+
/**
|
|
14
|
+
* Configuration for ECS capacity providers.
|
|
15
|
+
*/
|
|
16
|
+
export interface EcsCapacityProviderConfig {
|
|
17
|
+
/** Whether this uses Spot pricing */
|
|
18
|
+
usesSpot: boolean;
|
|
19
|
+
/** Whether this runs on EC2 instances (vs serverless Fargate) */
|
|
20
|
+
usesEc2Instances: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare const ECS_CAPACITY_PROVIDER_CONFIG: Record<EcsCapacityProvider, EcsCapacityProviderConfig>;
|
|
23
|
+
export declare function getEcsCapacityProviderConfig(provider: EcsCapacityProvider): EcsCapacityProviderConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Configuration for a container in an ECS task.
|
|
26
|
+
*
|
|
27
|
+
* For single-container services, `name` is optional and defaults to `${serviceName}Container`.
|
|
28
|
+
* For multi-container tasks, the first container with a `port` is the **primary container**
|
|
29
|
+
* that receives load balancer traffic.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Single container (name auto-generated)
|
|
33
|
+
* containers: [{ port: 3000 }]
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // Multi-container with sidecars
|
|
37
|
+
* containers: [
|
|
38
|
+
* { name: "app", port: 3000 }, // Primary - receives ALB traffic
|
|
39
|
+
* { name: "datadog", image: "datadog/agent" } // Sidecar - monitoring
|
|
40
|
+
* ]
|
|
41
|
+
*/
|
|
42
|
+
export interface EcsContainerConfig {
|
|
43
|
+
/** Container name. Optional for single-container services. */
|
|
44
|
+
name?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Container image. Options:
|
|
47
|
+
* - Omit: Uses app's default ECR repository (primary container only)
|
|
48
|
+
* - string: ECR repository name or public image URL
|
|
49
|
+
* - Repository: CDK ECR Repository construct
|
|
50
|
+
*/
|
|
51
|
+
image?: string | Repository;
|
|
52
|
+
/**
|
|
53
|
+
* Port the container listens on.
|
|
54
|
+
* The first container with a port becomes the **primary container**
|
|
55
|
+
* and is registered with the load balancer.
|
|
56
|
+
*/
|
|
57
|
+
port?: number;
|
|
58
|
+
/** Environment variables */
|
|
59
|
+
environment?: Record<string, string>;
|
|
60
|
+
/**
|
|
61
|
+
* Secrets from AWS SSM Parameter Store.
|
|
62
|
+
* Array of secret names that will be fetched from the service's SSM namespace.
|
|
63
|
+
* The namespace path is auto-determined from app/cluster/service names.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* // Secrets at /myapp/api-cluster/users/API_KEY and /myapp/api-cluster/users/DB_PASSWORD
|
|
67
|
+
* secrets: ["API_KEY", "DB_PASSWORD"]
|
|
68
|
+
*/
|
|
69
|
+
secrets?: string[];
|
|
70
|
+
/** Secrets imported from other CDK resources (AWS Secrets Manager) */
|
|
71
|
+
secretsImport?: Record<string, SecretImport>;
|
|
72
|
+
/** Command to run in the container */
|
|
73
|
+
command?: string[];
|
|
74
|
+
/** Entry point for the container */
|
|
75
|
+
entryPoint?: string[];
|
|
76
|
+
/**
|
|
77
|
+
* Whether this container is essential.
|
|
78
|
+
* If an essential container stops, all containers in the task stop.
|
|
79
|
+
* Default: true
|
|
80
|
+
*/
|
|
81
|
+
essential?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Health check configuration.
|
|
84
|
+
* Default: For primary container with port, uses curl health check.
|
|
85
|
+
*/
|
|
86
|
+
healthCheck?: {
|
|
87
|
+
command: string[];
|
|
88
|
+
interval?: number;
|
|
89
|
+
timeout?: number;
|
|
90
|
+
retries?: number;
|
|
91
|
+
startPeriod?: number;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* ECS scaling configuration.
|
|
96
|
+
* - Omit: enabled with defaults
|
|
97
|
+
* - `{}`: enabled with defaults
|
|
98
|
+
* - `{ minCapacity: 2, maxCapacity: 10 }`: custom scaling
|
|
99
|
+
* - `false`: explicitly disabled
|
|
100
|
+
*/
|
|
101
|
+
export interface EcsScalingConfig {
|
|
102
|
+
minCapacity?: number;
|
|
103
|
+
maxCapacity?: number;
|
|
104
|
+
scalingType?: ScalingType;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Cluster-level configuration.
|
|
108
|
+
* Controls the shared ALB for all services in this cluster.
|
|
109
|
+
*/
|
|
110
|
+
export interface EcsClusterConfig {
|
|
111
|
+
/**
|
|
112
|
+
* Domain for HTTPS access.
|
|
113
|
+
* - Omit: ALB created with default DNS (*.elb.amazonaws.com)
|
|
114
|
+
* - Specified: Creates ACM certificate + Route53 DNS A record
|
|
115
|
+
*/
|
|
116
|
+
domain?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Load balancer configuration.
|
|
119
|
+
* - Omit or "public": Internet-facing ALB (default)
|
|
120
|
+
* - "internal": VPC-only ALB
|
|
121
|
+
* - false: No ALB (for workers/background processors)
|
|
122
|
+
*/
|
|
123
|
+
loadBalancer?: false | "public" | "internal";
|
|
124
|
+
/**
|
|
125
|
+
* Enable direct EC2 access without ALB.
|
|
126
|
+
* Uses host network mode for predictable ports.
|
|
127
|
+
* Access via EC2 public IP at container port.
|
|
128
|
+
*/
|
|
129
|
+
directAccess?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Advanced domain configuration for routing policies (latency, weighted, geo).
|
|
132
|
+
* Only used when domain is specified.
|
|
133
|
+
* Allows for multi-region deployments with advanced DNS routing.
|
|
134
|
+
*/
|
|
135
|
+
domainConfig?: DomainConfig;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Routing configuration for path/host-based routing on the ALB.
|
|
139
|
+
* Required when cluster has multiple services with ports.
|
|
140
|
+
* Optional for single service (gets all traffic automatically).
|
|
141
|
+
*/
|
|
142
|
+
export interface EcsRoutingConfig {
|
|
143
|
+
/**
|
|
144
|
+
* Path pattern for routing (e.g., "/api/*", "/users/*").
|
|
145
|
+
* Uses ALB path-based routing.
|
|
146
|
+
*/
|
|
147
|
+
path?: string;
|
|
148
|
+
/**
|
|
149
|
+
* Host header for routing (e.g., "api.example.com").
|
|
150
|
+
* Uses ALB host-based routing.
|
|
151
|
+
*/
|
|
152
|
+
host?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Priority for this routing rule (1-50000).
|
|
155
|
+
* Lower number = higher priority.
|
|
156
|
+
* Auto-assigned if omitted.
|
|
157
|
+
*/
|
|
158
|
+
priority?: number;
|
|
159
|
+
/**
|
|
160
|
+
* Health check path for this service's target group.
|
|
161
|
+
* Default: "/"
|
|
162
|
+
*/
|
|
163
|
+
healthCheckPath?: string;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Configuration for a service in an ECS cluster.
|
|
167
|
+
* Each service gets its own task definition, scaling config, and target group.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* // Simple service
|
|
171
|
+
* { name: "api", containers: [{ port: 3000 }] }
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* // Service with routing (for multi-service clusters)
|
|
175
|
+
* { name: "users", containers: [{ port: 3000 }], routing: { path: "/users/*", priority: 100 } }
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* // Service with multiple routing rules (same target group)
|
|
179
|
+
* { name: "web", containers: [{ port: 3000 }], routing: [
|
|
180
|
+
* { path: "/api/v2/*", priority: 50 },
|
|
181
|
+
* { path: "/*", priority: 200 },
|
|
182
|
+
* ]}
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* // Service with sidecars
|
|
186
|
+
* {
|
|
187
|
+
* name: "api",
|
|
188
|
+
* containers: [
|
|
189
|
+
* { name: "app", port: 3000 },
|
|
190
|
+
* { name: "datadog", image: "datadog/agent" }
|
|
191
|
+
* ]
|
|
192
|
+
* }
|
|
193
|
+
*/
|
|
194
|
+
export interface EcsServiceConfig {
|
|
195
|
+
/** Service name (unique within cluster) */
|
|
196
|
+
name: string;
|
|
197
|
+
/**
|
|
198
|
+
* Container image for this service (applies to first container without explicit image).
|
|
199
|
+
* - Omit: Uses app's default ECR repository
|
|
200
|
+
* - string: ECR repository name or public image URL
|
|
201
|
+
* - Repository: CDK ECR Repository construct
|
|
202
|
+
*/
|
|
203
|
+
image?: string | Repository;
|
|
204
|
+
/**
|
|
205
|
+
* Container configuration(s) for this service.
|
|
206
|
+
* For single-container services, container name is optional and auto-generated.
|
|
207
|
+
* For multi-container services, the first container with a port is the primary container.
|
|
208
|
+
*/
|
|
209
|
+
containers?: EcsContainerConfig[];
|
|
210
|
+
/**
|
|
211
|
+
* Routing rules for this service on the cluster's ALB.
|
|
212
|
+
* Required when cluster has multiple services with ports.
|
|
213
|
+
* Optional for single service (gets /* automatically).
|
|
214
|
+
* Can be a single rule or an array of rules pointing to the same target group.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* // Multiple routes for the same service
|
|
218
|
+
* routing: [
|
|
219
|
+
* { path: "/api/v2/*", priority: 50 },
|
|
220
|
+
* { path: "/*", priority: 200 },
|
|
221
|
+
* ]
|
|
222
|
+
*/
|
|
223
|
+
routing?: EcsRoutingConfig | EcsRoutingConfig[];
|
|
224
|
+
/** CPU units for this service's tasks (256-4096) */
|
|
225
|
+
cpu?: number;
|
|
226
|
+
/** Memory in MiB for this service's tasks (512-30720) */
|
|
227
|
+
memoryLimitMiB?: number;
|
|
228
|
+
/** Desired number of tasks. Default: 2 */
|
|
229
|
+
desiredCount?: number;
|
|
230
|
+
/**
|
|
231
|
+
* Scaling configuration.
|
|
232
|
+
* - Omit: enabled with defaults
|
|
233
|
+
* - false: disabled
|
|
234
|
+
*/
|
|
235
|
+
scaling?: EcsScalingConfig | false;
|
|
236
|
+
/**
|
|
237
|
+
* Path to Dockerfile for building this service's image.
|
|
238
|
+
* Metadata for CLI build process, not used during CDK synthesis.
|
|
239
|
+
*/
|
|
240
|
+
dockerfilePath?: string;
|
|
241
|
+
/**
|
|
242
|
+
* Docker build target stage for multi-stage Dockerfiles.
|
|
243
|
+
* When specified, the CLI builds with `--target <dockerTarget>`.
|
|
244
|
+
* The image tag suffix is also updated: `<service>-<target>-latest`.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* // Dockerfile: FROM node AS base ... FROM base AS api ... FROM base AS worker
|
|
248
|
+
* { name: "api", dockerTarget: "api" } // builds: myapp-api-api-latest
|
|
249
|
+
* { name: "worker", dockerTarget: "worker" } // builds: myapp-worker-worker-latest
|
|
250
|
+
*/
|
|
251
|
+
dockerTarget?: string;
|
|
252
|
+
/**
|
|
253
|
+
* Additional inline policies for this service's task role.
|
|
254
|
+
* Added on top of the default ECS Exec permissions.
|
|
255
|
+
* Use for service-specific AWS permissions (S3, DynamoDB, SQS, etc.).
|
|
256
|
+
*/
|
|
257
|
+
taskRoleInlinePolicies?: Record<string, PolicyDocument>;
|
|
258
|
+
/**
|
|
259
|
+
* Additional managed policies for this service's task role.
|
|
260
|
+
* Added on top of the default ECS Exec permissions.
|
|
261
|
+
*/
|
|
262
|
+
taskRoleManagedPolicies?: IManagedPolicy[];
|
|
263
|
+
/**
|
|
264
|
+
* Resources this service needs to connect to (e.g., databases, S3 buckets, SQS queues).
|
|
265
|
+
* Creates security group rules for IConnectable resources and IAM grants for IAM resources.
|
|
266
|
+
* Follows least-privilege - only this service gets access, not all services in the cluster.
|
|
267
|
+
*
|
|
268
|
+
* Supports:
|
|
269
|
+
* - IConnectable: Security group resources (RDS, ECS, etc.)
|
|
270
|
+
* - IStorageConnector: S3 buckets (IAM grants)
|
|
271
|
+
* - IDynamoDBConnector: DynamoDB tables (IAM grants)
|
|
272
|
+
* - IQueueConnector: SQS queues (IAM grants)
|
|
273
|
+
* - ConnectionConfig: Explicit access level configuration
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* // Simple connections (default permissions)
|
|
277
|
+
* connections: [database, bucket, cache, queue]
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* // Explicit access levels
|
|
281
|
+
* connections: [
|
|
282
|
+
* database, // Security group (RDS)
|
|
283
|
+
* { resource: cache, access: "read" }, // Read-only DynamoDB
|
|
284
|
+
* { resource: bucket, access: "write" }, // Write-only S3
|
|
285
|
+
* { resource: queue, access: "consume" } // Consume-only SQS
|
|
286
|
+
* ]
|
|
287
|
+
*/
|
|
288
|
+
connections?: ConnectionSpec[];
|
|
289
|
+
/**
|
|
290
|
+
* Capacity provider for this service. REQUIRED.
|
|
291
|
+
* Each service specifies its own capacity provider.
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* // Mixed FARGATE and EC2 services in same cluster
|
|
295
|
+
* {
|
|
296
|
+
* services: [
|
|
297
|
+
* { name: "api", capacityProvider: "FARGATE" },
|
|
298
|
+
* { name: "worker", capacityProvider: "EC2", ec2Config: { instanceType: "t4g.micro" } }
|
|
299
|
+
* ]
|
|
300
|
+
* }
|
|
301
|
+
*/
|
|
302
|
+
capacityProvider: EcsCapacityProvider;
|
|
303
|
+
/**
|
|
304
|
+
* EC2 capacity configuration for this service.
|
|
305
|
+
* Only used when service capacityProvider is "EC2".
|
|
306
|
+
* Services with matching ec2Config share an ASG for efficiency.
|
|
307
|
+
*/
|
|
308
|
+
ec2Config?: Ec2CapacityConfig;
|
|
309
|
+
/**
|
|
310
|
+
* SSM Parameter Store path for secrets.
|
|
311
|
+
* If not specified, secrets are fetched from /<app>/<cluster>/<service>.
|
|
312
|
+
* Use this to override the default convention.
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* // Override default path
|
|
316
|
+
* ssmSecretsPath: "/custom/path/to/secrets"
|
|
317
|
+
*/
|
|
318
|
+
ssmSecretsPath?: string;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* ECS compute configuration.
|
|
322
|
+
* Creates an ECS cluster with one or more services sharing a load balancer.
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* // Single service
|
|
326
|
+
* app.addCompute(ComputeFactory.build("WebApp", {
|
|
327
|
+
* type: "ecs",
|
|
328
|
+
* cluster: { domain: "app.example.com" },
|
|
329
|
+
* services: [{ name: "web", containers: [{ port: 3000 }] }]
|
|
330
|
+
* }));
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* // Multi-service cluster with routing
|
|
334
|
+
* app.addCompute(ComputeFactory.build("ApiCluster", {
|
|
335
|
+
* type: "ecs",
|
|
336
|
+
* cluster: { domain: "api.example.com" },
|
|
337
|
+
* services: [
|
|
338
|
+
* { name: "users", containers: [{ port: 3000 }], routing: { path: "/users/*" } },
|
|
339
|
+
* { name: "orders", containers: [{ port: 3001 }], routing: { path: "/orders/*" } }
|
|
340
|
+
* ]
|
|
341
|
+
* }));
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* // Internal workers (no ALB)
|
|
345
|
+
* app.addCompute(ComputeFactory.build("Workers", {
|
|
346
|
+
* type: "ecs",
|
|
347
|
+
* cluster: { loadBalancer: false },
|
|
348
|
+
* services: [{ name: "processor" }, { name: "emailer" }]
|
|
349
|
+
* }));
|
|
350
|
+
*/
|
|
351
|
+
export interface EcsComputeProps {
|
|
352
|
+
type: "ecs";
|
|
353
|
+
vpc?: IVpc;
|
|
354
|
+
/**
|
|
355
|
+
* Application name for SSM secrets namespace.
|
|
356
|
+
* When containers use secrets, the path is derived as: /<appName>/<clusterName>/<serviceName>
|
|
357
|
+
* Auto-derived from App.getName() if not specified.
|
|
358
|
+
*/
|
|
359
|
+
appName?: string;
|
|
360
|
+
/**
|
|
361
|
+
* Cluster configuration.
|
|
362
|
+
* Controls the shared ALB for all services in this cluster.
|
|
363
|
+
* - Omit: ALB created with default settings
|
|
364
|
+
* - `{ domain: "..." }`: ALB with HTTPS + DNS
|
|
365
|
+
* - `{ loadBalancer: false }`: No ALB (internal workers)
|
|
366
|
+
*/
|
|
367
|
+
cluster?: EcsClusterConfig;
|
|
368
|
+
/**
|
|
369
|
+
* Services in this cluster.
|
|
370
|
+
* Each service gets its own task definition, scaling, and target group.
|
|
371
|
+
* Each service MUST specify its own capacityProvider.
|
|
372
|
+
* All services share the cluster's ALB (unless disabled).
|
|
373
|
+
*/
|
|
374
|
+
services: EcsServiceConfig[];
|
|
375
|
+
/**
|
|
376
|
+
* ECR repository for all services (default image).
|
|
377
|
+
* Individual services can override with their own `image` property.
|
|
378
|
+
*/
|
|
379
|
+
ecrRepository?: Repository | RepositoryImage;
|
|
380
|
+
/**
|
|
381
|
+
* Path to Dockerfile for building custom image.
|
|
382
|
+
* Note: This is metadata for the CLI build process,
|
|
383
|
+
* not used during CDK synthesis.
|
|
384
|
+
*/
|
|
385
|
+
dockerfilePath?: string;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Validates ECS-specific props.
|
|
389
|
+
* Extracted for clarity and detail parity with database/network patterns.
|
|
390
|
+
*/
|
|
391
|
+
export declare function validateEcsProps(props: EcsComputeProps): void;
|
|
392
|
+
/**
|
|
393
|
+
* Build container configurations for an ECS service.
|
|
394
|
+
* Converts user-facing EcsContainerConfig to internal EcsClusterProps format.
|
|
395
|
+
* @internal Exported for testing only
|
|
396
|
+
*/
|
|
397
|
+
export declare function buildContainerConfigs(service: EcsServiceConfig): EcsClusterProps["services"][number]["containers"];
|
|
398
|
+
/**
|
|
399
|
+
* Resolved scaling configuration for an ECS service.
|
|
400
|
+
* @internal Exported for testing only
|
|
401
|
+
*/
|
|
402
|
+
export interface ResolvedScalingConfig {
|
|
403
|
+
scalingType: ScalingType | undefined;
|
|
404
|
+
minCapacity: number | undefined;
|
|
405
|
+
maxCapacity: number | undefined;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Resolve scaling configuration from service props.
|
|
409
|
+
* Handles the three cases: explicit config, disabled (false), or default (undefined).
|
|
410
|
+
* @internal Exported for testing only
|
|
411
|
+
*/
|
|
412
|
+
export declare function resolveScalingConfig(scaling: EcsScalingConfig | false | undefined): ResolvedScalingConfig;
|
|
413
|
+
/**
|
|
414
|
+
* ECS compute wrapper implementing IEcsCompute.
|
|
415
|
+
* Provides type-safe access to ECS-specific resources.
|
|
416
|
+
*/
|
|
417
|
+
export declare class EcsCompute extends Construct implements IEcsCompute {
|
|
418
|
+
readonly computeType: "ecs";
|
|
419
|
+
readonly connections: Connections;
|
|
420
|
+
private readonly ecsCluster;
|
|
421
|
+
constructor(scope: Construct, id: string, props: EcsComputeProps);
|
|
422
|
+
/** Get the ECS cluster. */
|
|
423
|
+
getCluster(): ICluster;
|
|
424
|
+
/** Get the Application Load Balancer if one was created. */
|
|
425
|
+
getLoadBalancer(): IApplicationLoadBalancer | undefined;
|
|
426
|
+
/** Get a specific service by name. */
|
|
427
|
+
getService(name: string): IBaseService | undefined;
|
|
428
|
+
/** Get all services in the cluster. */
|
|
429
|
+
getAllServices(): IBaseService[];
|
|
430
|
+
/** Get the security group for the cluster. */
|
|
431
|
+
getSecurityGroup(): ISecurityGroup;
|
|
432
|
+
/**
|
|
433
|
+
* Get the ALB listener if this is an ECS compute with ALB.
|
|
434
|
+
*/
|
|
435
|
+
getListener(): ApplicationListener | undefined;
|
|
436
|
+
/**
|
|
437
|
+
* Get the underlying ECS cluster construct.
|
|
438
|
+
*/
|
|
439
|
+
getEcsCluster(): EcsCluster;
|
|
440
|
+
/**
|
|
441
|
+
* Grants ecs:ExecuteCommand permission for ECS services.
|
|
442
|
+
* Uses wildcard resource because ecs:ExecuteCommand targets task ARNs
|
|
443
|
+
* which are not known until runtime (tasks are ephemeral).
|
|
444
|
+
*/
|
|
445
|
+
grantExecuteCommand(grantee: IGrantable): Grant;
|
|
446
|
+
}
|