@jaypie/constructs 1.1.30 → 1.1.32
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 +2 -0
- package/dist/cjs/index.cjs +26 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/JaypieLambda.d.ts +2 -0
- package/dist/esm/index.js +27 -7
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -35,9 +35,11 @@ export interface JaypieLambdaProps {
|
|
|
35
35
|
}
|
|
36
36
|
export declare class JaypieLambda extends Construct implements lambda.IFunction {
|
|
37
37
|
private readonly _lambda;
|
|
38
|
+
private readonly _alias?;
|
|
38
39
|
private readonly _code;
|
|
39
40
|
constructor(scope: Construct, id: string, props: JaypieLambdaProps);
|
|
40
41
|
get lambda(): lambda.Function;
|
|
42
|
+
get alias(): lambda.Alias | undefined;
|
|
41
43
|
get code(): lambda.Code;
|
|
42
44
|
get functionArn(): string;
|
|
43
45
|
get functionName(): string;
|
package/dist/esm/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as apiGateway from 'aws-cdk-lib/aws-apigateway';
|
|
|
6
6
|
import * as route53 from 'aws-cdk-lib/aws-route53';
|
|
7
7
|
import { HostedZone } from 'aws-cdk-lib/aws-route53';
|
|
8
8
|
import * as route53Targets from 'aws-cdk-lib/aws-route53-targets';
|
|
9
|
-
import { CDK as CDK$2, isValidSubdomain, ConfigurationError, isValidHostname
|
|
9
|
+
import { CDK as CDK$2, mergeDomain, isValidSubdomain, ConfigurationError, isValidHostname } from '@jaypie/cdk';
|
|
10
10
|
import * as s3 from 'aws-cdk-lib/aws-s3';
|
|
11
11
|
import * as s3n from 'aws-cdk-lib/aws-s3-notifications';
|
|
12
12
|
import * as lambda from 'aws-cdk-lib/aws-lambda';
|
|
@@ -109,7 +109,23 @@ function stackTagger(stack, { name } = {}) {
|
|
|
109
109
|
class JaypieApiGateway extends Construct {
|
|
110
110
|
constructor(scope, id, props) {
|
|
111
111
|
super(scope, id);
|
|
112
|
-
const { certificate = true, handler, host, name, roleTag = CDK$2.ROLE.API, zone, } = props;
|
|
112
|
+
const { certificate = true, handler, host: propsHost, name, roleTag = CDK$2.ROLE.API, zone: propsZone, } = props;
|
|
113
|
+
// Determine zone from props or environment
|
|
114
|
+
let zone = propsZone;
|
|
115
|
+
if (!zone && process.env.CDK_ENV_API_HOSTED_ZONE) {
|
|
116
|
+
zone = process.env.CDK_ENV_API_HOSTED_ZONE;
|
|
117
|
+
}
|
|
118
|
+
// Determine host from props or environment
|
|
119
|
+
let host = propsHost;
|
|
120
|
+
if (!host) {
|
|
121
|
+
if (process.env.CDK_ENV_API_HOST_NAME) {
|
|
122
|
+
host = process.env.CDK_ENV_API_HOST_NAME;
|
|
123
|
+
}
|
|
124
|
+
else if (process.env.CDK_ENV_API_SUBDOMAIN &&
|
|
125
|
+
process.env.CDK_ENV_API_HOSTED_ZONE) {
|
|
126
|
+
host = mergeDomain(process.env.CDK_ENV_API_SUBDOMAIN, process.env.CDK_ENV_API_HOSTED_ZONE);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
113
129
|
const apiGatewayName = name || constructEnvName("ApiGateway");
|
|
114
130
|
const certificateName = constructEnvName("Certificate");
|
|
115
131
|
const apiDomainName = constructEnvName("ApiDomainName");
|
|
@@ -391,7 +407,7 @@ class JaypieLambda extends Construct {
|
|
|
391
407
|
}
|
|
392
408
|
// Configure provisioned concurrency if specified
|
|
393
409
|
if (provisionedConcurrentExecutions !== undefined) {
|
|
394
|
-
new lambda.Alias(this, "ProvisionedAlias", {
|
|
410
|
+
this._alias = new lambda.Alias(this, "ProvisionedAlias", {
|
|
395
411
|
aliasName: "provisioned",
|
|
396
412
|
version: this._lambda.currentVersion,
|
|
397
413
|
provisionedConcurrentExecutions,
|
|
@@ -408,15 +424,18 @@ class JaypieLambda extends Construct {
|
|
|
408
424
|
get lambda() {
|
|
409
425
|
return this._lambda;
|
|
410
426
|
}
|
|
427
|
+
get alias() {
|
|
428
|
+
return this._alias;
|
|
429
|
+
}
|
|
411
430
|
get code() {
|
|
412
431
|
return this._code;
|
|
413
432
|
}
|
|
414
433
|
// IFunction implementation
|
|
415
434
|
get functionArn() {
|
|
416
|
-
return this._lambda.functionArn;
|
|
435
|
+
return this._alias?.functionArn ?? this._lambda.functionArn;
|
|
417
436
|
}
|
|
418
437
|
get functionName() {
|
|
419
|
-
return this._lambda.functionName;
|
|
438
|
+
return this._alias?.functionName ?? this._lambda.functionName;
|
|
420
439
|
}
|
|
421
440
|
get grantPrincipal() {
|
|
422
441
|
return this._lambda.grantPrincipal;
|
|
@@ -440,7 +459,8 @@ class JaypieLambda extends Construct {
|
|
|
440
459
|
return this._lambda.permissionsNode;
|
|
441
460
|
}
|
|
442
461
|
get resourceArnsForGrantInvoke() {
|
|
443
|
-
return this.
|
|
462
|
+
return (this._alias?.resourceArnsForGrantInvoke ??
|
|
463
|
+
this._lambda.resourceArnsForGrantInvoke);
|
|
444
464
|
}
|
|
445
465
|
addEventSource(source) {
|
|
446
466
|
this._lambda.addEventSource(source);
|
|
@@ -464,7 +484,7 @@ class JaypieLambda extends Construct {
|
|
|
464
484
|
this._lambda.configureAsyncInvoke(options);
|
|
465
485
|
}
|
|
466
486
|
grantInvoke(grantee) {
|
|
467
|
-
return this._lambda.grantInvoke(grantee);
|
|
487
|
+
return (this._alias?.grantInvoke(grantee) ?? this._lambda.grantInvoke(grantee));
|
|
468
488
|
}
|
|
469
489
|
grantInvokeCompositePrincipal(compositePrincipal) {
|
|
470
490
|
return this._lambda.grantInvokeCompositePrincipal(compositePrincipal);
|