@jaypie/constructs 1.1.36 → 1.1.38

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.
@@ -1,5 +1,6 @@
1
1
  import { Construct } from "constructs";
2
2
  import { SecretValue, RemovalPolicy, Stack } from "aws-cdk-lib";
3
+ import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
3
4
  import { ISecret, ISecretAttachmentTarget, RotationSchedule, RotationScheduleOptions } from "aws-cdk-lib/aws-secretsmanager";
4
5
  import { IKey } from "aws-cdk-lib/aws-kms";
5
6
  import { Grant, IGrantable, PolicyStatement, AddToResourcePolicyResult } from "aws-cdk-lib/aws-iam";
@@ -7,6 +8,7 @@ export interface JaypieEnvSecretProps {
7
8
  consumer?: boolean;
8
9
  envKey?: string;
9
10
  export?: string;
11
+ generateSecretString?: secretsmanager.SecretStringGenerator;
10
12
  provider?: boolean;
11
13
  roleTag?: string;
12
14
  vendorTag?: string;
@@ -3,20 +3,36 @@ import { Duration, Stack, RemovalPolicy } from "aws-cdk-lib";
3
3
  import * as lambda from "aws-cdk-lib/aws-lambda";
4
4
  import * as iam from "aws-cdk-lib/aws-iam";
5
5
  import * as cloudwatch from "aws-cdk-lib/aws-cloudwatch";
6
+ import * as ec2 from "aws-cdk-lib/aws-ec2";
6
7
  import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
7
8
  import { JaypieEnvSecret } from "./JaypieEnvSecret.js";
8
9
  export interface JaypieLambdaProps {
10
+ allowAllOutbound?: boolean;
11
+ allowPublicSubnet?: boolean;
12
+ architecture?: lambda.Architecture;
9
13
  code: lambda.Code | string;
14
+ codeSigningConfig?: lambda.ICodeSigningConfig;
10
15
  datadogApiKeyArn?: string;
16
+ deadLetterQueue?: import("aws-cdk-lib/aws-sqs").IQueue;
17
+ deadLetterQueueEnabled?: boolean;
18
+ deadLetterTopic?: import("aws-cdk-lib/aws-sns").ITopic;
19
+ description?: string;
11
20
  environment?: {
12
21
  [key: string]: string;
13
22
  };
23
+ environmentEncryption?: import("aws-cdk-lib/aws-kms").IKey;
14
24
  envSecrets?: {
15
25
  [key: string]: secretsmanager.ISecret;
16
26
  };
27
+ ephemeralStorageSize?: import("aws-cdk-lib").Size;
28
+ filesystem?: lambda.FileSystemConfig;
17
29
  handler: string;
30
+ initialPolicy?: iam.PolicyStatement[];
18
31
  layers?: lambda.ILayerVersion[];
19
32
  logRetention?: number;
33
+ logRetentionRole?: iam.IRole;
34
+ logRetentionRetryOptions?: lambda.LogRetentionRetryOptions;
35
+ maxEventAge?: Duration;
20
36
  memorySize?: number;
21
37
  paramsAndSecrets?: lambda.ParamsAndSecretsLayerVersion | boolean;
22
38
  paramsAndSecretsOptions?: {
@@ -25,23 +41,60 @@ export interface JaypieLambdaProps {
25
41
  parameterStoreTtl?: number;
26
42
  secretsManagerTtl?: number;
27
43
  };
44
+ profiling?: boolean;
45
+ profilingGroup?: import("aws-cdk-lib/aws-codeguruprofiler").IProfilingGroup;
28
46
  provisionedConcurrentExecutions?: number;
29
47
  reservedConcurrentExecutions?: number;
48
+ retryAttempts?: number;
30
49
  roleTag?: string;
31
50
  runtime?: lambda.Runtime;
51
+ runtimeManagementMode?: lambda.RuntimeManagementMode;
32
52
  secrets?: JaypieEnvSecret[];
53
+ securityGroups?: ec2.ISecurityGroup[];
33
54
  timeout?: Duration | number;
55
+ tracing?: lambda.Tracing;
34
56
  vendorTag?: string;
57
+ vpc?: ec2.IVpc;
58
+ vpcSubnets?: ec2.SubnetSelection;
35
59
  }
36
60
  export declare class JaypieLambda extends Construct implements lambda.IFunction {
37
61
  private readonly _lambda;
38
62
  private readonly _provisioned?;
39
63
  private readonly _code;
40
64
  private readonly _reference;
65
+ private readonly _handler;
66
+ private readonly _memorySize;
67
+ private readonly _timeout;
68
+ private readonly _runtime;
69
+ private readonly _environment;
70
+ private readonly _vpc?;
71
+ private readonly _vpcSubnets?;
72
+ private readonly _securityGroups?;
73
+ private readonly _reservedConcurrentExecutions?;
74
+ private readonly _layers;
75
+ private readonly _architecture;
76
+ private readonly _ephemeralStorageSize?;
77
+ private readonly _codeSigningConfig?;
78
+ private readonly _filesystemConfigs?;
79
+ private readonly _environmentEncryption?;
80
+ private readonly _tracing?;
81
+ private readonly _profiling?;
82
+ private readonly _profilingGroup?;
83
+ private readonly _logRetentionRole?;
84
+ private readonly _logRetentionRetryOptions?;
85
+ private readonly _initialPolicy?;
86
+ private readonly _description?;
87
+ private readonly _maxEventAge?;
88
+ private readonly _retryAttempts?;
89
+ private readonly _runtimeManagementMode?;
90
+ private readonly _allowAllOutbound?;
91
+ private readonly _allowPublicSubnet?;
92
+ private readonly _deadLetterQueueEnabled?;
41
93
  constructor(scope: Construct, id: string, props: JaypieLambdaProps);
42
94
  get lambda(): lambda.Function;
43
95
  get provisioned(): lambda.Alias | undefined;
44
96
  get code(): lambda.Code;
97
+ get reference(): lambda.IFunction;
45
98
  get functionArn(): string;
46
99
  get functionName(): string;
47
100
  get grantPrincipal(): iam.IPrincipal;
@@ -75,4 +128,47 @@ export declare class JaypieLambda extends Construct implements lambda.IFunction
75
128
  };
76
129
  get stack(): Stack;
77
130
  applyRemovalPolicy(policy: RemovalPolicy): void;
131
+ get currentVersion(): lambda.Version;
132
+ get deadLetterQueue(): import("aws-cdk-lib/aws-sqs").IQueue | undefined;
133
+ get deadLetterTopic(): import("aws-cdk-lib/aws-sns").ITopic | undefined;
134
+ get logGroup(): import("aws-cdk-lib/aws-logs").ILogGroup;
135
+ get runtime(): lambda.Runtime;
136
+ get timeout(): Duration | undefined;
137
+ addAlias(aliasName: string, options?: lambda.AliasOptions): lambda.Alias;
138
+ addLayers(...layers: lambda.ILayerVersion[]): void;
139
+ invalidateVersionBasedOn(x: string): void;
140
+ metricConcurrentExecutions(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
141
+ metricUnreservedConcurrentExecutions(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
142
+ addVersion(name: string, codeSha256?: string, description?: string, provisionedExecutions?: number, asyncInvokeConfig?: lambda.EventInvokeConfigOptions): lambda.Version;
143
+ get memorySize(): number | undefined;
144
+ get handler(): string;
145
+ get environment(): {
146
+ [key: string]: string;
147
+ } | undefined;
148
+ get layers(): lambda.ILayerVersion[] | undefined;
149
+ get maxEventAge(): Duration | undefined;
150
+ get retryAttempts(): number | undefined;
151
+ get reservedConcurrentExecutions(): number | undefined;
152
+ get description(): string | undefined;
153
+ get initialPolicy(): iam.PolicyStatement[] | undefined;
154
+ get logRetentionRole(): iam.IRole | undefined;
155
+ get logRetentionRetryOptions(): lambda.LogRetentionRetryOptions | undefined;
156
+ get tracing(): lambda.Tracing | undefined;
157
+ get profiling(): boolean | undefined;
158
+ get profilingGroup(): import("aws-cdk-lib/aws-codeguruprofiler").IProfilingGroup | undefined;
159
+ get environmentEncryption(): import("aws-cdk-lib/aws-kms").IKey | undefined;
160
+ get codeSigningConfig(): lambda.ICodeSigningConfig | undefined;
161
+ get filesystemConfig(): lambda.FileSystemConfig | undefined;
162
+ get filesystemConfigs(): lambda.FileSystemConfig[] | undefined;
163
+ get ephemeralStorageSize(): number | undefined;
164
+ get runtimeManagementMode(): lambda.RuntimeManagementMode | undefined;
165
+ get architectureLabel(): string;
166
+ get vpc(): ec2.IVpc | undefined;
167
+ get vpcSubnets(): ec2.SubnetSelection | undefined;
168
+ get securityGroups(): ec2.ISecurityGroup[] | undefined;
169
+ get allowAllOutbound(): boolean | undefined;
170
+ get allowPublicSubnet(): boolean | undefined;
171
+ get canCreateLambdaLogGroup(): boolean;
172
+ get canCreatePermissions(): boolean;
173
+ get deadLetterQueueEnabled(): boolean | undefined;
78
174
  }
@@ -12,6 +12,7 @@ var s3n = require('aws-cdk-lib/aws-s3-notifications');
12
12
  var lambda = require('aws-cdk-lib/aws-lambda');
13
13
  var sqs = require('aws-cdk-lib/aws-sqs');
14
14
  var lambdaEventSources = require('aws-cdk-lib/aws-lambda-event-sources');
15
+ var cloudwatch = require('aws-cdk-lib/aws-cloudwatch');
15
16
  var secretsmanager = require('aws-cdk-lib/aws-secretsmanager');
16
17
  var awsIam = require('aws-cdk-lib/aws-iam');
17
18
  var awsLogs = require('aws-cdk-lib/aws-logs');
@@ -46,6 +47,7 @@ var s3n__namespace = /*#__PURE__*/_interopNamespaceDefault(s3n);
46
47
  var lambda__namespace = /*#__PURE__*/_interopNamespaceDefault(lambda);
47
48
  var sqs__namespace = /*#__PURE__*/_interopNamespaceDefault(sqs);
48
49
  var lambdaEventSources__namespace = /*#__PURE__*/_interopNamespaceDefault(lambdaEventSources);
50
+ var cloudwatch__namespace = /*#__PURE__*/_interopNamespaceDefault(cloudwatch);
49
51
  var secretsmanager__namespace = /*#__PURE__*/_interopNamespaceDefault(secretsmanager);
50
52
  var sso__namespace = /*#__PURE__*/_interopNamespaceDefault(sso);
51
53
  var cloudfront__namespace = /*#__PURE__*/_interopNamespaceDefault(cloudfront);
@@ -321,7 +323,7 @@ class JaypieAppStack extends JaypieStack {
321
323
  class JaypieLambda extends constructs.Construct {
322
324
  constructor(scope, id, props) {
323
325
  super(scope, id);
324
- const { code, datadogApiKeyArn, environment: initialEnvironment = {}, envSecrets = {}, handler = "index.handler", layers = [], logRetention = cdk.CDK.LAMBDA.LOG_RETENTION, memorySize = cdk.CDK.LAMBDA.MEMORY_SIZE, paramsAndSecrets, paramsAndSecretsOptions, provisionedConcurrentExecutions, reservedConcurrentExecutions, roleTag = cdk.CDK.ROLE.PROCESSING, runtime = lambda__namespace.Runtime.NODEJS_22_X, secrets = [], timeout = cdk$1.Duration.seconds(cdk.CDK.DURATION.LAMBDA_WORKER), vendorTag, } = props;
326
+ const { allowAllOutbound, allowPublicSubnet, architecture = lambda__namespace.Architecture.X86_64, code, codeSigningConfig, datadogApiKeyArn, deadLetterQueue, deadLetterQueueEnabled, deadLetterTopic, description, environment: initialEnvironment = {}, environmentEncryption, envSecrets = {}, ephemeralStorageSize, filesystem, handler = "index.handler", initialPolicy, layers = [], logRetention = cdk.CDK.LAMBDA.LOG_RETENTION, logRetentionRole, logRetentionRetryOptions, maxEventAge, memorySize = cdk.CDK.LAMBDA.MEMORY_SIZE, paramsAndSecrets, paramsAndSecretsOptions, profiling, profilingGroup, provisionedConcurrentExecutions, reservedConcurrentExecutions, retryAttempts, roleTag = cdk.CDK.ROLE.PROCESSING, runtime = lambda__namespace.Runtime.NODEJS_22_X, runtimeManagementMode, secrets = [], securityGroups, timeout = cdk$1.Duration.seconds(cdk.CDK.DURATION.LAMBDA_WORKER), tracing, vendorTag, vpc, vpcSubnets, } = props;
325
327
  // Create a mutable copy of the environment variables
326
328
  let environment = { ...initialEnvironment };
327
329
  // Default environment values
@@ -435,20 +437,43 @@ class JaypieLambda extends constructs.Construct {
435
437
  }, {});
436
438
  // Create Lambda Function
437
439
  this._lambda = new lambda__namespace.Function(this, "Function", {
440
+ allowAllOutbound,
441
+ allowPublicSubnet,
442
+ architecture,
438
443
  code: this._code,
444
+ codeSigningConfig,
445
+ deadLetterQueue,
446
+ deadLetterQueueEnabled,
447
+ deadLetterTopic,
448
+ description,
439
449
  environment: {
440
450
  ...environment,
441
451
  ...secretsEnvironment,
442
452
  ...jaypieSecretsEnvironment,
443
453
  },
454
+ environmentEncryption,
455
+ ephemeralStorageSize,
456
+ filesystem: filesystem ? { config: filesystem } : undefined,
444
457
  handler,
458
+ initialPolicy,
445
459
  layers: resolvedLayers,
446
460
  logRetention,
461
+ logRetentionRole,
462
+ logRetentionRetryOptions,
463
+ maxEventAge,
447
464
  memorySize,
448
465
  paramsAndSecrets: resolvedParamsAndSecrets,
466
+ profiling,
467
+ profilingGroup,
449
468
  reservedConcurrentExecutions,
469
+ retryAttempts,
450
470
  runtime,
471
+ runtimeManagementMode,
472
+ securityGroups,
451
473
  timeout: typeof timeout === "number" ? cdk$1.Duration.seconds(timeout) : timeout,
474
+ tracing,
475
+ vpc,
476
+ vpcSubnets,
452
477
  // Enable auto-publishing of versions when using provisioned concurrency
453
478
  currentVersionOptions: provisionedConcurrentExecutions !== undefined
454
479
  ? {
@@ -490,6 +515,40 @@ class JaypieLambda extends constructs.Construct {
490
515
  if (vendorTag) {
491
516
  cdk$1.Tags.of(this._lambda).add(cdk.CDK.TAG.VENDOR, vendorTag);
492
517
  }
518
+ // Store constructor props for later access
519
+ this._handler = handler;
520
+ this._memorySize = memorySize;
521
+ this._timeout =
522
+ typeof timeout === "number" ? cdk$1.Duration.seconds(timeout) : timeout;
523
+ this._runtime = runtime;
524
+ this._environment = {
525
+ ...environment,
526
+ ...secretsEnvironment,
527
+ ...jaypieSecretsEnvironment,
528
+ };
529
+ this._vpc = vpc;
530
+ this._vpcSubnets = vpcSubnets;
531
+ this._securityGroups = securityGroups;
532
+ this._reservedConcurrentExecutions = reservedConcurrentExecutions;
533
+ this._layers = resolvedLayers;
534
+ this._architecture = architecture;
535
+ this._ephemeralStorageSize = ephemeralStorageSize?.toMebibytes();
536
+ this._codeSigningConfig = codeSigningConfig;
537
+ this._filesystemConfigs = filesystem ? [filesystem] : undefined;
538
+ this._environmentEncryption = environmentEncryption;
539
+ this._tracing = tracing;
540
+ this._profiling = profiling;
541
+ this._profilingGroup = profilingGroup;
542
+ this._logRetentionRole = logRetentionRole;
543
+ this._logRetentionRetryOptions = logRetentionRetryOptions;
544
+ this._initialPolicy = initialPolicy;
545
+ this._description = description;
546
+ this._maxEventAge = maxEventAge;
547
+ this._retryAttempts = retryAttempts;
548
+ this._runtimeManagementMode = runtimeManagementMode;
549
+ this._allowAllOutbound = allowAllOutbound;
550
+ this._allowPublicSubnet = allowPublicSubnet;
551
+ this._deadLetterQueueEnabled = deadLetterQueueEnabled;
493
552
  // Assign _reference based on provisioned state
494
553
  this._reference =
495
554
  this._provisioned !== undefined ? this._provisioned : this._lambda;
@@ -504,6 +563,9 @@ class JaypieLambda extends constructs.Construct {
504
563
  get code() {
505
564
  return this._code;
506
565
  }
566
+ get reference() {
567
+ return this._reference;
568
+ }
507
569
  // IFunction implementation
508
570
  get functionArn() {
509
571
  return this._reference.functionArn;
@@ -599,6 +661,147 @@ class JaypieLambda extends constructs.Construct {
599
661
  applyRemovalPolicy(policy) {
600
662
  this._reference.applyRemovalPolicy(policy);
601
663
  }
664
+ // Additional Lambda Function specific methods
665
+ get currentVersion() {
666
+ return this._lambda.currentVersion;
667
+ }
668
+ get deadLetterQueue() {
669
+ return this._lambda.deadLetterQueue;
670
+ }
671
+ get deadLetterTopic() {
672
+ return this._lambda.deadLetterTopic;
673
+ }
674
+ get logGroup() {
675
+ return this._lambda.logGroup;
676
+ }
677
+ get runtime() {
678
+ return this._runtime;
679
+ }
680
+ get timeout() {
681
+ return this._timeout;
682
+ }
683
+ addAlias(aliasName, options) {
684
+ return this._lambda.addAlias(aliasName, options);
685
+ }
686
+ addLayers(...layers) {
687
+ this._lambda.addLayers(...layers);
688
+ }
689
+ invalidateVersionBasedOn(x) {
690
+ this._lambda.invalidateVersionBasedOn(x);
691
+ }
692
+ metricConcurrentExecutions(props) {
693
+ return new cloudwatch__namespace.Metric({
694
+ namespace: "AWS/Lambda",
695
+ metricName: "ConcurrentExecutions",
696
+ dimensionsMap: {
697
+ FunctionName: this.functionName,
698
+ },
699
+ ...props,
700
+ });
701
+ }
702
+ metricUnreservedConcurrentExecutions(props) {
703
+ return new cloudwatch__namespace.Metric({
704
+ namespace: "AWS/Lambda",
705
+ metricName: "UnreservedConcurrentExecutions",
706
+ ...props,
707
+ });
708
+ }
709
+ addVersion(name, codeSha256, description, provisionedExecutions, asyncInvokeConfig) {
710
+ return new lambda__namespace.Version(this, name, {
711
+ lambda: this._lambda,
712
+ codeSha256,
713
+ description,
714
+ provisionedConcurrentExecutions: provisionedExecutions,
715
+ ...asyncInvokeConfig,
716
+ });
717
+ }
718
+ get memorySize() {
719
+ return this._memorySize;
720
+ }
721
+ get handler() {
722
+ return this._handler;
723
+ }
724
+ get environment() {
725
+ return this._environment;
726
+ }
727
+ get layers() {
728
+ return this._layers;
729
+ }
730
+ get maxEventAge() {
731
+ return this._maxEventAge;
732
+ }
733
+ get retryAttempts() {
734
+ return this._retryAttempts;
735
+ }
736
+ get reservedConcurrentExecutions() {
737
+ return this._reservedConcurrentExecutions;
738
+ }
739
+ get description() {
740
+ return this._description;
741
+ }
742
+ get initialPolicy() {
743
+ return this._initialPolicy;
744
+ }
745
+ get logRetentionRole() {
746
+ return this._logRetentionRole;
747
+ }
748
+ get logRetentionRetryOptions() {
749
+ return this._logRetentionRetryOptions;
750
+ }
751
+ get tracing() {
752
+ return this._tracing;
753
+ }
754
+ get profiling() {
755
+ return this._profiling;
756
+ }
757
+ get profilingGroup() {
758
+ return this._profilingGroup;
759
+ }
760
+ get environmentEncryption() {
761
+ return this._environmentEncryption;
762
+ }
763
+ get codeSigningConfig() {
764
+ return this._codeSigningConfig;
765
+ }
766
+ get filesystemConfig() {
767
+ return this._filesystemConfigs?.[0];
768
+ }
769
+ get filesystemConfigs() {
770
+ return this._filesystemConfigs;
771
+ }
772
+ get ephemeralStorageSize() {
773
+ return this._ephemeralStorageSize;
774
+ }
775
+ get runtimeManagementMode() {
776
+ return this._runtimeManagementMode;
777
+ }
778
+ get architectureLabel() {
779
+ return this._lambda.architecture.name;
780
+ }
781
+ get vpc() {
782
+ return this._vpc;
783
+ }
784
+ get vpcSubnets() {
785
+ return this._vpcSubnets;
786
+ }
787
+ get securityGroups() {
788
+ return this._securityGroups;
789
+ }
790
+ get allowAllOutbound() {
791
+ return this._allowAllOutbound;
792
+ }
793
+ get allowPublicSubnet() {
794
+ return this._allowPublicSubnet;
795
+ }
796
+ get canCreateLambdaLogGroup() {
797
+ return true;
798
+ }
799
+ get canCreatePermissions() {
800
+ return true;
801
+ }
802
+ get deadLetterQueueEnabled() {
803
+ return this._lambda.deadLetterQueue !== undefined || this._lambda.deadLetterTopic !== undefined;
804
+ }
602
805
  }
603
806
 
604
807
  class JaypieQueuedLambda extends constructs.Construct {
@@ -1021,7 +1224,7 @@ function exportEnvName(name, env = process.env) {
1021
1224
  class JaypieEnvSecret extends constructs.Construct {
1022
1225
  constructor(scope, id, props) {
1023
1226
  super(scope, id);
1024
- const { consumer = checkEnvIsConsumer(), envKey, export: exportParam, provider = checkEnvIsProvider(), roleTag, vendorTag, value, } = props || {};
1227
+ const { consumer = checkEnvIsConsumer(), envKey, export: exportParam, generateSecretString, provider = checkEnvIsProvider(), roleTag, vendorTag, value, } = props || {};
1025
1228
  this._envKey = envKey;
1026
1229
  let exportName;
1027
1230
  if (!exportParam) {
@@ -1041,7 +1244,8 @@ class JaypieEnvSecret extends constructs.Construct {
1041
1244
  else {
1042
1245
  const secretValue = envKey && process.env[envKey] ? process.env[envKey] : value;
1043
1246
  const secretProps = {
1044
- secretStringValue: secretValue
1247
+ generateSecretString,
1248
+ secretStringValue: !generateSecretString && secretValue
1045
1249
  ? cdk$1.SecretValue.unsafePlainText(secretValue)
1046
1250
  : undefined,
1047
1251
  };