@openhi/constructs 0.0.104 → 0.0.105
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/README.md +14 -0
- package/lib/chunk-2PM2NGXI.mjs +31 -0
- package/lib/chunk-2PM2NGXI.mjs.map +1 -0
- package/lib/chunk-36YCDLLA.mjs +1258 -0
- package/lib/chunk-36YCDLLA.mjs.map +1 -0
- package/lib/chunk-BXEG7IOZ.mjs +108 -0
- package/lib/chunk-BXEG7IOZ.mjs.map +1 -0
- package/lib/chunk-WNUH2WDZ.mjs +45 -0
- package/lib/chunk-WNUH2WDZ.mjs.map +1 -0
- package/lib/events-CVA3_eEB.d.mts +23 -0
- package/lib/events-CVA3_eEB.d.ts +23 -0
- package/lib/index.d.mts +92 -21
- package/lib/index.d.ts +112 -22
- package/lib/index.js +214 -72
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +190 -74
- package/lib/index.mjs.map +1 -1
- package/lib/post-confirmation.handler.js +50 -904
- package/lib/post-confirmation.handler.js.map +1 -1
- package/lib/post-confirmation.handler.mjs +36 -111
- package/lib/post-confirmation.handler.mjs.map +1 -1
- package/lib/pre-token-generation.handler.js +62 -27
- package/lib/pre-token-generation.handler.js.map +1 -1
- package/lib/pre-token-generation.handler.mjs +22 -31
- package/lib/pre-token-generation.handler.mjs.map +1 -1
- package/lib/provision-default-workspace.handler.d.mts +13 -0
- package/lib/provision-default-workspace.handler.d.ts +13 -0
- package/lib/{chunk-MLTYFMSE.mjs → provision-default-workspace.handler.js} +346 -26
- package/lib/provision-default-workspace.handler.js.map +1 -0
- package/lib/provision-default-workspace.handler.mjs +173 -0
- package/lib/provision-default-workspace.handler.mjs.map +1 -0
- package/lib/rest-api-lambda.handler.mjs +40 -546
- package/lib/rest-api-lambda.handler.mjs.map +1 -1
- package/package.json +3 -3
- package/lib/chunk-MLTYFMSE.mjs.map +0 -1
package/lib/index.mjs
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PROVISION_DEFAULT_WORKSPACE_DETAIL_TYPE,
|
|
3
|
+
USER_ONBOARDING_EVENT_SOURCE,
|
|
4
|
+
buildProvisionDefaultWorkspaceRequestedDetail
|
|
5
|
+
} from "./chunk-2PM2NGXI.mjs";
|
|
1
6
|
import {
|
|
2
7
|
DATA_STORE_CHANGE_DETAIL_MAX_UTF8_BYTES,
|
|
3
8
|
DATA_STORE_CHANGE_DETAIL_TYPE,
|
|
@@ -711,14 +716,13 @@ import { Runtime as Runtime2 } from "aws-cdk-lib/aws-lambda";
|
|
|
711
716
|
import { NodejsFunction as NodejsFunction2 } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
712
717
|
import { Construct as Construct2 } from "constructs";
|
|
713
718
|
var HANDLER_NAME2 = "post-confirmation.handler.js";
|
|
714
|
-
|
|
719
|
+
var resolveHandlerEntry2 = (dirname) => {
|
|
715
720
|
const sameDir = path2.join(dirname, HANDLER_NAME2);
|
|
716
721
|
if (fs2.existsSync(sameDir)) {
|
|
717
722
|
return sameDir;
|
|
718
723
|
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
724
|
+
return path2.join(dirname, "..", "..", "..", "lib", HANDLER_NAME2);
|
|
725
|
+
};
|
|
722
726
|
var PostConfirmationLambda = class extends Construct2 {
|
|
723
727
|
constructor(scope, props) {
|
|
724
728
|
super(scope, "post-confirmation-lambda");
|
|
@@ -727,7 +731,7 @@ var PostConfirmationLambda = class extends Construct2 {
|
|
|
727
731
|
runtime: Runtime2.NODEJS_LATEST,
|
|
728
732
|
memorySize: 1024,
|
|
729
733
|
environment: {
|
|
730
|
-
|
|
734
|
+
CONTROL_EVENT_BUS_NAME: props.controlEventBusName
|
|
731
735
|
}
|
|
732
736
|
});
|
|
733
737
|
}
|
|
@@ -983,6 +987,28 @@ var OpsEventBus = class _OpsEventBus extends EventBus2 {
|
|
|
983
987
|
}
|
|
984
988
|
};
|
|
985
989
|
|
|
990
|
+
// src/components/event-bridge/control-event-bus.ts
|
|
991
|
+
import { EventBus as EventBus3 } from "aws-cdk-lib/aws-events";
|
|
992
|
+
var ControlEventBus = class _ControlEventBus extends EventBus3 {
|
|
993
|
+
/*****************************************************************************
|
|
994
|
+
*
|
|
995
|
+
* Return a name for this EventBus based on the stack environment hash. This
|
|
996
|
+
* name is common across all stacks since it's using the environment hash in
|
|
997
|
+
* its name.
|
|
998
|
+
*
|
|
999
|
+
****************************************************************************/
|
|
1000
|
+
static getEventBusName(scope) {
|
|
1001
|
+
const stack = OpenHiService.of(scope);
|
|
1002
|
+
return `controlv1${stack.branchHash}`;
|
|
1003
|
+
}
|
|
1004
|
+
constructor(scope, props) {
|
|
1005
|
+
super(scope, "control-event-bus-v1", {
|
|
1006
|
+
...props,
|
|
1007
|
+
eventBusName: _ControlEventBus.getEventBusName(scope)
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
|
|
986
1012
|
// src/components/postgres/data-store-postgres-replica.ts
|
|
987
1013
|
import fs5 from "fs";
|
|
988
1014
|
import path5 from "path";
|
|
@@ -1244,7 +1270,7 @@ import {
|
|
|
1244
1270
|
UserPoolDomain as UserPoolDomain2,
|
|
1245
1271
|
UserPoolOperation
|
|
1246
1272
|
} from "aws-cdk-lib/aws-cognito";
|
|
1247
|
-
import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
1273
|
+
import { Effect as Effect2, PolicyStatement as PolicyStatement2 } from "aws-cdk-lib/aws-iam";
|
|
1248
1274
|
import { Key as Key2 } from "aws-cdk-lib/aws-kms";
|
|
1249
1275
|
import { Stack as Stack3 } from "aws-cdk-lib/core";
|
|
1250
1276
|
|
|
@@ -1257,7 +1283,7 @@ import {
|
|
|
1257
1283
|
Certificate as Certificate2,
|
|
1258
1284
|
CertificateValidation
|
|
1259
1285
|
} from "aws-cdk-lib/aws-certificatemanager";
|
|
1260
|
-
import { EventBus as
|
|
1286
|
+
import { EventBus as EventBus4 } from "aws-cdk-lib/aws-events";
|
|
1261
1287
|
import {
|
|
1262
1288
|
HostedZone as HostedZone2
|
|
1263
1289
|
} from "aws-cdk-lib/aws-route53";
|
|
@@ -1300,7 +1326,7 @@ var _OpenHiGlobalService = class _OpenHiGlobalService extends OpenHiService {
|
|
|
1300
1326
|
* Returns the data event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
|
|
1301
1327
|
*/
|
|
1302
1328
|
static dataEventBusFromConstruct(scope) {
|
|
1303
|
-
return
|
|
1329
|
+
return EventBus4.fromEventBusName(
|
|
1304
1330
|
scope,
|
|
1305
1331
|
"data-event-bus",
|
|
1306
1332
|
DataEventBus.getEventBusName(scope)
|
|
@@ -1310,12 +1336,22 @@ var _OpenHiGlobalService = class _OpenHiGlobalService extends OpenHiService {
|
|
|
1310
1336
|
* Returns the ops event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
|
|
1311
1337
|
*/
|
|
1312
1338
|
static opsEventBusFromConstruct(scope) {
|
|
1313
|
-
return
|
|
1339
|
+
return EventBus4.fromEventBusName(
|
|
1314
1340
|
scope,
|
|
1315
1341
|
"ops-event-bus",
|
|
1316
1342
|
OpsEventBus.getEventBusName(scope)
|
|
1317
1343
|
);
|
|
1318
1344
|
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Returns the control-plane event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
|
|
1347
|
+
*/
|
|
1348
|
+
static controlEventBusFromConstruct(scope) {
|
|
1349
|
+
return EventBus4.fromEventBusName(
|
|
1350
|
+
scope,
|
|
1351
|
+
"control-event-bus",
|
|
1352
|
+
ControlEventBus.getEventBusName(scope)
|
|
1353
|
+
);
|
|
1354
|
+
}
|
|
1319
1355
|
get serviceType() {
|
|
1320
1356
|
return _OpenHiGlobalService.SERVICE_TYPE;
|
|
1321
1357
|
}
|
|
@@ -1328,6 +1364,7 @@ var _OpenHiGlobalService = class _OpenHiGlobalService extends OpenHiService {
|
|
|
1328
1364
|
this.rootWildcardCertificate = this.createRootWildcardCertificate();
|
|
1329
1365
|
this.dataEventBus = this.createDataEventBus();
|
|
1330
1366
|
this.opsEventBus = this.createOpsEventBus();
|
|
1367
|
+
this.controlEventBus = this.createControlEventBus();
|
|
1331
1368
|
}
|
|
1332
1369
|
/**
|
|
1333
1370
|
* Validates that config required for the Global stack is present.
|
|
@@ -1392,6 +1429,13 @@ var _OpenHiGlobalService = class _OpenHiGlobalService extends OpenHiService {
|
|
|
1392
1429
|
createOpsEventBus() {
|
|
1393
1430
|
return new OpsEventBus(this);
|
|
1394
1431
|
}
|
|
1432
|
+
/**
|
|
1433
|
+
* Creates the control-plane event bus.
|
|
1434
|
+
* Override to customize.
|
|
1435
|
+
*/
|
|
1436
|
+
createControlEventBus() {
|
|
1437
|
+
return new ControlEventBus(this);
|
|
1438
|
+
}
|
|
1395
1439
|
};
|
|
1396
1440
|
_OpenHiGlobalService.SERVICE_TYPE = "global";
|
|
1397
1441
|
var OpenHiGlobalService = _OpenHiGlobalService;
|
|
@@ -1458,6 +1502,75 @@ var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
|
|
|
1458
1502
|
_OpenHiDataService.SERVICE_TYPE = "data";
|
|
1459
1503
|
var OpenHiDataService = _OpenHiDataService;
|
|
1460
1504
|
|
|
1505
|
+
// src/workflows/control-plane/user-onboarding/provision-default-workspace-lambda.ts
|
|
1506
|
+
import fs6 from "fs";
|
|
1507
|
+
import path6 from "path";
|
|
1508
|
+
import { Duration as Duration6 } from "aws-cdk-lib";
|
|
1509
|
+
import { Rule } from "aws-cdk-lib/aws-events";
|
|
1510
|
+
import { LambdaFunction } from "aws-cdk-lib/aws-events-targets";
|
|
1511
|
+
import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
1512
|
+
import { Runtime as Runtime6 } from "aws-cdk-lib/aws-lambda";
|
|
1513
|
+
import { NodejsFunction as NodejsFunction6 } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
1514
|
+
import { Construct as Construct8 } from "constructs";
|
|
1515
|
+
var HANDLER_NAME6 = "provision-default-workspace.handler.js";
|
|
1516
|
+
function resolveHandlerEntry6(dirname) {
|
|
1517
|
+
const sameDir = path6.join(dirname, HANDLER_NAME6);
|
|
1518
|
+
if (fs6.existsSync(sameDir)) {
|
|
1519
|
+
return sameDir;
|
|
1520
|
+
}
|
|
1521
|
+
return path6.join(dirname, "..", "..", "..", "..", "lib", HANDLER_NAME6);
|
|
1522
|
+
}
|
|
1523
|
+
var ProvisionDefaultWorkspaceLambda = class extends Construct8 {
|
|
1524
|
+
constructor(scope, props) {
|
|
1525
|
+
super(scope, "provision-default-workspace-lambda");
|
|
1526
|
+
this.lambda = new NodejsFunction6(this, "handler", {
|
|
1527
|
+
entry: resolveHandlerEntry6(__dirname),
|
|
1528
|
+
runtime: Runtime6.NODEJS_LATEST,
|
|
1529
|
+
memorySize: 1024,
|
|
1530
|
+
environment: {
|
|
1531
|
+
DYNAMO_TABLE_NAME: props.dataStoreTable.tableName
|
|
1532
|
+
}
|
|
1533
|
+
});
|
|
1534
|
+
props.dataStoreTable.grant(
|
|
1535
|
+
this.lambda,
|
|
1536
|
+
"dynamodb:PutItem",
|
|
1537
|
+
"dynamodb:UpdateItem"
|
|
1538
|
+
);
|
|
1539
|
+
this.lambda.addToRolePolicy(
|
|
1540
|
+
new PolicyStatement({
|
|
1541
|
+
effect: Effect.ALLOW,
|
|
1542
|
+
actions: ["dynamodb:Query"],
|
|
1543
|
+
resources: [`${props.dataStoreTable.tableArn}/index/*`]
|
|
1544
|
+
})
|
|
1545
|
+
);
|
|
1546
|
+
this.rule = new Rule(this, "rule", {
|
|
1547
|
+
eventBus: props.controlEventBus,
|
|
1548
|
+
eventPattern: {
|
|
1549
|
+
source: [USER_ONBOARDING_EVENT_SOURCE],
|
|
1550
|
+
detailType: [PROVISION_DEFAULT_WORKSPACE_DETAIL_TYPE]
|
|
1551
|
+
},
|
|
1552
|
+
targets: [
|
|
1553
|
+
new LambdaFunction(this.lambda, {
|
|
1554
|
+
retryAttempts: 2,
|
|
1555
|
+
maxEventAge: Duration6.hours(2)
|
|
1556
|
+
})
|
|
1557
|
+
]
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
};
|
|
1561
|
+
|
|
1562
|
+
// src/workflows/control-plane/user-onboarding/user-onboarding-workflow.ts
|
|
1563
|
+
import { Construct as Construct9 } from "constructs";
|
|
1564
|
+
var UserOnboardingWorkflow = class extends Construct9 {
|
|
1565
|
+
constructor(scope, props) {
|
|
1566
|
+
super(scope, "user-onboarding-workflow");
|
|
1567
|
+
this.provisionDefaultWorkspace = new ProvisionDefaultWorkspaceLambda(this, {
|
|
1568
|
+
dataStoreTable: props.dataStoreTable,
|
|
1569
|
+
controlEventBus: props.controlEventBus
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
};
|
|
1573
|
+
|
|
1461
1574
|
// src/services/open-hi-auth-service.ts
|
|
1462
1575
|
var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
1463
1576
|
constructor(ohEnv, props = {}) {
|
|
@@ -1469,11 +1582,13 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
|
1469
1582
|
* would collide.
|
|
1470
1583
|
*/
|
|
1471
1584
|
this._dataStoreTable = null;
|
|
1585
|
+
this._controlEventBus = null;
|
|
1472
1586
|
this.props = props;
|
|
1473
1587
|
this.userPoolKmsKey = this.createUserPoolKmsKey();
|
|
1474
1588
|
this.preTokenGenerationLambda = this.createPreTokenGenerationLambda();
|
|
1475
1589
|
this.postAuthenticationLambda = this.createPostAuthenticationLambda();
|
|
1476
1590
|
this.postConfirmationLambda = this.createPostConfirmationLambda();
|
|
1591
|
+
this.userOnboardingWorkflow = this.createUserOnboardingWorkflow();
|
|
1477
1592
|
this.userPool = this.createUserPool();
|
|
1478
1593
|
this.grantPreTokenGenerationPermissions();
|
|
1479
1594
|
this.grantPostAuthenticationPermissions();
|
|
@@ -1590,23 +1705,33 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
|
1590
1705
|
}
|
|
1591
1706
|
/**
|
|
1592
1707
|
* Creates the Post Confirmation Lambda (Cognito trigger). On sign-up
|
|
1593
|
-
* confirmation,
|
|
1594
|
-
*
|
|
1595
|
-
* carrying the Cognito `sub` and current tenant/workspace pointers
|
|
1596
|
-
* (ADR 2026-03-17-01 invariants).
|
|
1708
|
+
* confirmation, publishes a control-plane workflow event; provisioning lives
|
|
1709
|
+
* behind EventBridge.
|
|
1597
1710
|
*/
|
|
1598
1711
|
createPostConfirmationLambda() {
|
|
1599
1712
|
const construct = new PostConfirmationLambda(this, {
|
|
1600
|
-
|
|
1713
|
+
controlEventBusName: this.controlEventBus().eventBusName
|
|
1601
1714
|
});
|
|
1602
1715
|
return construct.lambda;
|
|
1603
1716
|
}
|
|
1717
|
+
createUserOnboardingWorkflow() {
|
|
1718
|
+
return new UserOnboardingWorkflow(this, {
|
|
1719
|
+
controlEventBus: this.controlEventBus(),
|
|
1720
|
+
dataStoreTable: this.dataStoreTable()
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1604
1723
|
dataStoreTable() {
|
|
1605
1724
|
if (this._dataStoreTable === null) {
|
|
1606
1725
|
this._dataStoreTable = OpenHiDataService.dynamoDbDataStoreFromConstruct(this);
|
|
1607
1726
|
}
|
|
1608
1727
|
return this._dataStoreTable;
|
|
1609
1728
|
}
|
|
1729
|
+
controlEventBus() {
|
|
1730
|
+
if (this._controlEventBus === null) {
|
|
1731
|
+
this._controlEventBus = OpenHiGlobalService.controlEventBusFromConstruct(this);
|
|
1732
|
+
}
|
|
1733
|
+
return this._controlEventBus;
|
|
1734
|
+
}
|
|
1610
1735
|
/**
|
|
1611
1736
|
* Creates the Cognito User Pool and exports its ID to SSM.
|
|
1612
1737
|
* Look up via {@link OpenHiAuthService.userPoolFromConstruct}.
|
|
@@ -1651,8 +1776,8 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
|
1651
1776
|
const dynamoActions = ["dynamodb:GetItem", "dynamodb:Query"];
|
|
1652
1777
|
dataStoreTable.grant(this.preTokenGenerationLambda, ...dynamoActions);
|
|
1653
1778
|
this.preTokenGenerationLambda.addToRolePolicy(
|
|
1654
|
-
new
|
|
1655
|
-
effect:
|
|
1779
|
+
new PolicyStatement2({
|
|
1780
|
+
effect: Effect2.ALLOW,
|
|
1656
1781
|
actions: [...dynamoActions],
|
|
1657
1782
|
resources: [`${dataStoreTable.tableArn}/index/*`]
|
|
1658
1783
|
})
|
|
@@ -1673,7 +1798,7 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
|
1673
1798
|
*/
|
|
1674
1799
|
grantPostAuthenticationPermissions() {
|
|
1675
1800
|
this.postAuthenticationLambda.addToRolePolicy(
|
|
1676
|
-
new
|
|
1801
|
+
new PolicyStatement2({
|
|
1677
1802
|
actions: ["cognito-idp:AdminUserGlobalSignOut"],
|
|
1678
1803
|
resources: [
|
|
1679
1804
|
Stack3.of(this).formatArn({
|
|
@@ -1686,26 +1811,11 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
|
1686
1811
|
);
|
|
1687
1812
|
}
|
|
1688
1813
|
/**
|
|
1689
|
-
* Grants the Post Confirmation Lambda
|
|
1690
|
-
*
|
|
1691
|
-
* Memberships, RoleAssignment, and User records on sign-up confirmation.
|
|
1814
|
+
* Grants the Post Confirmation Lambda publish-only access to the
|
|
1815
|
+
* control-plane event bus. Workflow Lambdas own DynamoDB writes.
|
|
1692
1816
|
*/
|
|
1693
1817
|
grantPostConfirmationPermissions() {
|
|
1694
|
-
|
|
1695
|
-
const dynamoActions = [
|
|
1696
|
-
"dynamodb:PutItem",
|
|
1697
|
-
"dynamodb:UpdateItem",
|
|
1698
|
-
"dynamodb:BatchWriteItem",
|
|
1699
|
-
"dynamodb:DescribeTable"
|
|
1700
|
-
];
|
|
1701
|
-
dataStoreTable.grant(this.postConfirmationLambda, ...dynamoActions);
|
|
1702
|
-
this.postConfirmationLambda.addToRolePolicy(
|
|
1703
|
-
new PolicyStatement({
|
|
1704
|
-
effect: Effect.ALLOW,
|
|
1705
|
-
actions: [...dynamoActions],
|
|
1706
|
-
resources: [`${dataStoreTable.tableArn}/index/*`]
|
|
1707
|
-
})
|
|
1708
|
-
);
|
|
1818
|
+
this.controlEventBus().grantPutEventsTo(this.postConfirmationLambda);
|
|
1709
1819
|
}
|
|
1710
1820
|
/**
|
|
1711
1821
|
* Creates the User Pool Client and exports its ID to SSM (AUTH service type).
|
|
@@ -1784,62 +1894,62 @@ import {
|
|
|
1784
1894
|
} from "aws-cdk-lib/aws-apigatewayv2";
|
|
1785
1895
|
import { HttpUserPoolAuthorizer } from "aws-cdk-lib/aws-apigatewayv2-authorizers";
|
|
1786
1896
|
import { HttpLambdaIntegration } from "aws-cdk-lib/aws-apigatewayv2-integrations";
|
|
1787
|
-
import { Effect as
|
|
1897
|
+
import { Effect as Effect3, PolicyStatement as PolicyStatement3 } from "aws-cdk-lib/aws-iam";
|
|
1788
1898
|
import {
|
|
1789
1899
|
ARecord,
|
|
1790
1900
|
HostedZone as HostedZone3,
|
|
1791
1901
|
RecordTarget
|
|
1792
1902
|
} from "aws-cdk-lib/aws-route53";
|
|
1793
1903
|
import { ApiGatewayv2DomainProperties } from "aws-cdk-lib/aws-route53-targets";
|
|
1794
|
-
import { Duration as
|
|
1904
|
+
import { Duration as Duration7 } from "aws-cdk-lib/core";
|
|
1795
1905
|
|
|
1796
1906
|
// src/data/lambda/cors-options-lambda.ts
|
|
1797
|
-
import
|
|
1798
|
-
import
|
|
1799
|
-
import { Runtime as
|
|
1800
|
-
import { NodejsFunction as
|
|
1801
|
-
import { Construct as
|
|
1802
|
-
var
|
|
1803
|
-
function
|
|
1804
|
-
const sameDir =
|
|
1805
|
-
if (
|
|
1907
|
+
import fs7 from "fs";
|
|
1908
|
+
import path7 from "path";
|
|
1909
|
+
import { Runtime as Runtime7 } from "aws-cdk-lib/aws-lambda";
|
|
1910
|
+
import { NodejsFunction as NodejsFunction7 } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
1911
|
+
import { Construct as Construct10 } from "constructs";
|
|
1912
|
+
var HANDLER_NAME7 = "cors-options-lambda.handler.js";
|
|
1913
|
+
function resolveHandlerEntry7(dirname) {
|
|
1914
|
+
const sameDir = path7.join(dirname, HANDLER_NAME7);
|
|
1915
|
+
if (fs7.existsSync(sameDir)) {
|
|
1806
1916
|
return sameDir;
|
|
1807
1917
|
}
|
|
1808
|
-
const fromLib =
|
|
1918
|
+
const fromLib = path7.join(dirname, "..", "..", "..", "lib", HANDLER_NAME7);
|
|
1809
1919
|
return fromLib;
|
|
1810
1920
|
}
|
|
1811
|
-
var CorsOptionsLambda = class extends
|
|
1921
|
+
var CorsOptionsLambda = class extends Construct10 {
|
|
1812
1922
|
constructor(scope, id = "cors-options-lambda") {
|
|
1813
1923
|
super(scope, id);
|
|
1814
|
-
this.lambda = new
|
|
1815
|
-
entry:
|
|
1816
|
-
runtime:
|
|
1924
|
+
this.lambda = new NodejsFunction7(this, "handler", {
|
|
1925
|
+
entry: resolveHandlerEntry7(__dirname),
|
|
1926
|
+
runtime: Runtime7.NODEJS_LATEST,
|
|
1817
1927
|
memorySize: 128
|
|
1818
1928
|
});
|
|
1819
1929
|
}
|
|
1820
1930
|
};
|
|
1821
1931
|
|
|
1822
1932
|
// src/data/lambda/rest-api-lambda.ts
|
|
1823
|
-
import
|
|
1824
|
-
import
|
|
1825
|
-
import { Runtime as
|
|
1826
|
-
import { NodejsFunction as
|
|
1827
|
-
import { Construct as
|
|
1828
|
-
var
|
|
1829
|
-
function
|
|
1830
|
-
const sameDir =
|
|
1831
|
-
if (
|
|
1933
|
+
import fs8 from "fs";
|
|
1934
|
+
import path8 from "path";
|
|
1935
|
+
import { Runtime as Runtime8 } from "aws-cdk-lib/aws-lambda";
|
|
1936
|
+
import { NodejsFunction as NodejsFunction8 } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
1937
|
+
import { Construct as Construct11 } from "constructs";
|
|
1938
|
+
var HANDLER_NAME8 = "rest-api-lambda.handler.js";
|
|
1939
|
+
function resolveHandlerEntry8(dirname) {
|
|
1940
|
+
const sameDir = path8.join(dirname, HANDLER_NAME8);
|
|
1941
|
+
if (fs8.existsSync(sameDir)) {
|
|
1832
1942
|
return sameDir;
|
|
1833
1943
|
}
|
|
1834
|
-
const fromLib =
|
|
1944
|
+
const fromLib = path8.join(dirname, "..", "..", "..", "lib", HANDLER_NAME8);
|
|
1835
1945
|
return fromLib;
|
|
1836
1946
|
}
|
|
1837
|
-
var RestApiLambda = class extends
|
|
1947
|
+
var RestApiLambda = class extends Construct11 {
|
|
1838
1948
|
constructor(scope, props) {
|
|
1839
1949
|
super(scope, "rest-api-lambda");
|
|
1840
|
-
this.lambda = new
|
|
1841
|
-
entry:
|
|
1842
|
-
runtime:
|
|
1950
|
+
this.lambda = new NodejsFunction8(this, "handler", {
|
|
1951
|
+
entry: resolveHandlerEntry8(__dirname),
|
|
1952
|
+
runtime: Runtime8.NODEJS_LATEST,
|
|
1843
1953
|
memorySize: 1024,
|
|
1844
1954
|
environment: {
|
|
1845
1955
|
DYNAMO_TABLE_NAME: props.dynamoTableName,
|
|
@@ -1981,8 +2091,8 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
1981
2091
|
postgresSchema
|
|
1982
2092
|
});
|
|
1983
2093
|
lambda.addToRolePolicy(
|
|
1984
|
-
new
|
|
1985
|
-
effect:
|
|
2094
|
+
new PolicyStatement3({
|
|
2095
|
+
effect: Effect3.ALLOW,
|
|
1986
2096
|
actions: [
|
|
1987
2097
|
"rds-data:ExecuteStatement",
|
|
1988
2098
|
"rds-data:BatchExecuteStatement"
|
|
@@ -1991,8 +2101,8 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
1991
2101
|
})
|
|
1992
2102
|
);
|
|
1993
2103
|
lambda.addToRolePolicy(
|
|
1994
|
-
new
|
|
1995
|
-
effect:
|
|
2104
|
+
new PolicyStatement3({
|
|
2105
|
+
effect: Effect3.ALLOW,
|
|
1996
2106
|
actions: ["secretsmanager:GetSecretValue"],
|
|
1997
2107
|
resources: [postgresSecretArn]
|
|
1998
2108
|
})
|
|
@@ -2010,15 +2120,15 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
2010
2120
|
];
|
|
2011
2121
|
dataStoreTable.grant(lambda, ...dynamoActions);
|
|
2012
2122
|
lambda.addToRolePolicy(
|
|
2013
|
-
new
|
|
2014
|
-
effect:
|
|
2123
|
+
new PolicyStatement3({
|
|
2124
|
+
effect: Effect3.ALLOW,
|
|
2015
2125
|
actions: [...dynamoActions],
|
|
2016
2126
|
resources: [`${dataStoreTable.tableArn}/index/*`]
|
|
2017
2127
|
})
|
|
2018
2128
|
);
|
|
2019
2129
|
lambda.addToRolePolicy(
|
|
2020
|
-
new
|
|
2021
|
-
effect:
|
|
2130
|
+
new PolicyStatement3({
|
|
2131
|
+
effect: Effect3.ALLOW,
|
|
2022
2132
|
actions: [
|
|
2023
2133
|
"ssm:GetParameter",
|
|
2024
2134
|
"ssm:GetParameters",
|
|
@@ -2104,7 +2214,7 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
2104
2214
|
"Authorization"
|
|
2105
2215
|
],
|
|
2106
2216
|
allowCredentials: cors.allowCredentials ?? true,
|
|
2107
|
-
maxAge: cors.maxAge ??
|
|
2217
|
+
maxAge: cors.maxAge ?? Duration7.days(1),
|
|
2108
2218
|
...cors.exposeHeaders !== void 0 && {
|
|
2109
2219
|
exposeHeaders: cors.exposeHeaders
|
|
2110
2220
|
}
|
|
@@ -2175,6 +2285,7 @@ export {
|
|
|
2175
2285
|
CognitoUserPoolClient,
|
|
2176
2286
|
CognitoUserPoolDomain,
|
|
2177
2287
|
CognitoUserPoolKmsKey,
|
|
2288
|
+
ControlEventBus,
|
|
2178
2289
|
DATA_STORE_CHANGE_DETAIL_MAX_UTF8_BYTES,
|
|
2179
2290
|
DATA_STORE_CHANGE_DETAIL_TYPE,
|
|
2180
2291
|
DATA_STORE_CHANGE_EVENT_SOURCE,
|
|
@@ -2196,9 +2307,11 @@ export {
|
|
|
2196
2307
|
POSTGRES_REPLICA_CLUSTER_ARN_SSM_NAME,
|
|
2197
2308
|
POSTGRES_REPLICA_DATABASE_NAME_SSM_NAME,
|
|
2198
2309
|
POSTGRES_REPLICA_SECRET_ARN_SSM_NAME,
|
|
2310
|
+
PROVISION_DEFAULT_WORKSPACE_DETAIL_TYPE,
|
|
2199
2311
|
PostAuthenticationLambda,
|
|
2200
2312
|
PostConfirmationLambda,
|
|
2201
2313
|
PreTokenGenerationLambda,
|
|
2314
|
+
ProvisionDefaultWorkspaceLambda,
|
|
2202
2315
|
REST_API_BASE_URL_SSM_NAME,
|
|
2203
2316
|
RootGraphqlApi,
|
|
2204
2317
|
RootHostedZone,
|
|
@@ -2206,7 +2319,10 @@ export {
|
|
|
2206
2319
|
RootWildcardCertificate,
|
|
2207
2320
|
STATIC_HOSTING_SERVICE_TYPE,
|
|
2208
2321
|
StaticHosting,
|
|
2322
|
+
USER_ONBOARDING_EVENT_SOURCE,
|
|
2323
|
+
UserOnboardingWorkflow,
|
|
2209
2324
|
buildFhirCurrentResourceChangeDetail,
|
|
2325
|
+
buildProvisionDefaultWorkspaceRequestedDetail,
|
|
2210
2326
|
getDynamoDbDataStoreTableName,
|
|
2211
2327
|
getPostgresReplicaSchemaName
|
|
2212
2328
|
};
|