@jaypie/constructs 1.1.35 → 1.1.36-beta.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/cjs/JaypieLambda.d.ts +1 -0
- package/dist/cjs/index.cjs +215 -218
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/JaypieLambda.d.ts +1 -0
- package/dist/esm/index.js +214 -217
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -37,6 +37,7 @@ export declare class JaypieLambda extends Construct implements lambda.IFunction
|
|
|
37
37
|
private readonly _lambda;
|
|
38
38
|
private readonly _provisioned?;
|
|
39
39
|
private readonly _code;
|
|
40
|
+
private readonly _reference;
|
|
40
41
|
constructor(scope: Construct, id: string, props: JaypieLambdaProps);
|
|
41
42
|
get lambda(): lambda.Function;
|
|
42
43
|
get provisioned(): lambda.Alias | undefined;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -7,12 +7,12 @@ var apiGateway = require('aws-cdk-lib/aws-apigateway');
|
|
|
7
7
|
var route53 = require('aws-cdk-lib/aws-route53');
|
|
8
8
|
var route53Targets = require('aws-cdk-lib/aws-route53-targets');
|
|
9
9
|
var cdk = require('@jaypie/cdk');
|
|
10
|
-
var lambda = require('aws-cdk-lib/aws-lambda');
|
|
11
|
-
var secretsmanager = require('aws-cdk-lib/aws-secretsmanager');
|
|
12
10
|
var s3 = require('aws-cdk-lib/aws-s3');
|
|
13
11
|
var s3n = require('aws-cdk-lib/aws-s3-notifications');
|
|
12
|
+
var lambda = require('aws-cdk-lib/aws-lambda');
|
|
14
13
|
var sqs = require('aws-cdk-lib/aws-sqs');
|
|
15
14
|
var lambdaEventSources = require('aws-cdk-lib/aws-lambda-event-sources');
|
|
15
|
+
var secretsmanager = require('aws-cdk-lib/aws-secretsmanager');
|
|
16
16
|
var awsIam = require('aws-cdk-lib/aws-iam');
|
|
17
17
|
var awsLogs = require('aws-cdk-lib/aws-logs');
|
|
18
18
|
var sso = require('aws-cdk-lib/aws-sso');
|
|
@@ -41,12 +41,12 @@ var acm__namespace = /*#__PURE__*/_interopNamespaceDefault(acm);
|
|
|
41
41
|
var apiGateway__namespace = /*#__PURE__*/_interopNamespaceDefault(apiGateway);
|
|
42
42
|
var route53__namespace = /*#__PURE__*/_interopNamespaceDefault(route53);
|
|
43
43
|
var route53Targets__namespace = /*#__PURE__*/_interopNamespaceDefault(route53Targets);
|
|
44
|
-
var lambda__namespace = /*#__PURE__*/_interopNamespaceDefault(lambda);
|
|
45
|
-
var secretsmanager__namespace = /*#__PURE__*/_interopNamespaceDefault(secretsmanager);
|
|
46
44
|
var s3__namespace = /*#__PURE__*/_interopNamespaceDefault(s3);
|
|
47
45
|
var s3n__namespace = /*#__PURE__*/_interopNamespaceDefault(s3n);
|
|
46
|
+
var lambda__namespace = /*#__PURE__*/_interopNamespaceDefault(lambda);
|
|
48
47
|
var sqs__namespace = /*#__PURE__*/_interopNamespaceDefault(sqs);
|
|
49
48
|
var lambdaEventSources__namespace = /*#__PURE__*/_interopNamespaceDefault(lambdaEventSources);
|
|
49
|
+
var secretsmanager__namespace = /*#__PURE__*/_interopNamespaceDefault(secretsmanager);
|
|
50
50
|
var sso__namespace = /*#__PURE__*/_interopNamespaceDefault(sso);
|
|
51
51
|
var cloudfront__namespace = /*#__PURE__*/_interopNamespaceDefault(cloudfront);
|
|
52
52
|
var origins__namespace = /*#__PURE__*/_interopNamespaceDefault(origins);
|
|
@@ -138,6 +138,186 @@ function stackTagger(stack, { name } = {}) {
|
|
|
138
138
|
return true;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
class JaypieApiGateway extends constructs.Construct {
|
|
142
|
+
constructor(scope, id, props) {
|
|
143
|
+
super(scope, id);
|
|
144
|
+
const { certificate = true, handler, host: propsHost, name, roleTag = cdk.CDK.ROLE.API, zone: propsZone, } = props;
|
|
145
|
+
// Determine zone from props or environment
|
|
146
|
+
let zone = propsZone;
|
|
147
|
+
if (!zone && process.env.CDK_ENV_API_HOSTED_ZONE) {
|
|
148
|
+
zone = process.env.CDK_ENV_API_HOSTED_ZONE;
|
|
149
|
+
}
|
|
150
|
+
// Determine host from props or environment
|
|
151
|
+
let host = propsHost;
|
|
152
|
+
if (!host) {
|
|
153
|
+
if (process.env.CDK_ENV_API_HOST_NAME) {
|
|
154
|
+
host = process.env.CDK_ENV_API_HOST_NAME;
|
|
155
|
+
}
|
|
156
|
+
else if (process.env.CDK_ENV_API_SUBDOMAIN &&
|
|
157
|
+
process.env.CDK_ENV_API_HOSTED_ZONE) {
|
|
158
|
+
host = cdk.mergeDomain(process.env.CDK_ENV_API_SUBDOMAIN, process.env.CDK_ENV_API_HOSTED_ZONE);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const apiGatewayName = name || constructEnvName("ApiGateway");
|
|
162
|
+
const certificateName = constructEnvName("Certificate");
|
|
163
|
+
const apiDomainName = constructEnvName("ApiDomainName");
|
|
164
|
+
let hostedZone;
|
|
165
|
+
let certificateToUse;
|
|
166
|
+
if (host && zone) {
|
|
167
|
+
if (typeof zone === "string") {
|
|
168
|
+
hostedZone = route53__namespace.HostedZone.fromLookup(this, "HostedZone", {
|
|
169
|
+
domainName: zone,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
hostedZone = zone;
|
|
174
|
+
}
|
|
175
|
+
if (certificate === true) {
|
|
176
|
+
certificateToUse = new acm__namespace.Certificate(this, certificateName, {
|
|
177
|
+
domainName: host,
|
|
178
|
+
validation: acm__namespace.CertificateValidation.fromDns(hostedZone),
|
|
179
|
+
});
|
|
180
|
+
cdk$1.Tags.of(certificateToUse).add(cdk.CDK.TAG.ROLE, cdk.CDK.ROLE.HOSTING);
|
|
181
|
+
}
|
|
182
|
+
else if (typeof certificate === "object") {
|
|
183
|
+
certificateToUse = certificate;
|
|
184
|
+
}
|
|
185
|
+
this._certificate = certificateToUse;
|
|
186
|
+
this._host = host;
|
|
187
|
+
}
|
|
188
|
+
const {
|
|
189
|
+
// * `...lambdaRestApiProps` cannot be moved to the first const destructuring because it needs to exclude the custom properties first.
|
|
190
|
+
// Ignore the variables we already assigned to other properties
|
|
191
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
192
|
+
certificate: _certificate, host: _host, name: _name, roleTag: _roleTag, zone: _zone, handler: _handler,
|
|
193
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
194
|
+
...lambdaRestApiProps } = props;
|
|
195
|
+
this._api = new apiGateway__namespace.LambdaRestApi(this, apiGatewayName, {
|
|
196
|
+
handler,
|
|
197
|
+
...lambdaRestApiProps,
|
|
198
|
+
});
|
|
199
|
+
cdk$1.Tags.of(this._api).add(cdk.CDK.TAG.ROLE, roleTag);
|
|
200
|
+
if (host && certificateToUse && hostedZone) {
|
|
201
|
+
this._domainName = this._api.addDomainName(apiDomainName, {
|
|
202
|
+
domainName: host,
|
|
203
|
+
certificate: certificateToUse,
|
|
204
|
+
});
|
|
205
|
+
cdk$1.Tags.of(this._domainName).add(cdk.CDK.TAG.ROLE, roleTag);
|
|
206
|
+
const record = new route53__namespace.ARecord(this, "AliasRecord", {
|
|
207
|
+
recordName: host,
|
|
208
|
+
target: route53__namespace.RecordTarget.fromAlias(new route53Targets__namespace.ApiGatewayDomain(this._domainName)),
|
|
209
|
+
zone: hostedZone,
|
|
210
|
+
});
|
|
211
|
+
cdk$1.Tags.of(record).add(cdk.CDK.TAG.ROLE, cdk.CDK.ROLE.NETWORKING);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
get api() {
|
|
215
|
+
return this._api;
|
|
216
|
+
}
|
|
217
|
+
get url() {
|
|
218
|
+
return this._api.url;
|
|
219
|
+
}
|
|
220
|
+
get certificateArn() {
|
|
221
|
+
return this._certificate?.certificateArn;
|
|
222
|
+
}
|
|
223
|
+
get domainName() {
|
|
224
|
+
return this._domainName?.domainName;
|
|
225
|
+
}
|
|
226
|
+
get host() {
|
|
227
|
+
return this._host;
|
|
228
|
+
}
|
|
229
|
+
get restApiId() {
|
|
230
|
+
return this._api.restApiId;
|
|
231
|
+
}
|
|
232
|
+
get restApiName() {
|
|
233
|
+
return this._api.restApiName;
|
|
234
|
+
}
|
|
235
|
+
get restApiRootResourceId() {
|
|
236
|
+
return this._api.restApiRootResourceId;
|
|
237
|
+
}
|
|
238
|
+
get deploymentStage() {
|
|
239
|
+
return this._api.deploymentStage;
|
|
240
|
+
}
|
|
241
|
+
get domainNameAliasDomainName() {
|
|
242
|
+
return this._domainName?.domainNameAliasDomainName;
|
|
243
|
+
}
|
|
244
|
+
get domainNameAliasHostedZoneId() {
|
|
245
|
+
return this._domainName?.domainNameAliasHostedZoneId;
|
|
246
|
+
}
|
|
247
|
+
get root() {
|
|
248
|
+
return this._api.root;
|
|
249
|
+
}
|
|
250
|
+
get env() {
|
|
251
|
+
return {
|
|
252
|
+
account: cdk$1.Stack.of(this).account,
|
|
253
|
+
region: cdk$1.Stack.of(this).region,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
get stack() {
|
|
257
|
+
return this._api.stack;
|
|
258
|
+
}
|
|
259
|
+
arnForExecuteApi(method, path, stage) {
|
|
260
|
+
return this._api.arnForExecuteApi(method, path, stage);
|
|
261
|
+
}
|
|
262
|
+
metric(metricName, props) {
|
|
263
|
+
return this._api.metric(metricName, props);
|
|
264
|
+
}
|
|
265
|
+
metricCacheHitCount(props) {
|
|
266
|
+
return this._api.metricCacheHitCount(props);
|
|
267
|
+
}
|
|
268
|
+
metricCacheMissCount(props) {
|
|
269
|
+
return this._api.metricCacheMissCount(props);
|
|
270
|
+
}
|
|
271
|
+
metricClientError(props) {
|
|
272
|
+
return this._api.metricClientError(props);
|
|
273
|
+
}
|
|
274
|
+
metricCount(props) {
|
|
275
|
+
return this._api.metricCount(props);
|
|
276
|
+
}
|
|
277
|
+
metricIntegrationLatency(props) {
|
|
278
|
+
return this._api.metricIntegrationLatency(props);
|
|
279
|
+
}
|
|
280
|
+
metricLatency(props) {
|
|
281
|
+
return this._api.metricLatency(props);
|
|
282
|
+
}
|
|
283
|
+
metricServerError(props) {
|
|
284
|
+
return this._api.metricServerError(props);
|
|
285
|
+
}
|
|
286
|
+
applyRemovalPolicy(policy) {
|
|
287
|
+
this._api.applyRemovalPolicy(policy);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
class JaypieStack extends cdk$1.Stack {
|
|
292
|
+
constructor(scope, id, props = {}) {
|
|
293
|
+
const { key, ...stackProps } = props;
|
|
294
|
+
// Handle stackName
|
|
295
|
+
if (!stackProps.stackName) {
|
|
296
|
+
stackProps.stackName = constructStackName(key);
|
|
297
|
+
}
|
|
298
|
+
// Handle env
|
|
299
|
+
stackProps.env = {
|
|
300
|
+
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
301
|
+
region: process.env.CDK_DEFAULT_REGION,
|
|
302
|
+
...stackProps.env,
|
|
303
|
+
};
|
|
304
|
+
super(scope, id, stackProps);
|
|
305
|
+
// Apply tags
|
|
306
|
+
stackTagger(this, { name: stackProps.stackName });
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
class JaypieAppStack extends JaypieStack {
|
|
311
|
+
constructor(scope, id, props = {}) {
|
|
312
|
+
const { key = "app", ...stackProps } = props;
|
|
313
|
+
// Handle stackName
|
|
314
|
+
if (!stackProps.stackName) {
|
|
315
|
+
stackProps.stackName = constructStackName(key);
|
|
316
|
+
}
|
|
317
|
+
super(scope, id, { key, ...stackProps });
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
141
321
|
class JaypieLambda extends constructs.Construct {
|
|
142
322
|
constructor(scope, id, props) {
|
|
143
323
|
super(scope, id);
|
|
@@ -280,7 +460,6 @@ class JaypieLambda extends constructs.Construct {
|
|
|
280
460
|
});
|
|
281
461
|
// Grant read permissions for JaypieEnvSecrets
|
|
282
462
|
secrets.forEach((secret) => {
|
|
283
|
-
secret.grantRead(this);
|
|
284
463
|
secret.grantRead(this._lambda);
|
|
285
464
|
});
|
|
286
465
|
// Grant Datadog API key read permission if applicable
|
|
@@ -307,6 +486,9 @@ class JaypieLambda extends constructs.Construct {
|
|
|
307
486
|
if (vendorTag) {
|
|
308
487
|
cdk$1.Tags.of(this._lambda).add(cdk.CDK.TAG.VENDOR, vendorTag);
|
|
309
488
|
}
|
|
489
|
+
// Assign _reference based on provisioned state
|
|
490
|
+
this._reference =
|
|
491
|
+
this._provisioned !== undefined ? this._provisioned : this._lambda;
|
|
310
492
|
}
|
|
311
493
|
// Public accessors
|
|
312
494
|
get lambda() {
|
|
@@ -320,214 +502,86 @@ class JaypieLambda extends constructs.Construct {
|
|
|
320
502
|
}
|
|
321
503
|
// IFunction implementation
|
|
322
504
|
get functionArn() {
|
|
323
|
-
return this.
|
|
505
|
+
return this._reference.functionArn;
|
|
324
506
|
}
|
|
325
507
|
get functionName() {
|
|
326
|
-
return this.
|
|
508
|
+
return this._reference.functionName;
|
|
327
509
|
}
|
|
328
510
|
get grantPrincipal() {
|
|
329
|
-
return this.
|
|
511
|
+
return this._reference.grantPrincipal;
|
|
330
512
|
}
|
|
331
513
|
get role() {
|
|
332
|
-
return this.
|
|
514
|
+
return this._reference.role;
|
|
333
515
|
}
|
|
334
516
|
get architecture() {
|
|
335
|
-
return this.
|
|
517
|
+
return this._reference.architecture;
|
|
336
518
|
}
|
|
337
519
|
get connections() {
|
|
338
|
-
return this.
|
|
520
|
+
return this._reference.connections;
|
|
339
521
|
}
|
|
340
522
|
get isBoundToVpc() {
|
|
341
|
-
return this.
|
|
523
|
+
return this._reference.isBoundToVpc;
|
|
342
524
|
}
|
|
343
525
|
get latestVersion() {
|
|
344
|
-
return this.
|
|
526
|
+
return this._reference.latestVersion;
|
|
345
527
|
}
|
|
346
528
|
get permissionsNode() {
|
|
347
|
-
return this.
|
|
529
|
+
return this._reference.permissionsNode;
|
|
348
530
|
}
|
|
349
531
|
get resourceArnsForGrantInvoke() {
|
|
350
|
-
return this.
|
|
532
|
+
return this._reference.resourceArnsForGrantInvoke;
|
|
351
533
|
}
|
|
352
534
|
addEventSource(source) {
|
|
353
|
-
this.
|
|
535
|
+
this._reference.addEventSource(source);
|
|
354
536
|
}
|
|
355
537
|
addEventSourceMapping(id, options) {
|
|
356
|
-
return this.
|
|
538
|
+
return this._reference.addEventSourceMapping(id, options);
|
|
357
539
|
}
|
|
358
540
|
addFunctionUrl(options) {
|
|
359
|
-
return this.
|
|
541
|
+
return this._reference.addFunctionUrl(options);
|
|
360
542
|
}
|
|
361
543
|
addPermission(id, permission) {
|
|
362
|
-
this.
|
|
544
|
+
this._reference.addPermission(id, permission);
|
|
363
545
|
}
|
|
364
546
|
addToRolePolicy(statement) {
|
|
365
|
-
this.
|
|
547
|
+
this._reference.addToRolePolicy(statement);
|
|
366
548
|
}
|
|
367
549
|
addEnvironment(key, value, options) {
|
|
368
550
|
return this._lambda.addEnvironment(key, value, options);
|
|
369
551
|
}
|
|
370
552
|
configureAsyncInvoke(options) {
|
|
371
|
-
this.
|
|
553
|
+
this._reference.configureAsyncInvoke(options);
|
|
372
554
|
}
|
|
373
555
|
grantInvoke(grantee) {
|
|
374
|
-
return this.
|
|
556
|
+
return this._reference.grantInvoke(grantee);
|
|
375
557
|
}
|
|
376
558
|
grantInvokeCompositePrincipal(compositePrincipal) {
|
|
377
|
-
return this.
|
|
559
|
+
return this._reference.grantInvokeCompositePrincipal(compositePrincipal);
|
|
378
560
|
}
|
|
379
561
|
grantInvokeUrl(grantee) {
|
|
380
|
-
return this.
|
|
562
|
+
return this._reference.grantInvokeUrl(grantee);
|
|
381
563
|
}
|
|
382
564
|
metric(metricName, props) {
|
|
383
|
-
return this.
|
|
565
|
+
return this._reference.metric(metricName, props);
|
|
384
566
|
}
|
|
385
567
|
metricDuration(props) {
|
|
386
|
-
return this.
|
|
568
|
+
return this._reference.metricDuration(props);
|
|
387
569
|
}
|
|
388
570
|
metricErrors(props) {
|
|
389
|
-
return this.
|
|
571
|
+
return this._reference.metricErrors(props);
|
|
390
572
|
}
|
|
391
573
|
metricInvocations(props) {
|
|
392
|
-
return this.
|
|
574
|
+
return this._reference.metricInvocations(props);
|
|
393
575
|
}
|
|
394
576
|
metricThrottles(props) {
|
|
395
|
-
return this.
|
|
577
|
+
return this._reference.metricThrottles(props);
|
|
396
578
|
}
|
|
397
579
|
// Additional IFunction implementation
|
|
398
580
|
grantInvokeLatestVersion(grantee) {
|
|
399
|
-
return this.
|
|
581
|
+
return this._reference.grantInvokeLatestVersion(grantee);
|
|
400
582
|
}
|
|
401
583
|
grantInvokeVersion(grantee, version) {
|
|
402
|
-
return this.
|
|
403
|
-
}
|
|
404
|
-
get env() {
|
|
405
|
-
return {
|
|
406
|
-
account: cdk$1.Stack.of(this).account,
|
|
407
|
-
region: cdk$1.Stack.of(this).region,
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
get stack() {
|
|
411
|
-
return this._lambda.stack;
|
|
412
|
-
}
|
|
413
|
-
applyRemovalPolicy(policy) {
|
|
414
|
-
this._lambda.applyRemovalPolicy(policy);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
class JaypieApiGateway extends constructs.Construct {
|
|
419
|
-
constructor(scope, id, props) {
|
|
420
|
-
super(scope, id);
|
|
421
|
-
const { certificate = true, handler, host: propsHost, name, roleTag = cdk.CDK.ROLE.API, zone: propsZone, } = props;
|
|
422
|
-
// Determine zone from props or environment
|
|
423
|
-
let zone = propsZone;
|
|
424
|
-
if (!zone && process.env.CDK_ENV_API_HOSTED_ZONE) {
|
|
425
|
-
zone = process.env.CDK_ENV_API_HOSTED_ZONE;
|
|
426
|
-
}
|
|
427
|
-
// Determine host from props or environment
|
|
428
|
-
let host = propsHost;
|
|
429
|
-
if (!host) {
|
|
430
|
-
if (process.env.CDK_ENV_API_HOST_NAME) {
|
|
431
|
-
host = process.env.CDK_ENV_API_HOST_NAME;
|
|
432
|
-
}
|
|
433
|
-
else if (process.env.CDK_ENV_API_SUBDOMAIN &&
|
|
434
|
-
process.env.CDK_ENV_API_HOSTED_ZONE) {
|
|
435
|
-
host = cdk.mergeDomain(process.env.CDK_ENV_API_SUBDOMAIN, process.env.CDK_ENV_API_HOSTED_ZONE);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
const apiGatewayName = name || constructEnvName("ApiGateway");
|
|
439
|
-
const certificateName = constructEnvName("Certificate");
|
|
440
|
-
const apiDomainName = constructEnvName("ApiDomainName");
|
|
441
|
-
let hostedZone;
|
|
442
|
-
let certificateToUse;
|
|
443
|
-
if (host && zone) {
|
|
444
|
-
if (typeof zone === "string") {
|
|
445
|
-
hostedZone = route53__namespace.HostedZone.fromLookup(this, "HostedZone", {
|
|
446
|
-
domainName: zone,
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
else {
|
|
450
|
-
hostedZone = zone;
|
|
451
|
-
}
|
|
452
|
-
if (certificate === true) {
|
|
453
|
-
certificateToUse = new acm__namespace.Certificate(this, certificateName, {
|
|
454
|
-
domainName: host,
|
|
455
|
-
validation: acm__namespace.CertificateValidation.fromDns(hostedZone),
|
|
456
|
-
});
|
|
457
|
-
cdk$1.Tags.of(certificateToUse).add(cdk.CDK.TAG.ROLE, cdk.CDK.ROLE.HOSTING);
|
|
458
|
-
}
|
|
459
|
-
else if (typeof certificate === "object") {
|
|
460
|
-
certificateToUse = certificate;
|
|
461
|
-
}
|
|
462
|
-
this._certificate = certificateToUse;
|
|
463
|
-
this._host = host;
|
|
464
|
-
}
|
|
465
|
-
const {
|
|
466
|
-
// * `...lambdaRestApiProps` cannot be moved to the first const destructuring because it needs to exclude the custom properties first.
|
|
467
|
-
// Ignore the variables we already assigned to other properties
|
|
468
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
469
|
-
certificate: _certificate, host: _host, name: _name, roleTag: _roleTag, zone: _zone, handler: _handler,
|
|
470
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
471
|
-
...lambdaRestApiProps } = props;
|
|
472
|
-
// Check if handler is a JaypieLambda instance and use provisioned alias if available
|
|
473
|
-
let handlerToUse = handler;
|
|
474
|
-
if (handler instanceof JaypieLambda && handler.provisioned) {
|
|
475
|
-
handlerToUse = handler.provisioned;
|
|
476
|
-
}
|
|
477
|
-
this._api = new apiGateway__namespace.LambdaRestApi(this, apiGatewayName, {
|
|
478
|
-
handler: handlerToUse,
|
|
479
|
-
...lambdaRestApiProps,
|
|
480
|
-
});
|
|
481
|
-
cdk$1.Tags.of(this._api).add(cdk.CDK.TAG.ROLE, roleTag);
|
|
482
|
-
if (host && certificateToUse && hostedZone) {
|
|
483
|
-
this._domainName = this._api.addDomainName(apiDomainName, {
|
|
484
|
-
domainName: host,
|
|
485
|
-
certificate: certificateToUse,
|
|
486
|
-
});
|
|
487
|
-
cdk$1.Tags.of(this._domainName).add(cdk.CDK.TAG.ROLE, roleTag);
|
|
488
|
-
const record = new route53__namespace.ARecord(this, "AliasRecord", {
|
|
489
|
-
recordName: host,
|
|
490
|
-
target: route53__namespace.RecordTarget.fromAlias(new route53Targets__namespace.ApiGatewayDomain(this._domainName)),
|
|
491
|
-
zone: hostedZone,
|
|
492
|
-
});
|
|
493
|
-
cdk$1.Tags.of(record).add(cdk.CDK.TAG.ROLE, cdk.CDK.ROLE.NETWORKING);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
get api() {
|
|
497
|
-
return this._api;
|
|
498
|
-
}
|
|
499
|
-
get url() {
|
|
500
|
-
return this._api.url;
|
|
501
|
-
}
|
|
502
|
-
get certificateArn() {
|
|
503
|
-
return this._certificate?.certificateArn;
|
|
504
|
-
}
|
|
505
|
-
get domainName() {
|
|
506
|
-
return this._domainName?.domainName;
|
|
507
|
-
}
|
|
508
|
-
get host() {
|
|
509
|
-
return this._host;
|
|
510
|
-
}
|
|
511
|
-
get restApiId() {
|
|
512
|
-
return this._api.restApiId;
|
|
513
|
-
}
|
|
514
|
-
get restApiName() {
|
|
515
|
-
return this._api.restApiName;
|
|
516
|
-
}
|
|
517
|
-
get restApiRootResourceId() {
|
|
518
|
-
return this._api.restApiRootResourceId;
|
|
519
|
-
}
|
|
520
|
-
get deploymentStage() {
|
|
521
|
-
return this._api.deploymentStage;
|
|
522
|
-
}
|
|
523
|
-
get domainNameAliasDomainName() {
|
|
524
|
-
return this._domainName?.domainNameAliasDomainName;
|
|
525
|
-
}
|
|
526
|
-
get domainNameAliasHostedZoneId() {
|
|
527
|
-
return this._domainName?.domainNameAliasHostedZoneId;
|
|
528
|
-
}
|
|
529
|
-
get root() {
|
|
530
|
-
return this._api.root;
|
|
584
|
+
return this._reference.grantInvokeVersion(grantee, version);
|
|
531
585
|
}
|
|
532
586
|
get env() {
|
|
533
587
|
return {
|
|
@@ -536,67 +590,10 @@ class JaypieApiGateway extends constructs.Construct {
|
|
|
536
590
|
};
|
|
537
591
|
}
|
|
538
592
|
get stack() {
|
|
539
|
-
return this.
|
|
540
|
-
}
|
|
541
|
-
arnForExecuteApi(method, path, stage) {
|
|
542
|
-
return this._api.arnForExecuteApi(method, path, stage);
|
|
543
|
-
}
|
|
544
|
-
metric(metricName, props) {
|
|
545
|
-
return this._api.metric(metricName, props);
|
|
546
|
-
}
|
|
547
|
-
metricCacheHitCount(props) {
|
|
548
|
-
return this._api.metricCacheHitCount(props);
|
|
549
|
-
}
|
|
550
|
-
metricCacheMissCount(props) {
|
|
551
|
-
return this._api.metricCacheMissCount(props);
|
|
552
|
-
}
|
|
553
|
-
metricClientError(props) {
|
|
554
|
-
return this._api.metricClientError(props);
|
|
555
|
-
}
|
|
556
|
-
metricCount(props) {
|
|
557
|
-
return this._api.metricCount(props);
|
|
558
|
-
}
|
|
559
|
-
metricIntegrationLatency(props) {
|
|
560
|
-
return this._api.metricIntegrationLatency(props);
|
|
561
|
-
}
|
|
562
|
-
metricLatency(props) {
|
|
563
|
-
return this._api.metricLatency(props);
|
|
564
|
-
}
|
|
565
|
-
metricServerError(props) {
|
|
566
|
-
return this._api.metricServerError(props);
|
|
593
|
+
return this._reference.stack;
|
|
567
594
|
}
|
|
568
595
|
applyRemovalPolicy(policy) {
|
|
569
|
-
this.
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
class JaypieStack extends cdk$1.Stack {
|
|
574
|
-
constructor(scope, id, props = {}) {
|
|
575
|
-
const { key, ...stackProps } = props;
|
|
576
|
-
// Handle stackName
|
|
577
|
-
if (!stackProps.stackName) {
|
|
578
|
-
stackProps.stackName = constructStackName(key);
|
|
579
|
-
}
|
|
580
|
-
// Handle env
|
|
581
|
-
stackProps.env = {
|
|
582
|
-
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
583
|
-
region: process.env.CDK_DEFAULT_REGION,
|
|
584
|
-
...stackProps.env,
|
|
585
|
-
};
|
|
586
|
-
super(scope, id, stackProps);
|
|
587
|
-
// Apply tags
|
|
588
|
-
stackTagger(this, { name: stackProps.stackName });
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
class JaypieAppStack extends JaypieStack {
|
|
593
|
-
constructor(scope, id, props = {}) {
|
|
594
|
-
const { key = "app", ...stackProps } = props;
|
|
595
|
-
// Handle stackName
|
|
596
|
-
if (!stackProps.stackName) {
|
|
597
|
-
stackProps.stackName = constructStackName(key);
|
|
598
|
-
}
|
|
599
|
-
super(scope, id, { key, ...stackProps });
|
|
596
|
+
this._reference.applyRemovalPolicy(policy);
|
|
600
597
|
}
|
|
601
598
|
}
|
|
602
599
|
|