@codedazur/cdk-docker-cluster 1.1.1 → 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 CHANGED
@@ -1,5 +1,16 @@
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
+
3
14
  ## 1.1.1
4
15
 
5
16
  ### Patch 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
- port?: number;
12
- tasks?: number | AutoScalingConfig;
13
- cpu?: ApplicationLoadBalancedFargateServiceProps["cpu"];
14
- memory?: ApplicationLoadBalancedFargateServiceProps["memoryLimitMiB"];
15
- environment?: Record<string, string>;
16
- secrets?: Record<string, Secret>;
17
- };
18
- distribution?: Omit<SiteDistributionProps, "origin">;
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
- port?: number;
12
- tasks?: number | AutoScalingConfig;
13
- cpu?: ApplicationLoadBalancedFargateServiceProps["cpu"];
14
- memory?: ApplicationLoadBalancedFargateServiceProps["memoryLimitMiB"];
15
- environment?: Record<string, string>;
16
- secrets?: Record<string, Secret>;
17
- };
18
- distribution?: Omit<SiteDistributionProps, "origin">;
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
@@ -100,35 +100,44 @@ var DockerCluster = class extends import_constructs.Construct {
100
100
  return autoScaling;
101
101
  }
102
102
  createSiteDistribution() {
103
+ const { cachePolicy, originRequestPolicy, ...distribution } = this.props.distribution ?? {};
103
104
  return new import_cdk_site_distribution.SiteDistribution(this, "Distribution", {
104
105
  allowedMethods: import_aws_cloudfront.AllowedMethods.ALLOW_ALL,
105
- cachePolicy: {
106
- /**
107
- * The managed "UseOriginCacheControlHeaders-QueryStrings" cache policy,
108
- * which is designed for use with an origin that sends Cache-Control
109
- * headers with the object, which is recommended for use with an
110
- * Application Load Balancer, and includes query strings in the cache
111
- * key.
112
- * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html#managed-cache-policy-origin-cache-headers-query-strings
113
- */
114
- cachePolicyId: "4cc15a8a-d715-48a4-82b8-cc0b614638fe"
115
- },
116
- originRequestPolicy: {
117
- /**
118
- * The managed "AllViewer" origin request policy, which includes all
119
- * values (query strings, headers, and cookies) in the viewer request,
120
- * which is recommended for use with an Application Load Balancer
121
- * endpoint.
122
- * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-origin-request-policies.html#managed-origin-request-policy-all-viewer
123
- */
124
- originRequestPolicyId: "216adef6-5c7f-47e4-b989-5492eafa07d3"
125
- },
126
- ...this.props.distribution,
106
+ cachePolicy: cachePolicy ?? this.createCachePolicy(),
107
+ originRequestPolicy: originRequestPolicy ?? this.createOriginRequestPolicy(),
108
+ ...distribution,
127
109
  origin: new import_aws_cloudfront_origins.LoadBalancerV2Origin(this.service.loadBalancer, {
128
110
  protocolPolicy: import_aws_cloudfront.OriginProtocolPolicy.HTTP_ONLY
129
111
  })
130
112
  });
131
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
+ }
132
141
  getOutputDirectory() {
133
142
  return import_aws_cdk_lib.App.of(this)?.outdir ?? "cdk.out";
134
143
  }
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
- OriginProtocolPolicy
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";
@@ -84,35 +86,44 @@ var DockerCluster = class extends Construct {
84
86
  return autoScaling;
85
87
  }
86
88
  createSiteDistribution() {
89
+ const { cachePolicy, originRequestPolicy, ...distribution } = this.props.distribution ?? {};
87
90
  return new SiteDistribution(this, "Distribution", {
88
91
  allowedMethods: AllowedMethods.ALLOW_ALL,
89
- cachePolicy: {
90
- /**
91
- * The managed "UseOriginCacheControlHeaders-QueryStrings" cache policy,
92
- * which is designed for use with an origin that sends Cache-Control
93
- * headers with the object, which is recommended for use with an
94
- * Application Load Balancer, and includes query strings in the cache
95
- * key.
96
- * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html#managed-cache-policy-origin-cache-headers-query-strings
97
- */
98
- cachePolicyId: "4cc15a8a-d715-48a4-82b8-cc0b614638fe"
99
- },
100
- originRequestPolicy: {
101
- /**
102
- * The managed "AllViewer" origin request policy, which includes all
103
- * values (query strings, headers, and cookies) in the viewer request,
104
- * which is recommended for use with an Application Load Balancer
105
- * endpoint.
106
- * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-origin-request-policies.html#managed-origin-request-policy-all-viewer
107
- */
108
- originRequestPolicyId: "216adef6-5c7f-47e4-b989-5492eafa07d3"
109
- },
110
- ...this.props.distribution,
92
+ cachePolicy: cachePolicy ?? this.createCachePolicy(),
93
+ originRequestPolicy: originRequestPolicy ?? this.createOriginRequestPolicy(),
94
+ ...distribution,
111
95
  origin: new LoadBalancerV2Origin(this.service.loadBalancer, {
112
96
  protocolPolicy: OriginProtocolPolicy.HTTP_ONLY
113
97
  })
114
98
  });
115
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
+ }
116
127
  getOutputDirectory() {
117
128
  return App.of(this)?.outdir ?? "cdk.out";
118
129
  }
@@ -0,0 +1,5 @@
1
+ import { cdk, distribution } from "@codedazur/eslint-config";
2
+ import { defineConfig } from "eslint/config";
3
+ import root from "../../eslint.config";
4
+
5
+ export default defineConfig(root, cdk, distribution);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codedazur/cdk-docker-cluster",
3
- "version": "1.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",
@@ -19,7 +19,7 @@
19
19
  "develop": "tsup src/index.ts --format esm,cjs --dts --watch",
20
20
  "build": "tsup src/index.ts --format esm,cjs --dts",
21
21
  "audit": "npm audit --omit dev --audit-level high",
22
- "lint": "TIMING=1 eslint \"**/*.ts*\"",
22
+ "lint": "eslint .",
23
23
  "types": "tsc --noEmit",
24
24
  "test": "vitest run --passWithNoTests"
25
25
  },
@@ -28,12 +28,12 @@
28
28
  "constructs": ">=10"
29
29
  },
30
30
  "dependencies": {
31
- "@codedazur/cdk-site-distribution": "^1.0.1"
31
+ "@codedazur/cdk-site-distribution": "^1.0.2"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/node": "^24.0.3",
35
- "aws-cdk-lib": "^2.201.0",
36
- "constructs": "^10.4.2",
37
- "esbuild": "^0.25.5"
34
+ "@types/node": "^25.0.3",
35
+ "aws-cdk-lib": "^2.233.0",
36
+ "constructs": "^10.4.4",
37
+ "esbuild": "^0.27.2"
38
38
  }
39
39
  }