@jaypie/constructs 1.1.36 → 1.1.37
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/JaypieEnvSecret.d.ts +2 -0
- package/dist/cjs/JaypieLambda.d.ts +56 -0
- package/dist/cjs/index.cjs +163 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/JaypieEnvSecret.d.ts +2 -0
- package/dist/esm/JaypieLambda.d.ts +56 -0
- package/dist/esm/index.js +162 -3
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -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,6 +3,7 @@ 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 {
|
|
@@ -30,18 +31,32 @@ export interface JaypieLambdaProps {
|
|
|
30
31
|
roleTag?: string;
|
|
31
32
|
runtime?: lambda.Runtime;
|
|
32
33
|
secrets?: JaypieEnvSecret[];
|
|
34
|
+
securityGroups?: ec2.ISecurityGroup[];
|
|
33
35
|
timeout?: Duration | number;
|
|
34
36
|
vendorTag?: string;
|
|
37
|
+
vpc?: ec2.IVpc;
|
|
38
|
+
vpcSubnets?: ec2.SubnetSelection;
|
|
35
39
|
}
|
|
36
40
|
export declare class JaypieLambda extends Construct implements lambda.IFunction {
|
|
37
41
|
private readonly _lambda;
|
|
38
42
|
private readonly _provisioned?;
|
|
39
43
|
private readonly _code;
|
|
40
44
|
private readonly _reference;
|
|
45
|
+
private readonly _handler;
|
|
46
|
+
private readonly _memorySize;
|
|
47
|
+
private readonly _timeout;
|
|
48
|
+
private readonly _runtime;
|
|
49
|
+
private readonly _environment;
|
|
50
|
+
private readonly _vpc?;
|
|
51
|
+
private readonly _vpcSubnets?;
|
|
52
|
+
private readonly _securityGroups?;
|
|
53
|
+
private readonly _reservedConcurrentExecutions?;
|
|
54
|
+
private readonly _layers;
|
|
41
55
|
constructor(scope: Construct, id: string, props: JaypieLambdaProps);
|
|
42
56
|
get lambda(): lambda.Function;
|
|
43
57
|
get provisioned(): lambda.Alias | undefined;
|
|
44
58
|
get code(): lambda.Code;
|
|
59
|
+
get reference(): lambda.IFunction;
|
|
45
60
|
get functionArn(): string;
|
|
46
61
|
get functionName(): string;
|
|
47
62
|
get grantPrincipal(): iam.IPrincipal;
|
|
@@ -75,4 +90,45 @@ export declare class JaypieLambda extends Construct implements lambda.IFunction
|
|
|
75
90
|
};
|
|
76
91
|
get stack(): Stack;
|
|
77
92
|
applyRemovalPolicy(policy: RemovalPolicy): void;
|
|
93
|
+
get currentVersion(): lambda.Version;
|
|
94
|
+
get deadLetterQueue(): import("aws-cdk-lib/aws-sqs").IQueue | undefined;
|
|
95
|
+
get deadLetterTopic(): import("aws-cdk-lib/aws-sns").ITopic | undefined;
|
|
96
|
+
get logGroup(): import("aws-cdk-lib/aws-logs").ILogGroup;
|
|
97
|
+
get runtime(): lambda.Runtime;
|
|
98
|
+
get timeout(): Duration | undefined;
|
|
99
|
+
addAlias(aliasName: string, options?: lambda.AliasOptions): lambda.Alias;
|
|
100
|
+
addLayers(...layers: lambda.ILayerVersion[]): void;
|
|
101
|
+
invalidateVersionBasedOn(x: string): void;
|
|
102
|
+
metricConcurrentExecutions(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
|
|
103
|
+
metricUnreservedConcurrentExecutions(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
|
|
104
|
+
addVersion(name: string, codeSha256?: string, description?: string, provisionedExecutions?: number, asyncInvokeConfig?: lambda.EventInvokeConfigOptions): lambda.Version;
|
|
105
|
+
get memorySize(): number | undefined;
|
|
106
|
+
get handler(): string;
|
|
107
|
+
get environment(): {
|
|
108
|
+
[key: string]: string;
|
|
109
|
+
} | undefined;
|
|
110
|
+
get layers(): lambda.ILayerVersion[] | undefined;
|
|
111
|
+
get maxEventAge(): Duration | undefined;
|
|
112
|
+
get retryAttempts(): number | undefined;
|
|
113
|
+
get reservedConcurrentExecutions(): number | undefined;
|
|
114
|
+
get description(): string | undefined;
|
|
115
|
+
get initialPolicy(): iam.PolicyDocument[] | undefined;
|
|
116
|
+
get logRetentionRole(): iam.IRole | undefined;
|
|
117
|
+
get logRetentionRetryOptions(): lambda.LogRetentionRetryOptions | undefined;
|
|
118
|
+
get tracing(): lambda.Tracing | undefined;
|
|
119
|
+
get profiling(): boolean | undefined;
|
|
120
|
+
get profilingGroup(): import("aws-cdk-lib/aws-codeguruprofiler").IProfilingGroup | undefined;
|
|
121
|
+
get environmentEncryption(): import("aws-cdk-lib/aws-kms").IKey | undefined;
|
|
122
|
+
get codeSigningConfig(): lambda.ICodeSigningConfig | undefined;
|
|
123
|
+
get filesystemConfig(): lambda.FileSystemConfig | undefined;
|
|
124
|
+
get filesystemConfigs(): lambda.FileSystemConfig[] | undefined;
|
|
125
|
+
get ephemeralStorageSize(): number | undefined;
|
|
126
|
+
get runtimeManagementMode(): lambda.RuntimeManagementMode | undefined;
|
|
127
|
+
get architectureLabel(): string;
|
|
128
|
+
get vpc(): ec2.IVpc | undefined;
|
|
129
|
+
get vpcSubnets(): ec2.SubnetSelection | undefined;
|
|
130
|
+
get securityGroups(): ec2.ISecurityGroup[] | undefined;
|
|
131
|
+
get allowAllOutbound(): boolean | undefined;
|
|
132
|
+
get allowPublicSubnet(): boolean | undefined;
|
|
133
|
+
get canCreateLambdaLogGroup(): boolean;
|
|
78
134
|
}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -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 { 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 = [], securityGroups, timeout = cdk$1.Duration.seconds(cdk.CDK.DURATION.LAMBDA_WORKER), vendorTag, vpc, vpcSubnets, } = props;
|
|
325
327
|
// Create a mutable copy of the environment variables
|
|
326
328
|
let environment = { ...initialEnvironment };
|
|
327
329
|
// Default environment values
|
|
@@ -448,7 +450,10 @@ class JaypieLambda extends constructs.Construct {
|
|
|
448
450
|
paramsAndSecrets: resolvedParamsAndSecrets,
|
|
449
451
|
reservedConcurrentExecutions,
|
|
450
452
|
runtime,
|
|
453
|
+
securityGroups,
|
|
451
454
|
timeout: typeof timeout === "number" ? cdk$1.Duration.seconds(timeout) : timeout,
|
|
455
|
+
vpc,
|
|
456
|
+
vpcSubnets,
|
|
452
457
|
// Enable auto-publishing of versions when using provisioned concurrency
|
|
453
458
|
currentVersionOptions: provisionedConcurrentExecutions !== undefined
|
|
454
459
|
? {
|
|
@@ -490,6 +495,22 @@ class JaypieLambda extends constructs.Construct {
|
|
|
490
495
|
if (vendorTag) {
|
|
491
496
|
cdk$1.Tags.of(this._lambda).add(cdk.CDK.TAG.VENDOR, vendorTag);
|
|
492
497
|
}
|
|
498
|
+
// Store constructor props for later access
|
|
499
|
+
this._handler = handler;
|
|
500
|
+
this._memorySize = memorySize;
|
|
501
|
+
this._timeout =
|
|
502
|
+
typeof timeout === "number" ? cdk$1.Duration.seconds(timeout) : timeout;
|
|
503
|
+
this._runtime = runtime;
|
|
504
|
+
this._environment = {
|
|
505
|
+
...environment,
|
|
506
|
+
...secretsEnvironment,
|
|
507
|
+
...jaypieSecretsEnvironment,
|
|
508
|
+
};
|
|
509
|
+
this._vpc = vpc;
|
|
510
|
+
this._vpcSubnets = vpcSubnets;
|
|
511
|
+
this._securityGroups = securityGroups;
|
|
512
|
+
this._reservedConcurrentExecutions = reservedConcurrentExecutions;
|
|
513
|
+
this._layers = resolvedLayers;
|
|
493
514
|
// Assign _reference based on provisioned state
|
|
494
515
|
this._reference =
|
|
495
516
|
this._provisioned !== undefined ? this._provisioned : this._lambda;
|
|
@@ -504,6 +525,9 @@ class JaypieLambda extends constructs.Construct {
|
|
|
504
525
|
get code() {
|
|
505
526
|
return this._code;
|
|
506
527
|
}
|
|
528
|
+
get reference() {
|
|
529
|
+
return this._reference;
|
|
530
|
+
}
|
|
507
531
|
// IFunction implementation
|
|
508
532
|
get functionArn() {
|
|
509
533
|
return this._reference.functionArn;
|
|
@@ -599,6 +623,141 @@ class JaypieLambda extends constructs.Construct {
|
|
|
599
623
|
applyRemovalPolicy(policy) {
|
|
600
624
|
this._reference.applyRemovalPolicy(policy);
|
|
601
625
|
}
|
|
626
|
+
// Additional Lambda Function specific methods
|
|
627
|
+
get currentVersion() {
|
|
628
|
+
return this._lambda.currentVersion;
|
|
629
|
+
}
|
|
630
|
+
get deadLetterQueue() {
|
|
631
|
+
return this._lambda.deadLetterQueue;
|
|
632
|
+
}
|
|
633
|
+
get deadLetterTopic() {
|
|
634
|
+
return this._lambda.deadLetterTopic;
|
|
635
|
+
}
|
|
636
|
+
get logGroup() {
|
|
637
|
+
return this._lambda.logGroup;
|
|
638
|
+
}
|
|
639
|
+
get runtime() {
|
|
640
|
+
return this._runtime;
|
|
641
|
+
}
|
|
642
|
+
get timeout() {
|
|
643
|
+
return this._timeout;
|
|
644
|
+
}
|
|
645
|
+
addAlias(aliasName, options) {
|
|
646
|
+
return this._lambda.addAlias(aliasName, options);
|
|
647
|
+
}
|
|
648
|
+
addLayers(...layers) {
|
|
649
|
+
this._lambda.addLayers(...layers);
|
|
650
|
+
}
|
|
651
|
+
invalidateVersionBasedOn(x) {
|
|
652
|
+
this._lambda.invalidateVersionBasedOn(x);
|
|
653
|
+
}
|
|
654
|
+
metricConcurrentExecutions(props) {
|
|
655
|
+
return new cloudwatch__namespace.Metric({
|
|
656
|
+
namespace: "AWS/Lambda",
|
|
657
|
+
metricName: "ConcurrentExecutions",
|
|
658
|
+
dimensionsMap: {
|
|
659
|
+
FunctionName: this.functionName,
|
|
660
|
+
},
|
|
661
|
+
...props,
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
metricUnreservedConcurrentExecutions(props) {
|
|
665
|
+
return new cloudwatch__namespace.Metric({
|
|
666
|
+
namespace: "AWS/Lambda",
|
|
667
|
+
metricName: "UnreservedConcurrentExecutions",
|
|
668
|
+
...props,
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
addVersion(name, codeSha256, description, provisionedExecutions, asyncInvokeConfig) {
|
|
672
|
+
return new lambda__namespace.Version(this, name, {
|
|
673
|
+
lambda: this._lambda,
|
|
674
|
+
codeSha256,
|
|
675
|
+
description,
|
|
676
|
+
provisionedConcurrentExecutions: provisionedExecutions,
|
|
677
|
+
...asyncInvokeConfig,
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
get memorySize() {
|
|
681
|
+
return this._memorySize;
|
|
682
|
+
}
|
|
683
|
+
get handler() {
|
|
684
|
+
return this._handler;
|
|
685
|
+
}
|
|
686
|
+
get environment() {
|
|
687
|
+
return this._environment;
|
|
688
|
+
}
|
|
689
|
+
get layers() {
|
|
690
|
+
return this._layers;
|
|
691
|
+
}
|
|
692
|
+
get maxEventAge() {
|
|
693
|
+
return undefined;
|
|
694
|
+
}
|
|
695
|
+
get retryAttempts() {
|
|
696
|
+
return undefined;
|
|
697
|
+
}
|
|
698
|
+
get reservedConcurrentExecutions() {
|
|
699
|
+
return this._reservedConcurrentExecutions;
|
|
700
|
+
}
|
|
701
|
+
get description() {
|
|
702
|
+
return undefined;
|
|
703
|
+
}
|
|
704
|
+
get initialPolicy() {
|
|
705
|
+
return undefined;
|
|
706
|
+
}
|
|
707
|
+
get logRetentionRole() {
|
|
708
|
+
return undefined;
|
|
709
|
+
}
|
|
710
|
+
get logRetentionRetryOptions() {
|
|
711
|
+
return undefined;
|
|
712
|
+
}
|
|
713
|
+
get tracing() {
|
|
714
|
+
return undefined;
|
|
715
|
+
}
|
|
716
|
+
get profiling() {
|
|
717
|
+
return undefined;
|
|
718
|
+
}
|
|
719
|
+
get profilingGroup() {
|
|
720
|
+
return undefined;
|
|
721
|
+
}
|
|
722
|
+
get environmentEncryption() {
|
|
723
|
+
return undefined;
|
|
724
|
+
}
|
|
725
|
+
get codeSigningConfig() {
|
|
726
|
+
return undefined;
|
|
727
|
+
}
|
|
728
|
+
get filesystemConfig() {
|
|
729
|
+
return undefined;
|
|
730
|
+
}
|
|
731
|
+
get filesystemConfigs() {
|
|
732
|
+
return undefined;
|
|
733
|
+
}
|
|
734
|
+
get ephemeralStorageSize() {
|
|
735
|
+
return undefined;
|
|
736
|
+
}
|
|
737
|
+
get runtimeManagementMode() {
|
|
738
|
+
return undefined;
|
|
739
|
+
}
|
|
740
|
+
get architectureLabel() {
|
|
741
|
+
return this._lambda.architecture.name;
|
|
742
|
+
}
|
|
743
|
+
get vpc() {
|
|
744
|
+
return this._vpc;
|
|
745
|
+
}
|
|
746
|
+
get vpcSubnets() {
|
|
747
|
+
return this._vpcSubnets;
|
|
748
|
+
}
|
|
749
|
+
get securityGroups() {
|
|
750
|
+
return this._securityGroups;
|
|
751
|
+
}
|
|
752
|
+
get allowAllOutbound() {
|
|
753
|
+
return undefined;
|
|
754
|
+
}
|
|
755
|
+
get allowPublicSubnet() {
|
|
756
|
+
return undefined;
|
|
757
|
+
}
|
|
758
|
+
get canCreateLambdaLogGroup() {
|
|
759
|
+
return true;
|
|
760
|
+
}
|
|
602
761
|
}
|
|
603
762
|
|
|
604
763
|
class JaypieQueuedLambda extends constructs.Construct {
|
|
@@ -1021,7 +1180,7 @@ function exportEnvName(name, env = process.env) {
|
|
|
1021
1180
|
class JaypieEnvSecret extends constructs.Construct {
|
|
1022
1181
|
constructor(scope, id, props) {
|
|
1023
1182
|
super(scope, id);
|
|
1024
|
-
const { consumer = checkEnvIsConsumer(), envKey, export: exportParam, provider = checkEnvIsProvider(), roleTag, vendorTag, value, } = props || {};
|
|
1183
|
+
const { consumer = checkEnvIsConsumer(), envKey, export: exportParam, generateSecretString, provider = checkEnvIsProvider(), roleTag, vendorTag, value, } = props || {};
|
|
1025
1184
|
this._envKey = envKey;
|
|
1026
1185
|
let exportName;
|
|
1027
1186
|
if (!exportParam) {
|
|
@@ -1041,7 +1200,8 @@ class JaypieEnvSecret extends constructs.Construct {
|
|
|
1041
1200
|
else {
|
|
1042
1201
|
const secretValue = envKey && process.env[envKey] ? process.env[envKey] : value;
|
|
1043
1202
|
const secretProps = {
|
|
1044
|
-
|
|
1203
|
+
generateSecretString,
|
|
1204
|
+
secretStringValue: !generateSecretString && secretValue
|
|
1045
1205
|
? cdk$1.SecretValue.unsafePlainText(secretValue)
|
|
1046
1206
|
: undefined,
|
|
1047
1207
|
};
|