@jaypie/constructs 1.1.31 → 1.1.33

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;
@@ -422,6 +422,14 @@ class JaypieLambda extends constructs.Construct {
422
422
  reservedConcurrentExecutions,
423
423
  runtime,
424
424
  timeout: typeof timeout === "number" ? cdk$1.Duration.seconds(timeout) : timeout,
425
+ // Enable auto-publishing of versions when using provisioned concurrency
426
+ currentVersionOptions: provisionedConcurrentExecutions !== undefined
427
+ ? {
428
+ removalPolicy: cdk$1.RemovalPolicy.RETAIN,
429
+ description: "Auto-published version for provisioned concurrency",
430
+ // Don't set provisioned concurrency here - it will be set on the alias
431
+ }
432
+ : undefined,
425
433
  });
426
434
  // Grant secret read permissions
427
435
  Object.values(envSecrets).forEach((secret) => {
@@ -439,11 +447,16 @@ class JaypieLambda extends constructs.Construct {
439
447
  }
440
448
  // Configure provisioned concurrency if specified
441
449
  if (provisionedConcurrentExecutions !== undefined) {
442
- new lambda__namespace.Alias(this, "ProvisionedAlias", {
450
+ // Use currentVersion which is auto-published with proper configuration
451
+ const version = this._lambda.currentVersion;
452
+ // Create alias for provisioned concurrency
453
+ this._alias = new lambda__namespace.Alias(this, "ProvisionedAlias", {
443
454
  aliasName: "provisioned",
444
- version: this._lambda.currentVersion,
455
+ version,
445
456
  provisionedConcurrentExecutions,
446
457
  });
458
+ // Add explicit dependencies to ensure proper creation order
459
+ this._alias.node.addDependency(version);
447
460
  }
448
461
  if (roleTag) {
449
462
  cdk$1.Tags.of(this._lambda).add(cdk.CDK.TAG.ROLE, roleTag);
@@ -456,15 +469,18 @@ class JaypieLambda extends constructs.Construct {
456
469
  get lambda() {
457
470
  return this._lambda;
458
471
  }
472
+ get alias() {
473
+ return this._alias;
474
+ }
459
475
  get code() {
460
476
  return this._code;
461
477
  }
462
478
  // IFunction implementation
463
479
  get functionArn() {
464
- return this._lambda.functionArn;
480
+ return this._alias?.functionArn ?? this._lambda.functionArn;
465
481
  }
466
482
  get functionName() {
467
- return this._lambda.functionName;
483
+ return this._alias?.functionName ?? this._lambda.functionName;
468
484
  }
469
485
  get grantPrincipal() {
470
486
  return this._lambda.grantPrincipal;
@@ -488,7 +504,8 @@ class JaypieLambda extends constructs.Construct {
488
504
  return this._lambda.permissionsNode;
489
505
  }
490
506
  get resourceArnsForGrantInvoke() {
491
- return this._lambda.resourceArnsForGrantInvoke;
507
+ return (this._alias?.resourceArnsForGrantInvoke ??
508
+ this._lambda.resourceArnsForGrantInvoke);
492
509
  }
493
510
  addEventSource(source) {
494
511
  this._lambda.addEventSource(source);
@@ -512,7 +529,7 @@ class JaypieLambda extends constructs.Construct {
512
529
  this._lambda.configureAsyncInvoke(options);
513
530
  }
514
531
  grantInvoke(grantee) {
515
- return this._lambda.grantInvoke(grantee);
532
+ return (this._alias?.grantInvoke(grantee) ?? this._lambda.grantInvoke(grantee));
516
533
  }
517
534
  grantInvokeCompositePrincipal(compositePrincipal) {
518
535
  return this._lambda.grantInvokeCompositePrincipal(compositePrincipal);