@gradientedge/cdk-utils 6.1.0 → 6.3.1
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/src/lib/construct/static-site/main.d.ts +5 -1
- package/dist/src/lib/construct/static-site/main.js +10 -1
- package/dist/src/lib/manager/aws/cloudfront-manager.d.ts +2 -1
- package/dist/src/lib/manager/aws/cloudfront-manager.js +3 -1
- package/dist/src/lib/types/aws/index.d.ts +1 -0
- package/package.json +13 -13
- package/src/lib/construct/static-site/main.ts +16 -1
- package/src/lib/manager/aws/cloudfront-manager.ts +4 -1
- package/src/lib/types/aws/index.ts +1 -0
|
@@ -31,7 +31,6 @@ export declare class StaticSite extends CommonConstruct {
|
|
|
31
31
|
siteHostedZone: route53.IHostedZone;
|
|
32
32
|
siteCertificate: certificateManager.ICertificate;
|
|
33
33
|
siteARecord: route53.ARecord;
|
|
34
|
-
siteARecordAlt: route53.ARecord;
|
|
35
34
|
siteBucket: s3.IBucket;
|
|
36
35
|
siteOrigin: origins.S3Origin;
|
|
37
36
|
siteDistribution: cloudfront.Distribution;
|
|
@@ -91,4 +90,9 @@ export declare class StaticSite extends CommonConstruct {
|
|
|
91
90
|
* @protected
|
|
92
91
|
*/
|
|
93
92
|
protected deploySite(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Method to invalidation the cloudfront distribution cache after a deployment
|
|
95
|
+
* @protected
|
|
96
|
+
*/
|
|
97
|
+
protected invalidateDistributionCache(): void;
|
|
94
98
|
}
|
|
@@ -54,7 +54,6 @@ class StaticSite extends common_1.CommonConstruct {
|
|
|
54
54
|
siteHostedZone;
|
|
55
55
|
siteCertificate;
|
|
56
56
|
siteARecord;
|
|
57
|
-
siteARecordAlt;
|
|
58
57
|
siteBucket;
|
|
59
58
|
siteOrigin;
|
|
60
59
|
siteDistribution;
|
|
@@ -82,6 +81,7 @@ class StaticSite extends common_1.CommonConstruct {
|
|
|
82
81
|
this.createSiteDistribution();
|
|
83
82
|
this.createSiteRouteAssets();
|
|
84
83
|
this.deploySite();
|
|
84
|
+
this.invalidateDistributionCache();
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* @summary Method to resolve a hosted zone based on domain attributes
|
|
@@ -165,5 +165,14 @@ class StaticSite extends common_1.CommonConstruct {
|
|
|
165
165
|
deploySite() {
|
|
166
166
|
this.s3Manager.doBucketDeployment(`${this.id}-deployment`, this, this.siteBucket, this.siteDistribution, [this.props.siteSource], '', true);
|
|
167
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Method to invalidation the cloudfront distribution cache after a deployment
|
|
170
|
+
* @protected
|
|
171
|
+
*/
|
|
172
|
+
invalidateDistributionCache() {
|
|
173
|
+
if (this.props.siteCacheInvalidationDockerFilePath) {
|
|
174
|
+
this.cloudFrontManager.invalidateCache(`${this.id}-cache-invalidation`, this, this.props.siteCacheInvalidationDockerFilePath, this.siteDistribution.distributionId);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
168
177
|
}
|
|
169
178
|
exports.StaticSite = StaticSite;
|
|
@@ -75,8 +75,9 @@ export declare class CloudFrontManager {
|
|
|
75
75
|
* @param {s3.IBucket?} logBucket
|
|
76
76
|
* @param {acm.ICertificate?} certificate
|
|
77
77
|
* @param {cloudfront.FunctionAssociation?} defaultFunctionAssociations
|
|
78
|
+
* @param {cloudfront.IResponseHeadersPolicy?} responseHeadersPolicy
|
|
78
79
|
*/
|
|
79
|
-
createDistributionWithHttpOrigin(id: string, scope: common.CommonConstruct, props: types.DistributionProps, origin: origins.HttpOrigin, domainNames: string[], logBucket?: s3.IBucket, certificate?: acm.ICertificate, defaultFunctionAssociations?: cloudfront.FunctionAssociation[]): cdk.aws_cloudfront.Distribution;
|
|
80
|
+
createDistributionWithHttpOrigin(id: string, scope: common.CommonConstruct, props: types.DistributionProps, origin: origins.HttpOrigin, domainNames: string[], logBucket?: s3.IBucket, certificate?: acm.ICertificate, defaultFunctionAssociations?: cloudfront.FunctionAssociation[], responseHeadersPolicy?: cloudfront.IResponseHeadersPolicy): cdk.aws_cloudfront.Distribution;
|
|
80
81
|
/**
|
|
81
82
|
* @summary Method to provision a Lambda@Edge function
|
|
82
83
|
*
|
|
@@ -173,8 +173,9 @@ class CloudFrontManager {
|
|
|
173
173
|
* @param {s3.IBucket?} logBucket
|
|
174
174
|
* @param {acm.ICertificate?} certificate
|
|
175
175
|
* @param {cloudfront.FunctionAssociation?} defaultFunctionAssociations
|
|
176
|
+
* @param {cloudfront.IResponseHeadersPolicy?} responseHeadersPolicy
|
|
176
177
|
*/
|
|
177
|
-
createDistributionWithHttpOrigin(id, scope, props, origin, domainNames, logBucket, certificate, defaultFunctionAssociations) {
|
|
178
|
+
createDistributionWithHttpOrigin(id, scope, props, origin, domainNames, logBucket, certificate, defaultFunctionAssociations, responseHeadersPolicy) {
|
|
178
179
|
const distribution = new cloudfront.Distribution(scope, `${id}`, {
|
|
179
180
|
certificate: certificate,
|
|
180
181
|
comment: `${id} - ${scope.props.stage} stage`,
|
|
@@ -184,6 +185,7 @@ class CloudFrontManager {
|
|
|
184
185
|
originRequestPolicy: props.defaultBehavior ? props.defaultBehavior.originRequestPolicy : undefined,
|
|
185
186
|
functionAssociations: defaultFunctionAssociations ?? undefined,
|
|
186
187
|
viewerProtocolPolicy: props.defaultBehavior ? props.defaultBehavior.viewerProtocolPolicy : undefined,
|
|
188
|
+
responseHeadersPolicy: responseHeadersPolicy ?? undefined,
|
|
187
189
|
},
|
|
188
190
|
additionalBehaviors: props.additionalBehaviors,
|
|
189
191
|
defaultRootObject: props.defaultRootObject,
|
|
@@ -82,6 +82,7 @@ export interface SiteWithEcsBackendProps extends CommonStackProps {
|
|
|
82
82
|
* @subcategory Properties
|
|
83
83
|
*/
|
|
84
84
|
export interface StaticSiteProps extends CommonStackProps {
|
|
85
|
+
siteCacheInvalidationDockerFilePath?: string;
|
|
85
86
|
siteCreateAltARecord: boolean;
|
|
86
87
|
siteCertificate: AcmProps;
|
|
87
88
|
siteBucket: S3BucketProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradientedge/cdk-utils",
|
|
3
|
-
"version": "6.1
|
|
3
|
+
"version": "6.3.1",
|
|
4
4
|
"description": "Utilities for AWS CDK provisioning",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@types/lodash": "^4.14.182",
|
|
49
|
-
"@types/node": "^18.6
|
|
50
|
-
"app-root-path": "^3.
|
|
51
|
-
"aws-cdk-lib": "^2.
|
|
52
|
-
"aws-sdk": "^2.
|
|
53
|
-
"constructs": "^10.1.
|
|
49
|
+
"@types/node": "^18.7.6",
|
|
50
|
+
"app-root-path": "^3.1.0",
|
|
51
|
+
"aws-cdk-lib": "^2.37.1",
|
|
52
|
+
"aws-sdk": "^2.1195.0",
|
|
53
|
+
"constructs": "^10.1.77",
|
|
54
54
|
"lodash": "^4.17.21",
|
|
55
55
|
"moment": "^2.29.4",
|
|
56
56
|
"nconf": "^0.12.0",
|
|
@@ -59,16 +59,16 @@
|
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
62
|
-
"@types/jest": "^28.1.
|
|
63
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
64
|
-
"@typescript-eslint/parser": "^5.
|
|
62
|
+
"@types/jest": "^28.1.7",
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "^5.33.1",
|
|
64
|
+
"@typescript-eslint/parser": "^5.33.1",
|
|
65
65
|
"aws-cdk": "*",
|
|
66
66
|
"babel-eslint": "^10.1.0",
|
|
67
67
|
"better-docs": "^2.7.2",
|
|
68
68
|
"codecov": "^3.8.3",
|
|
69
69
|
"commitizen": "^4.2.5",
|
|
70
70
|
"dotenv": "^16.0.1",
|
|
71
|
-
"eslint": "^8.
|
|
71
|
+
"eslint": "^8.22.0",
|
|
72
72
|
"eslint-config-prettier": "^8.5.0",
|
|
73
73
|
"eslint-plugin-import": "^2.26.0",
|
|
74
74
|
"husky": "^8.0.1",
|
|
@@ -78,12 +78,12 @@
|
|
|
78
78
|
"jsdoc": "^3.6.11",
|
|
79
79
|
"jsdoc-babel": "^0.5.0",
|
|
80
80
|
"jsdoc-mermaid": "^1.0.0",
|
|
81
|
-
"lerna": "^5.
|
|
81
|
+
"lerna": "^5.4.2",
|
|
82
82
|
"prettier": "^2.7.1",
|
|
83
|
-
"prettier-plugin-organize-imports": "^3.0.
|
|
83
|
+
"prettier-plugin-organize-imports": "^3.0.3",
|
|
84
84
|
"rimraf": "^3.0.2",
|
|
85
85
|
"semantic-release": "^19.0.3",
|
|
86
|
-
"ts-jest": "^28.0.
|
|
86
|
+
"ts-jest": "^28.0.8",
|
|
87
87
|
"ts-node": "^10.9.1",
|
|
88
88
|
"typescript": "4.7.4"
|
|
89
89
|
},
|
|
@@ -35,7 +35,6 @@ export class StaticSite extends CommonConstruct {
|
|
|
35
35
|
siteHostedZone: route53.IHostedZone
|
|
36
36
|
siteCertificate: certificateManager.ICertificate
|
|
37
37
|
siteARecord: route53.ARecord
|
|
38
|
-
siteARecordAlt: route53.ARecord
|
|
39
38
|
siteBucket: s3.IBucket
|
|
40
39
|
siteOrigin: origins.S3Origin
|
|
41
40
|
siteDistribution: cloudfront.Distribution
|
|
@@ -66,6 +65,7 @@ export class StaticSite extends CommonConstruct {
|
|
|
66
65
|
this.createSiteDistribution()
|
|
67
66
|
this.createSiteRouteAssets()
|
|
68
67
|
this.deploySite()
|
|
68
|
+
this.invalidateDistributionCache()
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
@@ -204,4 +204,19 @@ export class StaticSite extends CommonConstruct {
|
|
|
204
204
|
true
|
|
205
205
|
)
|
|
206
206
|
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Method to invalidation the cloudfront distribution cache after a deployment
|
|
210
|
+
* @protected
|
|
211
|
+
*/
|
|
212
|
+
protected invalidateDistributionCache() {
|
|
213
|
+
if (this.props.siteCacheInvalidationDockerFilePath) {
|
|
214
|
+
this.cloudFrontManager.invalidateCache(
|
|
215
|
+
`${this.id}-cache-invalidation`,
|
|
216
|
+
this,
|
|
217
|
+
this.props.siteCacheInvalidationDockerFilePath,
|
|
218
|
+
this.siteDistribution.distributionId
|
|
219
|
+
)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
207
222
|
}
|
|
@@ -180,6 +180,7 @@ export class CloudFrontManager {
|
|
|
180
180
|
* @param {s3.IBucket?} logBucket
|
|
181
181
|
* @param {acm.ICertificate?} certificate
|
|
182
182
|
* @param {cloudfront.FunctionAssociation?} defaultFunctionAssociations
|
|
183
|
+
* @param {cloudfront.IResponseHeadersPolicy?} responseHeadersPolicy
|
|
183
184
|
*/
|
|
184
185
|
public createDistributionWithHttpOrigin(
|
|
185
186
|
id: string,
|
|
@@ -189,7 +190,8 @@ export class CloudFrontManager {
|
|
|
189
190
|
domainNames: string[],
|
|
190
191
|
logBucket?: s3.IBucket,
|
|
191
192
|
certificate?: acm.ICertificate,
|
|
192
|
-
defaultFunctionAssociations?: cloudfront.FunctionAssociation[]
|
|
193
|
+
defaultFunctionAssociations?: cloudfront.FunctionAssociation[],
|
|
194
|
+
responseHeadersPolicy?: cloudfront.IResponseHeadersPolicy
|
|
193
195
|
) {
|
|
194
196
|
const distribution = new cloudfront.Distribution(scope, `${id}`, {
|
|
195
197
|
certificate: certificate,
|
|
@@ -200,6 +202,7 @@ export class CloudFrontManager {
|
|
|
200
202
|
originRequestPolicy: props.defaultBehavior ? props.defaultBehavior.originRequestPolicy : undefined,
|
|
201
203
|
functionAssociations: defaultFunctionAssociations ?? undefined,
|
|
202
204
|
viewerProtocolPolicy: props.defaultBehavior ? props.defaultBehavior.viewerProtocolPolicy : undefined,
|
|
205
|
+
responseHeadersPolicy: responseHeadersPolicy ?? undefined,
|
|
203
206
|
},
|
|
204
207
|
additionalBehaviors: props.additionalBehaviors,
|
|
205
208
|
defaultRootObject: props.defaultRootObject,
|
|
@@ -86,6 +86,7 @@ export interface SiteWithEcsBackendProps extends CommonStackProps {
|
|
|
86
86
|
* @subcategory Properties
|
|
87
87
|
*/
|
|
88
88
|
export interface StaticSiteProps extends CommonStackProps {
|
|
89
|
+
siteCacheInvalidationDockerFilePath?: string
|
|
89
90
|
siteCreateAltARecord: boolean
|
|
90
91
|
siteCertificate: AcmProps
|
|
91
92
|
siteBucket: S3BucketProps
|