@gradientedge/cdk-utils 4.11.1 → 4.11.4

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.
@@ -34,6 +34,7 @@ export declare class CommonStack extends cdk.Stack {
34
34
  domainName: any;
35
35
  subDomain: any;
36
36
  extraContexts: any;
37
+ skipStageForARecords: any;
37
38
  };
38
39
  /**
39
40
  * @summary Method to determine extra cdk contexts apart from the main cdk.json
@@ -72,6 +72,7 @@ class CommonStack extends cdk.Stack {
72
72
  domainName: this.node.tryGetContext('domainName'),
73
73
  subDomain: this.node.tryGetContext('subDomain'),
74
74
  extraContexts: this.node.tryGetContext('extraContexts'),
75
+ skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
75
76
  };
76
77
  }
77
78
  /**
@@ -592,7 +592,7 @@ class ApiToEventBridgeTarget extends common_1.CommonConstruct {
592
592
  createApiDomain() {
593
593
  if (this.props.api.useExisting)
594
594
  return;
595
- this.apiDestinedRestApi.domain = this.apiManager.createApiDomain(`${this.id}-api-domain`, this, this.isProductionStage()
595
+ this.apiDestinedRestApi.domain = this.apiManager.createApiDomain(`${this.id}-api-domain`, this, this.isProductionStage() || this.props.skipStageForARecords
596
596
  ? `${this.props.apiSubDomain}.${this.fullyQualifiedDomainName}`
597
597
  : `${this.props.apiSubDomain}-${this.props.stage}.${this.fullyQualifiedDomainName}`, this.apiDestinedRestApi.certificate);
598
598
  }
@@ -617,7 +617,7 @@ class ApiToEventBridgeTarget extends common_1.CommonConstruct {
617
617
  createApiRouteAssets() {
618
618
  if (this.props.api.useExisting)
619
619
  return;
620
- this.route53Manager.createApiGatewayARecord(`${this.id}-custom-domain-a-record`, this, this.props.apiSubDomain, this.apiDestinedRestApi.domain, this.apiDestinedRestApi.hostedZone);
620
+ this.route53Manager.createApiGatewayARecord(`${this.id}-custom-domain-a-record`, this, this.props.apiSubDomain, this.apiDestinedRestApi.domain, this.apiDestinedRestApi.hostedZone, this.props.skipStageForARecords);
621
621
  }
622
622
  }
623
623
  exports.ApiToEventBridgeTarget = ApiToEventBridgeTarget;
@@ -173,7 +173,7 @@ class GraphQLApiLambda extends common_1.CommonConstruct {
173
173
  * @protected
174
174
  */
175
175
  createApiDomain() {
176
- this.graphQLApiDomain = this.apiManager.createApiDomain(`${this.id}-api-domain`, this, this.isProductionStage()
176
+ this.graphQLApiDomain = this.apiManager.createApiDomain(`${this.id}-api-domain`, this, this.isProductionStage() || this.props.skipStageForARecords
177
177
  ? `${this.props.apiSubDomain}.${this.fullyQualifiedDomainName}`
178
178
  : `${this.props.apiSubDomain}-${this.props.stage}.${this.fullyQualifiedDomainName}`, this.graphQLApiCertificate);
179
179
  }
@@ -206,7 +206,7 @@ class GraphQLApiLambda extends common_1.CommonConstruct {
206
206
  * @protected
207
207
  */
208
208
  createApiRouteAssets() {
209
- this.route53Manager.createApiGatewayARecord(`${this.id}-custom-domain-a-record`, this, this.props.apiSubDomain, this.graphQLApiDomain, this.graphQLApiHostedZone);
209
+ this.route53Manager.createApiGatewayARecord(`${this.id}-custom-domain-a-record`, this, this.props.apiSubDomain, this.graphQLApiDomain, this.graphQLApiHostedZone, this.props.skipStageForARecords);
210
210
  }
211
211
  }
212
212
  exports.GraphQLApiLambda = GraphQLApiLambda;
@@ -316,7 +316,7 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
316
316
  * @protected
317
317
  */
318
318
  createNetworkMappings() {
319
- this.route53Manager.createCloudFrontTargetARecord(`${this.id}-a-record`, this, this.siteDistribution, this.siteHostedZone, this.props.siteRecordName);
319
+ this.route53Manager.createCloudFrontTargetARecord(`${this.id}-a-record`, this, this.siteDistribution, this.siteHostedZone, this.props.siteRecordName, this.props.skipStageForARecords);
320
320
  }
321
321
  /**
322
322
  * Method to invalidation the cloudfront distribution cache after a deployment
@@ -156,10 +156,7 @@ class StaticSite extends common_1.CommonConstruct {
156
156
  * @protected
157
157
  */
158
158
  createSiteRouteAssets() {
159
- this.siteARecord = this.route53Manager.createCloudFrontTargetARecord(`${this.id}-domain-a-record`, this, this.siteDistribution, this.siteHostedZone, this.props.siteRecordName);
160
- if (!this.isProductionStage() && this.props.siteCreateAltARecord) {
161
- this.siteARecordAlt = this.route53Manager.createCloudFrontTargetARecordV2(`${this.id}-domain-a-record-alt`, this, this.siteDistribution, this.siteHostedZone, this.props.siteRecordName);
162
- }
159
+ this.siteARecord = this.route53Manager.createCloudFrontTargetARecord(`${this.id}-domain-a-record`, this, this.siteDistribution, this.siteHostedZone, this.props.siteRecordName, this.props.skipStageForARecords);
163
160
  }
164
161
  /**
165
162
  * @summary Method to deploy the static assets into s3 bucket for static site
@@ -45,8 +45,9 @@ export declare class Route53Manager {
45
45
  * @param {cloudfront.IDistribution} distribution
46
46
  * @param {route53.IHostedZone} hostedZone
47
47
  * @param {string} recordName
48
+ * @param skipStageFromRecord
48
49
  */
49
- createCloudFrontTargetARecord(id: string, scope: common.CommonConstruct, distribution?: cloudfront.IDistribution, hostedZone?: route53.IHostedZone, recordName?: string): route53.ARecord;
50
+ createCloudFrontTargetARecord(id: string, scope: common.CommonConstruct, distribution?: cloudfront.IDistribution, hostedZone?: route53.IHostedZone, recordName?: string, skipStageFromRecord?: boolean): route53.ARecord;
50
51
  /**
51
52
  * @summary Method to create a-record for cloudfront target
52
53
  * @param {string} id scoped id of the resource
@@ -63,6 +64,7 @@ export declare class Route53Manager {
63
64
  * @param recordName
64
65
  * @param apiDomain
65
66
  * @param hostedZone
67
+ * @param skipStageFromRecord
66
68
  */
67
- createApiGatewayARecord(id: string, scope: common.CommonConstruct, recordName: string, apiDomain: apig.DomainName, hostedZone: route53.IHostedZone): route53.ARecord;
69
+ createApiGatewayARecord(id: string, scope: common.CommonConstruct, recordName: string, apiDomain: apig.DomainName, hostedZone: route53.IHostedZone, skipStageFromRecord?: boolean): route53.ARecord;
68
70
  }
@@ -103,14 +103,17 @@ class Route53Manager {
103
103
  * @param {cloudfront.IDistribution} distribution
104
104
  * @param {route53.IHostedZone} hostedZone
105
105
  * @param {string} recordName
106
+ * @param skipStageFromRecord
106
107
  */
107
- createCloudFrontTargetARecord(id, scope, distribution, hostedZone, recordName) {
108
+ createCloudFrontTargetARecord(id, scope, distribution, hostedZone, recordName, skipStageFromRecord) {
108
109
  if (!distribution)
109
110
  throw `Distribution undefined`;
110
111
  if (!hostedZone)
111
112
  throw `HostedZone undefined`;
112
113
  const aRecord = new route53.ARecord(scope, `${id}`, {
113
- recordName: recordName && scope.isProductionStage() ? `${recordName}` : `${recordName}-${scope.props.stage}`,
114
+ recordName: (recordName && scope.isProductionStage()) || skipStageFromRecord
115
+ ? `${recordName}`
116
+ : `${recordName}-${scope.props.stage}`,
114
117
  target: route53.RecordTarget.fromAlias(new route53Targets.CloudFrontTarget(distribution)),
115
118
  zone: hostedZone,
116
119
  });
@@ -145,11 +148,13 @@ class Route53Manager {
145
148
  * @param recordName
146
149
  * @param apiDomain
147
150
  * @param hostedZone
151
+ * @param skipStageFromRecord
148
152
  */
149
- createApiGatewayARecord(id, scope, recordName, apiDomain, hostedZone) {
153
+ createApiGatewayARecord(id, scope, recordName, apiDomain, hostedZone, skipStageFromRecord) {
150
154
  let apiRecordName = '';
151
155
  if (recordName && recordName !== '')
152
- apiRecordName = scope.isProductionStage() ? `${recordName}` : `${recordName}-${scope.props.stage}`;
156
+ apiRecordName =
157
+ scope.isProductionStage() || skipStageFromRecord ? `${recordName}` : `${recordName}-${scope.props.stage}`;
153
158
  const apiARecord = new route53.ARecord(scope, `${id}`, {
154
159
  recordName: apiRecordName,
155
160
  target: route53.RecordTarget.fromAlias(new route53Targets.ApiGatewayDomain(apiDomain)),
@@ -49,6 +49,7 @@ export interface CommonStackProps extends cdk.StackProps {
49
49
  subDomain?: string;
50
50
  extraContexts?: string[];
51
51
  stageContextPath?: string;
52
+ skipStageForARecords: boolean;
52
53
  }
53
54
  /**
54
55
  * @category cdk-utils.site-with-ecs-backend
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "4.11.1",
3
+ "version": "4.11.4",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -55,6 +55,7 @@ export class CommonStack extends cdk.Stack {
55
55
  domainName: this.node.tryGetContext('domainName'),
56
56
  subDomain: this.node.tryGetContext('subDomain'),
57
57
  extraContexts: this.node.tryGetContext('extraContexts'),
58
+ skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
58
59
  }
59
60
  }
60
61
 
@@ -655,7 +655,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
655
655
  this.apiDestinedRestApi.domain = this.apiManager.createApiDomain(
656
656
  `${this.id}-api-domain`,
657
657
  this,
658
- this.isProductionStage()
658
+ this.isProductionStage() || this.props.skipStageForARecords
659
659
  ? `${this.props.apiSubDomain}.${this.fullyQualifiedDomainName}`
660
660
  : `${this.props.apiSubDomain}-${this.props.stage}.${this.fullyQualifiedDomainName}`,
661
661
  this.apiDestinedRestApi.certificate
@@ -687,7 +687,8 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
687
687
  this,
688
688
  this.props.apiSubDomain,
689
689
  this.apiDestinedRestApi.domain,
690
- this.apiDestinedRestApi.hostedZone
690
+ this.apiDestinedRestApi.hostedZone,
691
+ this.props.skipStageForARecords
691
692
  )
692
693
  }
693
694
  }
@@ -207,7 +207,7 @@ export class GraphQLApiLambda extends CommonConstruct {
207
207
  this.graphQLApiDomain = this.apiManager.createApiDomain(
208
208
  `${this.id}-api-domain`,
209
209
  this,
210
- this.isProductionStage()
210
+ this.isProductionStage() || this.props.skipStageForARecords
211
211
  ? `${this.props.apiSubDomain}.${this.fullyQualifiedDomainName}`
212
212
  : `${this.props.apiSubDomain}-${this.props.stage}.${this.fullyQualifiedDomainName}`,
213
213
  this.graphQLApiCertificate
@@ -252,7 +252,8 @@ export class GraphQLApiLambda extends CommonConstruct {
252
252
  this,
253
253
  this.props.apiSubDomain,
254
254
  this.graphQLApiDomain,
255
- this.graphQLApiHostedZone
255
+ this.graphQLApiHostedZone,
256
+ this.props.skipStageForARecords
256
257
  )
257
258
  }
258
259
  }
@@ -365,7 +365,8 @@ export class SiteWithEcsBackend extends CommonConstruct {
365
365
  this,
366
366
  this.siteDistribution,
367
367
  this.siteHostedZone,
368
- this.props.siteRecordName
368
+ this.props.siteRecordName,
369
+ this.props.skipStageForARecords
369
370
  )
370
371
  }
371
372
 
@@ -184,18 +184,9 @@ export class StaticSite extends CommonConstruct {
184
184
  this,
185
185
  this.siteDistribution,
186
186
  this.siteHostedZone,
187
- this.props.siteRecordName
187
+ this.props.siteRecordName,
188
+ this.props.skipStageForARecords
188
189
  )
189
-
190
- if (!this.isProductionStage() && this.props.siteCreateAltARecord) {
191
- this.siteARecordAlt = this.route53Manager.createCloudFrontTargetARecordV2(
192
- `${this.id}-domain-a-record-alt`,
193
- this,
194
- this.siteDistribution,
195
- this.siteHostedZone,
196
- this.props.siteRecordName
197
- )
198
- }
199
190
  }
200
191
 
201
192
  /**
@@ -92,19 +92,24 @@ export class Route53Manager {
92
92
  * @param {cloudfront.IDistribution} distribution
93
93
  * @param {route53.IHostedZone} hostedZone
94
94
  * @param {string} recordName
95
+ * @param skipStageFromRecord
95
96
  */
96
97
  public createCloudFrontTargetARecord(
97
98
  id: string,
98
99
  scope: common.CommonConstruct,
99
100
  distribution?: cloudfront.IDistribution,
100
101
  hostedZone?: route53.IHostedZone,
101
- recordName?: string
102
+ recordName?: string,
103
+ skipStageFromRecord?: boolean
102
104
  ) {
103
105
  if (!distribution) throw `Distribution undefined`
104
106
  if (!hostedZone) throw `HostedZone undefined`
105
107
 
106
108
  const aRecord = new route53.ARecord(scope, `${id}`, {
107
- recordName: recordName && scope.isProductionStage() ? `${recordName}` : `${recordName}-${scope.props.stage}`,
109
+ recordName:
110
+ (recordName && scope.isProductionStage()) || skipStageFromRecord
111
+ ? `${recordName}`
112
+ : `${recordName}-${scope.props.stage}`,
108
113
  target: route53.RecordTarget.fromAlias(new route53Targets.CloudFrontTarget(distribution)),
109
114
  zone: hostedZone,
110
115
  })
@@ -150,17 +155,20 @@ export class Route53Manager {
150
155
  * @param recordName
151
156
  * @param apiDomain
152
157
  * @param hostedZone
158
+ * @param skipStageFromRecord
153
159
  */
154
160
  public createApiGatewayARecord(
155
161
  id: string,
156
162
  scope: common.CommonConstruct,
157
163
  recordName: string,
158
164
  apiDomain: apig.DomainName,
159
- hostedZone: route53.IHostedZone
165
+ hostedZone: route53.IHostedZone,
166
+ skipStageFromRecord?: boolean
160
167
  ) {
161
168
  let apiRecordName = ''
162
169
  if (recordName && recordName !== '')
163
- apiRecordName = scope.isProductionStage() ? `${recordName}` : `${recordName}-${scope.props.stage}`
170
+ apiRecordName =
171
+ scope.isProductionStage() || skipStageFromRecord ? `${recordName}` : `${recordName}-${scope.props.stage}`
164
172
 
165
173
  const apiARecord = new route53.ARecord(scope, `${id}`, {
166
174
  recordName: apiRecordName,
@@ -51,6 +51,7 @@ export interface CommonStackProps extends cdk.StackProps {
51
51
  subDomain?: string
52
52
  extraContexts?: string[]
53
53
  stageContextPath?: string
54
+ skipStageForARecords: boolean
54
55
  }
55
56
 
56
57
  /**