@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.
@@ -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;
@@ -141,7 +141,23 @@ function stackTagger(stack, { name } = {}) {
141
141
  class JaypieApiGateway extends constructs.Construct {
142
142
  constructor(scope, id, props) {
143
143
  super(scope, id);
144
- const { certificate = true, handler, host, name, roleTag = cdk.CDK.ROLE.API, zone, } = props;
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
+ }
145
161
  const apiGatewayName = name || constructEnvName("ApiGateway");
146
162
  const certificateName = constructEnvName("Certificate");
147
163
  const apiDomainName = constructEnvName("ApiDomainName");
@@ -423,7 +439,7 @@ class JaypieLambda extends constructs.Construct {
423
439
  }
424
440
  // Configure provisioned concurrency if specified
425
441
  if (provisionedConcurrentExecutions !== undefined) {
426
- new lambda__namespace.Alias(this, "ProvisionedAlias", {
442
+ this._alias = new lambda__namespace.Alias(this, "ProvisionedAlias", {
427
443
  aliasName: "provisioned",
428
444
  version: this._lambda.currentVersion,
429
445
  provisionedConcurrentExecutions,
@@ -440,15 +456,18 @@ class JaypieLambda extends constructs.Construct {
440
456
  get lambda() {
441
457
  return this._lambda;
442
458
  }
459
+ get alias() {
460
+ return this._alias;
461
+ }
443
462
  get code() {
444
463
  return this._code;
445
464
  }
446
465
  // IFunction implementation
447
466
  get functionArn() {
448
- return this._lambda.functionArn;
467
+ return this._alias?.functionArn ?? this._lambda.functionArn;
449
468
  }
450
469
  get functionName() {
451
- return this._lambda.functionName;
470
+ return this._alias?.functionName ?? this._lambda.functionName;
452
471
  }
453
472
  get grantPrincipal() {
454
473
  return this._lambda.grantPrincipal;
@@ -472,7 +491,8 @@ class JaypieLambda extends constructs.Construct {
472
491
  return this._lambda.permissionsNode;
473
492
  }
474
493
  get resourceArnsForGrantInvoke() {
475
- return this._lambda.resourceArnsForGrantInvoke;
494
+ return (this._alias?.resourceArnsForGrantInvoke ??
495
+ this._lambda.resourceArnsForGrantInvoke);
476
496
  }
477
497
  addEventSource(source) {
478
498
  this._lambda.addEventSource(source);
@@ -496,7 +516,7 @@ class JaypieLambda extends constructs.Construct {
496
516
  this._lambda.configureAsyncInvoke(options);
497
517
  }
498
518
  grantInvoke(grantee) {
499
- return this._lambda.grantInvoke(grantee);
519
+ return (this._alias?.grantInvoke(grantee) ?? this._lambda.grantInvoke(grantee));
500
520
  }
501
521
  grantInvokeCompositePrincipal(compositePrincipal) {
502
522
  return this._lambda.grantInvokeCompositePrincipal(compositePrincipal);