@gradientedge/cdk-utils 8.113.0 → 8.114.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.
|
@@ -12,7 +12,7 @@ import * as s3 from 'aws-cdk-lib/aws-s3';
|
|
|
12
12
|
import * as efs from 'aws-cdk-lib/aws-efs';
|
|
13
13
|
import { Construct } from 'constructs';
|
|
14
14
|
import { CommonConstruct } from '../../common';
|
|
15
|
-
import { SiteWithEcsBackendProps, SiteResponseHeadersPolicyProps } from './types';
|
|
15
|
+
import { SiteWithEcsBackendProps, SiteResponseHeadersPolicyProps, SiteCachePolicyProps } from './types';
|
|
16
16
|
/**
|
|
17
17
|
* @classdesc Provides a construct to create and deploy a site hosted with an clustered ECS/ELB backend
|
|
18
18
|
* @example
|
|
@@ -126,7 +126,8 @@ export declare class SiteWithEcsBackend extends CommonConstruct {
|
|
|
126
126
|
* Method to create log bucket for site distribution
|
|
127
127
|
*/
|
|
128
128
|
protected createSiteLogBucket(): void;
|
|
129
|
-
protected
|
|
129
|
+
protected createSiteCachePolicy(id: string, siteCachePolicy: SiteCachePolicyProps): cdk.aws_cloudfront.CachePolicy;
|
|
130
|
+
protected createSiteOriginCachePolicy(): void;
|
|
130
131
|
protected createSiteOriginRequestPolicy(): void;
|
|
131
132
|
protected createResponseHeaderPolicy(props: SiteResponseHeadersPolicyProps): cdk.aws_cloudfront.ResponseHeadersPolicy | undefined;
|
|
132
133
|
protected createSiteOriginResponseHeadersPolicy(): void;
|
|
@@ -104,7 +104,7 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
104
104
|
this.createEcsBuildArgs();
|
|
105
105
|
this.createEcsContainerImage();
|
|
106
106
|
this.createEcsService();
|
|
107
|
-
this.
|
|
107
|
+
this.createSiteOriginCachePolicy();
|
|
108
108
|
this.createSiteOriginRequestPolicy();
|
|
109
109
|
this.createSiteOriginResponseHeadersPolicy();
|
|
110
110
|
this.createSiteOrigin();
|
|
@@ -347,20 +347,23 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
347
347
|
createSiteLogBucket() {
|
|
348
348
|
this.siteLogBucket = this.s3Manager.createS3Bucket(`${this.id}-site-logs`, this, this.props.siteLogBucket);
|
|
349
349
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
this.siteCachePolicy = new cloudfront.CachePolicy(this, `${this.id}-site-cache-policy`, {
|
|
354
|
-
cachePolicyName: `${this.id}-site-cache-policy`,
|
|
350
|
+
createSiteCachePolicy(id, siteCachePolicy) {
|
|
351
|
+
return new cloudfront.CachePolicy(this, `${id}`, {
|
|
352
|
+
cachePolicyName: `${this.id}-${siteCachePolicy.cachePolicyName}`,
|
|
355
353
|
comment: `Policy for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
356
|
-
defaultTtl: cdk.Duration.seconds(
|
|
357
|
-
minTtl: cdk.Duration.seconds(
|
|
358
|
-
maxTtl: cdk.Duration.seconds(
|
|
359
|
-
enableAcceptEncodingGzip:
|
|
360
|
-
queryStringBehavior:
|
|
361
|
-
headerBehavior:
|
|
362
|
-
cookieBehavior:
|
|
354
|
+
defaultTtl: cdk.Duration.seconds(siteCachePolicy.defaultTtlInSeconds),
|
|
355
|
+
minTtl: cdk.Duration.seconds(siteCachePolicy.minTtlInSeconds),
|
|
356
|
+
maxTtl: cdk.Duration.seconds(siteCachePolicy.maxTtlInSeconds),
|
|
357
|
+
enableAcceptEncodingGzip: siteCachePolicy.enableAcceptEncodingGzip,
|
|
358
|
+
queryStringBehavior: siteCachePolicy.queryStringBehavior,
|
|
359
|
+
headerBehavior: siteCachePolicy.headerBehavior,
|
|
360
|
+
cookieBehavior: siteCachePolicy.cookieBehavior,
|
|
363
361
|
});
|
|
362
|
+
}
|
|
363
|
+
createSiteOriginCachePolicy() {
|
|
364
|
+
if (!this.props.siteCachePolicy)
|
|
365
|
+
return;
|
|
366
|
+
this.siteCachePolicy = this.createSiteCachePolicy(`${this.id}-site-cache-policy`, this.props.siteCachePolicy);
|
|
364
367
|
_.assign(this.props.siteDistribution.defaultBehavior, {
|
|
365
368
|
cachePolicy: this.siteCachePolicy,
|
|
366
369
|
});
|
|
@@ -387,6 +390,7 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
387
390
|
comment: `Response Header Policy for ${props.type} for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
388
391
|
responseHeadersPolicyName: `${this.id}-${props.type}-response`,
|
|
389
392
|
securityHeadersBehavior: {
|
|
393
|
+
...props.securityHeadersBehavior,
|
|
390
394
|
strictTransportSecurity: {
|
|
391
395
|
...props.securityHeadersBehavior?.strictTransportSecurity,
|
|
392
396
|
accessControlMaxAge: cdk.Duration.seconds(props.securityHeadersBehavior?.strictTransportSecurity?.accessControlMaxAgeInSeconds),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradientedge/cdk-utils",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.114.0",
|
|
4
4
|
"description": "Utilities for AWS CDK provisioning",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
|
50
|
-
"@aws-sdk/credential-providers": "^3.
|
|
51
|
-
"@aws-sdk/types": "^3.
|
|
52
|
-
"@types/lodash": "^4.14.
|
|
53
|
-
"@types/node": "^20.
|
|
49
|
+
"@aws-sdk/client-secrets-manager": "^3.395.0",
|
|
50
|
+
"@aws-sdk/credential-providers": "^3.395.0",
|
|
51
|
+
"@aws-sdk/types": "^3.391.0",
|
|
52
|
+
"@types/lodash": "^4.14.197",
|
|
53
|
+
"@types/node": "^20.5.1",
|
|
54
54
|
"@types/uuid": "^9.0.2",
|
|
55
55
|
"app-root-path": "^3.1.0",
|
|
56
|
-
"aws-cdk-lib": "^2.
|
|
56
|
+
"aws-cdk-lib": "^2.92.0",
|
|
57
57
|
"constructs": "^10.2.69",
|
|
58
58
|
"lodash": "^4.17.21",
|
|
59
59
|
"moment": "^2.29.4",
|
|
@@ -63,22 +63,22 @@
|
|
|
63
63
|
"uuid": "^9.0.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@babel/core": "^7.22.
|
|
67
|
-
"@babel/eslint-parser": "^7.22.
|
|
66
|
+
"@babel/core": "^7.22.10",
|
|
67
|
+
"@babel/eslint-parser": "^7.22.10",
|
|
68
68
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
69
69
|
"@types/jest": "^29.5.3",
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
71
|
-
"@typescript-eslint/parser": "^6.
|
|
72
|
-
"aws-cdk": "^2.
|
|
70
|
+
"@typescript-eslint/eslint-plugin": "^6.4.0",
|
|
71
|
+
"@typescript-eslint/parser": "^6.4.0",
|
|
72
|
+
"aws-cdk": "^2.92.0",
|
|
73
73
|
"better-docs": "^2.7.2",
|
|
74
74
|
"codecov": "^3.8.3",
|
|
75
75
|
"commitizen": "^4.3.0",
|
|
76
76
|
"docdash": "^2.0.1",
|
|
77
77
|
"dotenv": "^16.3.1",
|
|
78
|
-
"eslint": "^8.
|
|
78
|
+
"eslint": "^8.47.0",
|
|
79
79
|
"eslint-config-prettier": "^9.0.0",
|
|
80
|
-
"eslint-plugin-import": "^2.28.
|
|
81
|
-
"eslint-plugin-jsdoc": "^46.
|
|
80
|
+
"eslint-plugin-import": "^2.28.1",
|
|
81
|
+
"eslint-plugin-jsdoc": "^46.5.0",
|
|
82
82
|
"husky": "^8.0.3",
|
|
83
83
|
"jest": "^29.6.2",
|
|
84
84
|
"jest-extended": "^4.0.1",
|
|
@@ -88,10 +88,10 @@
|
|
|
88
88
|
"jsdoc-mermaid": "^1.0.0",
|
|
89
89
|
"jsdoc-plugin-typescript": "^2.2.1",
|
|
90
90
|
"jsdoc-to-markdown": "^8.0.0",
|
|
91
|
-
"prettier": "^3.0.
|
|
91
|
+
"prettier": "^3.0.2",
|
|
92
92
|
"prettier-plugin-organize-imports": "^3.2.3",
|
|
93
93
|
"rimraf": "^5.0.1",
|
|
94
|
-
"semantic-release": "^21.0.
|
|
94
|
+
"semantic-release": "^21.0.9",
|
|
95
95
|
"taffydb": "^2.7.3",
|
|
96
96
|
"ts-jest": "^29.1.1",
|
|
97
97
|
"ts-node": "^10.9.1",
|
|
@@ -14,7 +14,7 @@ import * as s3 from 'aws-cdk-lib/aws-s3'
|
|
|
14
14
|
import * as efs from 'aws-cdk-lib/aws-efs'
|
|
15
15
|
import { Construct } from 'constructs'
|
|
16
16
|
import { CommonConstruct } from '../../common'
|
|
17
|
-
import { SiteWithEcsBackendProps, SiteResponseHeadersPolicyProps } from './types'
|
|
17
|
+
import { SiteWithEcsBackendProps, SiteResponseHeadersPolicyProps, SiteCachePolicyProps } from './types'
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @classdesc Provides a construct to create and deploy a site hosted with an clustered ECS/ELB backend
|
|
@@ -92,7 +92,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
92
92
|
this.createEcsBuildArgs()
|
|
93
93
|
this.createEcsContainerImage()
|
|
94
94
|
this.createEcsService()
|
|
95
|
-
this.
|
|
95
|
+
this.createSiteOriginCachePolicy()
|
|
96
96
|
this.createSiteOriginRequestPolicy()
|
|
97
97
|
this.createSiteOriginResponseHeadersPolicy()
|
|
98
98
|
this.createSiteOrigin()
|
|
@@ -410,20 +410,23 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
410
410
|
this.siteLogBucket = this.s3Manager.createS3Bucket(`${this.id}-site-logs`, this, this.props.siteLogBucket)
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
-
protected
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
cachePolicyName: `${this.id}-site-cache-policy`,
|
|
413
|
+
protected createSiteCachePolicy(id: string, siteCachePolicy: SiteCachePolicyProps) {
|
|
414
|
+
return new cloudfront.CachePolicy(this, `${id}`, {
|
|
415
|
+
cachePolicyName: `${this.id}-${siteCachePolicy.cachePolicyName}`,
|
|
417
416
|
comment: `Policy for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
418
|
-
defaultTtl: cdk.Duration.seconds(
|
|
419
|
-
minTtl: cdk.Duration.seconds(
|
|
420
|
-
maxTtl: cdk.Duration.seconds(
|
|
421
|
-
enableAcceptEncodingGzip:
|
|
422
|
-
queryStringBehavior:
|
|
423
|
-
headerBehavior:
|
|
424
|
-
cookieBehavior:
|
|
417
|
+
defaultTtl: cdk.Duration.seconds(siteCachePolicy.defaultTtlInSeconds),
|
|
418
|
+
minTtl: cdk.Duration.seconds(siteCachePolicy.minTtlInSeconds),
|
|
419
|
+
maxTtl: cdk.Duration.seconds(siteCachePolicy.maxTtlInSeconds),
|
|
420
|
+
enableAcceptEncodingGzip: siteCachePolicy.enableAcceptEncodingGzip,
|
|
421
|
+
queryStringBehavior: siteCachePolicy.queryStringBehavior,
|
|
422
|
+
headerBehavior: siteCachePolicy.headerBehavior,
|
|
423
|
+
cookieBehavior: siteCachePolicy.cookieBehavior,
|
|
425
424
|
})
|
|
425
|
+
}
|
|
426
426
|
|
|
427
|
+
protected createSiteOriginCachePolicy() {
|
|
428
|
+
if (!this.props.siteCachePolicy) return
|
|
429
|
+
this.siteCachePolicy = this.createSiteCachePolicy(`${this.id}-site-cache-policy`, this.props.siteCachePolicy)
|
|
427
430
|
_.assign(this.props.siteDistribution.defaultBehavior, {
|
|
428
431
|
cachePolicy: this.siteCachePolicy,
|
|
429
432
|
})
|
|
@@ -451,6 +454,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
451
454
|
comment: `Response Header Policy for ${props.type} for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
452
455
|
responseHeadersPolicyName: `${this.id}-${props.type}-response`,
|
|
453
456
|
securityHeadersBehavior: {
|
|
457
|
+
...props.securityHeadersBehavior,
|
|
454
458
|
strictTransportSecurity: {
|
|
455
459
|
...props.securityHeadersBehavior?.strictTransportSecurity,
|
|
456
460
|
accessControlMaxAge: cdk.Duration.seconds(
|