@mettlecast/domain-cdk-packer 0.2.5 → 0.2.8
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/DomainStack.d.ts +6 -0
- package/dist/DomainStack.js +8 -6
- package/dist/pack-domain.d.ts +7 -0
- package/dist/pack-domain.js +4 -1
- package/package.json +1 -1
package/dist/DomainStack.d.ts
CHANGED
|
@@ -11,18 +11,24 @@ export interface DomainStackProps extends cdk.StackProps {
|
|
|
11
11
|
registry: DomainRegistry;
|
|
12
12
|
/** ARN of the EventBridge event bus for event subscribers. */
|
|
13
13
|
eventBusArn: string;
|
|
14
|
+
/** EventBridge event bus name (recommended when ARN is dynamic reference). */
|
|
15
|
+
eventBusName?: string;
|
|
14
16
|
/** Database connection URL passed from DataStorageStack. */
|
|
15
17
|
databaseUrl?: string;
|
|
16
18
|
/** ARN of the RDS secret for DB credentials — added to Lambda env as DB_SECRET_ARN. */
|
|
17
19
|
dbSecretArn?: string;
|
|
18
20
|
/** Cognito User Pool ARN — when provided, HTTP API routes are JWT-protected. */
|
|
19
21
|
userPoolArn?: string;
|
|
22
|
+
/** Cognito User Pool ID — preferred over parsing userPoolArn for JWT authorizer issuer. */
|
|
23
|
+
userPoolId?: string;
|
|
20
24
|
/** Cognito User Pool Client ID — required alongside userPoolArn for JWT authorizer. */
|
|
21
25
|
userPoolClientId?: string;
|
|
22
26
|
/** VPC to place domain Lambdas in — required for Aurora connectivity. */
|
|
23
27
|
vpc?: ec2.IVpc;
|
|
24
28
|
/** Security group for domain Lambdas — must allow egress to Aurora SG. */
|
|
25
29
|
lambdaSg?: ec2.ISecurityGroup;
|
|
30
|
+
/** Shared HTTP API Gateway — when provided, domain routes are added here instead of creating a separate API. */
|
|
31
|
+
httpApi?: apigwv2.HttpApi;
|
|
26
32
|
/** Enable CMK encryption for DynamoDB, S3, SQS. */
|
|
27
33
|
enableCmk?: boolean;
|
|
28
34
|
/** Enable WAF WebACL on the domain API Gateway. */
|
package/dist/DomainStack.js
CHANGED
|
@@ -35,11 +35,11 @@ export class DomainStack extends cdk.Stack {
|
|
|
35
35
|
*/
|
|
36
36
|
constructor(scope, id, props) {
|
|
37
37
|
super(scope, id, props);
|
|
38
|
-
const { registry, eventBusArn, databaseUrl, dbSecretArn, userPoolArn, userPoolClientId, vpc, lambdaSg, enableCmk, enableWaf, enableAlarms, alarmSnsTopicArn, enableCanaryDeploy, reservedConcurrency, logRetentionDays, corsAllowedOrigins, allowCredentials } = props;
|
|
38
|
+
const { registry, eventBusArn, eventBusName, databaseUrl, dbSecretArn, userPoolArn, userPoolId, userPoolClientId, vpc, lambdaSg, httpApi, enableCmk, enableWaf, enableAlarms, alarmSnsTopicArn, enableCanaryDeploy, reservedConcurrency, logRetentionDays, corsAllowedOrigins, allowCredentials } = props;
|
|
39
39
|
const domainId = registry.domain.id;
|
|
40
40
|
const vpcProps = vpc ? { vpc, securityGroups: lambdaSg ? [lambdaSg] : undefined } : {};
|
|
41
41
|
const allowedOrigins = corsAllowedOrigins ?? ['*'];
|
|
42
|
-
this.httpApi = new apigwv2.HttpApi(this, 'HttpApi', {
|
|
42
|
+
this.httpApi = httpApi ?? new apigwv2.HttpApi(this, 'HttpApi', {
|
|
43
43
|
apiName: `${domainId}-api`,
|
|
44
44
|
corsPreflight: {
|
|
45
45
|
allowHeaders: ['Content-Type', 'Authorization'],
|
|
@@ -50,10 +50,10 @@ export class DomainStack extends cdk.Stack {
|
|
|
50
50
|
});
|
|
51
51
|
// Wire Cognito JWT authorizer when user pool is provided
|
|
52
52
|
let jwtAuthorizer;
|
|
53
|
-
if (userPoolArn && userPoolClientId) {
|
|
53
|
+
if ((userPoolId || userPoolArn) && userPoolClientId) {
|
|
54
54
|
const region = cdk.Stack.of(this).region;
|
|
55
|
-
const
|
|
56
|
-
jwtAuthorizer = new apigwv2Authorizers.HttpJwtAuthorizer('CognitoAuthorizer', `https://cognito-idp.${region}.amazonaws.com/${
|
|
55
|
+
const resolvedUserPoolId = userPoolId ?? cdk.Fn.select(1, cdk.Fn.split('/', userPoolArn));
|
|
56
|
+
jwtAuthorizer = new apigwv2Authorizers.HttpJwtAuthorizer('CognitoAuthorizer', `https://cognito-idp.${region}.amazonaws.com/${resolvedUserPoolId}`, {
|
|
57
57
|
jwtAudience: [userPoolClientId],
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -68,7 +68,9 @@ export class DomainStack extends cdk.Stack {
|
|
|
68
68
|
cmkKey = cmk.key;
|
|
69
69
|
}
|
|
70
70
|
const iamBuilder = new IamPolicyBuilder();
|
|
71
|
-
const eventBus =
|
|
71
|
+
const eventBus = eventBusName
|
|
72
|
+
? events.EventBus.fromEventBusName(this, 'TibEventBus', eventBusName)
|
|
73
|
+
: events.EventBus.fromEventBusArn(this, 'TibEventBus', eventBusArn);
|
|
72
74
|
// Build common environment for all Lambdas
|
|
73
75
|
const environment = {
|
|
74
76
|
TIB_DOMAIN_ID: domainId,
|
package/dist/pack-domain.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as cdk from 'aws-cdk-lib';
|
|
2
|
+
import * as apigwv2 from 'aws-cdk-lib/aws-apigatewayv2';
|
|
2
3
|
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
3
4
|
import { DomainStack } from './DomainStack.js';
|
|
4
5
|
import type { DomainRegistry } from './registry.js';
|
|
@@ -12,14 +13,20 @@ export interface PackDomainOptions {
|
|
|
12
13
|
vpc?: ec2.IVpc;
|
|
13
14
|
/** Security group for domain Lambdas. */
|
|
14
15
|
lambdaSg?: ec2.ISecurityGroup;
|
|
16
|
+
/** Shared HTTP API Gateway — when provided, domain routes use this instead of creating a separate API. */
|
|
17
|
+
httpApi?: apigwv2.HttpApi;
|
|
15
18
|
/** Cognito User Pool ARN — when provided, HTTP API routes are JWT-protected. */
|
|
16
19
|
userPoolArn?: string;
|
|
20
|
+
/** Cognito User Pool ID — preferred over parsing userPoolArn for JWT authorizer issuer. */
|
|
21
|
+
userPoolId?: string;
|
|
17
22
|
/** Cognito User Pool Client ID — required alongside userPoolArn for JWT authorizer. */
|
|
18
23
|
userPoolClientId?: string;
|
|
19
24
|
/** Database connection URL. */
|
|
20
25
|
databaseUrl?: string;
|
|
21
26
|
/** ARN of the RDS secret for DB credentials. */
|
|
22
27
|
dbSecretArn?: string;
|
|
28
|
+
/** EventBridge bus name; avoids ARN parsing when ARN is a dynamic reference. */
|
|
29
|
+
eventBusName?: string;
|
|
23
30
|
}
|
|
24
31
|
/**
|
|
25
32
|
* Convenience entry-point: constructs a DomainStack from a compiled registry.
|
package/dist/pack-domain.js
CHANGED
|
@@ -15,7 +15,7 @@ export function packDomain(registry, app, stackId, eventBusArn, options) {
|
|
|
15
15
|
// Check if options looks like a CDK Environment (has 'account' and/or 'region' props, not the full options interface)
|
|
16
16
|
const opts = options && typeof options === 'object'
|
|
17
17
|
&& ('account' in options || 'region' in options)
|
|
18
|
-
&& !('userPoolArn' in options || 'userPoolClientId' in options || 'databaseUrl' in options || 'dbSecretArn' in options)
|
|
18
|
+
&& !('userPoolArn' in options || 'userPoolId' in options || 'userPoolClientId' in options || 'databaseUrl' in options || 'dbSecretArn' in options)
|
|
19
19
|
? { env: options }
|
|
20
20
|
: options || {};
|
|
21
21
|
return new DomainStack(app, stackId, {
|
|
@@ -24,9 +24,12 @@ export function packDomain(registry, app, stackId, eventBusArn, options) {
|
|
|
24
24
|
env: opts.env,
|
|
25
25
|
vpc: opts.vpc,
|
|
26
26
|
lambdaSg: opts.lambdaSg,
|
|
27
|
+
httpApi: opts.httpApi,
|
|
27
28
|
userPoolArn: opts.userPoolArn,
|
|
29
|
+
userPoolId: opts.userPoolId,
|
|
28
30
|
userPoolClientId: opts.userPoolClientId,
|
|
29
31
|
databaseUrl: opts.databaseUrl,
|
|
30
32
|
dbSecretArn: opts.dbSecretArn,
|
|
33
|
+
eventBusName: opts.eventBusName,
|
|
31
34
|
});
|
|
32
35
|
}
|