@openhi/constructs 0.0.98 → 0.0.100

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 CHANGED
@@ -1083,9 +1083,10 @@ declare class OpenHiAuthService extends OpenHiService {
1083
1083
  interface OpenHiGlobalServiceProps extends OpenHiServiceProps {
1084
1084
  }
1085
1085
  /**
1086
- * Global Infrastructure stack: owns global DNS and certificates.
1087
- * Resources (root zone, optional child zone, wildcard cert) are created
1088
- * in protected methods; subclasses may override to customize.
1086
+ * Global Infrastructure stack: owns global DNS, certificates, and the
1087
+ * cross-region EventBridge buses (data, ops). Resources (root zone, optional
1088
+ * child zone, wildcard cert, data/ops buses) are created in protected methods;
1089
+ * subclasses may override to customize.
1089
1090
  */
1090
1091
  declare class OpenHiGlobalService extends OpenHiService {
1091
1092
  static readonly SERVICE_TYPE = "global";
@@ -1104,12 +1105,30 @@ declare class OpenHiGlobalService extends OpenHiService {
1104
1105
  zoneName: string;
1105
1106
  serviceType?: OpenHiServiceType;
1106
1107
  }): IHostedZone;
1108
+ /**
1109
+ * Returns the data event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
1110
+ */
1111
+ static dataEventBusFromConstruct(scope: Construct): IEventBus;
1112
+ /**
1113
+ * Returns the ops event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
1114
+ */
1115
+ static opsEventBusFromConstruct(scope: Construct): IEventBus;
1107
1116
  get serviceType(): string;
1108
1117
  /** Override so this.props is typed with this service's options. */
1109
1118
  props: OpenHiGlobalServiceProps;
1110
1119
  readonly rootHostedZone: IHostedZone;
1111
1120
  readonly childHostedZone?: IHostedZone;
1112
1121
  readonly rootWildcardCertificate: ICertificate;
1122
+ /**
1123
+ * Event bus for data-related events (ingestion, transformation, storage).
1124
+ * Other stacks obtain it via {@link OpenHiGlobalService.dataEventBusFromConstruct}.
1125
+ */
1126
+ readonly dataEventBus: IEventBus;
1127
+ /**
1128
+ * Event bus for operational events (monitoring, alerting, system health).
1129
+ * Other stacks obtain it via {@link OpenHiGlobalService.opsEventBusFromConstruct}.
1130
+ */
1131
+ readonly opsEventBus: IEventBus;
1113
1132
  constructor(ohEnv: OpenHiEnvironment, props?: OpenHiGlobalServiceProps);
1114
1133
  /**
1115
1134
  * Validates that config required for the Global stack is present.
@@ -1133,6 +1152,16 @@ declare class OpenHiGlobalService extends OpenHiService {
1133
1152
  * Override to customize certificate creation.
1134
1153
  */
1135
1154
  protected createRootWildcardCertificate(): ICertificate;
1155
+ /**
1156
+ * Creates the data event bus.
1157
+ * Override to customize.
1158
+ */
1159
+ protected createDataEventBus(): IEventBus;
1160
+ /**
1161
+ * Creates the ops event bus.
1162
+ * Override to customize.
1163
+ */
1164
+ protected createOpsEventBus(): IEventBus;
1136
1165
  }
1137
1166
 
1138
1167
  /**
@@ -1219,21 +1248,14 @@ declare class OpenHiRestApiService extends OpenHiService {
1219
1248
  interface OpenHiDataServiceProps extends OpenHiServiceProps {
1220
1249
  }
1221
1250
  /**
1222
- * Data storage service stack: centralizes DynamoDB, S3, EventBridge event buses,
1223
- * and other persistence resources for OpenHI. Creates the single-table data store
1224
- * and the data/ops event buses in protected methods;
1225
- * subclasses may override to customize.
1251
+ * Data storage service stack: centralizes DynamoDB, S3, and other persistence
1252
+ * resources for OpenHI. Creates the single-table data store in a protected
1253
+ * method; subclasses may override to customize. EventBridge event buses
1254
+ * (data, ops) are owned by {@link OpenHiGlobalService} so they deploy ahead of
1255
+ * regional services.
1226
1256
  */
1227
1257
  declare class OpenHiDataService extends OpenHiService {
1228
1258
  static readonly SERVICE_TYPE = "data";
1229
- /**
1230
- * Returns the data event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
1231
- */
1232
- static dataEventBusFromConstruct(scope: Construct): IEventBus;
1233
- /**
1234
- * Returns the ops event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
1235
- */
1236
- static opsEventBusFromConstruct(scope: Construct): IEventBus;
1237
1259
  /**
1238
1260
  * Returns the data store table by name. Use from other stacks (e.g. REST API Lambda) to obtain an ITable reference.
1239
1261
  */
@@ -1241,16 +1263,6 @@ declare class OpenHiDataService extends OpenHiService {
1241
1263
  get serviceType(): string;
1242
1264
  /** Override so this.props is typed with this service's options. */
1243
1265
  props: OpenHiDataServiceProps;
1244
- /**
1245
- * Event bus for data-related events (ingestion, transformation, storage).
1246
- * Other stacks obtain it via {@link OpenHiDataService.dataEventBusFromConstruct}.
1247
- */
1248
- readonly dataEventBus: IEventBus;
1249
- /**
1250
- * Event bus for operational events (monitoring, alerting, system health).
1251
- * Other stacks obtain it via {@link OpenHiDataService.opsEventBusFromConstruct}.
1252
- */
1253
- readonly opsEventBus: IEventBus;
1254
1266
  /**
1255
1267
  * The single-table DynamoDB data store. Use {@link OpenHiDataService.dynamoDbDataStoreFromConstruct}
1256
1268
  * from other stacks to obtain an ITable reference by name.
@@ -1273,16 +1285,6 @@ declare class OpenHiDataService extends OpenHiService {
1273
1285
  */
1274
1286
  readonly dataStorePostgresReplica: DataStorePostgresReplica;
1275
1287
  constructor(ohEnv: OpenHiEnvironment, props?: OpenHiDataServiceProps);
1276
- /**
1277
- * Creates the data event bus.
1278
- * Override to customize.
1279
- */
1280
- protected createDataEventBus(): IEventBus;
1281
- /**
1282
- * Creates the ops event bus.
1283
- * Override to customize.
1284
- */
1285
- protected createOpsEventBus(): IEventBus;
1286
1288
  /**
1287
1289
  * Creates the single-table DynamoDB data store.
1288
1290
  * Override to customize.
package/lib/index.d.ts CHANGED
@@ -1178,9 +1178,10 @@ declare class OpenHiAuthService extends OpenHiService {
1178
1178
  interface OpenHiGlobalServiceProps extends OpenHiServiceProps {
1179
1179
  }
1180
1180
  /**
1181
- * Global Infrastructure stack: owns global DNS and certificates.
1182
- * Resources (root zone, optional child zone, wildcard cert) are created
1183
- * in protected methods; subclasses may override to customize.
1181
+ * Global Infrastructure stack: owns global DNS, certificates, and the
1182
+ * cross-region EventBridge buses (data, ops). Resources (root zone, optional
1183
+ * child zone, wildcard cert, data/ops buses) are created in protected methods;
1184
+ * subclasses may override to customize.
1184
1185
  */
1185
1186
  declare class OpenHiGlobalService extends OpenHiService {
1186
1187
  static readonly SERVICE_TYPE = "global";
@@ -1199,12 +1200,30 @@ declare class OpenHiGlobalService extends OpenHiService {
1199
1200
  zoneName: string;
1200
1201
  serviceType?: OpenHiServiceType;
1201
1202
  }): IHostedZone;
1203
+ /**
1204
+ * Returns the data event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
1205
+ */
1206
+ static dataEventBusFromConstruct(scope: Construct): IEventBus;
1207
+ /**
1208
+ * Returns the ops event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
1209
+ */
1210
+ static opsEventBusFromConstruct(scope: Construct): IEventBus;
1202
1211
  get serviceType(): string;
1203
1212
  /** Override so this.props is typed with this service's options. */
1204
1213
  props: OpenHiGlobalServiceProps;
1205
1214
  readonly rootHostedZone: IHostedZone;
1206
1215
  readonly childHostedZone?: IHostedZone;
1207
1216
  readonly rootWildcardCertificate: ICertificate;
1217
+ /**
1218
+ * Event bus for data-related events (ingestion, transformation, storage).
1219
+ * Other stacks obtain it via {@link OpenHiGlobalService.dataEventBusFromConstruct}.
1220
+ */
1221
+ readonly dataEventBus: IEventBus;
1222
+ /**
1223
+ * Event bus for operational events (monitoring, alerting, system health).
1224
+ * Other stacks obtain it via {@link OpenHiGlobalService.opsEventBusFromConstruct}.
1225
+ */
1226
+ readonly opsEventBus: IEventBus;
1208
1227
  constructor(ohEnv: OpenHiEnvironment, props?: OpenHiGlobalServiceProps);
1209
1228
  /**
1210
1229
  * Validates that config required for the Global stack is present.
@@ -1228,6 +1247,16 @@ declare class OpenHiGlobalService extends OpenHiService {
1228
1247
  * Override to customize certificate creation.
1229
1248
  */
1230
1249
  protected createRootWildcardCertificate(): ICertificate;
1250
+ /**
1251
+ * Creates the data event bus.
1252
+ * Override to customize.
1253
+ */
1254
+ protected createDataEventBus(): IEventBus;
1255
+ /**
1256
+ * Creates the ops event bus.
1257
+ * Override to customize.
1258
+ */
1259
+ protected createOpsEventBus(): IEventBus;
1231
1260
  }
1232
1261
 
1233
1262
  /**
@@ -1314,21 +1343,14 @@ declare class OpenHiRestApiService extends OpenHiService {
1314
1343
  interface OpenHiDataServiceProps extends OpenHiServiceProps {
1315
1344
  }
1316
1345
  /**
1317
- * Data storage service stack: centralizes DynamoDB, S3, EventBridge event buses,
1318
- * and other persistence resources for OpenHI. Creates the single-table data store
1319
- * and the data/ops event buses in protected methods;
1320
- * subclasses may override to customize.
1346
+ * Data storage service stack: centralizes DynamoDB, S3, and other persistence
1347
+ * resources for OpenHI. Creates the single-table data store in a protected
1348
+ * method; subclasses may override to customize. EventBridge event buses
1349
+ * (data, ops) are owned by {@link OpenHiGlobalService} so they deploy ahead of
1350
+ * regional services.
1321
1351
  */
1322
1352
  declare class OpenHiDataService extends OpenHiService {
1323
1353
  static readonly SERVICE_TYPE = "data";
1324
- /**
1325
- * Returns the data event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
1326
- */
1327
- static dataEventBusFromConstruct(scope: Construct): IEventBus;
1328
- /**
1329
- * Returns the ops event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
1330
- */
1331
- static opsEventBusFromConstruct(scope: Construct): IEventBus;
1332
1354
  /**
1333
1355
  * Returns the data store table by name. Use from other stacks (e.g. REST API Lambda) to obtain an ITable reference.
1334
1356
  */
@@ -1336,16 +1358,6 @@ declare class OpenHiDataService extends OpenHiService {
1336
1358
  get serviceType(): string;
1337
1359
  /** Override so this.props is typed with this service's options. */
1338
1360
  props: OpenHiDataServiceProps;
1339
- /**
1340
- * Event bus for data-related events (ingestion, transformation, storage).
1341
- * Other stacks obtain it via {@link OpenHiDataService.dataEventBusFromConstruct}.
1342
- */
1343
- readonly dataEventBus: IEventBus;
1344
- /**
1345
- * Event bus for operational events (monitoring, alerting, system health).
1346
- * Other stacks obtain it via {@link OpenHiDataService.opsEventBusFromConstruct}.
1347
- */
1348
- readonly opsEventBus: IEventBus;
1349
1361
  /**
1350
1362
  * The single-table DynamoDB data store. Use {@link OpenHiDataService.dynamoDbDataStoreFromConstruct}
1351
1363
  * from other stacks to obtain an ITable reference by name.
@@ -1368,16 +1380,6 @@ declare class OpenHiDataService extends OpenHiService {
1368
1380
  */
1369
1381
  readonly dataStorePostgresReplica: DataStorePostgresReplica;
1370
1382
  constructor(ohEnv: OpenHiEnvironment, props?: OpenHiDataServiceProps);
1371
- /**
1372
- * Creates the data event bus.
1373
- * Override to customize.
1374
- */
1375
- protected createDataEventBus(): IEventBus;
1376
- /**
1377
- * Creates the ops event bus.
1378
- * Override to customize.
1379
- */
1380
- protected createOpsEventBus(): IEventBus;
1381
1383
  /**
1382
1384
  * Creates the single-table DynamoDB data store.
1383
1385
  * Override to customize.
package/lib/index.js CHANGED
@@ -1117,10 +1117,10 @@ var DataEventBus = class _DataEventBus extends import_aws_events.EventBus {
1117
1117
  ****************************************************************************/
1118
1118
  static getEventBusName(scope) {
1119
1119
  const stack = OpenHiService.of(scope);
1120
- return `data${stack.branchHash}`;
1120
+ return `datav1${stack.branchHash}`;
1121
1121
  }
1122
1122
  constructor(scope, props) {
1123
- super(scope, "data-event-bus", {
1123
+ super(scope, "data-event-bus-v1", {
1124
1124
  ...props,
1125
1125
  eventBusName: _DataEventBus.getEventBusName(scope)
1126
1126
  });
@@ -1139,10 +1139,10 @@ var OpsEventBus = class _OpsEventBus extends import_aws_events2.EventBus {
1139
1139
  ****************************************************************************/
1140
1140
  static getEventBusName(scope) {
1141
1141
  const stack = OpenHiService.of(scope);
1142
- return `ops${stack.branchHash}`;
1142
+ return `opsv1${stack.branchHash}`;
1143
1143
  }
1144
1144
  constructor(scope, props) {
1145
- super(scope, "ops-event-bus", {
1145
+ super(scope, "ops-event-bus-v1", {
1146
1146
  ...props,
1147
1147
  eventBusName: _OpsEventBus.getEventBusName(scope)
1148
1148
  });
@@ -1404,9 +1404,47 @@ var import_core2 = require("aws-cdk-lib/core");
1404
1404
 
1405
1405
  // src/services/open-hi-data-service.ts
1406
1406
  var import_aws_dynamodb2 = require("aws-cdk-lib/aws-dynamodb");
1407
- var import_aws_events3 = require("aws-cdk-lib/aws-events");
1408
1407
  var kinesis = __toESM(require("aws-cdk-lib/aws-kinesis"));
1409
- var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
1408
+
1409
+ // src/services/open-hi-global-service.ts
1410
+ var import_aws_certificatemanager2 = require("aws-cdk-lib/aws-certificatemanager");
1411
+ var import_aws_events3 = require("aws-cdk-lib/aws-events");
1412
+ var import_aws_route532 = require("aws-cdk-lib/aws-route53");
1413
+ var import_aws_ssm3 = require("aws-cdk-lib/aws-ssm");
1414
+ var _OpenHiGlobalService = class _OpenHiGlobalService extends OpenHiService {
1415
+ /**
1416
+ * Returns an IHostedZone from the given attributes (no SSM). Use when the zone is imported from config.
1417
+ */
1418
+ static rootHostedZoneFromConstruct(scope, props) {
1419
+ return import_aws_route532.HostedZone.fromHostedZoneAttributes(scope, "root-zone", props);
1420
+ }
1421
+ /**
1422
+ * Returns an ICertificate by looking up the Global stack's wildcard cert ARN from SSM.
1423
+ */
1424
+ static rootWildcardCertificateFromConstruct(scope) {
1425
+ const certificateArn = import_aws_ssm3.StringParameter.valueForStringParameter(
1426
+ scope,
1427
+ RootWildcardCertificate.ssmParameterName()
1428
+ );
1429
+ return import_aws_certificatemanager2.Certificate.fromCertificateArn(
1430
+ scope,
1431
+ "wildcard-certificate",
1432
+ certificateArn
1433
+ );
1434
+ }
1435
+ /**
1436
+ * Returns an IHostedZone by looking up the child hosted zone ID from SSM. Defaults to GLOBAL service type.
1437
+ */
1438
+ static childHostedZoneFromConstruct(scope, props) {
1439
+ const hostedZoneId = DiscoverableStringParameter.valueForLookupName(scope, {
1440
+ ssmParamName: ChildHostedZone.SSM_PARAM_NAME,
1441
+ serviceType: props.serviceType ?? _OpenHiGlobalService.SERVICE_TYPE
1442
+ });
1443
+ return import_aws_route532.HostedZone.fromHostedZoneAttributes(scope, "child-zone", {
1444
+ hostedZoneId,
1445
+ zoneName: props.zoneName
1446
+ });
1447
+ }
1410
1448
  /**
1411
1449
  * Returns the data event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
1412
1450
  */
@@ -1427,6 +1465,88 @@ var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
1427
1465
  OpsEventBus.getEventBusName(scope)
1428
1466
  );
1429
1467
  }
1468
+ get serviceType() {
1469
+ return _OpenHiGlobalService.SERVICE_TYPE;
1470
+ }
1471
+ constructor(ohEnv, props = {}) {
1472
+ super(ohEnv, _OpenHiGlobalService.SERVICE_TYPE, props);
1473
+ this.props = props;
1474
+ this.validateConfig(props);
1475
+ this.rootHostedZone = this.createRootHostedZone();
1476
+ this.childHostedZone = this.createChildHostedZone();
1477
+ this.rootWildcardCertificate = this.createRootWildcardCertificate();
1478
+ this.dataEventBus = this.createDataEventBus();
1479
+ this.opsEventBus = this.createOpsEventBus();
1480
+ }
1481
+ /**
1482
+ * Validates that config required for the Global stack is present.
1483
+ */
1484
+ validateConfig(props) {
1485
+ const { config } = props;
1486
+ if (!config) {
1487
+ throw new Error("Config is required");
1488
+ }
1489
+ if (!config.zoneName) {
1490
+ throw new Error("Zone name is required to import the root zone");
1491
+ }
1492
+ if (!config.hostedZoneId) {
1493
+ throw new Error("Hosted zone ID is required to import the root zone");
1494
+ }
1495
+ }
1496
+ /**
1497
+ * Creates the root hosted zone (imported via attributes from config).
1498
+ * Override to customize or create the zone.
1499
+ */
1500
+ createRootHostedZone() {
1501
+ return _OpenHiGlobalService.rootHostedZoneFromConstruct(this, {
1502
+ zoneName: this.config.zoneName,
1503
+ hostedZoneId: this.config.hostedZoneId
1504
+ });
1505
+ }
1506
+ /**
1507
+ * Creates the optional child hosted zone (e.g. branch subdomain).
1508
+ * Override to create a child zone when config provides childHostedZoneAttributes.
1509
+ * If you create a ChildHostedZone, also create a DiscoverableStringParameter
1510
+ * with ChildHostedZone.SSM_PARAM_NAME and the zone's hostedZoneId.
1511
+ */
1512
+ createChildHostedZone() {
1513
+ return void 0;
1514
+ }
1515
+ /**
1516
+ * Creates the root wildcard certificate. On main branch, creates a new cert
1517
+ * with DNS validation; otherwise imports from SSM.
1518
+ * Override to customize certificate creation.
1519
+ */
1520
+ createRootWildcardCertificate() {
1521
+ if (this.branchName === "main") {
1522
+ return new RootWildcardCertificate(this, {
1523
+ domainName: `*.${this.rootHostedZone.zoneName}`,
1524
+ subjectAlternativeNames: [this.rootHostedZone.zoneName],
1525
+ validation: import_aws_certificatemanager2.CertificateValidation.fromDns(this.rootHostedZone)
1526
+ });
1527
+ }
1528
+ return _OpenHiGlobalService.rootWildcardCertificateFromConstruct(this);
1529
+ }
1530
+ /**
1531
+ * Creates the data event bus.
1532
+ * Override to customize.
1533
+ */
1534
+ createDataEventBus() {
1535
+ return new DataEventBus(this);
1536
+ }
1537
+ /**
1538
+ * Creates the ops event bus.
1539
+ * Override to customize.
1540
+ */
1541
+ createOpsEventBus() {
1542
+ return new OpsEventBus(this);
1543
+ }
1544
+ };
1545
+ _OpenHiGlobalService.SERVICE_TYPE = "global";
1546
+ var OpenHiGlobalService = _OpenHiGlobalService;
1547
+
1548
+ // src/services/open-hi-data-service.ts
1549
+ var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
1430
1550
  /**
1431
1551
  * Returns the data store table by name. Use from other stacks (e.g. REST API Lambda) to obtain an ITable reference.
1432
1552
  */
@@ -1439,8 +1559,6 @@ var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
1439
1559
  constructor(ohEnv, props = {}) {
1440
1560
  super(ohEnv, _OpenHiDataService.SERVICE_TYPE, props);
1441
1561
  this.props = props;
1442
- this.dataEventBus = this.createDataEventBus();
1443
- this.opsEventBus = this.createOpsEventBus();
1444
1562
  this.dataStoreChangeStream = new kinesis.Stream(
1445
1563
  this,
1446
1564
  "data-store-change-stream",
@@ -1461,7 +1579,7 @@ var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
1461
1579
  kinesisStream: this.dataStoreChangeStream,
1462
1580
  removalPolicy: this.removalPolicy,
1463
1581
  stackHash: this.stackHash,
1464
- dataEventBus: this.dataEventBus
1582
+ dataEventBus: OpenHiGlobalService.dataEventBusFromConstruct(this)
1465
1583
  }
1466
1584
  );
1467
1585
  this.dataStorePostgresReplica = new DataStorePostgresReplica(
@@ -1475,20 +1593,6 @@ var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
1475
1593
  }
1476
1594
  );
1477
1595
  }
1478
- /**
1479
- * Creates the data event bus.
1480
- * Override to customize.
1481
- */
1482
- createDataEventBus() {
1483
- return new DataEventBus(this);
1484
- }
1485
- /**
1486
- * Creates the ops event bus.
1487
- * Override to customize.
1488
- */
1489
- createOpsEventBus() {
1490
- return new OpsEventBus(this);
1491
- }
1492
1596
  /**
1493
1597
  * Creates the single-table DynamoDB data store.
1494
1598
  * Override to customize.
@@ -1816,108 +1920,6 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
1816
1920
  _OpenHiAuthService.SERVICE_TYPE = "auth";
1817
1921
  var OpenHiAuthService = _OpenHiAuthService;
1818
1922
 
1819
- // src/services/open-hi-global-service.ts
1820
- var import_aws_certificatemanager2 = require("aws-cdk-lib/aws-certificatemanager");
1821
- var import_aws_route532 = require("aws-cdk-lib/aws-route53");
1822
- var import_aws_ssm3 = require("aws-cdk-lib/aws-ssm");
1823
- var _OpenHiGlobalService = class _OpenHiGlobalService extends OpenHiService {
1824
- /**
1825
- * Returns an IHostedZone from the given attributes (no SSM). Use when the zone is imported from config.
1826
- */
1827
- static rootHostedZoneFromConstruct(scope, props) {
1828
- return import_aws_route532.HostedZone.fromHostedZoneAttributes(scope, "root-zone", props);
1829
- }
1830
- /**
1831
- * Returns an ICertificate by looking up the Global stack's wildcard cert ARN from SSM.
1832
- */
1833
- static rootWildcardCertificateFromConstruct(scope) {
1834
- const certificateArn = import_aws_ssm3.StringParameter.valueForStringParameter(
1835
- scope,
1836
- RootWildcardCertificate.ssmParameterName()
1837
- );
1838
- return import_aws_certificatemanager2.Certificate.fromCertificateArn(
1839
- scope,
1840
- "wildcard-certificate",
1841
- certificateArn
1842
- );
1843
- }
1844
- /**
1845
- * Returns an IHostedZone by looking up the child hosted zone ID from SSM. Defaults to GLOBAL service type.
1846
- */
1847
- static childHostedZoneFromConstruct(scope, props) {
1848
- const hostedZoneId = DiscoverableStringParameter.valueForLookupName(scope, {
1849
- ssmParamName: ChildHostedZone.SSM_PARAM_NAME,
1850
- serviceType: props.serviceType ?? _OpenHiGlobalService.SERVICE_TYPE
1851
- });
1852
- return import_aws_route532.HostedZone.fromHostedZoneAttributes(scope, "child-zone", {
1853
- hostedZoneId,
1854
- zoneName: props.zoneName
1855
- });
1856
- }
1857
- get serviceType() {
1858
- return _OpenHiGlobalService.SERVICE_TYPE;
1859
- }
1860
- constructor(ohEnv, props = {}) {
1861
- super(ohEnv, _OpenHiGlobalService.SERVICE_TYPE, props);
1862
- this.props = props;
1863
- this.validateConfig(props);
1864
- this.rootHostedZone = this.createRootHostedZone();
1865
- this.childHostedZone = this.createChildHostedZone();
1866
- this.rootWildcardCertificate = this.createRootWildcardCertificate();
1867
- }
1868
- /**
1869
- * Validates that config required for the Global stack is present.
1870
- */
1871
- validateConfig(props) {
1872
- const { config } = props;
1873
- if (!config) {
1874
- throw new Error("Config is required");
1875
- }
1876
- if (!config.zoneName) {
1877
- throw new Error("Zone name is required to import the root zone");
1878
- }
1879
- if (!config.hostedZoneId) {
1880
- throw new Error("Hosted zone ID is required to import the root zone");
1881
- }
1882
- }
1883
- /**
1884
- * Creates the root hosted zone (imported via attributes from config).
1885
- * Override to customize or create the zone.
1886
- */
1887
- createRootHostedZone() {
1888
- return _OpenHiGlobalService.rootHostedZoneFromConstruct(this, {
1889
- zoneName: this.config.zoneName,
1890
- hostedZoneId: this.config.hostedZoneId
1891
- });
1892
- }
1893
- /**
1894
- * Creates the optional child hosted zone (e.g. branch subdomain).
1895
- * Override to create a child zone when config provides childHostedZoneAttributes.
1896
- * If you create a ChildHostedZone, also create a DiscoverableStringParameter
1897
- * with ChildHostedZone.SSM_PARAM_NAME and the zone's hostedZoneId.
1898
- */
1899
- createChildHostedZone() {
1900
- return void 0;
1901
- }
1902
- /**
1903
- * Creates the root wildcard certificate. On main branch, creates a new cert
1904
- * with DNS validation; otherwise imports from SSM.
1905
- * Override to customize certificate creation.
1906
- */
1907
- createRootWildcardCertificate() {
1908
- if (this.branchName === "main") {
1909
- return new RootWildcardCertificate(this, {
1910
- domainName: `*.${this.rootHostedZone.zoneName}`,
1911
- subjectAlternativeNames: [this.rootHostedZone.zoneName],
1912
- validation: import_aws_certificatemanager2.CertificateValidation.fromDns(this.rootHostedZone)
1913
- });
1914
- }
1915
- return _OpenHiGlobalService.rootWildcardCertificateFromConstruct(this);
1916
- }
1917
- };
1918
- _OpenHiGlobalService.SERVICE_TYPE = "global";
1919
- var OpenHiGlobalService = _OpenHiGlobalService;
1920
-
1921
1923
  // src/services/open-hi-rest-api-service.ts
1922
1924
  var import_config5 = __toESM(require_lib());
1923
1925
  var import_aws_apigatewayv22 = require("aws-cdk-lib/aws-apigatewayv2");