@codedazur/cdk-docker-cluster 1.1.0 → 1.1.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/CHANGELOG.md +20 -0
- package/dist/index.d.mts +33 -16
- package/dist/index.d.ts +33 -16
- package/dist/index.js +50 -44
- package/dist/index.mjs +50 -42
- package/eslint.config.ts +5 -0
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @codedazur/cdk-docker-cluster
|
|
2
2
|
|
|
3
|
+
## 1.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`2734c9d`](https://github.com/codedazur/toolkit/commit/2734c9d2f1a6fbdbae8e7d676b1e06437200df23) Thanks [@thijsdaniels](https://github.com/thijsdaniels)! - Props are now marked as readonly.
|
|
8
|
+
|
|
9
|
+
- [`62b823b`](https://github.com/codedazur/toolkit/commit/62b823bfb366f0b7b037b0485aafe7084fe3743f) Thanks [@thijsdaniels](https://github.com/thijsdaniels)! - Following a CDK update, the cache policy and origin request policy are now created as constructs instead of using a simple object.
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`2734c9d`](https://github.com/codedazur/toolkit/commit/2734c9d2f1a6fbdbae8e7d676b1e06437200df23)]:
|
|
12
|
+
- @codedazur/cdk-site-distribution@1.0.2
|
|
13
|
+
|
|
14
|
+
## 1.1.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`b24894a`](https://github.com/codedazur/toolkit/commit/b24894a2de01e596669c2b5aca51bc0b28533106) Thanks [@thijsdaniels](https://github.com/thijsdaniels)! - Mark the package as side-effect-free for tree shaking.
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`b24894a`](https://github.com/codedazur/toolkit/commit/b24894a2de01e596669c2b5aca51bc0b28533106)]:
|
|
21
|
+
- @codedazur/cdk-site-distribution@1.0.1
|
|
22
|
+
|
|
3
23
|
## 1.1.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as aws_cdk_lib_aws_cloudfront from 'aws-cdk-lib/aws-cloudfront';
|
|
1
2
|
import * as aws_cdk_lib_aws_ecs from 'aws-cdk-lib/aws-ecs';
|
|
2
3
|
import { ContainerImage, Secret, ScalableTaskCount } from 'aws-cdk-lib/aws-ecs';
|
|
3
4
|
import { SiteDistributionProps, SiteDistribution } from '@codedazur/cdk-site-distribution';
|
|
@@ -6,16 +7,17 @@ import { ApplicationLoadBalancedFargateServiceProps, ApplicationLoadBalancedFarg
|
|
|
6
7
|
import { Construct } from 'constructs';
|
|
7
8
|
|
|
8
9
|
interface DockerClusterProps {
|
|
9
|
-
source: string | SourceProps | ContainerImage;
|
|
10
|
-
service?:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
readonly source: string | SourceProps | ContainerImage;
|
|
11
|
+
readonly service?: ServiceProps;
|
|
12
|
+
readonly distribution?: Omit<SiteDistributionProps, "origin">;
|
|
13
|
+
}
|
|
14
|
+
interface ServiceProps {
|
|
15
|
+
readonly port?: number;
|
|
16
|
+
readonly tasks?: number | AutoScalingConfig;
|
|
17
|
+
readonly cpu?: ApplicationLoadBalancedFargateServiceProps["cpu"];
|
|
18
|
+
readonly memory?: ApplicationLoadBalancedFargateServiceProps["memoryLimitMiB"];
|
|
19
|
+
readonly environment?: Record<string, string>;
|
|
20
|
+
readonly secrets?: Record<string, Secret>;
|
|
19
21
|
}
|
|
20
22
|
interface AutoScalingConfig {
|
|
21
23
|
/**
|
|
@@ -52,11 +54,11 @@ interface AutoScalingConfig {
|
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
interface SourceProps {
|
|
55
|
-
directory: string;
|
|
56
|
-
exclude?: string[];
|
|
57
|
-
file?: string;
|
|
58
|
-
arguments?: Record<string, string>;
|
|
59
|
-
secrets?: Record<string, string>;
|
|
57
|
+
readonly directory: string;
|
|
58
|
+
readonly exclude?: string[];
|
|
59
|
+
readonly file?: string;
|
|
60
|
+
readonly arguments?: Record<string, string>;
|
|
61
|
+
readonly secrets?: Record<string, string>;
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
62
64
|
* An Docker cluster on a load balanced Fargate service on EC2, using an image
|
|
@@ -76,7 +78,22 @@ declare class DockerCluster extends Construct {
|
|
|
76
78
|
protected createService(): ApplicationLoadBalancedFargateService;
|
|
77
79
|
protected createAutoScaling(service: ApplicationLoadBalancedFargateService): ScalableTaskCount | undefined;
|
|
78
80
|
protected createSiteDistribution(): SiteDistribution;
|
|
81
|
+
/**
|
|
82
|
+
* The managed "UseOriginCacheControlHeaders-QueryStrings" cache policy, which
|
|
83
|
+
* is designed for use with an origin that sends Cache-Control headers with
|
|
84
|
+
* the object, which is recommended for use with an Application Load Balancer,
|
|
85
|
+
* and includes query strings in the cache key.
|
|
86
|
+
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html#managed-cache-policy-origin-cache-headers-query-strings
|
|
87
|
+
*/
|
|
88
|
+
protected createCachePolicy(): aws_cdk_lib_aws_cloudfront.ICachePolicy;
|
|
89
|
+
/**
|
|
90
|
+
* The managed "AllViewer" origin request policy, which includes all values
|
|
91
|
+
* (query strings, headers, and cookies) in the viewer request, which is
|
|
92
|
+
* recommended for use with an Application Load Balancer endpoint.
|
|
93
|
+
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-origin-request-policies.html#managed-origin-request-policy-all-viewer
|
|
94
|
+
*/
|
|
95
|
+
protected createOriginRequestPolicy(): aws_cdk_lib_aws_cloudfront.IOriginRequestPolicy;
|
|
79
96
|
protected getOutputDirectory(): string;
|
|
80
97
|
}
|
|
81
98
|
|
|
82
|
-
export { DockerCluster, type DockerClusterProps };
|
|
99
|
+
export { DockerCluster, type DockerClusterProps, type ServiceProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as aws_cdk_lib_aws_cloudfront from 'aws-cdk-lib/aws-cloudfront';
|
|
1
2
|
import * as aws_cdk_lib_aws_ecs from 'aws-cdk-lib/aws-ecs';
|
|
2
3
|
import { ContainerImage, Secret, ScalableTaskCount } from 'aws-cdk-lib/aws-ecs';
|
|
3
4
|
import { SiteDistributionProps, SiteDistribution } from '@codedazur/cdk-site-distribution';
|
|
@@ -6,16 +7,17 @@ import { ApplicationLoadBalancedFargateServiceProps, ApplicationLoadBalancedFarg
|
|
|
6
7
|
import { Construct } from 'constructs';
|
|
7
8
|
|
|
8
9
|
interface DockerClusterProps {
|
|
9
|
-
source: string | SourceProps | ContainerImage;
|
|
10
|
-
service?:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
readonly source: string | SourceProps | ContainerImage;
|
|
11
|
+
readonly service?: ServiceProps;
|
|
12
|
+
readonly distribution?: Omit<SiteDistributionProps, "origin">;
|
|
13
|
+
}
|
|
14
|
+
interface ServiceProps {
|
|
15
|
+
readonly port?: number;
|
|
16
|
+
readonly tasks?: number | AutoScalingConfig;
|
|
17
|
+
readonly cpu?: ApplicationLoadBalancedFargateServiceProps["cpu"];
|
|
18
|
+
readonly memory?: ApplicationLoadBalancedFargateServiceProps["memoryLimitMiB"];
|
|
19
|
+
readonly environment?: Record<string, string>;
|
|
20
|
+
readonly secrets?: Record<string, Secret>;
|
|
19
21
|
}
|
|
20
22
|
interface AutoScalingConfig {
|
|
21
23
|
/**
|
|
@@ -52,11 +54,11 @@ interface AutoScalingConfig {
|
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
interface SourceProps {
|
|
55
|
-
directory: string;
|
|
56
|
-
exclude?: string[];
|
|
57
|
-
file?: string;
|
|
58
|
-
arguments?: Record<string, string>;
|
|
59
|
-
secrets?: Record<string, string>;
|
|
57
|
+
readonly directory: string;
|
|
58
|
+
readonly exclude?: string[];
|
|
59
|
+
readonly file?: string;
|
|
60
|
+
readonly arguments?: Record<string, string>;
|
|
61
|
+
readonly secrets?: Record<string, string>;
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
62
64
|
* An Docker cluster on a load balanced Fargate service on EC2, using an image
|
|
@@ -76,7 +78,22 @@ declare class DockerCluster extends Construct {
|
|
|
76
78
|
protected createService(): ApplicationLoadBalancedFargateService;
|
|
77
79
|
protected createAutoScaling(service: ApplicationLoadBalancedFargateService): ScalableTaskCount | undefined;
|
|
78
80
|
protected createSiteDistribution(): SiteDistribution;
|
|
81
|
+
/**
|
|
82
|
+
* The managed "UseOriginCacheControlHeaders-QueryStrings" cache policy, which
|
|
83
|
+
* is designed for use with an origin that sends Cache-Control headers with
|
|
84
|
+
* the object, which is recommended for use with an Application Load Balancer,
|
|
85
|
+
* and includes query strings in the cache key.
|
|
86
|
+
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html#managed-cache-policy-origin-cache-headers-query-strings
|
|
87
|
+
*/
|
|
88
|
+
protected createCachePolicy(): aws_cdk_lib_aws_cloudfront.ICachePolicy;
|
|
89
|
+
/**
|
|
90
|
+
* The managed "AllViewer" origin request policy, which includes all values
|
|
91
|
+
* (query strings, headers, and cookies) in the viewer request, which is
|
|
92
|
+
* recommended for use with an Application Load Balancer endpoint.
|
|
93
|
+
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-origin-request-policies.html#managed-origin-request-policy-all-viewer
|
|
94
|
+
*/
|
|
95
|
+
protected createOriginRequestPolicy(): aws_cdk_lib_aws_cloudfront.IOriginRequestPolicy;
|
|
79
96
|
protected getOutputDirectory(): string;
|
|
80
97
|
}
|
|
81
98
|
|
|
82
|
-
export { DockerCluster, type DockerClusterProps };
|
|
99
|
+
export { DockerCluster, type DockerClusterProps, type ServiceProps };
|
package/dist/index.js
CHANGED
|
@@ -18,11 +18,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
DockerCluster: () => DockerCluster
|
|
24
24
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
26
|
|
|
27
27
|
// src/constructs/DockerCluster.ts
|
|
28
28
|
var import_cdk_site_distribution = require("@codedazur/cdk-site-distribution");
|
|
@@ -60,18 +60,17 @@ var DockerCluster = class extends import_constructs.Construct {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
createService() {
|
|
63
|
-
|
|
64
|
-
const desiredTasks = typeof ((_a = this.props.service) == null ? void 0 : _a.tasks) === "number" ? (_b = this.props.service) == null ? void 0 : _b.tasks : (_d = (_c = this.props.service) == null ? void 0 : _c.tasks) == null ? void 0 : _d.minimum;
|
|
63
|
+
const desiredTasks = typeof this.props.service?.tasks === "number" ? this.props.service?.tasks : this.props.service?.tasks?.minimum;
|
|
65
64
|
const service = new import_aws_ecs_patterns.ApplicationLoadBalancedFargateService(this, "Service", {
|
|
66
65
|
cluster: new import_aws_ecs.Cluster(this, "Cluster"),
|
|
67
|
-
cpu:
|
|
68
|
-
memoryLimitMiB:
|
|
66
|
+
cpu: this.props.service?.cpu,
|
|
67
|
+
memoryLimitMiB: this.props.service?.memory,
|
|
69
68
|
desiredCount: desiredTasks,
|
|
70
69
|
taskImageOptions: {
|
|
71
70
|
image: this.image,
|
|
72
|
-
containerPort:
|
|
73
|
-
environment:
|
|
74
|
-
secrets:
|
|
71
|
+
containerPort: this.props.service?.port,
|
|
72
|
+
environment: this.props.service?.environment,
|
|
73
|
+
secrets: this.props.service?.secrets
|
|
75
74
|
},
|
|
76
75
|
circuitBreaker: {
|
|
77
76
|
enable: true,
|
|
@@ -81,59 +80,66 @@ var DockerCluster = class extends import_constructs.Construct {
|
|
|
81
80
|
return service;
|
|
82
81
|
}
|
|
83
82
|
createAutoScaling(service) {
|
|
84
|
-
|
|
85
|
-
if (typeof ((_a = this.props.service) == null ? void 0 : _a.tasks) !== "object") {
|
|
83
|
+
if (typeof this.props.service?.tasks !== "object") {
|
|
86
84
|
return;
|
|
87
85
|
}
|
|
88
86
|
const autoScaling = service.service.autoScaleTaskCount({
|
|
89
|
-
minCapacity:
|
|
90
|
-
maxCapacity:
|
|
87
|
+
minCapacity: this.props.service?.tasks.minimum,
|
|
88
|
+
maxCapacity: this.props.service?.tasks.maximum
|
|
91
89
|
});
|
|
92
90
|
autoScaling.scaleOnMemoryUtilization("MemoryScaling", {
|
|
93
|
-
targetUtilizationPercent:
|
|
94
|
-
scaleInCooldown:
|
|
95
|
-
scaleOutCooldown:
|
|
91
|
+
targetUtilizationPercent: this.props.service?.tasks.threshold?.memory ?? 75,
|
|
92
|
+
scaleInCooldown: this.props.service?.tasks.cooldown?.in,
|
|
93
|
+
scaleOutCooldown: this.props.service?.tasks.cooldown?.out
|
|
96
94
|
});
|
|
97
95
|
autoScaling.scaleOnCpuUtilization("CpuScaling", {
|
|
98
|
-
targetUtilizationPercent:
|
|
99
|
-
scaleInCooldown:
|
|
100
|
-
scaleOutCooldown:
|
|
96
|
+
targetUtilizationPercent: this.props.service?.tasks.threshold?.cpu ?? 75,
|
|
97
|
+
scaleInCooldown: this.props.service?.tasks.cooldown?.in,
|
|
98
|
+
scaleOutCooldown: this.props.service?.tasks.cooldown?.out
|
|
101
99
|
});
|
|
102
100
|
return autoScaling;
|
|
103
101
|
}
|
|
104
102
|
createSiteDistribution() {
|
|
103
|
+
const { cachePolicy, originRequestPolicy, ...distribution } = this.props.distribution ?? {};
|
|
105
104
|
return new import_cdk_site_distribution.SiteDistribution(this, "Distribution", {
|
|
106
105
|
allowedMethods: import_aws_cloudfront.AllowedMethods.ALLOW_ALL,
|
|
107
|
-
cachePolicy:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
* which is designed for use with an origin that sends Cache-Control
|
|
111
|
-
* headers with the object, which is recommended for use with an
|
|
112
|
-
* Application Load Balancer, and includes query strings in the cache
|
|
113
|
-
* key.
|
|
114
|
-
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html#managed-cache-policy-origin-cache-headers-query-strings
|
|
115
|
-
*/
|
|
116
|
-
cachePolicyId: "4cc15a8a-d715-48a4-82b8-cc0b614638fe"
|
|
117
|
-
},
|
|
118
|
-
originRequestPolicy: {
|
|
119
|
-
/**
|
|
120
|
-
* The managed "AllViewer" origin request policy, which includes all
|
|
121
|
-
* values (query strings, headers, and cookies) in the viewer request,
|
|
122
|
-
* which is recommended for use with an Application Load Balancer
|
|
123
|
-
* endpoint.
|
|
124
|
-
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-origin-request-policies.html#managed-origin-request-policy-all-viewer
|
|
125
|
-
*/
|
|
126
|
-
originRequestPolicyId: "216adef6-5c7f-47e4-b989-5492eafa07d3"
|
|
127
|
-
},
|
|
128
|
-
...this.props.distribution,
|
|
106
|
+
cachePolicy: cachePolicy ?? this.createCachePolicy(),
|
|
107
|
+
originRequestPolicy: originRequestPolicy ?? this.createOriginRequestPolicy(),
|
|
108
|
+
...distribution,
|
|
129
109
|
origin: new import_aws_cloudfront_origins.LoadBalancerV2Origin(this.service.loadBalancer, {
|
|
130
110
|
protocolPolicy: import_aws_cloudfront.OriginProtocolPolicy.HTTP_ONLY
|
|
131
111
|
})
|
|
132
112
|
});
|
|
133
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* The managed "UseOriginCacheControlHeaders-QueryStrings" cache policy, which
|
|
116
|
+
* is designed for use with an origin that sends Cache-Control headers with
|
|
117
|
+
* the object, which is recommended for use with an Application Load Balancer,
|
|
118
|
+
* and includes query strings in the cache key.
|
|
119
|
+
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html#managed-cache-policy-origin-cache-headers-query-strings
|
|
120
|
+
*/
|
|
121
|
+
createCachePolicy() {
|
|
122
|
+
return import_aws_cloudfront.CachePolicy.fromCachePolicyId(
|
|
123
|
+
this,
|
|
124
|
+
"CachePolicy",
|
|
125
|
+
"4cc15a8a-d715-48a4-82b8-cc0b614638fe" /* UseOriginCacheControlHeadersQueryStrings */
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The managed "AllViewer" origin request policy, which includes all values
|
|
130
|
+
* (query strings, headers, and cookies) in the viewer request, which is
|
|
131
|
+
* recommended for use with an Application Load Balancer endpoint.
|
|
132
|
+
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-origin-request-policies.html#managed-origin-request-policy-all-viewer
|
|
133
|
+
*/
|
|
134
|
+
createOriginRequestPolicy() {
|
|
135
|
+
return import_aws_cloudfront.OriginRequestPolicy.fromOriginRequestPolicyId(
|
|
136
|
+
this,
|
|
137
|
+
"OriginRequestPolicy",
|
|
138
|
+
"216adef6-5c7f-47e4-b989-5492eafa07d3" /* AllViewer */
|
|
139
|
+
);
|
|
140
|
+
}
|
|
134
141
|
getOutputDirectory() {
|
|
135
|
-
|
|
136
|
-
return (_b = (_a = import_aws_cdk_lib.App.of(this)) == null ? void 0 : _a.outdir) != null ? _b : "cdk.out";
|
|
142
|
+
return import_aws_cdk_lib.App.of(this)?.outdir ?? "cdk.out";
|
|
137
143
|
}
|
|
138
144
|
};
|
|
139
145
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,9 @@ import {
|
|
|
5
5
|
import { App } from "aws-cdk-lib";
|
|
6
6
|
import {
|
|
7
7
|
AllowedMethods,
|
|
8
|
-
|
|
8
|
+
CachePolicy,
|
|
9
|
+
OriginProtocolPolicy,
|
|
10
|
+
OriginRequestPolicy
|
|
9
11
|
} from "aws-cdk-lib/aws-cloudfront";
|
|
10
12
|
import { LoadBalancerV2Origin } from "aws-cdk-lib/aws-cloudfront-origins";
|
|
11
13
|
import { Platform } from "aws-cdk-lib/aws-ecr-assets";
|
|
@@ -44,18 +46,17 @@ var DockerCluster = class extends Construct {
|
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
48
|
createService() {
|
|
47
|
-
|
|
48
|
-
const desiredTasks = typeof ((_a = this.props.service) == null ? void 0 : _a.tasks) === "number" ? (_b = this.props.service) == null ? void 0 : _b.tasks : (_d = (_c = this.props.service) == null ? void 0 : _c.tasks) == null ? void 0 : _d.minimum;
|
|
49
|
+
const desiredTasks = typeof this.props.service?.tasks === "number" ? this.props.service?.tasks : this.props.service?.tasks?.minimum;
|
|
49
50
|
const service = new ApplicationLoadBalancedFargateService(this, "Service", {
|
|
50
51
|
cluster: new Cluster(this, "Cluster"),
|
|
51
|
-
cpu:
|
|
52
|
-
memoryLimitMiB:
|
|
52
|
+
cpu: this.props.service?.cpu,
|
|
53
|
+
memoryLimitMiB: this.props.service?.memory,
|
|
53
54
|
desiredCount: desiredTasks,
|
|
54
55
|
taskImageOptions: {
|
|
55
56
|
image: this.image,
|
|
56
|
-
containerPort:
|
|
57
|
-
environment:
|
|
58
|
-
secrets:
|
|
57
|
+
containerPort: this.props.service?.port,
|
|
58
|
+
environment: this.props.service?.environment,
|
|
59
|
+
secrets: this.props.service?.secrets
|
|
59
60
|
},
|
|
60
61
|
circuitBreaker: {
|
|
61
62
|
enable: true,
|
|
@@ -65,59 +66,66 @@ var DockerCluster = class extends Construct {
|
|
|
65
66
|
return service;
|
|
66
67
|
}
|
|
67
68
|
createAutoScaling(service) {
|
|
68
|
-
|
|
69
|
-
if (typeof ((_a = this.props.service) == null ? void 0 : _a.tasks) !== "object") {
|
|
69
|
+
if (typeof this.props.service?.tasks !== "object") {
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
const autoScaling = service.service.autoScaleTaskCount({
|
|
73
|
-
minCapacity:
|
|
74
|
-
maxCapacity:
|
|
73
|
+
minCapacity: this.props.service?.tasks.minimum,
|
|
74
|
+
maxCapacity: this.props.service?.tasks.maximum
|
|
75
75
|
});
|
|
76
76
|
autoScaling.scaleOnMemoryUtilization("MemoryScaling", {
|
|
77
|
-
targetUtilizationPercent:
|
|
78
|
-
scaleInCooldown:
|
|
79
|
-
scaleOutCooldown:
|
|
77
|
+
targetUtilizationPercent: this.props.service?.tasks.threshold?.memory ?? 75,
|
|
78
|
+
scaleInCooldown: this.props.service?.tasks.cooldown?.in,
|
|
79
|
+
scaleOutCooldown: this.props.service?.tasks.cooldown?.out
|
|
80
80
|
});
|
|
81
81
|
autoScaling.scaleOnCpuUtilization("CpuScaling", {
|
|
82
|
-
targetUtilizationPercent:
|
|
83
|
-
scaleInCooldown:
|
|
84
|
-
scaleOutCooldown:
|
|
82
|
+
targetUtilizationPercent: this.props.service?.tasks.threshold?.cpu ?? 75,
|
|
83
|
+
scaleInCooldown: this.props.service?.tasks.cooldown?.in,
|
|
84
|
+
scaleOutCooldown: this.props.service?.tasks.cooldown?.out
|
|
85
85
|
});
|
|
86
86
|
return autoScaling;
|
|
87
87
|
}
|
|
88
88
|
createSiteDistribution() {
|
|
89
|
+
const { cachePolicy, originRequestPolicy, ...distribution } = this.props.distribution ?? {};
|
|
89
90
|
return new SiteDistribution(this, "Distribution", {
|
|
90
91
|
allowedMethods: AllowedMethods.ALLOW_ALL,
|
|
91
|
-
cachePolicy:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
* which is designed for use with an origin that sends Cache-Control
|
|
95
|
-
* headers with the object, which is recommended for use with an
|
|
96
|
-
* Application Load Balancer, and includes query strings in the cache
|
|
97
|
-
* key.
|
|
98
|
-
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html#managed-cache-policy-origin-cache-headers-query-strings
|
|
99
|
-
*/
|
|
100
|
-
cachePolicyId: "4cc15a8a-d715-48a4-82b8-cc0b614638fe"
|
|
101
|
-
},
|
|
102
|
-
originRequestPolicy: {
|
|
103
|
-
/**
|
|
104
|
-
* The managed "AllViewer" origin request policy, which includes all
|
|
105
|
-
* values (query strings, headers, and cookies) in the viewer request,
|
|
106
|
-
* which is recommended for use with an Application Load Balancer
|
|
107
|
-
* endpoint.
|
|
108
|
-
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-origin-request-policies.html#managed-origin-request-policy-all-viewer
|
|
109
|
-
*/
|
|
110
|
-
originRequestPolicyId: "216adef6-5c7f-47e4-b989-5492eafa07d3"
|
|
111
|
-
},
|
|
112
|
-
...this.props.distribution,
|
|
92
|
+
cachePolicy: cachePolicy ?? this.createCachePolicy(),
|
|
93
|
+
originRequestPolicy: originRequestPolicy ?? this.createOriginRequestPolicy(),
|
|
94
|
+
...distribution,
|
|
113
95
|
origin: new LoadBalancerV2Origin(this.service.loadBalancer, {
|
|
114
96
|
protocolPolicy: OriginProtocolPolicy.HTTP_ONLY
|
|
115
97
|
})
|
|
116
98
|
});
|
|
117
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* The managed "UseOriginCacheControlHeaders-QueryStrings" cache policy, which
|
|
102
|
+
* is designed for use with an origin that sends Cache-Control headers with
|
|
103
|
+
* the object, which is recommended for use with an Application Load Balancer,
|
|
104
|
+
* and includes query strings in the cache key.
|
|
105
|
+
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html#managed-cache-policy-origin-cache-headers-query-strings
|
|
106
|
+
*/
|
|
107
|
+
createCachePolicy() {
|
|
108
|
+
return CachePolicy.fromCachePolicyId(
|
|
109
|
+
this,
|
|
110
|
+
"CachePolicy",
|
|
111
|
+
"4cc15a8a-d715-48a4-82b8-cc0b614638fe" /* UseOriginCacheControlHeadersQueryStrings */
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The managed "AllViewer" origin request policy, which includes all values
|
|
116
|
+
* (query strings, headers, and cookies) in the viewer request, which is
|
|
117
|
+
* recommended for use with an Application Load Balancer endpoint.
|
|
118
|
+
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-origin-request-policies.html#managed-origin-request-policy-all-viewer
|
|
119
|
+
*/
|
|
120
|
+
createOriginRequestPolicy() {
|
|
121
|
+
return OriginRequestPolicy.fromOriginRequestPolicyId(
|
|
122
|
+
this,
|
|
123
|
+
"OriginRequestPolicy",
|
|
124
|
+
"216adef6-5c7f-47e4-b989-5492eafa07d3" /* AllViewer */
|
|
125
|
+
);
|
|
126
|
+
}
|
|
118
127
|
getOutputDirectory() {
|
|
119
|
-
|
|
120
|
-
return (_b = (_a = App.of(this)) == null ? void 0 : _a.outdir) != null ? _b : "cdk.out";
|
|
128
|
+
return App.of(this)?.outdir ?? "cdk.out";
|
|
121
129
|
}
|
|
122
130
|
};
|
|
123
131
|
export {
|
package/eslint.config.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codedazur/cdk-docker-cluster",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"main": ".dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"license": "MIT",
|
|
17
|
+
"sideEffects": false,
|
|
17
18
|
"scripts": {
|
|
18
19
|
"develop": "tsup src/index.ts --format esm,cjs --dts --watch",
|
|
19
20
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
20
21
|
"audit": "npm audit --omit dev --audit-level high",
|
|
21
|
-
"lint": "
|
|
22
|
+
"lint": "eslint .",
|
|
22
23
|
"types": "tsc --noEmit",
|
|
23
24
|
"test": "vitest run --passWithNoTests"
|
|
24
25
|
},
|
|
@@ -27,12 +28,12 @@
|
|
|
27
28
|
"constructs": ">=10"
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"@codedazur/cdk-site-distribution": "^1.0.
|
|
31
|
+
"@codedazur/cdk-site-distribution": "^1.0.2"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"@types/node": "^
|
|
34
|
-
"aws-cdk-lib": "^2.
|
|
35
|
-
"constructs": "^10.
|
|
36
|
-
"esbuild": "^0.
|
|
34
|
+
"@types/node": "^25.0.3",
|
|
35
|
+
"aws-cdk-lib": "^2.233.0",
|
|
36
|
+
"constructs": "^10.4.4",
|
|
37
|
+
"esbuild": "^0.27.2"
|
|
37
38
|
}
|
|
38
39
|
}
|