@mettlecast/domain-cdk-packer 0.2.55 → 0.2.57

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.
@@ -33,6 +33,18 @@ export interface DomainStackProps extends cdk.StackProps {
33
33
  internetSubnetSelection?: ec2.SubnetSelection;
34
34
  /** Shared HTTP API Gateway — when provided, domain routes are added here instead of creating a separate API. */
35
35
  httpApi?: apigwv2.IHttpApi;
36
+ /** Raw VPC id — when provided, the VPC is imported inside this stack's scope. */
37
+ vpcId?: string;
38
+ /** Availability zones for the imported shared VPC. */
39
+ vpcAvailabilityZones?: string[];
40
+ /** Private subnet ids for the imported shared VPC. */
41
+ vpcPrivateSubnetIds?: string[];
42
+ /** Raw Lambda security group id — imported inside this stack's scope. */
43
+ lambdaSgId?: string;
44
+ /** Raw HTTP API id — imported inside this stack's scope. */
45
+ httpApiId?: string;
46
+ /** HTTP API endpoint URL paired with httpApiId. */
47
+ httpApiUrl?: string;
36
48
  /** Path to domain source root � defaults to ../../domains/{domainId}. */
37
49
  domainRoot?: string;
38
50
  /** Enable CMK encryption for DynamoDB, S3, SQS. */
@@ -60,6 +72,16 @@ export interface DomainStackProps extends cdk.StackProps {
60
72
  * Requires corsAllowedOrigins to be a non-wildcard list.
61
73
  */
62
74
  allowCredentials?: boolean;
75
+ /**
76
+ * Project id used to prefix per-domain physical resource names (e.g. `mtc-dev-data-management`).
77
+ * Defaults to the first segment of the stack name; falls back to `tib` when not derivable.
78
+ */
79
+ projectId?: string;
80
+ /**
81
+ * Environment code used to prefix per-domain physical resource names (e.g. `dev`, `prod`).
82
+ * Defaults to the second segment of the stack name; falls back to `dev` when not derivable.
83
+ */
84
+ envCode?: string;
63
85
  }
64
86
  export declare class DomainStack extends cdk.Stack {
65
87
  /** Shared HTTP API for routing API and webhook requests. */
@@ -9,6 +9,7 @@ import * as lambdaEventSources from 'aws-cdk-lib/aws-lambda-event-sources';
9
9
  import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
10
10
  import * as iam from 'aws-cdk-lib/aws-iam';
11
11
  import * as scheduler from 'aws-cdk-lib/aws-scheduler';
12
+ import * as ec2 from 'aws-cdk-lib/aws-ec2';
12
13
  import * as s3 from 'aws-cdk-lib/aws-s3';
13
14
  import { createGroupedLambdas } from './grouped-lambda-factory.js';
14
15
  import { IamPolicyBuilder } from './iam/iam-policy-builder.js';
@@ -18,6 +19,7 @@ import { CmkConstruct } from './constructs/cmk-construct.js';
18
19
  import { WafConstruct } from './constructs/waf-construct.js';
19
20
  import { AlarmConstruct } from './constructs/alarm-construct.js';
20
21
  import { CanaryConstruct } from './constructs/canary-construct.js';
22
+ import { domainResourceName } from './naming.js';
21
23
  /**
22
24
  * Top-level CDK Stack that composes all domain constructs from a single DomainRegistry input.
23
25
  * Uses grouped Lambdas for each primitive type to reduce deployment artifact size.
@@ -55,8 +57,27 @@ export class DomainStack extends cdk.Stack {
55
57
  */
56
58
  constructor(scope, id, props) {
57
59
  super(scope, id, props);
58
- const { registry, eventBusArn, eventBusName, databaseUrl, dbSecretArn, userPoolArn, userPoolId, userPoolClientId, vpc, lambdaSg, internalSubnetSelection, internetSubnetSelection, httpApi, enableCmk, enableWaf, enableAlarms, alarmSnsTopicArn, enableCanaryDeploy, reservedConcurrency, logRetentionDays, corsAllowedOrigins, allowCredentials } = props;
60
+ const { registry, eventBusArn, eventBusName, databaseUrl, dbSecretArn, userPoolArn, userPoolId, userPoolClientId, internalSubnetSelection, internetSubnetSelection, enableCmk, enableWaf, enableAlarms, alarmSnsTopicArn, enableCanaryDeploy, reservedConcurrency, logRetentionDays, corsAllowedOrigins, allowCredentials } = props;
61
+ const vpc = props.vpc ?? (props.vpcId
62
+ ? ec2.Vpc.fromVpcAttributes(this, 'SharedVpc', {
63
+ vpcId: props.vpcId,
64
+ availabilityZones: props.vpcAvailabilityZones ?? [cdk.Fn.select(0, cdk.Fn.getAzs()), cdk.Fn.select(1, cdk.Fn.getAzs())],
65
+ privateSubnetIds: props.vpcPrivateSubnetIds ?? [],
66
+ })
67
+ : undefined);
68
+ const lambdaSg = props.lambdaSg ?? (props.lambdaSgId
69
+ ? ec2.SecurityGroup.fromSecurityGroupId(this, 'LambdaSg', props.lambdaSgId)
70
+ : undefined);
71
+ const httpApi = props.httpApi ?? (props.httpApiId
72
+ ? apigwv2.HttpApi.fromHttpApiAttributes(this, 'SharedHttpApi', {
73
+ httpApiId: props.httpApiId,
74
+ apiEndpoint: props.httpApiUrl,
75
+ })
76
+ : undefined);
59
77
  const domainId = registry.domain.id;
78
+ const projectId = props.projectId ?? this.stackName.split('-')[0] ?? 'tib';
79
+ const envCode = props.envCode ?? this.stackName.split('-')[1] ?? 'dev';
80
+ const resourceBaseName = domainResourceName(projectId, envCode, domainId);
60
81
  const allowedOrigins = corsAllowedOrigins ?? ['*'];
61
82
  this.httpApi = httpApi ?? new apigwv2.HttpApi(this, 'HttpApi', {
62
83
  apiName: `${domainId}-api`,
@@ -78,7 +99,7 @@ export class DomainStack extends cdk.Stack {
78
99
  }
79
100
  // Optional WAF
80
101
  if (enableWaf) {
81
- new WafConstruct(this, 'Waf', { domainId, httpApi: this.httpApi });
102
+ new WafConstruct(this, 'Waf', { domainId, namePrefix: resourceBaseName, httpApi: this.httpApi });
82
103
  }
83
104
  // Optional CMK — customer-managed encryption key for DynamoDB, S3, SQS
84
105
  let cmkKey;
@@ -147,7 +168,7 @@ export class DomainStack extends cdk.Stack {
147
168
  };
148
169
  // Per-domain DynamoDB table — PK=tenantId (tenant is primary partition), SK=entity key
149
170
  const domainTable = new dynamodb.Table(this, 'DomainTable', {
150
- tableName: `tib-${domainId}`,
171
+ tableName: resourceBaseName,
151
172
  partitionKey: { name: 'tenantId', type: dynamodb.AttributeType.STRING },
152
173
  sortKey: { name: 'sk', type: dynamodb.AttributeType.STRING },
153
174
  billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
@@ -158,9 +179,9 @@ export class DomainStack extends cdk.Stack {
158
179
  pointInTimeRecovery: true,
159
180
  });
160
181
  // Per-domain S3 bucket — all objects prefixed {tenantId}/ enforced in runtime
161
- const bucketName = `tib-${domainId}`.length <= 63
162
- ? `tib-${domainId}`
163
- : `tib-${domainId.slice(0, 55)}-${cdk.Fn.select(0, cdk.Fn.split('-', cdk.Names.uniqueId(this))).toLowerCase()}`;
182
+ const bucketName = resourceBaseName.length <= 63
183
+ ? resourceBaseName
184
+ : `${resourceBaseName.slice(0, 55)}-${cdk.Fn.select(0, cdk.Fn.split('-', cdk.Names.uniqueId(this))).toLowerCase()}`;
164
185
  const domainBucket = new s3.Bucket(this, 'DomainBucket', {
165
186
  bucketName,
166
187
  blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
@@ -177,7 +198,7 @@ export class DomainStack extends cdk.Stack {
177
198
  environment['DOMAIN_BUCKET_NAME'] = domainBucket.bucketName;
178
199
  // Per-domain tenant-scoped IAM role for defence-in-depth storage segregation
179
200
  const tenantScopedRole = new iam.Role(this, 'DomainTenantScopedRole', {
180
- roleName: `tib-${domainId}-tenant-scoped`,
201
+ roleName: `${resourceBaseName}-tenant-scoped`,
181
202
  assumedBy: new iam.AccountPrincipal(cdk.Stack.of(this).account),
182
203
  description: `Tenant-scoped role for ${domainId} domain. Only assumable with tenantId session tag.`,
183
204
  maxSessionDuration: cdk.Duration.hours(1),
@@ -461,6 +482,7 @@ export class DomainStack extends cdk.Stack {
461
482
  if (enableAlarms) {
462
483
  alarmConstruct = new AlarmConstruct(this, 'Alarms', {
463
484
  domainId,
485
+ namePrefix: resourceBaseName,
464
486
  lambdaFunctions: allDomainLambdas,
465
487
  dlqs: allDlqs,
466
488
  snsTopicArn: alarmSnsTopicArn,
@@ -471,6 +493,7 @@ export class DomainStack extends cdk.Stack {
471
493
  if (enableCanaryDeploy) {
472
494
  new CanaryConstruct(this, 'Canary', {
473
495
  domainId,
496
+ namePrefix: resourceBaseName,
474
497
  lambdaFunctions: allDomainLambdas,
475
498
  rollbackAlarms: alarmConstruct?.alarms ?? [],
476
499
  });
@@ -134,7 +134,7 @@ describe('DomainStack', () => {
134
134
  const template = Template.fromStack(stack);
135
135
  it('creates a tenant-scoped IAM role', () => {
136
136
  template.hasResourceProperties('AWS::IAM::Role', {
137
- RoleName: 'tib-test-domain-tenant-scoped',
137
+ RoleName: 'testdomainstacktenant-dev-test-domain-tenant-scoped',
138
138
  });
139
139
  });
140
140
  it('sets DOMAIN_TENANT_ROLE_ARN env var on each Lambda', () => {
@@ -4,6 +4,8 @@ import * as lambda from 'aws-cdk-lib/aws-lambda';
4
4
  import { Construct } from 'constructs';
5
5
  export interface AlarmConstructProps {
6
6
  domainId: string;
7
+ /** Project/env/domain-qualified lowercased prefix (from domainResourceName) used in alarm names. */
8
+ namePrefix: string;
7
9
  lambdaFunctions: lambda.Function[];
8
10
  dlqs: sqs.Queue[];
9
11
  /** SNS topic ARN for alarm notifications. If omitted, alarms are created without actions. */
@@ -16,7 +16,7 @@ export class AlarmConstruct extends Construct {
16
16
  // DLQ depth alarms — fire immediately when any message lands in DLQ
17
17
  for (const dlq of props.dlqs) {
18
18
  const alarm = new cloudwatch.Alarm(this, `DlqAlarm-${dlq.node.id}`, {
19
- alarmName: `tib-${props.domainId}-dlq-${dlq.node.id}-depth`,
19
+ alarmName: `${props.namePrefix}-dlq-${dlq.node.id}-depth`,
20
20
  alarmDescription: `DLQ ${dlq.node.id} has messages — investigate failed processing`,
21
21
  metric: dlq.metricApproximateNumberOfMessagesVisible({
22
22
  period: cdk.Duration.minutes(1),
@@ -35,7 +35,7 @@ export class AlarmConstruct extends Construct {
35
35
  const errorThreshold = props.errorRateThreshold ?? 0.01;
36
36
  for (const fn of props.lambdaFunctions) {
37
37
  const errorAlarm = new cloudwatch.Alarm(this, `ErrorAlarm-${fn.node.id}`, {
38
- alarmName: `tib-${props.domainId}-${fn.node.id}-error-rate`,
38
+ alarmName: `${props.namePrefix}-${fn.node.id}-error-rate`,
39
39
  alarmDescription: `Lambda ${fn.node.id} error rate exceeded ${errorThreshold * 100}%`,
40
40
  metric: new cloudwatch.MathExpression({
41
41
  expression: 'errors / invocations',
@@ -3,6 +3,8 @@ import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';
3
3
  import { Construct } from 'constructs';
4
4
  export interface CanaryConstructProps {
5
5
  domainId: string;
6
+ /** Project/env/domain-qualified lowercased prefix (from domainResourceName) used in CodeDeploy application name. */
7
+ namePrefix: string;
6
8
  lambdaFunctions: lambda.Function[];
7
9
  /** CloudWatch alarms that trigger auto-rollback. Typically from AlarmConstruct. */
8
10
  rollbackAlarms?: cloudwatch.Alarm[];
@@ -6,7 +6,7 @@ export class CanaryConstruct extends Construct {
6
6
  constructor(scope, id, props) {
7
7
  super(scope, id);
8
8
  const app = new codedeploy.LambdaApplication(this, 'DeployApp', {
9
- applicationName: `tib-${props.domainId}`,
9
+ applicationName: props.namePrefix,
10
10
  });
11
11
  for (const fn of props.lambdaFunctions) {
12
12
  const alias = new lambda.Alias(this, `${fn.node.id}LiveAlias`, {
@@ -3,6 +3,8 @@ import * as apigwv2 from 'aws-cdk-lib/aws-apigatewayv2';
3
3
  import { Construct } from 'constructs';
4
4
  export interface WafConstructProps {
5
5
  domainId: string;
6
+ /** Project/env/domain-qualified lowercased prefix (from domainResourceName) used in WAF names and metrics. */
7
+ namePrefix: string;
6
8
  httpApi: apigwv2.IHttpApi;
7
9
  /** Requests per 5-minute window per IP before blocking. Default: 2000. */
8
10
  rateLimit?: number;
@@ -7,13 +7,13 @@ export class WafConstruct extends Construct {
7
7
  super(scope, id);
8
8
  const rateLimit = props.rateLimit ?? 2000;
9
9
  this.webAcl = new wafv2.CfnWebACL(this, 'WebAcl', {
10
- name: `tib-${props.domainId}-waf`,
10
+ name: `${props.namePrefix}-waf`,
11
11
  scope: 'REGIONAL',
12
12
  defaultAction: { allow: {} },
13
13
  visibilityConfig: {
14
14
  sampledRequestsEnabled: true,
15
15
  cloudWatchMetricsEnabled: true,
16
- metricName: `tib-${props.domainId}-waf`,
16
+ metricName: `${props.namePrefix}-waf`,
17
17
  },
18
18
  rules: [
19
19
  {
@@ -29,7 +29,7 @@ export class WafConstruct extends Construct {
29
29
  visibilityConfig: {
30
30
  sampledRequestsEnabled: true,
31
31
  cloudWatchMetricsEnabled: true,
32
- metricName: `tib-${props.domainId}-common-rules`,
32
+ metricName: `${props.namePrefix}-common-rules`,
33
33
  },
34
34
  },
35
35
  {
@@ -45,7 +45,7 @@ export class WafConstruct extends Construct {
45
45
  visibilityConfig: {
46
46
  sampledRequestsEnabled: true,
47
47
  cloudWatchMetricsEnabled: true,
48
- metricName: `tib-${props.domainId}-bad-inputs`,
48
+ metricName: `${props.namePrefix}-bad-inputs`,
49
49
  },
50
50
  },
51
51
  {
@@ -61,7 +61,7 @@ export class WafConstruct extends Construct {
61
61
  visibilityConfig: {
62
62
  sampledRequestsEnabled: true,
63
63
  cloudWatchMetricsEnabled: true,
64
- metricName: `tib-${props.domainId}-rate-limit`,
64
+ metricName: `${props.namePrefix}-rate-limit`,
65
65
  },
66
66
  },
67
67
  ],
package/dist/index.d.ts CHANGED
@@ -34,3 +34,4 @@ export type { DomainActionFlowNode, StepFunctionsTaskState } from './step-functi
34
34
  export type { FlowRegistry, FlowRegistryEntry, SerialFlowStep, SerialDomainActionStep, SerialDomainApiStep, SerialDomainEventStep, SerialDomainQueryStep, SerialAwsServiceStep, SerialFlowControlStep } from './flow-registry.js';
35
35
  export { FlowsStack, packFlows } from './pack-flows.js';
36
36
  export type { PackFlowsOptions } from './pack-flows.js';
37
+ export { domainResourceName } from './naming.js';
package/dist/index.js CHANGED
@@ -15,3 +15,4 @@ export { DomainStack } from './DomainStack.js';
15
15
  export { packDomain } from './pack-domain.js';
16
16
  export { StepFunctionsCodegen } from './step-functions-codegen.js';
17
17
  export { FlowsStack, packFlows } from './pack-flows.js';
18
+ export { domainResourceName } from './naming.js';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Canonical physical-name builder for per-domain AWS resources.
3
+ *
4
+ * Project/env-qualified + lowercased so names are unique per project and
5
+ * environment and never collide globally (S3) or across environments.
6
+ *
7
+ * Used by BOTH the resource constructors (DomainStack table/bucket/role,
8
+ * WAF/canary/alarm constructs) AND the IAM ARNs that grant access to them
9
+ * (pack-flows domain-query grants) so the two can never drift.
10
+ */
11
+ export declare function domainResourceName(projectId: string, envCode: string, domainId: string): string;
package/dist/naming.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Canonical physical-name builder for per-domain AWS resources.
3
+ *
4
+ * Project/env-qualified + lowercased so names are unique per project and
5
+ * environment and never collide globally (S3) or across environments.
6
+ *
7
+ * Used by BOTH the resource constructors (DomainStack table/bucket/role,
8
+ * WAF/canary/alarm constructs) AND the IAM ARNs that grant access to them
9
+ * (pack-flows domain-query grants) so the two can never drift.
10
+ */
11
+ export function domainResourceName(projectId, envCode, domainId) {
12
+ return `${projectId}-${envCode}-${domainId}`.toLowerCase();
13
+ }
@@ -19,6 +19,18 @@ export interface PackDomainOptions {
19
19
  internetSubnetSelection?: ec2.SubnetSelection;
20
20
  /** Shared HTTP API Gateway — when provided, domain routes use this instead of creating a separate API. */
21
21
  httpApi?: apigwv2.HttpApi;
22
+ /** Raw VPC id for importing a shared VPC inside the stack scope (avoids App-scope import errors). */
23
+ vpcId?: string;
24
+ /** Availability zones for the imported shared VPC. */
25
+ vpcAvailabilityZones?: string[];
26
+ /** Private subnet ids for the imported shared VPC. */
27
+ vpcPrivateSubnetIds?: string[];
28
+ /** Raw security group id for importing the shared Lambda SG inside the stack scope. */
29
+ lambdaSgId?: string;
30
+ /** Raw HTTP API id for importing the shared HTTP API inside the stack scope. */
31
+ httpApiId?: string;
32
+ /** HTTP API endpoint URL paired with httpApiId. */
33
+ httpApiUrl?: string;
22
34
  /** Cognito User Pool ARN — when provided, HTTP API routes are JWT-protected. */
23
35
  userPoolArn?: string;
24
36
  /** Cognito User Pool ID — preferred over parsing userPoolArn for JWT authorizer issuer. */
@@ -31,6 +43,10 @@ export interface PackDomainOptions {
31
43
  dbSecretArn?: string;
32
44
  /** EventBridge bus name; avoids ARN parsing when ARN is a dynamic reference. */
33
45
  eventBusName?: string;
46
+ /** Project id used to prefix per-domain physical resource names (e.g. `mtc-dev-data-management`). */
47
+ projectId?: string;
48
+ /** Environment code used to prefix per-domain physical resource names (e.g. `dev`, `prod`). */
49
+ envCode?: string;
34
50
  }
35
51
  /**
36
52
  * Convenience entry-point: constructs a DomainStack from a compiled registry.
@@ -27,11 +27,19 @@ export function packDomain(registry, app, stackId, eventBusArn, options) {
27
27
  internalSubnetSelection: opts.internalSubnetSelection,
28
28
  internetSubnetSelection: opts.internetSubnetSelection,
29
29
  httpApi: opts.httpApi,
30
+ vpcId: opts.vpcId,
31
+ vpcAvailabilityZones: opts.vpcAvailabilityZones,
32
+ vpcPrivateSubnetIds: opts.vpcPrivateSubnetIds,
33
+ lambdaSgId: opts.lambdaSgId,
34
+ httpApiId: opts.httpApiId,
35
+ httpApiUrl: opts.httpApiUrl,
30
36
  userPoolArn: opts.userPoolArn,
31
37
  userPoolId: opts.userPoolId,
32
38
  userPoolClientId: opts.userPoolClientId,
33
39
  databaseUrl: opts.databaseUrl,
34
40
  dbSecretArn: opts.dbSecretArn,
35
41
  eventBusName: opts.eventBusName,
42
+ projectId: opts.projectId,
43
+ envCode: opts.envCode,
36
44
  });
37
45
  }
@@ -8,6 +8,10 @@ export interface PackFlowsOptions {
8
8
  domainLambdaArns: Record<string, string>;
9
9
  /** EventBridge bus ARN for domain-event steps and triggers. */
10
10
  eventBusArn: string;
11
+ /** Project id used to prefix per-domain physical resource names (e.g. `mtc-dev-data-management`). */
12
+ projectId?: string;
13
+ /** Environment code used to prefix per-domain physical resource names (e.g. `dev`, `prod`). */
14
+ envCode?: string;
11
15
  }
12
16
  /** CDK stack containing one Step Functions state machine per flow in the registry. */
13
17
  export declare class FlowsStack extends cdk.Stack {
@@ -15,6 +19,8 @@ export declare class FlowsStack extends cdk.Stack {
15
19
  readonly flowArnMap: Record<string, string>;
16
20
  readonly taskTokensTableName: string;
17
21
  readonly taskTokensTableArn: string;
22
+ private readonly projectId;
23
+ private readonly envCode;
18
24
  constructor(scope: Construct, id: string, props: {
19
25
  registry: FlowRegistry;
20
26
  options: PackFlowsOptions;
@@ -4,15 +4,20 @@ import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
4
4
  import * as events from 'aws-cdk-lib/aws-events';
5
5
  import * as eventsTargets from 'aws-cdk-lib/aws-events-targets';
6
6
  import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
7
+ import { domainResourceName } from './naming.js';
7
8
  /** CDK stack containing one Step Functions state machine per flow in the registry. */
8
9
  export class FlowsStack extends cdk.Stack {
9
10
  /** Map of flow id -> SFN ARN. Used by domain Lambdas via FLOWS_SFN_ARN_MAP env var. */
10
11
  flowArnMap = {};
11
12
  taskTokensTableName;
12
13
  taskTokensTableArn;
14
+ projectId;
15
+ envCode;
13
16
  constructor(scope, id, props) {
14
17
  super(scope, id, props);
15
18
  const { registry, options } = props;
19
+ this.projectId = options.projectId ?? this.stackName.split('-')[0] ?? 'tib';
20
+ this.envCode = options.envCode ?? this.stackName.split('-')[1] ?? 'dev';
16
21
  // DDB table for WaitForTaskToken task token persistence
17
22
  const taskTokensTable = new dynamodb.Table(this, 'FlowTaskTokensTable', {
18
23
  tableName: `${this.stackName}-task-tokens`,
@@ -78,18 +83,20 @@ export class FlowsStack extends cdk.Stack {
78
83
  }
79
84
  }
80
85
  for (const domainId of ddbDomains) {
86
+ const tableName = domainResourceName(this.projectId, this.envCode, domainId);
81
87
  stateMachine.addToRolePolicy(new iam.PolicyStatement({
82
88
  actions: ['dynamodb:GetItem', 'dynamodb:Query'],
83
89
  resources: [
84
- this.formatArn({ service: 'dynamodb', resource: `table/tib-${domainId}` }),
85
- this.formatArn({ service: 'dynamodb', resource: `table/tib-${domainId}/index/*` }),
90
+ this.formatArn({ service: 'dynamodb', resource: `table/${tableName}` }),
91
+ this.formatArn({ service: 'dynamodb', resource: `table/${tableName}/index/*` }),
86
92
  ],
87
93
  }));
88
94
  }
89
95
  for (const domainId of s3Domains) {
96
+ const bucketName = domainResourceName(this.projectId, this.envCode, domainId);
90
97
  stateMachine.addToRolePolicy(new iam.PolicyStatement({
91
98
  actions: ['s3:GetObject'],
92
- resources: [`arn:aws:s3:::tib-${domainId}/*`],
99
+ resources: [`arn:aws:s3:::${bucketName}/*`],
93
100
  }));
94
101
  }
95
102
  // Grant IAM for aws-service steps
@@ -261,7 +268,7 @@ export class FlowsStack extends cdk.Stack {
261
268
  translateDomainQuery(step, flowId) {
262
269
  switch (step.queryType) {
263
270
  case 'dynamodb-get-item': {
264
- const tableName = `tib-${step.domainId}`;
271
+ const tableName = domainResourceName(this.projectId, this.envCode, step.domainId);
265
272
  const key = {};
266
273
  for (const [k, v] of Object.entries(step.key)) {
267
274
  key[k] = v.startsWith('$') ? { 'S.$': v } : { S: v };
@@ -277,7 +284,7 @@ export class FlowsStack extends cdk.Stack {
277
284
  return getItem;
278
285
  }
279
286
  case 'dynamodb-query': {
280
- const tableName = `tib-${step.domainId}`;
287
+ const tableName = domainResourceName(this.projectId, this.envCode, step.domainId);
281
288
  const eav = {};
282
289
  for (const [k, v] of Object.entries(step.expressionAttributeValues)) {
283
290
  eav[k] = v.value.startsWith('$') ? { [`${v.type}.$`]: v.value } : { [v.type]: v.value };
@@ -308,7 +315,7 @@ export class FlowsStack extends cdk.Stack {
308
315
  return query;
309
316
  }
310
317
  case 's3-get-object': {
311
- const bucketName = `tib-${step.domainId}`;
318
+ const bucketName = domainResourceName(this.projectId, this.envCode, step.domainId);
312
319
  const getObject = {
313
320
  Type: 'Task',
314
321
  Resource: 'arn:aws:states:::aws-sdk:s3:getObject',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mettlecast/domain-cdk-packer",
3
- "version": "0.2.55",
3
+ "version": "0.2.57",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org",