@jaypie/constructs 1.2.2 → 1.2.4
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 +28 -0
- package/dist/cjs/index.cjs +75 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/JaypieLambda.d.ts +6 -1
- package/dist/esm/JaypieNextJs.d.ts +28 -0
- package/dist/esm/index.js +75 -4
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -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,3 +1,4 @@
|
|
|
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";
|
|
@@ -19,6 +20,10 @@ export interface JaypieNextjsProps {
|
|
|
19
20
|
* - { component, domain, env, subdomain }
|
|
20
21
|
*/
|
|
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[];
|
|
22
27
|
/**
|
|
23
28
|
* Environment variables for the Next.js application.
|
|
24
29
|
*
|
|
@@ -45,6 +50,29 @@ export interface JaypieNextjsProps {
|
|
|
45
50
|
secrets?: SecretsArrayItem[];
|
|
46
51
|
}
|
|
47
52
|
export declare class JaypieNextJs extends Construct {
|
|
53
|
+
private readonly _nextjs;
|
|
48
54
|
readonly domainName: string;
|
|
49
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;
|
|
50
78
|
}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -394,10 +394,17 @@ function envHostname({ component, domain, env, subdomain, } = {}) {
|
|
|
394
394
|
const resolvedSubdomain = providedSubdomain || process.env.CDK_ENV_SUBDOMAIN;
|
|
395
395
|
const resolvedEnv = env || process.env.PROJECT_ENV;
|
|
396
396
|
const filteredEnv = resolvedEnv === CDK$2.ENV.PRODUCTION ? undefined : resolvedEnv;
|
|
397
|
+
// Check if parts are already contained in the domain to avoid duplication
|
|
398
|
+
const domainParts = resolvedDomain.split(".");
|
|
399
|
+
const isPartInDomain = (part) => {
|
|
400
|
+
if (!part)
|
|
401
|
+
return false;
|
|
402
|
+
return domainParts.includes(part);
|
|
403
|
+
};
|
|
397
404
|
const parts = [
|
|
398
|
-
resolvedComponent,
|
|
399
|
-
resolvedSubdomain,
|
|
400
|
-
filteredEnv,
|
|
405
|
+
isPartInDomain(resolvedComponent) ? undefined : resolvedComponent,
|
|
406
|
+
isPartInDomain(resolvedSubdomain) ? undefined : resolvedSubdomain,
|
|
407
|
+
isPartInDomain(filteredEnv) ? undefined : filteredEnv,
|
|
401
408
|
resolvedDomain,
|
|
402
409
|
].filter((part) => part);
|
|
403
410
|
return parts.join(".");
|
|
@@ -1201,7 +1208,7 @@ class JaypieAppStack extends JaypieStack {
|
|
|
1201
1208
|
class JaypieLambda extends constructs.Construct {
|
|
1202
1209
|
constructor(scope, id, props) {
|
|
1203
1210
|
super(scope, id);
|
|
1204
|
-
const { allowAllOutbound, allowPublicSubnet, architecture = lambda__namespace.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__namespace.Runtime("nodejs24.x", lambda__namespace.RuntimeFamily.NODEJS, {
|
|
1211
|
+
const { allowAllOutbound, allowPublicSubnet, architecture = lambda__namespace.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__namespace.Runtime("nodejs24.x", lambda__namespace.RuntimeFamily.NODEJS, {
|
|
1205
1212
|
supportsInlineCode: true,
|
|
1206
1213
|
}), runtimeManagementMode, secrets: secretsInput = [], securityGroups, timeout = cdk.Duration.seconds(CDK$2.DURATION.LAMBDA_WORKER), tracing, vendorTag, vpc, vpcSubnets, } = props;
|
|
1207
1214
|
// Resolve environment from array or object syntax
|
|
@@ -1292,6 +1299,14 @@ class JaypieLambda extends constructs.Construct {
|
|
|
1292
1299
|
secrets.forEach((secret) => {
|
|
1293
1300
|
secret.grantRead(this._lambda);
|
|
1294
1301
|
});
|
|
1302
|
+
// Grant read/write permissions for DynamoDB tables
|
|
1303
|
+
dynamoTables.forEach((table) => {
|
|
1304
|
+
table.grantReadWriteData(this._lambda);
|
|
1305
|
+
});
|
|
1306
|
+
// Add table name to environment if there's exactly one table
|
|
1307
|
+
if (dynamoTables.length === 1) {
|
|
1308
|
+
this._lambda.addEnvironment("CDK_ENV_DYNAMO_TABLE", dynamoTables[0].tableName);
|
|
1309
|
+
}
|
|
1295
1310
|
// Configure provisioned concurrency if specified
|
|
1296
1311
|
if (provisionedConcurrentExecutions !== undefined) {
|
|
1297
1312
|
// Use currentVersion which is auto-published with proper configuration
|
|
@@ -2684,6 +2699,62 @@ class JaypieNextJs extends constructs.Construct {
|
|
|
2684
2699
|
secrets.forEach((secret) => {
|
|
2685
2700
|
secret.grantRead(nextjs.serverFunction.lambdaFunction);
|
|
2686
2701
|
});
|
|
2702
|
+
// Grant read/write permissions for DynamoDB tables
|
|
2703
|
+
const dynamoTables = props?.dynamoTables || [];
|
|
2704
|
+
dynamoTables.forEach((table) => {
|
|
2705
|
+
table.grantReadWriteData(nextjs.serverFunction.lambdaFunction);
|
|
2706
|
+
});
|
|
2707
|
+
// Add table name to environment if there's exactly one table
|
|
2708
|
+
if (dynamoTables.length === 1) {
|
|
2709
|
+
nextjs.serverFunction.lambdaFunction.addEnvironment("CDK_ENV_DYNAMO_TABLE", dynamoTables[0].tableName);
|
|
2710
|
+
}
|
|
2711
|
+
// Store reference to nextjs for property exposure
|
|
2712
|
+
this._nextjs = nextjs;
|
|
2713
|
+
}
|
|
2714
|
+
// Expose Nextjs construct properties
|
|
2715
|
+
/** S3 bucket for static assets */
|
|
2716
|
+
get bucket() {
|
|
2717
|
+
return this._nextjs.bucket;
|
|
2718
|
+
}
|
|
2719
|
+
/** CloudFront distribution */
|
|
2720
|
+
get distribution() {
|
|
2721
|
+
return this._nextjs.distribution;
|
|
2722
|
+
}
|
|
2723
|
+
/** Route53 domain configuration */
|
|
2724
|
+
get domain() {
|
|
2725
|
+
return this._nextjs.domain;
|
|
2726
|
+
}
|
|
2727
|
+
/** Image optimization Lambda function */
|
|
2728
|
+
get imageOptimizationFunction() {
|
|
2729
|
+
return this._nextjs.imageOptimizationFunction;
|
|
2730
|
+
}
|
|
2731
|
+
/** Image optimization Lambda function URL */
|
|
2732
|
+
get imageOptimizationLambdaFunctionUrl() {
|
|
2733
|
+
return this._nextjs.imageOptimizationLambdaFunctionUrl;
|
|
2734
|
+
}
|
|
2735
|
+
/** Server Lambda function URL */
|
|
2736
|
+
get lambdaFunctionUrl() {
|
|
2737
|
+
return this._nextjs.lambdaFunctionUrl;
|
|
2738
|
+
}
|
|
2739
|
+
/** Next.js build output */
|
|
2740
|
+
get nextBuild() {
|
|
2741
|
+
return this._nextjs.nextBuild;
|
|
2742
|
+
}
|
|
2743
|
+
/** ISR revalidation configuration */
|
|
2744
|
+
get revalidation() {
|
|
2745
|
+
return this._nextjs.revalidation;
|
|
2746
|
+
}
|
|
2747
|
+
/** Next.js server function */
|
|
2748
|
+
get serverFunction() {
|
|
2749
|
+
return this._nextjs.serverFunction;
|
|
2750
|
+
}
|
|
2751
|
+
/** Static assets configuration */
|
|
2752
|
+
get staticAssets() {
|
|
2753
|
+
return this._nextjs.staticAssets;
|
|
2754
|
+
}
|
|
2755
|
+
/** CloudFront distribution URL */
|
|
2756
|
+
get url() {
|
|
2757
|
+
return this._nextjs.url;
|
|
2687
2758
|
}
|
|
2688
2759
|
}
|
|
2689
2760
|
|