@gradientedge/cdk-utils 4.11.1 → 4.11.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/dist/src/lib/common/stack.d.ts +1 -0
- package/dist/src/lib/common/stack.js +1 -0
- package/dist/src/lib/construct/api-to-eventbridge-target/main.js +1 -1
- package/dist/src/lib/construct/graphql-api-lambda/main.js +1 -1
- package/dist/src/lib/construct/site-with-ecs-backend/main.js +1 -1
- package/dist/src/lib/construct/static-site/main.js +1 -4
- package/dist/src/lib/manager/aws/route53-manager.d.ts +4 -2
- package/dist/src/lib/manager/aws/route53-manager.js +9 -4
- package/dist/src/lib/types/aws/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/lib/common/stack.ts +1 -0
- package/src/lib/construct/api-to-eventbridge-target/main.ts +2 -1
- package/src/lib/construct/graphql-api-lambda/main.ts +2 -1
- package/src/lib/construct/site-with-ecs-backend/main.ts +2 -1
- package/src/lib/construct/static-site/main.ts +2 -11
- package/src/lib/manager/aws/route53-manager.ts +12 -4
- package/src/lib/types/aws/index.ts +1 -0
|
@@ -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
|
/**
|
|
@@ -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;
|
|
@@ -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()
|
|
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 =
|
|
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)),
|
package/package.json
CHANGED
package/src/lib/common/stack.ts
CHANGED
|
@@ -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
|
|
|
@@ -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
|
}
|
|
@@ -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:
|
|
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 =
|
|
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,
|