@gradientedge/cdk-utils 6.2.0 → 6.4.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.
@@ -31,10 +31,9 @@ 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
- siteDistribution: cloudfront.Distribution;
36
+ siteDistribution: cloudfront.IDistribution;
38
37
  siteLogBucket: s3.IBucket;
39
38
  siteOriginAccessIdentity: cloudfront.OriginAccessIdentity;
40
39
  siteCloudfrontFunction: cloudfront.Function;
@@ -76,6 +75,11 @@ export declare class StaticSite extends CommonConstruct {
76
75
  * @protected
77
76
  */
78
77
  protected resolveSiteFunctionAssociations(): void;
78
+ /**
79
+ * @summary Method to create a site origin access identity
80
+ * @protected
81
+ */
82
+ protected createSiteOriginAccessIdentity(): void;
79
83
  /**
80
84
  * @summary Method to create a site cloudfront distribution
81
85
  * @protected
@@ -91,4 +95,9 @@ export declare class StaticSite extends CommonConstruct {
91
95
  * @protected
92
96
  */
93
97
  protected deploySite(): void;
98
+ /**
99
+ * Method to invalidation the cloudfront distribution cache after a deployment
100
+ * @protected
101
+ */
102
+ protected invalidateDistributionCache(): void;
94
103
  }
@@ -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;
@@ -79,9 +78,11 @@ class StaticSite extends common_1.CommonConstruct {
79
78
  this.createSiteOrigin();
80
79
  this.createSiteCloudfrontFunction();
81
80
  this.resolveSiteFunctionAssociations();
81
+ this.createSiteOriginAccessIdentity();
82
82
  this.createSiteDistribution();
83
83
  this.createSiteRouteAssets();
84
84
  this.deploySite();
85
+ this.invalidateDistributionCache();
85
86
  }
86
87
  /**
87
88
  * @summary Method to resolve a hosted zone based on domain attributes
@@ -142,6 +143,11 @@ class StaticSite extends common_1.CommonConstruct {
142
143
  ];
143
144
  }
144
145
  }
146
+ /**
147
+ * @summary Method to create a site origin access identity
148
+ * @protected
149
+ */
150
+ createSiteOriginAccessIdentity() { }
145
151
  /**
146
152
  * @summary Method to create a site cloudfront distribution
147
153
  * @protected
@@ -165,5 +171,14 @@ class StaticSite extends common_1.CommonConstruct {
165
171
  deploySite() {
166
172
  this.s3Manager.doBucketDeployment(`${this.id}-deployment`, this, this.siteBucket, this.siteDistribution, [this.props.siteSource], '', true);
167
173
  }
174
+ /**
175
+ * Method to invalidation the cloudfront distribution cache after a deployment
176
+ * @protected
177
+ */
178
+ invalidateDistributionCache() {
179
+ if (this.props.siteCacheInvalidationDockerFilePath) {
180
+ this.cloudFrontManager.invalidateCache(`${this.id}-cache-invalidation`, this, this.props.siteCacheInvalidationDockerFilePath, this.siteDistribution.distributionId);
181
+ }
182
+ }
168
183
  }
169
184
  exports.StaticSite = StaticSite;
@@ -38,8 +38,6 @@ import * as types from '../../types';
38
38
  export declare class CloudFrontManager {
39
39
  createOriginAccessIdentity(id: string, scope: common.CommonConstruct, accessBucket?: s3.IBucket): cdk.aws_cloudfront.OriginAccessIdentity;
40
40
  /**
41
- * @deprecated Use `createDistributionWithS3Origin` instead
42
- *
43
41
  * @summary Method to create a cloudfront distribution
44
42
  * @param {string} id scoped id of the resource
45
43
  * @param {common.CommonConstruct} scope scope in which this resource is defined
@@ -67,8 +67,6 @@ class CloudFrontManager {
67
67
  return oai;
68
68
  }
69
69
  /**
70
- * @deprecated Use `createDistributionWithS3Origin` instead
71
- *
72
70
  * @summary Method to create a cloudfront distribution
73
71
  * @param {string} id scoped id of the resource
74
72
  * @param {common.CommonConstruct} scope scope in which this resource is defined
@@ -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.2.0",
3
+ "version": "6.4.0",
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.4",
50
- "app-root-path": "^3.0.0",
51
- "aws-cdk-lib": "^2.35.0",
52
- "aws-sdk": "^2.1189.0",
53
- "constructs": "^10.1.67",
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.6",
63
- "@typescript-eslint/eslint-plugin": "^5.32.0",
64
- "@typescript-eslint/parser": "^5.32.0",
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.21.0",
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.3.0",
81
+ "lerna": "^5.4.2",
82
82
  "prettier": "^2.7.1",
83
- "prettier-plugin-organize-imports": "^3.0.1",
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.7",
86
+ "ts-jest": "^28.0.8",
87
87
  "ts-node": "^10.9.1",
88
88
  "typescript": "4.7.4"
89
89
  },
@@ -35,10 +35,9 @@ 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
- siteDistribution: cloudfront.Distribution
40
+ siteDistribution: cloudfront.IDistribution
42
41
  siteLogBucket: s3.IBucket
43
42
  siteOriginAccessIdentity: cloudfront.OriginAccessIdentity
44
43
  siteCloudfrontFunction: cloudfront.Function
@@ -63,9 +62,11 @@ export class StaticSite extends CommonConstruct {
63
62
  this.createSiteOrigin()
64
63
  this.createSiteCloudfrontFunction()
65
64
  this.resolveSiteFunctionAssociations()
65
+ this.createSiteOriginAccessIdentity()
66
66
  this.createSiteDistribution()
67
67
  this.createSiteRouteAssets()
68
68
  this.deploySite()
69
+ this.invalidateDistributionCache()
69
70
  }
70
71
 
71
72
  /**
@@ -153,6 +154,12 @@ export class StaticSite extends CommonConstruct {
153
154
  }
154
155
  }
155
156
 
157
+ /**
158
+ * @summary Method to create a site origin access identity
159
+ * @protected
160
+ */
161
+ protected createSiteOriginAccessIdentity() {}
162
+
156
163
  /**
157
164
  * @summary Method to create a site cloudfront distribution
158
165
  * @protected
@@ -204,4 +211,19 @@ export class StaticSite extends CommonConstruct {
204
211
  true
205
212
  )
206
213
  }
214
+
215
+ /**
216
+ * Method to invalidation the cloudfront distribution cache after a deployment
217
+ * @protected
218
+ */
219
+ protected invalidateDistributionCache() {
220
+ if (this.props.siteCacheInvalidationDockerFilePath) {
221
+ this.cloudFrontManager.invalidateCache(
222
+ `${this.id}-cache-invalidation`,
223
+ this,
224
+ this.props.siteCacheInvalidationDockerFilePath,
225
+ this.siteDistribution.distributionId
226
+ )
227
+ }
228
+ }
207
229
  }
@@ -50,8 +50,6 @@ export class CloudFrontManager {
50
50
  }
51
51
 
52
52
  /**
53
- * @deprecated Use `createDistributionWithS3Origin` instead
54
- *
55
53
  * @summary Method to create a cloudfront distribution
56
54
  * @param {string} id scoped id of the resource
57
55
  * @param {common.CommonConstruct} scope scope in which this resource is defined
@@ -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