@openhi/constructs 0.0.69 → 0.0.71
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/lib/firehose-archive-transform.handler.d.mts +42 -0
- package/lib/firehose-archive-transform.handler.d.ts +42 -0
- package/lib/firehose-archive-transform.handler.js +222 -0
- package/lib/firehose-archive-transform.handler.js.map +1 -0
- package/lib/firehose-archive-transform.handler.mjs +197 -0
- package/lib/firehose-archive-transform.handler.mjs.map +1 -0
- package/lib/index.d.mts +41 -2
- package/lib/index.d.ts +42 -3
- package/lib/index.js +138 -35
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +146 -44
- package/lib/index.mjs.map +1 -1
- package/package.json +3 -3
package/lib/index.mjs
CHANGED
|
@@ -649,6 +649,86 @@ var PreTokenGenerationLambda = class extends Construct {
|
|
|
649
649
|
}
|
|
650
650
|
};
|
|
651
651
|
|
|
652
|
+
// src/components/dynamodb/data-store-historical-archive.ts
|
|
653
|
+
import fs2 from "fs";
|
|
654
|
+
import path2 from "path";
|
|
655
|
+
import { Duration, RemovalPolicy as RemovalPolicy2, Size } from "aws-cdk-lib";
|
|
656
|
+
import * as kinesisfirehose from "aws-cdk-lib/aws-kinesisfirehose";
|
|
657
|
+
import { Runtime as Runtime2 } from "aws-cdk-lib/aws-lambda";
|
|
658
|
+
import { NodejsFunction as NodejsFunction2 } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
659
|
+
import * as s3 from "aws-cdk-lib/aws-s3";
|
|
660
|
+
import { Construct as Construct2 } from "constructs";
|
|
661
|
+
var HANDLER_NAME2 = "firehose-archive-transform.handler.js";
|
|
662
|
+
function resolveHandlerEntry2(dirname) {
|
|
663
|
+
const sameDir = path2.join(dirname, HANDLER_NAME2);
|
|
664
|
+
if (fs2.existsSync(sameDir)) {
|
|
665
|
+
return sameDir;
|
|
666
|
+
}
|
|
667
|
+
return path2.join(dirname, "..", "..", "..", "lib", HANDLER_NAME2);
|
|
668
|
+
}
|
|
669
|
+
var DataStoreHistoricalArchive = class extends Construct2 {
|
|
670
|
+
constructor(scope, id, props) {
|
|
671
|
+
super(scope, id);
|
|
672
|
+
this.archiveBucket = new s3.Bucket(this, "ArchiveBucket", {
|
|
673
|
+
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
|
|
674
|
+
encryption: s3.BucketEncryption.S3_MANAGED,
|
|
675
|
+
enforceSSL: true,
|
|
676
|
+
removalPolicy: props.removalPolicy,
|
|
677
|
+
autoDeleteObjects: props.removalPolicy === RemovalPolicy2.DESTROY,
|
|
678
|
+
versioned: true
|
|
679
|
+
});
|
|
680
|
+
this.transformFunction = new NodejsFunction2(this, "FirehoseTransform", {
|
|
681
|
+
entry: resolveHandlerEntry2(__dirname),
|
|
682
|
+
runtime: Runtime2.NODEJS_LATEST,
|
|
683
|
+
memorySize: 512,
|
|
684
|
+
timeout: Duration.minutes(1),
|
|
685
|
+
description: "Firehose transform: filter CURRENT resource rows, S3 dynamic partition keys",
|
|
686
|
+
bundling: {
|
|
687
|
+
minify: true,
|
|
688
|
+
sourceMap: false
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
const processor = new kinesisfirehose.LambdaFunctionProcessor(
|
|
692
|
+
this.transformFunction,
|
|
693
|
+
{
|
|
694
|
+
bufferInterval: Duration.seconds(60),
|
|
695
|
+
bufferSize: Size.mebibytes(3),
|
|
696
|
+
retries: 3
|
|
697
|
+
}
|
|
698
|
+
);
|
|
699
|
+
const destination = new kinesisfirehose.S3Bucket(this.archiveBucket, {
|
|
700
|
+
compression: kinesisfirehose.Compression.GZIP,
|
|
701
|
+
bufferingInterval: Duration.seconds(300),
|
|
702
|
+
// Firehose requires SizeInMBs ≥ 64 when dynamic partitioning is enabled.
|
|
703
|
+
bufferingSize: Size.mebibytes(64),
|
|
704
|
+
processors: [processor],
|
|
705
|
+
errorOutputPrefix: "errors/!{firehose:error-output-type}/!{timestamp:yyyy/MM/dd/HH}/",
|
|
706
|
+
loggingConfig: new kinesisfirehose.EnableLogging()
|
|
707
|
+
});
|
|
708
|
+
this.deliveryStream = new kinesisfirehose.DeliveryStream(
|
|
709
|
+
this,
|
|
710
|
+
"ArchiveDeliveryStream",
|
|
711
|
+
{
|
|
712
|
+
deliveryStreamName: `openhi-dstore-arch-${props.stackHash}`,
|
|
713
|
+
source: new kinesisfirehose.KinesisStreamSource(props.kinesisStream),
|
|
714
|
+
destination
|
|
715
|
+
}
|
|
716
|
+
);
|
|
717
|
+
const cfn = this.deliveryStream.node.defaultChild;
|
|
718
|
+
cfn.addPropertyOverride(
|
|
719
|
+
"ExtendedS3DestinationConfiguration.DynamicPartitioningConfiguration",
|
|
720
|
+
{
|
|
721
|
+
Enabled: true,
|
|
722
|
+
RetryOptions: { DurationInSeconds: 300 }
|
|
723
|
+
}
|
|
724
|
+
);
|
|
725
|
+
cfn.addPropertyOverride(
|
|
726
|
+
"ExtendedS3DestinationConfiguration.Prefix",
|
|
727
|
+
"!{partitionKeyFromLambda:tenantId}/!{partitionKeyFromLambda:workspaceId}/!{partitionKeyFromLambda:resourceType}/!{partitionKeyFromLambda:resourceId}/!{partitionKeyFromLambda:version}/"
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
|
|
652
732
|
// src/components/dynamodb/dynamo-db-data-store.ts
|
|
653
733
|
import {
|
|
654
734
|
AttributeType,
|
|
@@ -776,7 +856,7 @@ var OpsEventBus = class _OpsEventBus extends EventBus2 {
|
|
|
776
856
|
};
|
|
777
857
|
|
|
778
858
|
// src/components/route-53/child-hosted-zone.ts
|
|
779
|
-
import { Duration } from "aws-cdk-lib";
|
|
859
|
+
import { Duration as Duration2 } from "aws-cdk-lib";
|
|
780
860
|
import {
|
|
781
861
|
HostedZone,
|
|
782
862
|
NsRecord
|
|
@@ -788,7 +868,7 @@ var ChildHostedZone = class extends HostedZone {
|
|
|
788
868
|
zone: props.parentHostedZone,
|
|
789
869
|
recordName: this.zoneName,
|
|
790
870
|
values: this.hostedZoneNameServers || [],
|
|
791
|
-
ttl:
|
|
871
|
+
ttl: Duration2.minutes(5)
|
|
792
872
|
});
|
|
793
873
|
}
|
|
794
874
|
};
|
|
@@ -798,8 +878,8 @@ var ChildHostedZone = class extends HostedZone {
|
|
|
798
878
|
ChildHostedZone.SSM_PARAM_NAME = "CHILDHOSTEDZONE";
|
|
799
879
|
|
|
800
880
|
// src/components/route-53/root-hosted-zone.ts
|
|
801
|
-
import { Construct as
|
|
802
|
-
var RootHostedZone = class extends
|
|
881
|
+
import { Construct as Construct3 } from "constructs";
|
|
882
|
+
var RootHostedZone = class extends Construct3 {
|
|
803
883
|
};
|
|
804
884
|
|
|
805
885
|
// src/components/static-hosting/static-hosting.ts
|
|
@@ -808,16 +888,16 @@ import {
|
|
|
808
888
|
Distribution
|
|
809
889
|
} from "aws-cdk-lib/aws-cloudfront";
|
|
810
890
|
import { S3BucketOrigin } from "aws-cdk-lib/aws-cloudfront-origins";
|
|
811
|
-
import { Bucket } from "aws-cdk-lib/aws-s3";
|
|
812
|
-
import { Duration as
|
|
813
|
-
import { Construct as
|
|
891
|
+
import { Bucket as Bucket2 } from "aws-cdk-lib/aws-s3";
|
|
892
|
+
import { Duration as Duration3 } from "aws-cdk-lib/core";
|
|
893
|
+
import { Construct as Construct4 } from "constructs";
|
|
814
894
|
var STATIC_HOSTING_SERVICE_TYPE = "website";
|
|
815
|
-
var _StaticHosting = class _StaticHosting extends
|
|
895
|
+
var _StaticHosting = class _StaticHosting extends Construct4 {
|
|
816
896
|
constructor(scope, id, props = {}) {
|
|
817
897
|
super(scope, id);
|
|
818
898
|
const stack = OpenHiService.of(scope);
|
|
819
899
|
const serviceType = props.serviceType ?? STATIC_HOSTING_SERVICE_TYPE;
|
|
820
|
-
this.bucket = new
|
|
900
|
+
this.bucket = new Bucket2(this, "bucket", {
|
|
821
901
|
blockPublicAccess: {
|
|
822
902
|
blockPublicAcls: true,
|
|
823
903
|
blockPublicPolicy: true,
|
|
@@ -830,9 +910,9 @@ var _StaticHosting = class _StaticHosting extends Construct3 {
|
|
|
830
910
|
const cachePolicy = new CachePolicy(this, "cache-policy", {
|
|
831
911
|
cachePolicyName: `static-hosting-10s-${stack.branchHash}`,
|
|
832
912
|
comment: "Low TTL (10s) for static hosting; no invalidation",
|
|
833
|
-
defaultTtl:
|
|
834
|
-
minTtl:
|
|
835
|
-
maxTtl:
|
|
913
|
+
defaultTtl: Duration3.seconds(10),
|
|
914
|
+
minTtl: Duration3.seconds(0),
|
|
915
|
+
maxTtl: Duration3.seconds(10)
|
|
836
916
|
});
|
|
837
917
|
this.distribution = new Distribution(this, "distribution", {
|
|
838
918
|
defaultBehavior: {
|
|
@@ -1141,11 +1221,12 @@ import {
|
|
|
1141
1221
|
RecordTarget
|
|
1142
1222
|
} from "aws-cdk-lib/aws-route53";
|
|
1143
1223
|
import { ApiGatewayv2DomainProperties } from "aws-cdk-lib/aws-route53-targets";
|
|
1144
|
-
import { Duration as
|
|
1224
|
+
import { Duration as Duration4 } from "aws-cdk-lib/core";
|
|
1145
1225
|
|
|
1146
1226
|
// src/services/open-hi-data-service.ts
|
|
1147
|
-
import { Table as Table2 } from "aws-cdk-lib/aws-dynamodb";
|
|
1227
|
+
import { StreamViewType, Table as Table2 } from "aws-cdk-lib/aws-dynamodb";
|
|
1148
1228
|
import { EventBus as EventBus3 } from "aws-cdk-lib/aws-events";
|
|
1229
|
+
import * as kinesis from "aws-cdk-lib/aws-kinesis";
|
|
1149
1230
|
var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
|
|
1150
1231
|
/**
|
|
1151
1232
|
* Returns the data event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
|
|
@@ -1181,7 +1262,24 @@ var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
|
|
|
1181
1262
|
this.props = props;
|
|
1182
1263
|
this.dataEventBus = this.createDataEventBus();
|
|
1183
1264
|
this.opsEventBus = this.createOpsEventBus();
|
|
1265
|
+
this.dataStoreChangeStream = new kinesis.Stream(
|
|
1266
|
+
this,
|
|
1267
|
+
"data-store-change-stream",
|
|
1268
|
+
{
|
|
1269
|
+
streamName: `openhi-dstore-cdc-${this.branchHash}`,
|
|
1270
|
+
streamMode: kinesis.StreamMode.ON_DEMAND
|
|
1271
|
+
}
|
|
1272
|
+
);
|
|
1184
1273
|
this.dataStore = this.createDataStore();
|
|
1274
|
+
this.dataStoreHistoricalArchive = new DataStoreHistoricalArchive(
|
|
1275
|
+
this,
|
|
1276
|
+
"data-store-historical-archive",
|
|
1277
|
+
{
|
|
1278
|
+
kinesisStream: this.dataStoreChangeStream,
|
|
1279
|
+
removalPolicy: this.removalPolicy,
|
|
1280
|
+
stackHash: this.stackHash
|
|
1281
|
+
}
|
|
1282
|
+
);
|
|
1185
1283
|
}
|
|
1186
1284
|
/**
|
|
1187
1285
|
* Creates the data event bus.
|
|
@@ -1202,59 +1300,62 @@ var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
|
|
|
1202
1300
|
* Override to customize.
|
|
1203
1301
|
*/
|
|
1204
1302
|
createDataStore() {
|
|
1205
|
-
return new DynamoDbDataStore(this, "dynamo-db-data-store"
|
|
1303
|
+
return new DynamoDbDataStore(this, "dynamo-db-data-store", {
|
|
1304
|
+
kinesisStream: this.dataStoreChangeStream,
|
|
1305
|
+
stream: StreamViewType.NEW_AND_OLD_IMAGES
|
|
1306
|
+
});
|
|
1206
1307
|
}
|
|
1207
1308
|
};
|
|
1208
1309
|
_OpenHiDataService.SERVICE_TYPE = "data";
|
|
1209
1310
|
var OpenHiDataService = _OpenHiDataService;
|
|
1210
1311
|
|
|
1211
1312
|
// src/data/lambda/cors-options-lambda.ts
|
|
1212
|
-
import
|
|
1213
|
-
import
|
|
1214
|
-
import { Runtime as
|
|
1215
|
-
import { NodejsFunction as
|
|
1216
|
-
import { Construct as
|
|
1217
|
-
var
|
|
1218
|
-
function
|
|
1219
|
-
const sameDir =
|
|
1220
|
-
if (
|
|
1313
|
+
import fs3 from "fs";
|
|
1314
|
+
import path3 from "path";
|
|
1315
|
+
import { Runtime as Runtime3 } from "aws-cdk-lib/aws-lambda";
|
|
1316
|
+
import { NodejsFunction as NodejsFunction3 } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
1317
|
+
import { Construct as Construct5 } from "constructs";
|
|
1318
|
+
var HANDLER_NAME3 = "cors-options-lambda.handler.js";
|
|
1319
|
+
function resolveHandlerEntry3(dirname) {
|
|
1320
|
+
const sameDir = path3.join(dirname, HANDLER_NAME3);
|
|
1321
|
+
if (fs3.existsSync(sameDir)) {
|
|
1221
1322
|
return sameDir;
|
|
1222
1323
|
}
|
|
1223
|
-
const fromLib =
|
|
1324
|
+
const fromLib = path3.join(dirname, "..", "..", "..", "lib", HANDLER_NAME3);
|
|
1224
1325
|
return fromLib;
|
|
1225
1326
|
}
|
|
1226
|
-
var CorsOptionsLambda = class extends
|
|
1327
|
+
var CorsOptionsLambda = class extends Construct5 {
|
|
1227
1328
|
constructor(scope, id = "cors-options-lambda") {
|
|
1228
1329
|
super(scope, id);
|
|
1229
|
-
this.lambda = new
|
|
1230
|
-
entry:
|
|
1231
|
-
runtime:
|
|
1330
|
+
this.lambda = new NodejsFunction3(this, "handler", {
|
|
1331
|
+
entry: resolveHandlerEntry3(__dirname),
|
|
1332
|
+
runtime: Runtime3.NODEJS_LATEST,
|
|
1232
1333
|
memorySize: 128
|
|
1233
1334
|
});
|
|
1234
1335
|
}
|
|
1235
1336
|
};
|
|
1236
1337
|
|
|
1237
1338
|
// src/data/lambda/rest-api-lambda.ts
|
|
1238
|
-
import
|
|
1239
|
-
import
|
|
1240
|
-
import { Runtime as
|
|
1241
|
-
import { NodejsFunction as
|
|
1242
|
-
import { Construct as
|
|
1243
|
-
var
|
|
1244
|
-
function
|
|
1245
|
-
const sameDir =
|
|
1246
|
-
if (
|
|
1339
|
+
import fs4 from "fs";
|
|
1340
|
+
import path4 from "path";
|
|
1341
|
+
import { Runtime as Runtime4 } from "aws-cdk-lib/aws-lambda";
|
|
1342
|
+
import { NodejsFunction as NodejsFunction4 } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
1343
|
+
import { Construct as Construct6 } from "constructs";
|
|
1344
|
+
var HANDLER_NAME4 = "rest-api-lambda.handler.js";
|
|
1345
|
+
function resolveHandlerEntry4(dirname) {
|
|
1346
|
+
const sameDir = path4.join(dirname, HANDLER_NAME4);
|
|
1347
|
+
if (fs4.existsSync(sameDir)) {
|
|
1247
1348
|
return sameDir;
|
|
1248
1349
|
}
|
|
1249
|
-
const fromLib =
|
|
1350
|
+
const fromLib = path4.join(dirname, "..", "..", "..", "lib", HANDLER_NAME4);
|
|
1250
1351
|
return fromLib;
|
|
1251
1352
|
}
|
|
1252
|
-
var RestApiLambda = class extends
|
|
1353
|
+
var RestApiLambda = class extends Construct6 {
|
|
1253
1354
|
constructor(scope, props) {
|
|
1254
1355
|
super(scope, "rest-api-lambda");
|
|
1255
|
-
this.lambda = new
|
|
1256
|
-
entry:
|
|
1257
|
-
runtime:
|
|
1356
|
+
this.lambda = new NodejsFunction4(this, "handler", {
|
|
1357
|
+
entry: resolveHandlerEntry4(__dirname),
|
|
1358
|
+
runtime: Runtime4.NODEJS_LATEST,
|
|
1258
1359
|
memorySize: 1024,
|
|
1259
1360
|
environment: {
|
|
1260
1361
|
DYNAMO_TABLE_NAME: props.dynamoTableName,
|
|
@@ -1484,7 +1585,7 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
1484
1585
|
"Authorization"
|
|
1485
1586
|
],
|
|
1486
1587
|
allowCredentials: cors.allowCredentials ?? true,
|
|
1487
|
-
maxAge: cors.maxAge ??
|
|
1588
|
+
maxAge: cors.maxAge ?? Duration4.days(1),
|
|
1488
1589
|
...cors.exposeHeaders !== void 0 && {
|
|
1489
1590
|
exposeHeaders: cors.exposeHeaders
|
|
1490
1591
|
}
|
|
@@ -1555,6 +1656,7 @@ export {
|
|
|
1555
1656
|
CognitoUserPoolDomain,
|
|
1556
1657
|
CognitoUserPoolKmsKey,
|
|
1557
1658
|
DataEventBus,
|
|
1659
|
+
DataStoreHistoricalArchive,
|
|
1558
1660
|
DiscoverableStringParameter,
|
|
1559
1661
|
DynamoDbDataStore,
|
|
1560
1662
|
OpenHiApp,
|