@jaypie/constructs 1.2.1 → 1.2.3
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/JaypieLambda.d.ts +6 -1
- package/dist/cjs/JaypieNextJs.d.ts +43 -1
- package/dist/cjs/index.cjs +70 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/esm/JaypieLambda.d.ts +6 -1
- package/dist/esm/JaypieNextJs.d.ts +43 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +70 -3
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export { JaypieHostedZone, JaypieHostedZoneRecordProps, } from "./JaypieHostedZo
|
|
|
16
16
|
export { JaypieInfrastructureStack } from "./JaypieInfrastructureStack";
|
|
17
17
|
export { JaypieLambda, JaypieLambdaProps } from "./JaypieLambda";
|
|
18
18
|
export { JaypieMongoDbSecret } from "./JaypieMongoDbSecret";
|
|
19
|
-
export { JaypieNextJs, JaypieNextjsProps } from "./JaypieNextJs";
|
|
19
|
+
export { DomainNameConfig, JaypieNextJs, JaypieNextjsProps, } from "./JaypieNextJs";
|
|
20
20
|
export { JaypieOpenAiSecret } from "./JaypieOpenAiSecret";
|
|
21
21
|
export { JaypieOrganizationTrail, JaypieOrganizationTrailProps, } from "./JaypieOrganizationTrail";
|
|
22
22
|
export { AccountAssignments, JaypieSsoPermissions, JaypieSsoPermissionsProps, } from "./JaypieSsoPermissions";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
2
|
import { Duration, Stack, RemovalPolicy } from "aws-cdk-lib";
|
|
3
|
-
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
4
3
|
import * as cloudwatch from "aws-cdk-lib/aws-cloudwatch";
|
|
4
|
+
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
|
|
5
5
|
import * as ec2 from "aws-cdk-lib/aws-ec2";
|
|
6
6
|
import * as iam from "aws-cdk-lib/aws-iam";
|
|
7
|
+
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
7
8
|
import * as logs from "aws-cdk-lib/aws-logs";
|
|
8
9
|
import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
|
|
9
10
|
import { EnvironmentInput, SecretsArrayItem } from "./helpers/index.js";
|
|
@@ -17,6 +18,10 @@ export interface JaypieLambdaProps {
|
|
|
17
18
|
deadLetterQueueEnabled?: boolean;
|
|
18
19
|
deadLetterTopic?: import("aws-cdk-lib/aws-sns").ITopic;
|
|
19
20
|
description?: string;
|
|
21
|
+
/**
|
|
22
|
+
* DynamoDB tables to grant read/write access to the Lambda function.
|
|
23
|
+
*/
|
|
24
|
+
dynamoTables?: dynamodb.ITable[];
|
|
20
25
|
/**
|
|
21
26
|
* Environment variables for the Lambda function.
|
|
22
27
|
*
|
|
@@ -1,10 +1,29 @@
|
|
|
1
|
+
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
|
|
1
2
|
import { IHostedZone } from "aws-cdk-lib/aws-route53";
|
|
2
3
|
import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
|
|
3
4
|
import { Construct } from "constructs";
|
|
4
5
|
import { EnvironmentInput, SecretsArrayItem } from "./helpers";
|
|
6
|
+
export interface DomainNameConfig {
|
|
7
|
+
component?: string;
|
|
8
|
+
domain?: string;
|
|
9
|
+
env?: string;
|
|
10
|
+
subdomain?: string;
|
|
11
|
+
}
|
|
5
12
|
export interface JaypieNextjsProps {
|
|
6
13
|
datadogApiKeyArn?: string;
|
|
7
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Domain name for the Next.js application.
|
|
16
|
+
*
|
|
17
|
+
* Supports both string and config object:
|
|
18
|
+
* - String: used directly as the domain name
|
|
19
|
+
* - Object: passed to envHostname() to construct the domain name
|
|
20
|
+
* - { component, domain, env, subdomain }
|
|
21
|
+
*/
|
|
22
|
+
domainName?: string | DomainNameConfig;
|
|
23
|
+
/**
|
|
24
|
+
* DynamoDB tables to grant read/write access to the Next.js server function.
|
|
25
|
+
*/
|
|
26
|
+
dynamoTables?: dynamodb.ITable[];
|
|
8
27
|
/**
|
|
9
28
|
* Environment variables for the Next.js application.
|
|
10
29
|
*
|
|
@@ -31,6 +50,29 @@ export interface JaypieNextjsProps {
|
|
|
31
50
|
secrets?: SecretsArrayItem[];
|
|
32
51
|
}
|
|
33
52
|
export declare class JaypieNextJs extends Construct {
|
|
53
|
+
private readonly _nextjs;
|
|
34
54
|
readonly domainName: string;
|
|
35
55
|
constructor(scope: Construct, id: string, props?: JaypieNextjsProps);
|
|
56
|
+
/** S3 bucket for static assets */
|
|
57
|
+
get bucket(): import("aws-cdk-lib/aws-s3").IBucket;
|
|
58
|
+
/** CloudFront distribution */
|
|
59
|
+
get distribution(): import("cdk-nextjs-standalone").NextjsDistribution;
|
|
60
|
+
/** Route53 domain configuration */
|
|
61
|
+
get domain(): import("cdk-nextjs-standalone").NextjsDomain | undefined;
|
|
62
|
+
/** Image optimization Lambda function */
|
|
63
|
+
get imageOptimizationFunction(): import("cdk-nextjs-standalone").NextjsImage;
|
|
64
|
+
/** Image optimization Lambda function URL */
|
|
65
|
+
get imageOptimizationLambdaFunctionUrl(): import("aws-cdk-lib/aws-lambda").FunctionUrl;
|
|
66
|
+
/** Server Lambda function URL */
|
|
67
|
+
get lambdaFunctionUrl(): import("aws-cdk-lib/aws-lambda").FunctionUrl;
|
|
68
|
+
/** Next.js build output */
|
|
69
|
+
get nextBuild(): import("cdk-nextjs-standalone").NextjsBuild;
|
|
70
|
+
/** ISR revalidation configuration */
|
|
71
|
+
get revalidation(): import("cdk-nextjs-standalone").NextjsRevalidation;
|
|
72
|
+
/** Next.js server function */
|
|
73
|
+
get serverFunction(): import("cdk-nextjs-standalone").NextjsServer;
|
|
74
|
+
/** Static assets configuration */
|
|
75
|
+
get staticAssets(): import("cdk-nextjs-standalone").NextjsStaticAssets;
|
|
76
|
+
/** CloudFront distribution URL */
|
|
77
|
+
get url(): string;
|
|
36
78
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export { JaypieHostedZone, JaypieHostedZoneRecordProps, } from "./JaypieHostedZo
|
|
|
16
16
|
export { JaypieInfrastructureStack } from "./JaypieInfrastructureStack";
|
|
17
17
|
export { JaypieLambda, JaypieLambdaProps } from "./JaypieLambda";
|
|
18
18
|
export { JaypieMongoDbSecret } from "./JaypieMongoDbSecret";
|
|
19
|
-
export { JaypieNextJs, JaypieNextjsProps } from "./JaypieNextJs";
|
|
19
|
+
export { DomainNameConfig, JaypieNextJs, JaypieNextjsProps, } from "./JaypieNextJs";
|
|
20
20
|
export { JaypieOpenAiSecret } from "./JaypieOpenAiSecret";
|
|
21
21
|
export { JaypieOrganizationTrail, JaypieOrganizationTrailProps, } from "./JaypieOrganizationTrail";
|
|
22
22
|
export { AccountAssignments, JaypieSsoPermissions, JaypieSsoPermissionsProps, } from "./JaypieSsoPermissions";
|
package/dist/esm/index.js
CHANGED
|
@@ -359,7 +359,8 @@ function envHostname({ component, domain, env, subdomain, } = {}) {
|
|
|
359
359
|
throw new ConfigurationError("No hostname `domain` provided. Set CDK_ENV_DOMAIN or CDK_ENV_HOSTED_ZONE to use environment domain");
|
|
360
360
|
}
|
|
361
361
|
const resolvedComponent = component === "@" || component === "" ? undefined : component;
|
|
362
|
-
const
|
|
362
|
+
const providedSubdomain = subdomain === "@" || subdomain === "" ? undefined : subdomain;
|
|
363
|
+
const resolvedSubdomain = providedSubdomain || process.env.CDK_ENV_SUBDOMAIN;
|
|
363
364
|
const resolvedEnv = env || process.env.PROJECT_ENV;
|
|
364
365
|
const filteredEnv = resolvedEnv === CDK$2.ENV.PRODUCTION ? undefined : resolvedEnv;
|
|
365
366
|
const parts = [
|
|
@@ -1169,7 +1170,7 @@ class JaypieAppStack extends JaypieStack {
|
|
|
1169
1170
|
class JaypieLambda extends Construct {
|
|
1170
1171
|
constructor(scope, id, props) {
|
|
1171
1172
|
super(scope, id);
|
|
1172
|
-
const { allowAllOutbound, allowPublicSubnet, architecture = lambda.Architecture.X86_64, code, datadogApiKeyArn, deadLetterQueue, deadLetterQueueEnabled, deadLetterTopic, description, environment: environmentInput, envSecrets = {}, ephemeralStorageSize, filesystem, handler = "index.handler", initialPolicy, layers = [], logGroup, logRetention = CDK$2.LAMBDA.LOG_RETENTION, maxEventAge, memorySize = CDK$2.LAMBDA.MEMORY_SIZE, paramsAndSecrets, paramsAndSecretsOptions, profiling, profilingGroup, provisionedConcurrentExecutions, reservedConcurrentExecutions, retryAttempts, roleTag = CDK$2.ROLE.PROCESSING, runtime = new lambda.Runtime("nodejs24.x", lambda.RuntimeFamily.NODEJS, {
|
|
1173
|
+
const { allowAllOutbound, allowPublicSubnet, architecture = lambda.Architecture.X86_64, code, datadogApiKeyArn, deadLetterQueue, deadLetterQueueEnabled, deadLetterTopic, description, dynamoTables = [], environment: environmentInput, envSecrets = {}, ephemeralStorageSize, filesystem, handler = "index.handler", initialPolicy, layers = [], logGroup, logRetention = CDK$2.LAMBDA.LOG_RETENTION, maxEventAge, memorySize = CDK$2.LAMBDA.MEMORY_SIZE, paramsAndSecrets, paramsAndSecretsOptions, profiling, profilingGroup, provisionedConcurrentExecutions, reservedConcurrentExecutions, retryAttempts, roleTag = CDK$2.ROLE.PROCESSING, runtime = new lambda.Runtime("nodejs24.x", lambda.RuntimeFamily.NODEJS, {
|
|
1173
1174
|
supportsInlineCode: true,
|
|
1174
1175
|
}), runtimeManagementMode, secrets: secretsInput = [], securityGroups, timeout = Duration.seconds(CDK$2.DURATION.LAMBDA_WORKER), tracing, vendorTag, vpc, vpcSubnets, } = props;
|
|
1175
1176
|
// Resolve environment from array or object syntax
|
|
@@ -1260,6 +1261,14 @@ class JaypieLambda extends Construct {
|
|
|
1260
1261
|
secrets.forEach((secret) => {
|
|
1261
1262
|
secret.grantRead(this._lambda);
|
|
1262
1263
|
});
|
|
1264
|
+
// Grant read/write permissions for DynamoDB tables
|
|
1265
|
+
dynamoTables.forEach((table) => {
|
|
1266
|
+
table.grantReadWriteData(this._lambda);
|
|
1267
|
+
});
|
|
1268
|
+
// Add table name to environment if there's exactly one table
|
|
1269
|
+
if (dynamoTables.length === 1) {
|
|
1270
|
+
this._lambda.addEnvironment("CDK_ENV_DYNAMO_TABLE", dynamoTables[0].tableName);
|
|
1271
|
+
}
|
|
1263
1272
|
// Configure provisioned concurrency if specified
|
|
1264
1273
|
if (provisionedConcurrentExecutions !== undefined) {
|
|
1265
1274
|
// Use currentVersion which is auto-published with proper configuration
|
|
@@ -2564,7 +2573,9 @@ class JaypieMongoDbSecret extends JaypieEnvSecret {
|
|
|
2564
2573
|
class JaypieNextJs extends Construct {
|
|
2565
2574
|
constructor(scope, id, props) {
|
|
2566
2575
|
super(scope, id);
|
|
2567
|
-
const domainName = props?.domainName
|
|
2576
|
+
const domainName = typeof props?.domainName === "string"
|
|
2577
|
+
? props.domainName
|
|
2578
|
+
: envHostname(props?.domainName);
|
|
2568
2579
|
this.domainName = domainName;
|
|
2569
2580
|
const domainNameSanitized = domainName
|
|
2570
2581
|
.replace(/\./g, "-")
|
|
@@ -2650,6 +2661,62 @@ class JaypieNextJs extends Construct {
|
|
|
2650
2661
|
secrets.forEach((secret) => {
|
|
2651
2662
|
secret.grantRead(nextjs.serverFunction.lambdaFunction);
|
|
2652
2663
|
});
|
|
2664
|
+
// Grant read/write permissions for DynamoDB tables
|
|
2665
|
+
const dynamoTables = props?.dynamoTables || [];
|
|
2666
|
+
dynamoTables.forEach((table) => {
|
|
2667
|
+
table.grantReadWriteData(nextjs.serverFunction.lambdaFunction);
|
|
2668
|
+
});
|
|
2669
|
+
// Add table name to environment if there's exactly one table
|
|
2670
|
+
if (dynamoTables.length === 1) {
|
|
2671
|
+
nextjs.serverFunction.lambdaFunction.addEnvironment("CDK_ENV_DYNAMO_TABLE", dynamoTables[0].tableName);
|
|
2672
|
+
}
|
|
2673
|
+
// Store reference to nextjs for property exposure
|
|
2674
|
+
this._nextjs = nextjs;
|
|
2675
|
+
}
|
|
2676
|
+
// Expose Nextjs construct properties
|
|
2677
|
+
/** S3 bucket for static assets */
|
|
2678
|
+
get bucket() {
|
|
2679
|
+
return this._nextjs.bucket;
|
|
2680
|
+
}
|
|
2681
|
+
/** CloudFront distribution */
|
|
2682
|
+
get distribution() {
|
|
2683
|
+
return this._nextjs.distribution;
|
|
2684
|
+
}
|
|
2685
|
+
/** Route53 domain configuration */
|
|
2686
|
+
get domain() {
|
|
2687
|
+
return this._nextjs.domain;
|
|
2688
|
+
}
|
|
2689
|
+
/** Image optimization Lambda function */
|
|
2690
|
+
get imageOptimizationFunction() {
|
|
2691
|
+
return this._nextjs.imageOptimizationFunction;
|
|
2692
|
+
}
|
|
2693
|
+
/** Image optimization Lambda function URL */
|
|
2694
|
+
get imageOptimizationLambdaFunctionUrl() {
|
|
2695
|
+
return this._nextjs.imageOptimizationLambdaFunctionUrl;
|
|
2696
|
+
}
|
|
2697
|
+
/** Server Lambda function URL */
|
|
2698
|
+
get lambdaFunctionUrl() {
|
|
2699
|
+
return this._nextjs.lambdaFunctionUrl;
|
|
2700
|
+
}
|
|
2701
|
+
/** Next.js build output */
|
|
2702
|
+
get nextBuild() {
|
|
2703
|
+
return this._nextjs.nextBuild;
|
|
2704
|
+
}
|
|
2705
|
+
/** ISR revalidation configuration */
|
|
2706
|
+
get revalidation() {
|
|
2707
|
+
return this._nextjs.revalidation;
|
|
2708
|
+
}
|
|
2709
|
+
/** Next.js server function */
|
|
2710
|
+
get serverFunction() {
|
|
2711
|
+
return this._nextjs.serverFunction;
|
|
2712
|
+
}
|
|
2713
|
+
/** Static assets configuration */
|
|
2714
|
+
get staticAssets() {
|
|
2715
|
+
return this._nextjs.staticAssets;
|
|
2716
|
+
}
|
|
2717
|
+
/** CloudFront distribution URL */
|
|
2718
|
+
get url() {
|
|
2719
|
+
return this._nextjs.url;
|
|
2653
2720
|
}
|
|
2654
2721
|
}
|
|
2655
2722
|
|