@fjall/components-infrastructure 39.0.5 → 39.0.7
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/layers/secrets-resolver/bin/resolve-secrets.mjs +10 -1
- package/dist/lib/patterns/aws/computeEcs.d.ts +65 -21
- package/dist/lib/patterns/aws/computeEcs.js +243 -95
- package/dist/lib/patterns/aws/computeEcsTypes.d.ts +49 -25
- package/dist/lib/resources/aws/compute/ecs.d.ts +3 -0
- package/dist/lib/resources/aws/compute/ecs.js +4 -0
- package/dist/lib/resources/aws/compute/ecsLifecycleHookMigration.d.ts +32 -62
- package/dist/lib/resources/aws/compute/ecsLifecycleHookMigration.js +96 -50
- package/dist/lib/resources/aws/compute/ecsRolloutBarrier.d.ts +61 -0
- package/dist/lib/resources/aws/compute/ecsRolloutBarrier.js +185 -0
- package/dist/lib/resources/aws/compute/ecsRolloutBarrierLambda.source.cjs +475 -0
- package/dist/lib/resources/aws/compute/ecsTaskDefinition.d.ts +19 -8
- package/dist/lib/resources/aws/compute/ecsTaskDefinition.js +16 -7
- package/dist/lib/resources/aws/compute/ecsValidation.d.ts +3 -3
- package/dist/lib/resources/aws/compute/ecsValidation.js +3 -3
- package/dist/lib/resources/aws/compute/lambda.d.ts +6 -0
- package/dist/lib/resources/aws/compute/lambda.js +18 -12
- package/dist/lib/resources/aws/compute/lifecycleHookLambda.source.cjs +329 -82
- package/package.json +5 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FargateTaskDefinition, Ec2TaskDefinition, NetworkMode, type ContainerDefinition } from "aws-cdk-lib/aws-ecs";
|
|
2
2
|
import type { Construct } from "constructs";
|
|
3
3
|
import type { ILogGroup } from "aws-cdk-lib/aws-logs";
|
|
4
|
-
import { type Role } from "aws-cdk-lib/aws-iam";
|
|
4
|
+
import { type IRole, type Role } from "aws-cdk-lib/aws-iam";
|
|
5
5
|
import type { EcsConstructContext } from "./ecsContext.js";
|
|
6
6
|
import type { EcsClusterProps, EcsServiceProps, EcsCapacityProvider } from "./ecsTypes.js";
|
|
7
7
|
export { createExecutionRole, createTaskRole } from "./ecsRoles.js";
|
|
@@ -20,6 +20,17 @@ export declare function isServiceEc2(serviceProps: EcsServiceProps): boolean;
|
|
|
20
20
|
* Uses explicit path if provided, otherwise derives from app/cluster/service names.
|
|
21
21
|
*/
|
|
22
22
|
export declare function deriveSsmSecretsPath(props: EcsClusterProps, serviceName: string, explicitPath?: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* The CPU and memory a service's task runs with, its own or the defaults. A
|
|
25
|
+
* hook migration without `separateTaskDef` runs at its service's size.
|
|
26
|
+
*/
|
|
27
|
+
export declare function taskSize(props: {
|
|
28
|
+
readonly cpu?: number;
|
|
29
|
+
readonly memoryLimitMiB?: number;
|
|
30
|
+
}): {
|
|
31
|
+
cpu: number;
|
|
32
|
+
memoryLimitMiB: number;
|
|
33
|
+
};
|
|
23
34
|
export declare function createTaskDefinition(ctx: EcsConstructContext, serviceName: string, serviceProps: EcsServiceProps, executionRole: Role, taskRole: Role): FargateTaskDefinition | Ec2TaskDefinition;
|
|
24
35
|
/**
|
|
25
36
|
* Routing point for `Ec2TaskDefinition`s used by EventBridge-triggered scheduled
|
|
@@ -37,18 +48,18 @@ export declare function createScheduledTaskDefinition(scope: Construct, id: stri
|
|
|
37
48
|
networkMode?: NetworkMode;
|
|
38
49
|
}): Ec2TaskDefinition;
|
|
39
50
|
/**
|
|
40
|
-
* Routing point for `FargateTaskDefinition`
|
|
41
|
-
* migration
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* match the service task def default.
|
|
51
|
+
* Routing point for the `FargateTaskDefinition` every lifecycle-hook
|
|
52
|
+
* migration runs from. Synthesises a dedicated Fargate task definition with
|
|
53
|
+
* caller-supplied CPU/memory and the supplied execution + task roles: the
|
|
54
|
+
* migration's own with `separateTaskDef`, its service's without. Runtime
|
|
55
|
+
* platform pinned to ARM64/Linux to match the service task def default.
|
|
45
56
|
*/
|
|
46
57
|
export declare function createMigrationTaskDefinition(scope: Construct, id: string, props: {
|
|
47
58
|
family: string;
|
|
48
59
|
cpu: number;
|
|
49
60
|
memoryLimitMiB: number;
|
|
50
|
-
executionRole:
|
|
51
|
-
taskRole:
|
|
61
|
+
executionRole: IRole;
|
|
62
|
+
taskRole: IRole;
|
|
52
63
|
}): FargateTaskDefinition;
|
|
53
64
|
export declare function addContainersToTask(ctx: EcsConstructContext, serviceName: string, serviceProps: EcsServiceProps, taskDefinition: FargateTaskDefinition | Ec2TaskDefinition): {
|
|
54
65
|
containers: ContainerDefinition[];
|
|
@@ -65,9 +65,18 @@ export function deriveSsmSecretsPath(props, serviceName, explicitPath) {
|
|
|
65
65
|
service: serviceName
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* The CPU and memory a service's task runs with, its own or the defaults. A
|
|
70
|
+
* hook migration without `separateTaskDef` runs at its service's size.
|
|
71
|
+
*/
|
|
72
|
+
export function taskSize(props) {
|
|
73
|
+
return {
|
|
74
|
+
cpu: props.cpu ?? DEFAULT_FARGATE_CPU,
|
|
75
|
+
memoryLimitMiB: props.memoryLimitMiB ?? DEFAULT_FARGATE_MEMORY_MIB
|
|
76
|
+
};
|
|
77
|
+
}
|
|
68
78
|
export function createTaskDefinition(ctx, serviceName, serviceProps, executionRole, taskRole) {
|
|
69
|
-
const cpu = serviceProps
|
|
70
|
-
const memoryLimitMiB = serviceProps.memoryLimitMiB ?? DEFAULT_FARGATE_MEMORY_MIB;
|
|
79
|
+
const { cpu, memoryLimitMiB } = taskSize(serviceProps);
|
|
71
80
|
if (isServiceFargate(serviceProps)) {
|
|
72
81
|
return new FargateTaskDefinition(ctx.scope, `${serviceName}TaskDefinition`, {
|
|
73
82
|
family: `${ctx.props.clusterName}-${serviceName}`,
|
|
@@ -110,11 +119,11 @@ export function createScheduledTaskDefinition(scope, id, props) {
|
|
|
110
119
|
});
|
|
111
120
|
}
|
|
112
121
|
/**
|
|
113
|
-
* Routing point for `FargateTaskDefinition`
|
|
114
|
-
* migration
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* match the service task def default.
|
|
122
|
+
* Routing point for the `FargateTaskDefinition` every lifecycle-hook
|
|
123
|
+
* migration runs from. Synthesises a dedicated Fargate task definition with
|
|
124
|
+
* caller-supplied CPU/memory and the supplied execution + task roles: the
|
|
125
|
+
* migration's own with `separateTaskDef`, its service's without. Runtime
|
|
126
|
+
* platform pinned to ARM64/Linux to match the service task def default.
|
|
118
127
|
*/
|
|
119
128
|
export function createMigrationTaskDefinition(scope, id, props) {
|
|
120
129
|
return new FargateTaskDefinition(scope, id, {
|
|
@@ -14,9 +14,9 @@ import type { DomainConfig, EcsCapacityProvider, EcsClusterProps } from "./ecsTy
|
|
|
14
14
|
* validation here would be unreachable.
|
|
15
15
|
*
|
|
16
16
|
* Same applies to `service.awaitMigrationsFrom`: it is a patterns-layer
|
|
17
|
-
* cross-service ordering knob, resolved into a
|
|
18
|
-
* (`wireServiceMigrationDependencies` in
|
|
19
|
-
* resources layer. It is not a field on `EcsServiceProps`, so a direct
|
|
17
|
+
* cross-service ordering knob, resolved into a dependency on the named
|
|
18
|
+
* service's rollout barrier (`wireServiceMigrationDependencies` in
|
|
19
|
+
* `computeEcs.ts`) BEFORE reaching the resources layer. It is not a field on `EcsServiceProps`, so a direct
|
|
20
20
|
* `new EcsCluster(...)` consumer cannot pass it — there is no resources-layer
|
|
21
21
|
* code path to validate.
|
|
22
22
|
*
|
|
@@ -20,9 +20,9 @@ import { validateSharedEc2CapacityConfig } from "./ecsCapacityConfig.js";
|
|
|
20
20
|
* validation here would be unreachable.
|
|
21
21
|
*
|
|
22
22
|
* Same applies to `service.awaitMigrationsFrom`: it is a patterns-layer
|
|
23
|
-
* cross-service ordering knob, resolved into a
|
|
24
|
-
* (`wireServiceMigrationDependencies` in
|
|
25
|
-
* resources layer. It is not a field on `EcsServiceProps`, so a direct
|
|
23
|
+
* cross-service ordering knob, resolved into a dependency on the named
|
|
24
|
+
* service's rollout barrier (`wireServiceMigrationDependencies` in
|
|
25
|
+
* `computeEcs.ts`) BEFORE reaching the resources layer. It is not a field on `EcsServiceProps`, so a direct
|
|
26
26
|
* `new EcsCluster(...)` consumer cannot pass it — there is no resources-layer
|
|
27
27
|
* code path to validate.
|
|
28
28
|
*
|
|
@@ -82,6 +82,12 @@ export interface LambdaFunctionProps {
|
|
|
82
82
|
* async event source get no queue.
|
|
83
83
|
*/
|
|
84
84
|
asyncFailureQueue?: IQueue | false;
|
|
85
|
+
/**
|
|
86
|
+
* Whether the function emits its ARN output, and its URL output when
|
|
87
|
+
* `enableFunctionUrl` is set. Default `"emit"`. `"none"` emits neither, for
|
|
88
|
+
* a handler that is another construct's plumbing.
|
|
89
|
+
*/
|
|
90
|
+
stackOutputs?: "emit" | "none";
|
|
85
91
|
environment?: KeyValue;
|
|
86
92
|
secrets?: string[];
|
|
87
93
|
ssmSecretsPath?: string;
|
|
@@ -179,9 +179,10 @@ export class LambdaFunction extends Function {
|
|
|
179
179
|
asyncFailureQueueWired;
|
|
180
180
|
constructor(scope, id, props) {
|
|
181
181
|
validateRuntimeNotDeprecated(props.runtime, id);
|
|
182
|
-
//
|
|
183
|
-
// enum of the same name and `appBackupTier`
|
|
184
|
-
|
|
182
|
+
// These are Fjall props, not CDK ones: `tracing` collides with the CDK
|
|
183
|
+
// enum of the same name, and `appBackupTier` and `stackOutputs` are
|
|
184
|
+
// unknown to CDK.
|
|
185
|
+
const { tracing, appBackupTier, stackOutputs, ...cdkProps } = props;
|
|
185
186
|
const vpcSubnets = props.vpc
|
|
186
187
|
? { subnetType: resolvePrivateSubnetType(props.vpc) }
|
|
187
188
|
: undefined;
|
|
@@ -219,6 +220,7 @@ export class LambdaFunction extends Function {
|
|
|
219
220
|
this.addSecretsSupport(props.secrets, props.ssmSecretsPath, props.secretsImport, props.appName, props.functionName, props.architecture);
|
|
220
221
|
// Sanitise id for CloudFormation output keys (must be alphanumeric)
|
|
221
222
|
const outputName = toPascalCase(id);
|
|
223
|
+
const emitOutputs = (stackOutputs ?? "emit") === "emit";
|
|
222
224
|
if (props.enableFunctionUrl) {
|
|
223
225
|
const authType = props.functionUrlAuthType ?? FunctionUrlAuthType.AWS_IAM;
|
|
224
226
|
const functionUrl = this.addFunctionUrl({
|
|
@@ -234,17 +236,21 @@ export class LambdaFunction extends Function {
|
|
|
234
236
|
`concurrency with it — set reservedConcurrentExecutions to cap it.`);
|
|
235
237
|
}
|
|
236
238
|
this.functionUrlValue = functionUrl.url;
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
239
|
+
if (emitOutputs) {
|
|
240
|
+
new CfnOutput(this, `${outputName}FunctionUrl`, {
|
|
241
|
+
key: `${outputName}FunctionUrl`,
|
|
242
|
+
value: functionUrl.url,
|
|
243
|
+
description: `${id} Function URL`
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (emitOutputs) {
|
|
248
|
+
new CfnOutput(this, `${outputName}FunctionArn`, {
|
|
249
|
+
key: `${outputName}FunctionArn`,
|
|
250
|
+
value: this.functionArn,
|
|
251
|
+
description: `${id} Function ARN`
|
|
241
252
|
});
|
|
242
253
|
}
|
|
243
|
-
new CfnOutput(this, `${outputName}FunctionArn`, {
|
|
244
|
-
key: `${outputName}FunctionArn`,
|
|
245
|
-
value: this.functionArn,
|
|
246
|
-
description: `${id} Function ARN`
|
|
247
|
-
});
|
|
248
254
|
if (props.alertsTopic && props.alarms !== false) {
|
|
249
255
|
const timeoutSeconds = props.timeout ?? LAMBDA_DEFAULT_TIMEOUT_SECONDS;
|
|
250
256
|
createLambdaAlarms({
|