@mettlecast/domain-cdk-packer 0.2.4 → 0.2.7
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 +4 -0
- package/dist/DomainStack.js +5 -5
- package/dist/pack-domain.d.ts +5 -0
- package/dist/pack-domain.js +3 -1
- package/package.json +1 -1
package/dist/DomainStack.d.ts
CHANGED
|
@@ -17,12 +17,16 @@ export interface DomainStackProps extends cdk.StackProps {
|
|
|
17
17
|
dbSecretArn?: string;
|
|
18
18
|
/** Cognito User Pool ARN — when provided, HTTP API routes are JWT-protected. */
|
|
19
19
|
userPoolArn?: string;
|
|
20
|
+
/** Cognito User Pool ID — preferred over parsing userPoolArn for JWT authorizer issuer. */
|
|
21
|
+
userPoolId?: string;
|
|
20
22
|
/** Cognito User Pool Client ID — required alongside userPoolArn for JWT authorizer. */
|
|
21
23
|
userPoolClientId?: string;
|
|
22
24
|
/** VPC to place domain Lambdas in — required for Aurora connectivity. */
|
|
23
25
|
vpc?: ec2.IVpc;
|
|
24
26
|
/** Security group for domain Lambdas — must allow egress to Aurora SG. */
|
|
25
27
|
lambdaSg?: ec2.ISecurityGroup;
|
|
28
|
+
/** Shared HTTP API Gateway — when provided, domain routes are added here instead of creating a separate API. */
|
|
29
|
+
httpApi?: apigwv2.HttpApi;
|
|
26
30
|
/** Enable CMK encryption for DynamoDB, S3, SQS. */
|
|
27
31
|
enableCmk?: boolean;
|
|
28
32
|
/** 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, 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
|
}
|
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,8 +13,12 @@ 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. */
|
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,7 +24,9 @@ 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,
|