@codedazur/cdk-docker-cluster 0.5.2 → 0.6.0
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 +6 -0
- package/README.md +15 -7
- package/dist/index.d.mts +11 -7
- package/dist/index.d.ts +11 -7
- package/dist/index.js +10 -8
- package/dist/index.mjs +14 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @codedazur/cdk-docker-cluster
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`4bbe16d`](https://github.com/codedazur/toolkit/commit/4bbe16ddf6880fa33649d70f45144e8c7d7c82de) Thanks [@thijsdaniels](https://github.com/thijsdaniels)! - Container environment and secrets are now supported.
|
|
8
|
+
|
|
3
9
|
## 0.5.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -9,7 +9,9 @@ The minimum needed to get a DockerCluster up and running is a path to the source
|
|
|
9
9
|
```ts
|
|
10
10
|
new DockerCluster(this, "DockerCluster", {
|
|
11
11
|
source: "../path/to/source",
|
|
12
|
-
|
|
12
|
+
service: {
|
|
13
|
+
port: 3000,
|
|
14
|
+
},
|
|
13
15
|
});
|
|
14
16
|
```
|
|
15
17
|
|
|
@@ -94,9 +96,12 @@ The `DockerCluster` construct supports both vertical and horizontal scaling.
|
|
|
94
96
|
```ts
|
|
95
97
|
new DockerCluster(this, "DockerCluster", {
|
|
96
98
|
// ...
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
service: {
|
|
100
|
+
// ...
|
|
101
|
+
cpu: 1024, // 1vCPU
|
|
102
|
+
memory: 4096, // 4GB
|
|
103
|
+
tasks: 3,
|
|
104
|
+
},
|
|
100
105
|
});
|
|
101
106
|
```
|
|
102
107
|
|
|
@@ -105,9 +110,12 @@ Horizontal auto-scaling is also supported.
|
|
|
105
110
|
```ts
|
|
106
111
|
new DockerCluster(this, "DockerCluster", {
|
|
107
112
|
// ...
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
113
|
+
service: {
|
|
114
|
+
// ...
|
|
115
|
+
tasks: {
|
|
116
|
+
minimum: 1,
|
|
117
|
+
maximum: 5,
|
|
118
|
+
},
|
|
111
119
|
},
|
|
112
120
|
});
|
|
113
121
|
```
|
package/dist/index.d.mts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import * as aws_cdk_lib_aws_ecs from 'aws-cdk-lib/aws-ecs';
|
|
2
|
-
import { ContainerImage } from 'aws-cdk-lib/aws-ecs';
|
|
2
|
+
import { ContainerImage, Secret } from 'aws-cdk-lib/aws-ecs';
|
|
3
3
|
import { SiteDistributionProps, SiteDistribution } from '@codedazur/cdk-site-distribution';
|
|
4
4
|
import { ApplicationLoadBalancedFargateServiceProps, ApplicationLoadBalancedFargateService } from 'aws-cdk-lib/aws-ecs-patterns';
|
|
5
5
|
import { Construct } from 'constructs';
|
|
6
6
|
|
|
7
7
|
interface DockerClusterProps {
|
|
8
8
|
source: string | SourceProps | ContainerImage;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
service?: {
|
|
10
|
+
port?: number;
|
|
11
|
+
tasks?: number | {
|
|
12
|
+
minimum: number;
|
|
13
|
+
maximum: number;
|
|
14
|
+
};
|
|
15
|
+
cpu?: ApplicationLoadBalancedFargateServiceProps["cpu"];
|
|
16
|
+
memory?: ApplicationLoadBalancedFargateServiceProps["memoryLimitMiB"];
|
|
17
|
+
environment?: Record<string, string>;
|
|
18
|
+
secrets?: Record<string, Secret>;
|
|
13
19
|
};
|
|
14
|
-
cpu?: ApplicationLoadBalancedFargateServiceProps["cpu"];
|
|
15
|
-
memory?: ApplicationLoadBalancedFargateServiceProps["memoryLimitMiB"];
|
|
16
20
|
distribution?: Omit<SiteDistributionProps, "origin">;
|
|
17
21
|
}
|
|
18
22
|
interface SourceProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import * as aws_cdk_lib_aws_ecs from 'aws-cdk-lib/aws-ecs';
|
|
2
|
-
import { ContainerImage } from 'aws-cdk-lib/aws-ecs';
|
|
2
|
+
import { ContainerImage, Secret } from 'aws-cdk-lib/aws-ecs';
|
|
3
3
|
import { SiteDistributionProps, SiteDistribution } from '@codedazur/cdk-site-distribution';
|
|
4
4
|
import { ApplicationLoadBalancedFargateServiceProps, ApplicationLoadBalancedFargateService } from 'aws-cdk-lib/aws-ecs-patterns';
|
|
5
5
|
import { Construct } from 'constructs';
|
|
6
6
|
|
|
7
7
|
interface DockerClusterProps {
|
|
8
8
|
source: string | SourceProps | ContainerImage;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
service?: {
|
|
10
|
+
port?: number;
|
|
11
|
+
tasks?: number | {
|
|
12
|
+
minimum: number;
|
|
13
|
+
maximum: number;
|
|
14
|
+
};
|
|
15
|
+
cpu?: ApplicationLoadBalancedFargateServiceProps["cpu"];
|
|
16
|
+
memory?: ApplicationLoadBalancedFargateServiceProps["memoryLimitMiB"];
|
|
17
|
+
environment?: Record<string, string>;
|
|
18
|
+
secrets?: Record<string, Secret>;
|
|
13
19
|
};
|
|
14
|
-
cpu?: ApplicationLoadBalancedFargateServiceProps["cpu"];
|
|
15
|
-
memory?: ApplicationLoadBalancedFargateServiceProps["memoryLimitMiB"];
|
|
16
20
|
distribution?: Omit<SiteDistributionProps, "origin">;
|
|
17
21
|
}
|
|
18
22
|
interface SourceProps {
|
package/dist/index.js
CHANGED
|
@@ -57,16 +57,18 @@ var DockerCluster = class extends import_constructs.Construct {
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
createService() {
|
|
60
|
-
var _a;
|
|
61
|
-
const desiredTasks = typeof this.props.tasks === "number" ? this.props.tasks : (
|
|
60
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
61
|
+
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;
|
|
62
62
|
const service = new import_aws_ecs_patterns.ApplicationLoadBalancedFargateService(this, "Service", {
|
|
63
63
|
cluster: new import_aws_ecs.Cluster(this, "Cluster"),
|
|
64
|
-
cpu: this.props.cpu,
|
|
65
|
-
memoryLimitMiB: this.props.memory,
|
|
64
|
+
cpu: (_e = this.props.service) == null ? void 0 : _e.cpu,
|
|
65
|
+
memoryLimitMiB: (_f = this.props.service) == null ? void 0 : _f.memory,
|
|
66
66
|
desiredCount: desiredTasks,
|
|
67
67
|
taskImageOptions: {
|
|
68
68
|
image: this.image,
|
|
69
|
-
containerPort: this.props.port
|
|
69
|
+
containerPort: (_g = this.props.service) == null ? void 0 : _g.port,
|
|
70
|
+
environment: (_h = this.props.service) == null ? void 0 : _h.environment,
|
|
71
|
+
secrets: (_i = this.props.service) == null ? void 0 : _i.secrets
|
|
70
72
|
},
|
|
71
73
|
circuitBreaker: {
|
|
72
74
|
enable: true,
|
|
@@ -74,10 +76,10 @@ var DockerCluster = class extends import_constructs.Construct {
|
|
|
74
76
|
},
|
|
75
77
|
publicLoadBalancer: false
|
|
76
78
|
});
|
|
77
|
-
if (typeof this.props.tasks === "object") {
|
|
79
|
+
if (typeof ((_j = this.props.service) == null ? void 0 : _j.tasks) === "object") {
|
|
78
80
|
this.service.service.autoScaleTaskCount({
|
|
79
|
-
minCapacity: this.props.tasks.minimum,
|
|
80
|
-
maxCapacity: this.props.tasks.maximum
|
|
81
|
+
minCapacity: (_k = this.props.service) == null ? void 0 : _k.tasks.minimum,
|
|
82
|
+
maxCapacity: (_l = this.props.service) == null ? void 0 : _l.tasks.maximum
|
|
81
83
|
});
|
|
82
84
|
}
|
|
83
85
|
return service;
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,10 @@ import { App } from "aws-cdk-lib";
|
|
|
6
6
|
import { OriginProtocolPolicy } from "aws-cdk-lib/aws-cloudfront";
|
|
7
7
|
import { LoadBalancerV2Origin } from "aws-cdk-lib/aws-cloudfront-origins";
|
|
8
8
|
import { Platform } from "aws-cdk-lib/aws-ecr-assets";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
Cluster,
|
|
11
|
+
ContainerImage
|
|
12
|
+
} from "aws-cdk-lib/aws-ecs";
|
|
10
13
|
import {
|
|
11
14
|
ApplicationLoadBalancedFargateService
|
|
12
15
|
} from "aws-cdk-lib/aws-ecs-patterns";
|
|
@@ -35,16 +38,18 @@ var DockerCluster = class extends Construct {
|
|
|
35
38
|
});
|
|
36
39
|
}
|
|
37
40
|
createService() {
|
|
38
|
-
var _a;
|
|
39
|
-
const desiredTasks = typeof this.props.tasks === "number" ? this.props.tasks : (
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
42
|
+
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;
|
|
40
43
|
const service = new ApplicationLoadBalancedFargateService(this, "Service", {
|
|
41
44
|
cluster: new Cluster(this, "Cluster"),
|
|
42
|
-
cpu: this.props.cpu,
|
|
43
|
-
memoryLimitMiB: this.props.memory,
|
|
45
|
+
cpu: (_e = this.props.service) == null ? void 0 : _e.cpu,
|
|
46
|
+
memoryLimitMiB: (_f = this.props.service) == null ? void 0 : _f.memory,
|
|
44
47
|
desiredCount: desiredTasks,
|
|
45
48
|
taskImageOptions: {
|
|
46
49
|
image: this.image,
|
|
47
|
-
containerPort: this.props.port
|
|
50
|
+
containerPort: (_g = this.props.service) == null ? void 0 : _g.port,
|
|
51
|
+
environment: (_h = this.props.service) == null ? void 0 : _h.environment,
|
|
52
|
+
secrets: (_i = this.props.service) == null ? void 0 : _i.secrets
|
|
48
53
|
},
|
|
49
54
|
circuitBreaker: {
|
|
50
55
|
enable: true,
|
|
@@ -52,10 +57,10 @@ var DockerCluster = class extends Construct {
|
|
|
52
57
|
},
|
|
53
58
|
publicLoadBalancer: false
|
|
54
59
|
});
|
|
55
|
-
if (typeof this.props.tasks === "object") {
|
|
60
|
+
if (typeof ((_j = this.props.service) == null ? void 0 : _j.tasks) === "object") {
|
|
56
61
|
this.service.service.autoScaleTaskCount({
|
|
57
|
-
minCapacity: this.props.tasks.minimum,
|
|
58
|
-
maxCapacity: this.props.tasks.maximum
|
|
62
|
+
minCapacity: (_k = this.props.service) == null ? void 0 : _k.tasks.minimum,
|
|
63
|
+
maxCapacity: (_l = this.props.service) == null ? void 0 : _l.tasks.maximum
|
|
59
64
|
});
|
|
60
65
|
}
|
|
61
66
|
return service;
|