@jaypie/constructs 1.2.6 → 1.2.8
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/JaypieDistribution.d.ts +13 -3
- package/dist/cjs/JaypieStreamingLambda.d.ts +44 -0
- package/dist/cjs/__tests__/JaypieStreamingLambda.spec.d.ts +1 -0
- package/dist/cjs/constants.d.ts +15 -0
- package/dist/cjs/index.cjs +130 -26
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +5 -4
- package/dist/esm/JaypieDistribution.d.ts +13 -3
- package/dist/esm/JaypieStreamingLambda.d.ts +44 -0
- package/dist/esm/__tests__/JaypieStreamingLambda.spec.d.ts +1 -0
- package/dist/esm/constants.d.ts +15 -0
- package/dist/esm/index.d.ts +5 -4
- package/dist/esm/index.js +129 -27
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export { CDK } from "./constants";
|
|
1
|
+
export { CDK, LAMBDA_WEB_ADAPTER } from "./constants";
|
|
2
2
|
export { JaypieAccountLoggingBucket, JaypieAccountLoggingBucketProps, } from "./JaypieAccountLoggingBucket";
|
|
3
3
|
export { JaypieApiGateway } from "./JaypieApiGateway";
|
|
4
4
|
export { JaypieAppStack } from "./JaypieAppStack";
|
|
5
5
|
export { JaypieBucketQueuedLambda } from "./JaypieBucketQueuedLambda";
|
|
6
6
|
export { JaypieDatadogBucket, JaypieDatadogBucketProps, } from "./JaypieDatadogBucket";
|
|
7
7
|
export { JaypieDatadogForwarder, JaypieDatadogForwarderProps, } from "./JaypieDatadogForwarder";
|
|
8
|
-
export { JaypieDistribution, JaypieDistributionProps, } from "./JaypieDistribution";
|
|
9
8
|
export { JaypieDatadogSecret } from "./JaypieDatadogSecret";
|
|
9
|
+
export { JaypieDistribution, JaypieDistributionProps, } from "./JaypieDistribution";
|
|
10
10
|
export { JaypieDnsRecord, JaypieDnsRecordProps } from "./JaypieDnsRecord";
|
|
11
11
|
export { JaypieDynamoDb, JaypieDynamoDbProps } from "./JaypieDynamoDb";
|
|
12
12
|
export { JaypieEnvSecret } from "./JaypieEnvSecret";
|
|
13
13
|
export { JaypieEventsRule, JaypieEventsRuleProps } from "./JaypieEventsRule";
|
|
14
|
-
export { JaypieGitHubDeployRole, JaypieGitHubDeployRoleProps, } from "./JaypieGitHubDeployRole";
|
|
15
14
|
export { JaypieExpressLambda } from "./JaypieExpressLambda";
|
|
15
|
+
export { JaypieGitHubDeployRole, JaypieGitHubDeployRoleProps, } from "./JaypieGitHubDeployRole";
|
|
16
16
|
export { JaypieHostedZone, JaypieHostedZoneRecordProps, } from "./JaypieHostedZone";
|
|
17
17
|
export { JaypieInfrastructureStack } from "./JaypieInfrastructureStack";
|
|
18
18
|
export { JaypieLambda, JaypieLambdaProps } from "./JaypieLambda";
|
|
@@ -20,11 +20,12 @@ export { JaypieMongoDbSecret } from "./JaypieMongoDbSecret";
|
|
|
20
20
|
export { DomainNameConfig, JaypieNextJs, JaypieNextjsProps, } from "./JaypieNextJs";
|
|
21
21
|
export { JaypieOpenAiSecret } from "./JaypieOpenAiSecret";
|
|
22
22
|
export { JaypieOrganizationTrail, JaypieOrganizationTrailProps, } from "./JaypieOrganizationTrail";
|
|
23
|
+
export { JaypieQueuedLambda } from "./JaypieQueuedLambda";
|
|
23
24
|
export { AccountAssignments, JaypieSsoPermissions, JaypieSsoPermissionsProps, } from "./JaypieSsoPermissions";
|
|
24
25
|
export { JaypieSsoSyncApplication, JaypieSsoSyncApplicationProps, } from "./JaypieSsoSyncApplication";
|
|
25
|
-
export { JaypieQueuedLambda } from "./JaypieQueuedLambda";
|
|
26
26
|
export { JaypieStack, JaypieStackProps } from "./JaypieStack";
|
|
27
27
|
export { JaypieStaticWebBucket, JaypieStaticWebBucketProps, } from "./JaypieStaticWebBucket";
|
|
28
|
+
export { JaypieStreamingLambda, JaypieStreamingLambdaProps, } from "./JaypieStreamingLambda";
|
|
28
29
|
export { JaypieTraceSigningKeySecret } from "./JaypieTraceSigningKeySecret";
|
|
29
30
|
export { JaypieWebDeploymentBucket } from "./JaypieWebDeploymentBucket";
|
|
30
31
|
export * from "./helpers";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RemovalPolicy, Stack } from "aws-cdk-lib";
|
|
1
|
+
import { Duration, RemovalPolicy, Stack } from "aws-cdk-lib";
|
|
2
2
|
import * as acm from "aws-cdk-lib/aws-certificatemanager";
|
|
3
3
|
import * as cloudfront from "aws-cdk-lib/aws-cloudfront";
|
|
4
4
|
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
@@ -35,10 +35,19 @@ export interface JaypieDistributionProps extends Omit<cloudfront.DistributionPro
|
|
|
35
35
|
*/
|
|
36
36
|
host?: string;
|
|
37
37
|
/**
|
|
38
|
-
* Invoke mode for Lambda Function URLs
|
|
39
|
-
*
|
|
38
|
+
* Invoke mode for Lambda Function URLs.
|
|
39
|
+
* If not provided, auto-detects from handler if it has an invokeMode property
|
|
40
|
+
* (e.g., JaypieStreamingLambda).
|
|
41
|
+
* @default InvokeMode.BUFFERED (or auto-detected from handler)
|
|
40
42
|
*/
|
|
41
43
|
invokeMode?: lambda.InvokeMode;
|
|
44
|
+
/**
|
|
45
|
+
* Origin read timeout - how long CloudFront waits for a response from the origin.
|
|
46
|
+
* This is the maximum time allowed for the origin to respond.
|
|
47
|
+
* @default CDK.DURATION.CLOUDFRONT_API (180 seconds)
|
|
48
|
+
* @max Duration.seconds(180)
|
|
49
|
+
*/
|
|
50
|
+
originReadTimeout?: Duration;
|
|
42
51
|
/**
|
|
43
52
|
* Role tag for tagging resources
|
|
44
53
|
* @default CDK.ROLE.HOSTING
|
|
@@ -64,6 +73,7 @@ export declare class JaypieDistribution extends Construct implements cloudfront.
|
|
|
64
73
|
private isIOrigin;
|
|
65
74
|
private isIFunctionUrl;
|
|
66
75
|
private isIFunction;
|
|
76
|
+
private hasInvokeMode;
|
|
67
77
|
get env(): {
|
|
68
78
|
account: string;
|
|
69
79
|
region: string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Construct } from "constructs";
|
|
2
|
+
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
3
|
+
import { JaypieLambda, JaypieLambdaProps } from "./JaypieLambda.js";
|
|
4
|
+
export interface JaypieStreamingLambdaProps extends JaypieLambdaProps {
|
|
5
|
+
/**
|
|
6
|
+
* The port your application listens on.
|
|
7
|
+
* @default 8000
|
|
8
|
+
*/
|
|
9
|
+
port?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Enable response streaming mode.
|
|
12
|
+
* When true, uses RESPONSE_STREAM invoke mode.
|
|
13
|
+
* When false, uses BUFFERED invoke mode.
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
streaming?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A Lambda construct that uses AWS Lambda Web Adapter for streaming support.
|
|
20
|
+
* This allows running web applications (Express, Fastify, etc.) with streaming responses.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const streamingLambda = new JaypieStreamingLambda(this, "StreamingApi", {
|
|
25
|
+
* code: "dist/api",
|
|
26
|
+
* handler: "run.sh",
|
|
27
|
+
* streaming: true,
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // Use with JaypieDistribution
|
|
31
|
+
* new JaypieDistribution(this, "Distribution", {
|
|
32
|
+
* handler: streamingLambda,
|
|
33
|
+
* invokeMode: streamingLambda.invokeMode,
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare class JaypieStreamingLambda extends JaypieLambda {
|
|
38
|
+
/**
|
|
39
|
+
* The invoke mode for this Lambda function.
|
|
40
|
+
* Use this when configuring JaypieDistribution.
|
|
41
|
+
*/
|
|
42
|
+
readonly invokeMode: lambda.InvokeMode;
|
|
43
|
+
constructor(scope: Construct, id: string, props: JaypieStreamingLambdaProps);
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
export declare const LAMBDA_WEB_ADAPTER: {
|
|
2
|
+
ACCOUNT: string;
|
|
3
|
+
DEFAULT_PORT: number;
|
|
4
|
+
EXEC_WRAPPER: string;
|
|
5
|
+
INVOKE_MODE: {
|
|
6
|
+
BUFFERED: string;
|
|
7
|
+
RESPONSE_STREAM: string;
|
|
8
|
+
};
|
|
9
|
+
LAYER: {
|
|
10
|
+
ARM64: string;
|
|
11
|
+
X86: string;
|
|
12
|
+
};
|
|
13
|
+
VERSION: number;
|
|
14
|
+
};
|
|
1
15
|
export declare const CDK: {
|
|
2
16
|
ACCOUNT: {
|
|
3
17
|
DEVELOPMENT: string;
|
|
@@ -55,6 +69,7 @@ export declare const CDK: {
|
|
|
55
69
|
};
|
|
56
70
|
DURATION: {
|
|
57
71
|
EXPRESS_API: number;
|
|
72
|
+
CLOUDFRONT_API: number;
|
|
58
73
|
LAMBDA_MAXIMUM: number;
|
|
59
74
|
LAMBDA_WORKER: number;
|
|
60
75
|
};
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export { CDK } from "./constants";
|
|
1
|
+
export { CDK, LAMBDA_WEB_ADAPTER } from "./constants";
|
|
2
2
|
export { JaypieAccountLoggingBucket, JaypieAccountLoggingBucketProps, } from "./JaypieAccountLoggingBucket";
|
|
3
3
|
export { JaypieApiGateway } from "./JaypieApiGateway";
|
|
4
4
|
export { JaypieAppStack } from "./JaypieAppStack";
|
|
5
5
|
export { JaypieBucketQueuedLambda } from "./JaypieBucketQueuedLambda";
|
|
6
6
|
export { JaypieDatadogBucket, JaypieDatadogBucketProps, } from "./JaypieDatadogBucket";
|
|
7
7
|
export { JaypieDatadogForwarder, JaypieDatadogForwarderProps, } from "./JaypieDatadogForwarder";
|
|
8
|
-
export { JaypieDistribution, JaypieDistributionProps, } from "./JaypieDistribution";
|
|
9
8
|
export { JaypieDatadogSecret } from "./JaypieDatadogSecret";
|
|
9
|
+
export { JaypieDistribution, JaypieDistributionProps, } from "./JaypieDistribution";
|
|
10
10
|
export { JaypieDnsRecord, JaypieDnsRecordProps } from "./JaypieDnsRecord";
|
|
11
11
|
export { JaypieDynamoDb, JaypieDynamoDbProps } from "./JaypieDynamoDb";
|
|
12
12
|
export { JaypieEnvSecret } from "./JaypieEnvSecret";
|
|
13
13
|
export { JaypieEventsRule, JaypieEventsRuleProps } from "./JaypieEventsRule";
|
|
14
|
-
export { JaypieGitHubDeployRole, JaypieGitHubDeployRoleProps, } from "./JaypieGitHubDeployRole";
|
|
15
14
|
export { JaypieExpressLambda } from "./JaypieExpressLambda";
|
|
15
|
+
export { JaypieGitHubDeployRole, JaypieGitHubDeployRoleProps, } from "./JaypieGitHubDeployRole";
|
|
16
16
|
export { JaypieHostedZone, JaypieHostedZoneRecordProps, } from "./JaypieHostedZone";
|
|
17
17
|
export { JaypieInfrastructureStack } from "./JaypieInfrastructureStack";
|
|
18
18
|
export { JaypieLambda, JaypieLambdaProps } from "./JaypieLambda";
|
|
@@ -20,11 +20,12 @@ export { JaypieMongoDbSecret } from "./JaypieMongoDbSecret";
|
|
|
20
20
|
export { DomainNameConfig, JaypieNextJs, JaypieNextjsProps, } from "./JaypieNextJs";
|
|
21
21
|
export { JaypieOpenAiSecret } from "./JaypieOpenAiSecret";
|
|
22
22
|
export { JaypieOrganizationTrail, JaypieOrganizationTrailProps, } from "./JaypieOrganizationTrail";
|
|
23
|
+
export { JaypieQueuedLambda } from "./JaypieQueuedLambda";
|
|
23
24
|
export { AccountAssignments, JaypieSsoPermissions, JaypieSsoPermissionsProps, } from "./JaypieSsoPermissions";
|
|
24
25
|
export { JaypieSsoSyncApplication, JaypieSsoSyncApplicationProps, } from "./JaypieSsoSyncApplication";
|
|
25
|
-
export { JaypieQueuedLambda } from "./JaypieQueuedLambda";
|
|
26
26
|
export { JaypieStack, JaypieStackProps } from "./JaypieStack";
|
|
27
27
|
export { JaypieStaticWebBucket, JaypieStaticWebBucketProps, } from "./JaypieStaticWebBucket";
|
|
28
|
+
export { JaypieStreamingLambda, JaypieStreamingLambdaProps, } from "./JaypieStreamingLambda";
|
|
28
29
|
export { JaypieTraceSigningKeySecret } from "./JaypieTraceSigningKeySecret";
|
|
29
30
|
export { JaypieWebDeploymentBucket } from "./JaypieWebDeploymentBucket";
|
|
30
31
|
export * from "./helpers";
|
package/dist/esm/index.js
CHANGED
|
@@ -31,6 +31,20 @@ import { Trail, ReadWriteType } from 'aws-cdk-lib/aws-cloudtrail';
|
|
|
31
31
|
import { CfnPermissionSet, CfnAssignment } from 'aws-cdk-lib/aws-sso';
|
|
32
32
|
import { CfnApplication } from 'aws-cdk-lib/aws-sam';
|
|
33
33
|
|
|
34
|
+
const LAMBDA_WEB_ADAPTER = {
|
|
35
|
+
ACCOUNT: "753240598075",
|
|
36
|
+
DEFAULT_PORT: 8000,
|
|
37
|
+
EXEC_WRAPPER: "/opt/bootstrap",
|
|
38
|
+
INVOKE_MODE: {
|
|
39
|
+
BUFFERED: "BUFFERED",
|
|
40
|
+
RESPONSE_STREAM: "RESPONSE_STREAM",
|
|
41
|
+
},
|
|
42
|
+
LAYER: {
|
|
43
|
+
ARM64: "LambdaAdapterLayerArm64",
|
|
44
|
+
X86: "LambdaAdapterLayerX86",
|
|
45
|
+
},
|
|
46
|
+
VERSION: 25,
|
|
47
|
+
};
|
|
34
48
|
const CDK$2 = {
|
|
35
49
|
ACCOUNT: {
|
|
36
50
|
DEVELOPMENT: "development",
|
|
@@ -89,6 +103,7 @@ const CDK$2 = {
|
|
|
89
103
|
},
|
|
90
104
|
DURATION: {
|
|
91
105
|
EXPRESS_API: 30,
|
|
106
|
+
CLOUDFRONT_API: 180,
|
|
92
107
|
LAMBDA_MAXIMUM: 900,
|
|
93
108
|
LAMBDA_WORKER: 900,
|
|
94
109
|
},
|
|
@@ -1962,10 +1977,22 @@ class JaypieDatadogForwarder extends Construct {
|
|
|
1962
1977
|
}
|
|
1963
1978
|
}
|
|
1964
1979
|
|
|
1980
|
+
class JaypieDatadogSecret extends JaypieEnvSecret {
|
|
1981
|
+
constructor(scope, id = "MongoConnectionString", props) {
|
|
1982
|
+
const defaultProps = {
|
|
1983
|
+
envKey: "DATADOG_API_KEY",
|
|
1984
|
+
roleTag: CDK$2.ROLE.MONITORING,
|
|
1985
|
+
vendorTag: CDK$2.VENDOR.DATADOG,
|
|
1986
|
+
...props,
|
|
1987
|
+
};
|
|
1988
|
+
super(scope, id, defaultProps);
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1965
1992
|
class JaypieDistribution extends Construct {
|
|
1966
1993
|
constructor(scope, id, props) {
|
|
1967
1994
|
super(scope, id);
|
|
1968
|
-
const { certificate: certificateProp = true, defaultBehavior: propsDefaultBehavior, destination: destinationProp = true, handler, host: propsHost, invokeMode = lambda.InvokeMode.BUFFERED, roleTag = CDK$2.ROLE.API, zone: propsZone, ...distributionProps } = props;
|
|
1995
|
+
const { certificate: certificateProp = true, defaultBehavior: propsDefaultBehavior, destination: destinationProp = true, handler, host: propsHost, invokeMode = lambda.InvokeMode.BUFFERED, originReadTimeout = Duration.seconds(CDK$2.DURATION.CLOUDFRONT_API), roleTag = CDK$2.ROLE.API, zone: propsZone, ...distributionProps } = props;
|
|
1969
1996
|
// Validate environment variables
|
|
1970
1997
|
if (process.env.CDK_ENV_API_SUBDOMAIN &&
|
|
1971
1998
|
!isValidSubdomain(process.env.CDK_ENV_API_SUBDOMAIN)) {
|
|
@@ -2007,18 +2034,29 @@ class JaypieDistribution extends Construct {
|
|
|
2007
2034
|
// IFunction before IFunctionUrl (IFunction doesn't have functionUrlId)
|
|
2008
2035
|
let origin;
|
|
2009
2036
|
if (handler) {
|
|
2037
|
+
// Auto-detect invoke mode from handler (e.g., JaypieStreamingLambda)
|
|
2038
|
+
// Explicit invokeMode prop takes precedence over auto-detection
|
|
2039
|
+
const resolvedInvokeMode = invokeMode !== lambda.InvokeMode.BUFFERED
|
|
2040
|
+
? invokeMode // Explicit non-default value, use it
|
|
2041
|
+
: this.hasInvokeMode(handler)
|
|
2042
|
+
? handler.invokeMode // Auto-detect from handler
|
|
2043
|
+
: invokeMode; // Use default BUFFERED
|
|
2010
2044
|
if (this.isIFunction(handler)) {
|
|
2011
2045
|
// Create FunctionUrl for the Lambda function
|
|
2012
2046
|
const functionUrl = new lambda.FunctionUrl(this, "FunctionUrl", {
|
|
2013
2047
|
function: handler,
|
|
2014
2048
|
authType: lambda.FunctionUrlAuthType.NONE,
|
|
2015
|
-
invokeMode,
|
|
2049
|
+
invokeMode: resolvedInvokeMode,
|
|
2016
2050
|
});
|
|
2017
2051
|
this.functionUrl = functionUrl;
|
|
2018
|
-
origin = new origins.FunctionUrlOrigin(functionUrl
|
|
2052
|
+
origin = new origins.FunctionUrlOrigin(functionUrl, {
|
|
2053
|
+
readTimeout: originReadTimeout,
|
|
2054
|
+
});
|
|
2019
2055
|
}
|
|
2020
2056
|
else if (this.isIFunctionUrl(handler)) {
|
|
2021
|
-
origin = new origins.FunctionUrlOrigin(handler
|
|
2057
|
+
origin = new origins.FunctionUrlOrigin(handler, {
|
|
2058
|
+
readTimeout: originReadTimeout,
|
|
2059
|
+
});
|
|
2022
2060
|
}
|
|
2023
2061
|
else if (this.isIOrigin(handler)) {
|
|
2024
2062
|
origin = handler;
|
|
@@ -2149,6 +2187,13 @@ class JaypieDistribution extends Construct {
|
|
|
2149
2187
|
"functionName" in handler &&
|
|
2150
2188
|
!("url" in handler));
|
|
2151
2189
|
}
|
|
2190
|
+
hasInvokeMode(handler) {
|
|
2191
|
+
// Check if handler has an invokeMode property (e.g., JaypieStreamingLambda)
|
|
2192
|
+
return (typeof handler === "object" &&
|
|
2193
|
+
handler !== null &&
|
|
2194
|
+
"invokeMode" in handler &&
|
|
2195
|
+
typeof handler.invokeMode === "string");
|
|
2196
|
+
}
|
|
2152
2197
|
// Implement IDistribution interface
|
|
2153
2198
|
get env() {
|
|
2154
2199
|
return {
|
|
@@ -2175,18 +2220,6 @@ class JaypieDistribution extends Construct {
|
|
|
2175
2220
|
}
|
|
2176
2221
|
}
|
|
2177
2222
|
|
|
2178
|
-
class JaypieDatadogSecret extends JaypieEnvSecret {
|
|
2179
|
-
constructor(scope, id = "MongoConnectionString", props) {
|
|
2180
|
-
const defaultProps = {
|
|
2181
|
-
envKey: "DATADOG_API_KEY",
|
|
2182
|
-
roleTag: CDK$2.ROLE.MONITORING,
|
|
2183
|
-
vendorTag: CDK$2.VENDOR.DATADOG,
|
|
2184
|
-
...props,
|
|
2185
|
-
};
|
|
2186
|
-
super(scope, id, defaultProps);
|
|
2187
|
-
}
|
|
2188
|
-
}
|
|
2189
|
-
|
|
2190
2223
|
class JaypieDnsRecord extends Construct {
|
|
2191
2224
|
constructor(scope, id, props) {
|
|
2192
2225
|
super(scope, id);
|
|
@@ -2586,6 +2619,16 @@ class JaypieEventsRule extends Construct {
|
|
|
2586
2619
|
}
|
|
2587
2620
|
}
|
|
2588
2621
|
|
|
2622
|
+
class JaypieExpressLambda extends JaypieLambda {
|
|
2623
|
+
constructor(scope, id, props) {
|
|
2624
|
+
super(scope, id, {
|
|
2625
|
+
timeout: Duration.seconds(CDK$2.DURATION.EXPRESS_API),
|
|
2626
|
+
roleTag: CDK$2.ROLE.API,
|
|
2627
|
+
...props,
|
|
2628
|
+
});
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2589
2632
|
class JaypieGitHubDeployRole extends Construct {
|
|
2590
2633
|
constructor(scope, id = "GitHubDeployRole", props = {}) {
|
|
2591
2634
|
super(scope, id);
|
|
@@ -2668,16 +2711,6 @@ class JaypieGitHubDeployRole extends Construct {
|
|
|
2668
2711
|
}
|
|
2669
2712
|
}
|
|
2670
2713
|
|
|
2671
|
-
class JaypieExpressLambda extends JaypieLambda {
|
|
2672
|
-
constructor(scope, id, props) {
|
|
2673
|
-
super(scope, id, {
|
|
2674
|
-
timeout: Duration.seconds(CDK$2.DURATION.EXPRESS_API),
|
|
2675
|
-
roleTag: CDK$2.ROLE.API,
|
|
2676
|
-
...props,
|
|
2677
|
-
});
|
|
2678
|
-
}
|
|
2679
|
-
}
|
|
2680
|
-
|
|
2681
2714
|
const SERVICE = {
|
|
2682
2715
|
ROUTE53: "route53.amazonaws.com",
|
|
2683
2716
|
};
|
|
@@ -3722,6 +3755,75 @@ class JaypieStaticWebBucket extends JaypieWebDeploymentBucket {
|
|
|
3722
3755
|
}
|
|
3723
3756
|
}
|
|
3724
3757
|
|
|
3758
|
+
/**
|
|
3759
|
+
* A Lambda construct that uses AWS Lambda Web Adapter for streaming support.
|
|
3760
|
+
* This allows running web applications (Express, Fastify, etc.) with streaming responses.
|
|
3761
|
+
*
|
|
3762
|
+
* @example
|
|
3763
|
+
* ```typescript
|
|
3764
|
+
* const streamingLambda = new JaypieStreamingLambda(this, "StreamingApi", {
|
|
3765
|
+
* code: "dist/api",
|
|
3766
|
+
* handler: "run.sh",
|
|
3767
|
+
* streaming: true,
|
|
3768
|
+
* });
|
|
3769
|
+
*
|
|
3770
|
+
* // Use with JaypieDistribution
|
|
3771
|
+
* new JaypieDistribution(this, "Distribution", {
|
|
3772
|
+
* handler: streamingLambda,
|
|
3773
|
+
* invokeMode: streamingLambda.invokeMode,
|
|
3774
|
+
* });
|
|
3775
|
+
* ```
|
|
3776
|
+
*/
|
|
3777
|
+
class JaypieStreamingLambda extends JaypieLambda {
|
|
3778
|
+
constructor(scope, id, props) {
|
|
3779
|
+
const { architecture = lambda.Architecture.X86_64, environment: propsEnvironment, layers: propsLayers = [], port = LAMBDA_WEB_ADAPTER.DEFAULT_PORT, streaming = false, ...restProps } = props;
|
|
3780
|
+
// Determine the Lambda Web Adapter layer ARN based on architecture
|
|
3781
|
+
const region = Stack.of(scope).region;
|
|
3782
|
+
const layerArn = architecture === lambda.Architecture.ARM_64
|
|
3783
|
+
? `arn:aws:lambda:${region}:${LAMBDA_WEB_ADAPTER.ACCOUNT}:layer:${LAMBDA_WEB_ADAPTER.LAYER.ARM64}:${LAMBDA_WEB_ADAPTER.VERSION}`
|
|
3784
|
+
: `arn:aws:lambda:${region}:${LAMBDA_WEB_ADAPTER.ACCOUNT}:layer:${LAMBDA_WEB_ADAPTER.LAYER.X86}:${LAMBDA_WEB_ADAPTER.VERSION}`;
|
|
3785
|
+
// Create the Lambda Web Adapter layer
|
|
3786
|
+
const webAdapterLayer = lambda.LayerVersion.fromLayerVersionArn(scope, `${id}WebAdapterLayer`, layerArn);
|
|
3787
|
+
// Build environment variables with Lambda Web Adapter configuration
|
|
3788
|
+
const lwaInvokeMode = streaming
|
|
3789
|
+
? LAMBDA_WEB_ADAPTER.INVOKE_MODE.RESPONSE_STREAM
|
|
3790
|
+
: LAMBDA_WEB_ADAPTER.INVOKE_MODE.BUFFERED;
|
|
3791
|
+
const webAdapterEnvironment = {
|
|
3792
|
+
AWS_LAMBDA_EXEC_WRAPPER: LAMBDA_WEB_ADAPTER.EXEC_WRAPPER,
|
|
3793
|
+
AWS_LWA_INVOKE_MODE: lwaInvokeMode,
|
|
3794
|
+
PORT: String(port),
|
|
3795
|
+
};
|
|
3796
|
+
// Merge environment variables - props environment takes precedence
|
|
3797
|
+
let mergedEnvironment;
|
|
3798
|
+
if (Array.isArray(propsEnvironment)) {
|
|
3799
|
+
// Array syntax: prepend our object to the array
|
|
3800
|
+
mergedEnvironment = [webAdapterEnvironment, ...propsEnvironment];
|
|
3801
|
+
}
|
|
3802
|
+
else if (propsEnvironment && typeof propsEnvironment === "object") {
|
|
3803
|
+
// Object syntax: merge objects
|
|
3804
|
+
mergedEnvironment = {
|
|
3805
|
+
...webAdapterEnvironment,
|
|
3806
|
+
...propsEnvironment,
|
|
3807
|
+
};
|
|
3808
|
+
}
|
|
3809
|
+
else {
|
|
3810
|
+
mergedEnvironment = webAdapterEnvironment;
|
|
3811
|
+
}
|
|
3812
|
+
super(scope, id, {
|
|
3813
|
+
architecture,
|
|
3814
|
+
environment: mergedEnvironment,
|
|
3815
|
+
layers: [webAdapterLayer, ...propsLayers],
|
|
3816
|
+
roleTag: CDK$2.ROLE.API,
|
|
3817
|
+
timeout: Duration.seconds(CDK$2.DURATION.EXPRESS_API),
|
|
3818
|
+
...restProps,
|
|
3819
|
+
});
|
|
3820
|
+
// Set invoke mode for use with JaypieDistribution
|
|
3821
|
+
this.invokeMode = streaming
|
|
3822
|
+
? lambda.InvokeMode.RESPONSE_STREAM
|
|
3823
|
+
: lambda.InvokeMode.BUFFERED;
|
|
3824
|
+
}
|
|
3825
|
+
}
|
|
3826
|
+
|
|
3725
3827
|
class JaypieTraceSigningKeySecret extends JaypieEnvSecret {
|
|
3726
3828
|
constructor(scope, id = "TraceSigningKey", props) {
|
|
3727
3829
|
const defaultProps = {
|
|
@@ -3734,5 +3836,5 @@ class JaypieTraceSigningKeySecret extends JaypieEnvSecret {
|
|
|
3734
3836
|
}
|
|
3735
3837
|
}
|
|
3736
3838
|
|
|
3737
|
-
export { CDK$2 as CDK, JaypieAccountLoggingBucket, JaypieApiGateway, JaypieAppStack, JaypieBucketQueuedLambda, JaypieDatadogBucket, JaypieDatadogForwarder, JaypieDatadogSecret, JaypieDistribution, JaypieDnsRecord, JaypieDynamoDb, JaypieEnvSecret, JaypieEventsRule, JaypieExpressLambda, JaypieGitHubDeployRole, JaypieHostedZone, JaypieInfrastructureStack, JaypieLambda, JaypieMongoDbSecret, JaypieNextJs, JaypieOpenAiSecret, JaypieOrganizationTrail, JaypieQueuedLambda, JaypieSsoPermissions, JaypieSsoSyncApplication, JaypieStack, JaypieStaticWebBucket, JaypieTraceSigningKeySecret, JaypieWebDeploymentBucket, addDatadogLayers, clearAllSecretsCaches, clearSecretsCache, constructEnvName, constructStackName, constructTagger, envHostname, extendDatadogRole, isEnv, isProductionEnv, isSandboxEnv, isValidHostname$1 as isValidHostname, isValidSubdomain, jaypieLambdaEnv, mergeDomain, resolveDatadogForwarderFunction, resolveDatadogLayers, resolveDatadogLoggingDestination, resolveEnvironment, resolveHostedZone, resolveParamsAndSecrets, resolveSecrets };
|
|
3839
|
+
export { CDK$2 as CDK, JaypieAccountLoggingBucket, JaypieApiGateway, JaypieAppStack, JaypieBucketQueuedLambda, JaypieDatadogBucket, JaypieDatadogForwarder, JaypieDatadogSecret, JaypieDistribution, JaypieDnsRecord, JaypieDynamoDb, JaypieEnvSecret, JaypieEventsRule, JaypieExpressLambda, JaypieGitHubDeployRole, JaypieHostedZone, JaypieInfrastructureStack, JaypieLambda, JaypieMongoDbSecret, JaypieNextJs, JaypieOpenAiSecret, JaypieOrganizationTrail, JaypieQueuedLambda, JaypieSsoPermissions, JaypieSsoSyncApplication, JaypieStack, JaypieStaticWebBucket, JaypieStreamingLambda, JaypieTraceSigningKeySecret, JaypieWebDeploymentBucket, LAMBDA_WEB_ADAPTER, addDatadogLayers, clearAllSecretsCaches, clearSecretsCache, constructEnvName, constructStackName, constructTagger, envHostname, extendDatadogRole, isEnv, isProductionEnv, isSandboxEnv, isValidHostname$1 as isValidHostname, isValidSubdomain, jaypieLambdaEnv, mergeDomain, resolveDatadogForwarderFunction, resolveDatadogLayers, resolveDatadogLoggingDestination, resolveEnvironment, resolveHostedZone, resolveParamsAndSecrets, resolveSecrets };
|
|
3738
3840
|
//# sourceMappingURL=index.js.map
|