@jaypie/constructs 1.2.33 → 1.2.35
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/JaypieDynamoDb.d.ts +1 -0
- package/dist/cjs/JaypieMigration.d.ts +21 -0
- package/dist/cjs/__tests__/JaypieMigration.spec.d.ts +1 -0
- package/dist/cjs/index.cjs +43 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/esm/JaypieDynamoDb.d.ts +1 -0
- package/dist/esm/JaypieMigration.d.ts +21 -0
- package/dist/esm/__tests__/JaypieMigration.spec.d.ts +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +42 -4
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -89,6 +89,7 @@ export declare class JaypieDynamoDb extends Construct implements dynamodb.ITable
|
|
|
89
89
|
get tableRef(): dynamodb.TableReference;
|
|
90
90
|
get tableStreamArn(): string | undefined;
|
|
91
91
|
get encryptionKey(): import("aws-cdk-lib/aws-kms").IKey | undefined;
|
|
92
|
+
get grants(): dynamodb.TableGrants;
|
|
92
93
|
applyRemovalPolicy(policy: RemovalPolicy): void;
|
|
93
94
|
grant(grantee: import("aws-cdk-lib/aws-iam").IGrantable, ...actions: string[]): import("aws-cdk-lib/aws-iam").Grant;
|
|
94
95
|
grantFullAccess(grantee: import("aws-cdk-lib/aws-iam").IGrantable): import("aws-cdk-lib/aws-iam").Grant;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Construct } from "constructs";
|
|
2
|
+
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
|
|
3
|
+
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
4
|
+
import { JaypieLambda } from "./JaypieLambda";
|
|
5
|
+
import type { SecretsArrayItem } from "./helpers/index.js";
|
|
6
|
+
export interface JaypieMigrationProps {
|
|
7
|
+
/** Path to the bundled migration code (esbuild output directory) */
|
|
8
|
+
code: lambda.Code | string;
|
|
9
|
+
/** Constructs that must be created before the migration runs */
|
|
10
|
+
dependencies?: Construct[];
|
|
11
|
+
/** Lambda handler entry point */
|
|
12
|
+
handler?: string;
|
|
13
|
+
/** Secrets to make available to the migration Lambda */
|
|
14
|
+
secrets?: SecretsArrayItem[];
|
|
15
|
+
/** DynamoDB tables to grant read/write access */
|
|
16
|
+
tables?: dynamodb.ITable[];
|
|
17
|
+
}
|
|
18
|
+
export declare class JaypieMigration extends Construct {
|
|
19
|
+
readonly lambda: JaypieLambda;
|
|
20
|
+
constructor(scope: Construct, id: string, props: JaypieMigrationProps);
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -24,6 +24,7 @@ var origins = require('aws-cdk-lib/aws-cloudfront-origins');
|
|
|
24
24
|
var wafv2 = require('aws-cdk-lib/aws-wafv2');
|
|
25
25
|
var dynamodb = require('aws-cdk-lib/aws-dynamodb');
|
|
26
26
|
var fabric = require('@jaypie/fabric');
|
|
27
|
+
var cr = require('aws-cdk-lib/custom-resources');
|
|
27
28
|
var cdkNextjsStandalone = require('cdk-nextjs-standalone');
|
|
28
29
|
var path = require('path');
|
|
29
30
|
var awsAccessanalyzer = require('aws-cdk-lib/aws-accessanalyzer');
|
|
@@ -67,6 +68,7 @@ var cloudfront__namespace = /*#__PURE__*/_interopNamespaceDefault(cloudfront);
|
|
|
67
68
|
var origins__namespace = /*#__PURE__*/_interopNamespaceDefault(origins);
|
|
68
69
|
var wafv2__namespace = /*#__PURE__*/_interopNamespaceDefault(wafv2);
|
|
69
70
|
var dynamodb__namespace = /*#__PURE__*/_interopNamespaceDefault(dynamodb);
|
|
71
|
+
var cr__namespace = /*#__PURE__*/_interopNamespaceDefault(cr);
|
|
70
72
|
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
71
73
|
var apigatewayv2__namespace = /*#__PURE__*/_interopNamespaceDefault(apigatewayv2);
|
|
72
74
|
var apigatewayv2Integrations__namespace = /*#__PURE__*/_interopNamespaceDefault(apigatewayv2Integrations);
|
|
@@ -405,11 +407,16 @@ function envHostname({ component, domain, env, subdomain, } = {}) {
|
|
|
405
407
|
if (!resolvedDomain) {
|
|
406
408
|
throw new errors.ConfigurationError("No hostname `domain` provided. Set CDK_ENV_DOMAIN or CDK_ENV_HOSTED_ZONE to use environment domain");
|
|
407
409
|
}
|
|
410
|
+
const personal = process.env.CDK_ENV_PERSONAL;
|
|
408
411
|
const resolvedComponent = component === "@" || component === "" ? undefined : component;
|
|
409
412
|
const providedSubdomain = subdomain === "@" || subdomain === "" ? undefined : subdomain;
|
|
410
413
|
const resolvedSubdomain = providedSubdomain || process.env.CDK_ENV_SUBDOMAIN;
|
|
411
414
|
const resolvedEnv = env || process.env.PROJECT_ENV;
|
|
412
|
-
const filteredEnv = resolvedEnv === CDK$2.ENV.PRODUCTION
|
|
415
|
+
const filteredEnv = resolvedEnv === CDK$2.ENV.PRODUCTION
|
|
416
|
+
? undefined
|
|
417
|
+
: personal && resolvedEnv === personal
|
|
418
|
+
? undefined
|
|
419
|
+
: resolvedEnv;
|
|
413
420
|
// Check if parts are already contained in the domain to avoid duplication
|
|
414
421
|
const domainParts = resolvedDomain.split(".");
|
|
415
422
|
const isPartInDomain = (part) => {
|
|
@@ -418,6 +425,7 @@ function envHostname({ component, domain, env, subdomain, } = {}) {
|
|
|
418
425
|
return domainParts.includes(part);
|
|
419
426
|
};
|
|
420
427
|
const parts = [
|
|
428
|
+
personal && !isPartInDomain(personal) ? personal : undefined,
|
|
421
429
|
isPartInDomain(resolvedComponent) ? undefined : resolvedComponent,
|
|
422
430
|
isPartInDomain(resolvedSubdomain) ? undefined : resolvedSubdomain,
|
|
423
431
|
isPartInDomain(filteredEnv) ? undefined : filteredEnv,
|
|
@@ -2702,7 +2710,6 @@ class JaypieDistribution extends constructs.Construct {
|
|
|
2702
2710
|
if (wafLogBucketProp === true) {
|
|
2703
2711
|
// Create inline WAF logging bucket with Datadog forwarding
|
|
2704
2712
|
const createdBucket = new s3__namespace.Bucket(this, constructEnvName("WafLogBucket"), {
|
|
2705
|
-
autoDeleteObjects: true,
|
|
2706
2713
|
bucketName: `aws-waf-logs-${constructEnvName("waf").toLowerCase()}`,
|
|
2707
2714
|
lifecycleRules: [
|
|
2708
2715
|
{
|
|
@@ -2716,7 +2723,7 @@ class JaypieDistribution extends constructs.Construct {
|
|
|
2716
2723
|
},
|
|
2717
2724
|
],
|
|
2718
2725
|
objectOwnership: s3__namespace.ObjectOwnership.OBJECT_WRITER,
|
|
2719
|
-
removalPolicy: cdk.RemovalPolicy.
|
|
2726
|
+
removalPolicy: cdk.RemovalPolicy.RETAIN,
|
|
2720
2727
|
});
|
|
2721
2728
|
cdk.Tags.of(createdBucket).add(CDK$2.TAG.ROLE, CDK$2.ROLE.MONITORING);
|
|
2722
2729
|
// Add Datadog forwarder notification
|
|
@@ -3059,6 +3066,9 @@ class JaypieDynamoDb extends constructs.Construct {
|
|
|
3059
3066
|
get encryptionKey() {
|
|
3060
3067
|
return this._table.encryptionKey;
|
|
3061
3068
|
}
|
|
3069
|
+
get grants() {
|
|
3070
|
+
return this._table.grants;
|
|
3071
|
+
}
|
|
3062
3072
|
applyRemovalPolicy(policy) {
|
|
3063
3073
|
this._table.applyRemovalPolicy(policy);
|
|
3064
3074
|
}
|
|
@@ -3417,6 +3427,35 @@ class JaypieInfrastructureStack extends JaypieStack {
|
|
|
3417
3427
|
}
|
|
3418
3428
|
}
|
|
3419
3429
|
|
|
3430
|
+
class JaypieMigration extends constructs.Construct {
|
|
3431
|
+
constructor(scope, id, props) {
|
|
3432
|
+
super(scope, id);
|
|
3433
|
+
const { code, dependencies = [], handler = "index.handler", secrets = [], tables = [], } = props;
|
|
3434
|
+
// Migration Lambda — 5 minute timeout for long-running migrations
|
|
3435
|
+
this.lambda = new JaypieLambda(this, "MigrationLambda", {
|
|
3436
|
+
code,
|
|
3437
|
+
description: "DynamoDB migration custom resource",
|
|
3438
|
+
handler,
|
|
3439
|
+
roleTag: CDK$2.ROLE.PROCESSING,
|
|
3440
|
+
secrets,
|
|
3441
|
+
tables,
|
|
3442
|
+
timeout: cdk__namespace.Duration.minutes(5),
|
|
3443
|
+
});
|
|
3444
|
+
// Custom Resource provider wrapping the Lambda
|
|
3445
|
+
const provider = new cr__namespace.Provider(this, "MigrationProvider", {
|
|
3446
|
+
onEventHandler: this.lambda,
|
|
3447
|
+
});
|
|
3448
|
+
// Custom Resource that triggers on every deploy
|
|
3449
|
+
const resource = new cdk__namespace.CustomResource(this, "MigrationResource", {
|
|
3450
|
+
serviceToken: provider.serviceToken,
|
|
3451
|
+
});
|
|
3452
|
+
// Ensure dependencies are created before the migration runs
|
|
3453
|
+
for (const dep of dependencies) {
|
|
3454
|
+
resource.node.addDependency(dep);
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
|
|
3420
3459
|
class JaypieMongoDbSecret extends JaypieEnvSecret {
|
|
3421
3460
|
constructor(scope, id = "MongoConnectionString", props) {
|
|
3422
3461
|
const defaultProps = {
|
|
@@ -4785,6 +4824,7 @@ exports.JaypieGitHubDeployRole = JaypieGitHubDeployRole;
|
|
|
4785
4824
|
exports.JaypieHostedZone = JaypieHostedZone;
|
|
4786
4825
|
exports.JaypieInfrastructureStack = JaypieInfrastructureStack;
|
|
4787
4826
|
exports.JaypieLambda = JaypieLambda;
|
|
4827
|
+
exports.JaypieMigration = JaypieMigration;
|
|
4788
4828
|
exports.JaypieMongoDbSecret = JaypieMongoDbSecret;
|
|
4789
4829
|
exports.JaypieNextJs = JaypieNextJs;
|
|
4790
4830
|
exports.JaypieOpenAiSecret = JaypieOpenAiSecret;
|