@openhi/constructs 0.0.98 → 0.0.99
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/index.d.mts +37 -35
- package/lib/index.d.ts +37 -35
- package/lib/index.js +127 -125
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +132 -130
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -951,10 +951,10 @@ var DataEventBus = class _DataEventBus extends EventBus {
|
|
|
951
951
|
****************************************************************************/
|
|
952
952
|
static getEventBusName(scope) {
|
|
953
953
|
const stack = OpenHiService.of(scope);
|
|
954
|
-
return `
|
|
954
|
+
return `datav1${stack.branchHash}`;
|
|
955
955
|
}
|
|
956
956
|
constructor(scope, props) {
|
|
957
|
-
super(scope, "data-event-bus", {
|
|
957
|
+
super(scope, "data-event-bus-v1", {
|
|
958
958
|
...props,
|
|
959
959
|
eventBusName: _DataEventBus.getEventBusName(scope)
|
|
960
960
|
});
|
|
@@ -973,10 +973,10 @@ var OpsEventBus = class _OpsEventBus extends EventBus2 {
|
|
|
973
973
|
****************************************************************************/
|
|
974
974
|
static getEventBusName(scope) {
|
|
975
975
|
const stack = OpenHiService.of(scope);
|
|
976
|
-
return `
|
|
976
|
+
return `opsv1${stack.branchHash}`;
|
|
977
977
|
}
|
|
978
978
|
constructor(scope, props) {
|
|
979
|
-
super(scope, "ops-event-bus", {
|
|
979
|
+
super(scope, "ops-event-bus-v1", {
|
|
980
980
|
...props,
|
|
981
981
|
eventBusName: _OpsEventBus.getEventBusName(scope)
|
|
982
982
|
});
|
|
@@ -1250,9 +1250,52 @@ import { Stack as Stack3 } from "aws-cdk-lib/core";
|
|
|
1250
1250
|
|
|
1251
1251
|
// src/services/open-hi-data-service.ts
|
|
1252
1252
|
import { StreamViewType, Table as Table2 } from "aws-cdk-lib/aws-dynamodb";
|
|
1253
|
-
import { EventBus as EventBus3 } from "aws-cdk-lib/aws-events";
|
|
1254
1253
|
import * as kinesis from "aws-cdk-lib/aws-kinesis";
|
|
1255
|
-
|
|
1254
|
+
|
|
1255
|
+
// src/services/open-hi-global-service.ts
|
|
1256
|
+
import {
|
|
1257
|
+
Certificate as Certificate2,
|
|
1258
|
+
CertificateValidation
|
|
1259
|
+
} from "aws-cdk-lib/aws-certificatemanager";
|
|
1260
|
+
import { EventBus as EventBus3 } from "aws-cdk-lib/aws-events";
|
|
1261
|
+
import {
|
|
1262
|
+
HostedZone as HostedZone2
|
|
1263
|
+
} from "aws-cdk-lib/aws-route53";
|
|
1264
|
+
import { StringParameter as StringParameter3 } from "aws-cdk-lib/aws-ssm";
|
|
1265
|
+
var _OpenHiGlobalService = class _OpenHiGlobalService extends OpenHiService {
|
|
1266
|
+
/**
|
|
1267
|
+
* Returns an IHostedZone from the given attributes (no SSM). Use when the zone is imported from config.
|
|
1268
|
+
*/
|
|
1269
|
+
static rootHostedZoneFromConstruct(scope, props) {
|
|
1270
|
+
return HostedZone2.fromHostedZoneAttributes(scope, "root-zone", props);
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Returns an ICertificate by looking up the Global stack's wildcard cert ARN from SSM.
|
|
1274
|
+
*/
|
|
1275
|
+
static rootWildcardCertificateFromConstruct(scope) {
|
|
1276
|
+
const certificateArn = StringParameter3.valueForStringParameter(
|
|
1277
|
+
scope,
|
|
1278
|
+
RootWildcardCertificate.ssmParameterName()
|
|
1279
|
+
);
|
|
1280
|
+
return Certificate2.fromCertificateArn(
|
|
1281
|
+
scope,
|
|
1282
|
+
"wildcard-certificate",
|
|
1283
|
+
certificateArn
|
|
1284
|
+
);
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Returns an IHostedZone by looking up the child hosted zone ID from SSM. Defaults to GLOBAL service type.
|
|
1288
|
+
*/
|
|
1289
|
+
static childHostedZoneFromConstruct(scope, props) {
|
|
1290
|
+
const hostedZoneId = DiscoverableStringParameter.valueForLookupName(scope, {
|
|
1291
|
+
ssmParamName: ChildHostedZone.SSM_PARAM_NAME,
|
|
1292
|
+
serviceType: props.serviceType ?? _OpenHiGlobalService.SERVICE_TYPE
|
|
1293
|
+
});
|
|
1294
|
+
return HostedZone2.fromHostedZoneAttributes(scope, "child-zone", {
|
|
1295
|
+
hostedZoneId,
|
|
1296
|
+
zoneName: props.zoneName
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1256
1299
|
/**
|
|
1257
1300
|
* Returns the data event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
|
|
1258
1301
|
*/
|
|
@@ -1273,6 +1316,88 @@ var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
|
|
|
1273
1316
|
OpsEventBus.getEventBusName(scope)
|
|
1274
1317
|
);
|
|
1275
1318
|
}
|
|
1319
|
+
get serviceType() {
|
|
1320
|
+
return _OpenHiGlobalService.SERVICE_TYPE;
|
|
1321
|
+
}
|
|
1322
|
+
constructor(ohEnv, props = {}) {
|
|
1323
|
+
super(ohEnv, _OpenHiGlobalService.SERVICE_TYPE, props);
|
|
1324
|
+
this.props = props;
|
|
1325
|
+
this.validateConfig(props);
|
|
1326
|
+
this.rootHostedZone = this.createRootHostedZone();
|
|
1327
|
+
this.childHostedZone = this.createChildHostedZone();
|
|
1328
|
+
this.rootWildcardCertificate = this.createRootWildcardCertificate();
|
|
1329
|
+
this.dataEventBus = this.createDataEventBus();
|
|
1330
|
+
this.opsEventBus = this.createOpsEventBus();
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* Validates that config required for the Global stack is present.
|
|
1334
|
+
*/
|
|
1335
|
+
validateConfig(props) {
|
|
1336
|
+
const { config } = props;
|
|
1337
|
+
if (!config) {
|
|
1338
|
+
throw new Error("Config is required");
|
|
1339
|
+
}
|
|
1340
|
+
if (!config.zoneName) {
|
|
1341
|
+
throw new Error("Zone name is required to import the root zone");
|
|
1342
|
+
}
|
|
1343
|
+
if (!config.hostedZoneId) {
|
|
1344
|
+
throw new Error("Hosted zone ID is required to import the root zone");
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Creates the root hosted zone (imported via attributes from config).
|
|
1349
|
+
* Override to customize or create the zone.
|
|
1350
|
+
*/
|
|
1351
|
+
createRootHostedZone() {
|
|
1352
|
+
return _OpenHiGlobalService.rootHostedZoneFromConstruct(this, {
|
|
1353
|
+
zoneName: this.config.zoneName,
|
|
1354
|
+
hostedZoneId: this.config.hostedZoneId
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
/**
|
|
1358
|
+
* Creates the optional child hosted zone (e.g. branch subdomain).
|
|
1359
|
+
* Override to create a child zone when config provides childHostedZoneAttributes.
|
|
1360
|
+
* If you create a ChildHostedZone, also create a DiscoverableStringParameter
|
|
1361
|
+
* with ChildHostedZone.SSM_PARAM_NAME and the zone's hostedZoneId.
|
|
1362
|
+
*/
|
|
1363
|
+
createChildHostedZone() {
|
|
1364
|
+
return void 0;
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Creates the root wildcard certificate. On main branch, creates a new cert
|
|
1368
|
+
* with DNS validation; otherwise imports from SSM.
|
|
1369
|
+
* Override to customize certificate creation.
|
|
1370
|
+
*/
|
|
1371
|
+
createRootWildcardCertificate() {
|
|
1372
|
+
if (this.branchName === "main") {
|
|
1373
|
+
return new RootWildcardCertificate(this, {
|
|
1374
|
+
domainName: `*.${this.rootHostedZone.zoneName}`,
|
|
1375
|
+
subjectAlternativeNames: [this.rootHostedZone.zoneName],
|
|
1376
|
+
validation: CertificateValidation.fromDns(this.rootHostedZone)
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
return _OpenHiGlobalService.rootWildcardCertificateFromConstruct(this);
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* Creates the data event bus.
|
|
1383
|
+
* Override to customize.
|
|
1384
|
+
*/
|
|
1385
|
+
createDataEventBus() {
|
|
1386
|
+
return new DataEventBus(this);
|
|
1387
|
+
}
|
|
1388
|
+
/**
|
|
1389
|
+
* Creates the ops event bus.
|
|
1390
|
+
* Override to customize.
|
|
1391
|
+
*/
|
|
1392
|
+
createOpsEventBus() {
|
|
1393
|
+
return new OpsEventBus(this);
|
|
1394
|
+
}
|
|
1395
|
+
};
|
|
1396
|
+
_OpenHiGlobalService.SERVICE_TYPE = "global";
|
|
1397
|
+
var OpenHiGlobalService = _OpenHiGlobalService;
|
|
1398
|
+
|
|
1399
|
+
// src/services/open-hi-data-service.ts
|
|
1400
|
+
var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
|
|
1276
1401
|
/**
|
|
1277
1402
|
* Returns the data store table by name. Use from other stacks (e.g. REST API Lambda) to obtain an ITable reference.
|
|
1278
1403
|
*/
|
|
@@ -1285,8 +1410,6 @@ var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
|
|
|
1285
1410
|
constructor(ohEnv, props = {}) {
|
|
1286
1411
|
super(ohEnv, _OpenHiDataService.SERVICE_TYPE, props);
|
|
1287
1412
|
this.props = props;
|
|
1288
|
-
this.dataEventBus = this.createDataEventBus();
|
|
1289
|
-
this.opsEventBus = this.createOpsEventBus();
|
|
1290
1413
|
this.dataStoreChangeStream = new kinesis.Stream(
|
|
1291
1414
|
this,
|
|
1292
1415
|
"data-store-change-stream",
|
|
@@ -1307,7 +1430,7 @@ var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
|
|
|
1307
1430
|
kinesisStream: this.dataStoreChangeStream,
|
|
1308
1431
|
removalPolicy: this.removalPolicy,
|
|
1309
1432
|
stackHash: this.stackHash,
|
|
1310
|
-
dataEventBus: this
|
|
1433
|
+
dataEventBus: OpenHiGlobalService.dataEventBusFromConstruct(this)
|
|
1311
1434
|
}
|
|
1312
1435
|
);
|
|
1313
1436
|
this.dataStorePostgresReplica = new DataStorePostgresReplica(
|
|
@@ -1321,20 +1444,6 @@ var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
|
|
|
1321
1444
|
}
|
|
1322
1445
|
);
|
|
1323
1446
|
}
|
|
1324
|
-
/**
|
|
1325
|
-
* Creates the data event bus.
|
|
1326
|
-
* Override to customize.
|
|
1327
|
-
*/
|
|
1328
|
-
createDataEventBus() {
|
|
1329
|
-
return new DataEventBus(this);
|
|
1330
|
-
}
|
|
1331
|
-
/**
|
|
1332
|
-
* Creates the ops event bus.
|
|
1333
|
-
* Override to customize.
|
|
1334
|
-
*/
|
|
1335
|
-
createOpsEventBus() {
|
|
1336
|
-
return new OpsEventBus(this);
|
|
1337
|
-
}
|
|
1338
1447
|
/**
|
|
1339
1448
|
* Creates the single-table DynamoDB data store.
|
|
1340
1449
|
* Override to customize.
|
|
@@ -1662,113 +1771,6 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
|
1662
1771
|
_OpenHiAuthService.SERVICE_TYPE = "auth";
|
|
1663
1772
|
var OpenHiAuthService = _OpenHiAuthService;
|
|
1664
1773
|
|
|
1665
|
-
// src/services/open-hi-global-service.ts
|
|
1666
|
-
import {
|
|
1667
|
-
Certificate as Certificate2,
|
|
1668
|
-
CertificateValidation
|
|
1669
|
-
} from "aws-cdk-lib/aws-certificatemanager";
|
|
1670
|
-
import {
|
|
1671
|
-
HostedZone as HostedZone2
|
|
1672
|
-
} from "aws-cdk-lib/aws-route53";
|
|
1673
|
-
import { StringParameter as StringParameter3 } from "aws-cdk-lib/aws-ssm";
|
|
1674
|
-
var _OpenHiGlobalService = class _OpenHiGlobalService extends OpenHiService {
|
|
1675
|
-
/**
|
|
1676
|
-
* Returns an IHostedZone from the given attributes (no SSM). Use when the zone is imported from config.
|
|
1677
|
-
*/
|
|
1678
|
-
static rootHostedZoneFromConstruct(scope, props) {
|
|
1679
|
-
return HostedZone2.fromHostedZoneAttributes(scope, "root-zone", props);
|
|
1680
|
-
}
|
|
1681
|
-
/**
|
|
1682
|
-
* Returns an ICertificate by looking up the Global stack's wildcard cert ARN from SSM.
|
|
1683
|
-
*/
|
|
1684
|
-
static rootWildcardCertificateFromConstruct(scope) {
|
|
1685
|
-
const certificateArn = StringParameter3.valueForStringParameter(
|
|
1686
|
-
scope,
|
|
1687
|
-
RootWildcardCertificate.ssmParameterName()
|
|
1688
|
-
);
|
|
1689
|
-
return Certificate2.fromCertificateArn(
|
|
1690
|
-
scope,
|
|
1691
|
-
"wildcard-certificate",
|
|
1692
|
-
certificateArn
|
|
1693
|
-
);
|
|
1694
|
-
}
|
|
1695
|
-
/**
|
|
1696
|
-
* Returns an IHostedZone by looking up the child hosted zone ID from SSM. Defaults to GLOBAL service type.
|
|
1697
|
-
*/
|
|
1698
|
-
static childHostedZoneFromConstruct(scope, props) {
|
|
1699
|
-
const hostedZoneId = DiscoverableStringParameter.valueForLookupName(scope, {
|
|
1700
|
-
ssmParamName: ChildHostedZone.SSM_PARAM_NAME,
|
|
1701
|
-
serviceType: props.serviceType ?? _OpenHiGlobalService.SERVICE_TYPE
|
|
1702
|
-
});
|
|
1703
|
-
return HostedZone2.fromHostedZoneAttributes(scope, "child-zone", {
|
|
1704
|
-
hostedZoneId,
|
|
1705
|
-
zoneName: props.zoneName
|
|
1706
|
-
});
|
|
1707
|
-
}
|
|
1708
|
-
get serviceType() {
|
|
1709
|
-
return _OpenHiGlobalService.SERVICE_TYPE;
|
|
1710
|
-
}
|
|
1711
|
-
constructor(ohEnv, props = {}) {
|
|
1712
|
-
super(ohEnv, _OpenHiGlobalService.SERVICE_TYPE, props);
|
|
1713
|
-
this.props = props;
|
|
1714
|
-
this.validateConfig(props);
|
|
1715
|
-
this.rootHostedZone = this.createRootHostedZone();
|
|
1716
|
-
this.childHostedZone = this.createChildHostedZone();
|
|
1717
|
-
this.rootWildcardCertificate = this.createRootWildcardCertificate();
|
|
1718
|
-
}
|
|
1719
|
-
/**
|
|
1720
|
-
* Validates that config required for the Global stack is present.
|
|
1721
|
-
*/
|
|
1722
|
-
validateConfig(props) {
|
|
1723
|
-
const { config } = props;
|
|
1724
|
-
if (!config) {
|
|
1725
|
-
throw new Error("Config is required");
|
|
1726
|
-
}
|
|
1727
|
-
if (!config.zoneName) {
|
|
1728
|
-
throw new Error("Zone name is required to import the root zone");
|
|
1729
|
-
}
|
|
1730
|
-
if (!config.hostedZoneId) {
|
|
1731
|
-
throw new Error("Hosted zone ID is required to import the root zone");
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
/**
|
|
1735
|
-
* Creates the root hosted zone (imported via attributes from config).
|
|
1736
|
-
* Override to customize or create the zone.
|
|
1737
|
-
*/
|
|
1738
|
-
createRootHostedZone() {
|
|
1739
|
-
return _OpenHiGlobalService.rootHostedZoneFromConstruct(this, {
|
|
1740
|
-
zoneName: this.config.zoneName,
|
|
1741
|
-
hostedZoneId: this.config.hostedZoneId
|
|
1742
|
-
});
|
|
1743
|
-
}
|
|
1744
|
-
/**
|
|
1745
|
-
* Creates the optional child hosted zone (e.g. branch subdomain).
|
|
1746
|
-
* Override to create a child zone when config provides childHostedZoneAttributes.
|
|
1747
|
-
* If you create a ChildHostedZone, also create a DiscoverableStringParameter
|
|
1748
|
-
* with ChildHostedZone.SSM_PARAM_NAME and the zone's hostedZoneId.
|
|
1749
|
-
*/
|
|
1750
|
-
createChildHostedZone() {
|
|
1751
|
-
return void 0;
|
|
1752
|
-
}
|
|
1753
|
-
/**
|
|
1754
|
-
* Creates the root wildcard certificate. On main branch, creates a new cert
|
|
1755
|
-
* with DNS validation; otherwise imports from SSM.
|
|
1756
|
-
* Override to customize certificate creation.
|
|
1757
|
-
*/
|
|
1758
|
-
createRootWildcardCertificate() {
|
|
1759
|
-
if (this.branchName === "main") {
|
|
1760
|
-
return new RootWildcardCertificate(this, {
|
|
1761
|
-
domainName: `*.${this.rootHostedZone.zoneName}`,
|
|
1762
|
-
subjectAlternativeNames: [this.rootHostedZone.zoneName],
|
|
1763
|
-
validation: CertificateValidation.fromDns(this.rootHostedZone)
|
|
1764
|
-
});
|
|
1765
|
-
}
|
|
1766
|
-
return _OpenHiGlobalService.rootWildcardCertificateFromConstruct(this);
|
|
1767
|
-
}
|
|
1768
|
-
};
|
|
1769
|
-
_OpenHiGlobalService.SERVICE_TYPE = "global";
|
|
1770
|
-
var OpenHiGlobalService = _OpenHiGlobalService;
|
|
1771
|
-
|
|
1772
1774
|
// src/services/open-hi-rest-api-service.ts
|
|
1773
1775
|
var import_config5 = __toESM(require_lib());
|
|
1774
1776
|
import {
|