@fjall/components-infrastructure 0.96.0 → 0.99.1

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.
Files changed (209) hide show
  1. package/dist/lib/app.d.ts +68 -1
  2. package/dist/lib/app.js +113 -4
  3. package/dist/lib/config/aws/__t17fixture.d.ts +1 -0
  4. package/dist/lib/config/aws/__t17fixture.js +3 -0
  5. package/dist/lib/config/aws/__t17fixtureType.d.ts +2 -0
  6. package/dist/lib/config/aws/__t17fixtureType.js +1 -0
  7. package/dist/lib/config/aws/alarmTopic.js +8 -4
  8. package/dist/lib/config/aws/cloudTrail.js +1 -1
  9. package/dist/lib/config/aws/disasterRecovery.js +11 -16
  10. package/dist/lib/config/aws/ecrDefaultImage.d.ts +0 -1
  11. package/dist/lib/config/aws/ecrDefaultImage.js +13 -23
  12. package/dist/lib/config/aws/identityCenter.d.ts +10 -3
  13. package/dist/lib/config/aws/identityCenter.js +101 -37
  14. package/dist/lib/config/aws/identityCenterGroupMembership.js +8 -2
  15. package/dist/lib/config/aws/identityCenterMembership.d.ts +11 -0
  16. package/dist/lib/config/aws/identityCenterMembership.js +61 -0
  17. package/dist/lib/config/aws/index.d.ts +1 -1
  18. package/dist/lib/config/aws/index.js +1 -1
  19. package/dist/lib/config/aws/ipam.js +6 -11
  20. package/dist/lib/config/aws/oidcConnector.js +5 -1
  21. package/dist/lib/config/aws/scpPreset.js +4 -1
  22. package/dist/lib/patterns/aws/_eslint_test_tmp/leak.d.ts +1 -0
  23. package/dist/lib/patterns/aws/_eslint_test_tmp/leak.js +4 -0
  24. package/dist/lib/patterns/aws/account.js +2 -4
  25. package/dist/lib/patterns/aws/apexDomainPattern.js +10 -10
  26. package/dist/lib/patterns/aws/bastionFactory.d.ts +10 -0
  27. package/dist/lib/patterns/aws/bastionFactory.js +29 -0
  28. package/dist/lib/patterns/aws/buildkite.d.ts +2 -2
  29. package/dist/lib/patterns/aws/buildkite.js +51 -97
  30. package/dist/lib/patterns/aws/cdn.js +1 -1
  31. package/dist/lib/patterns/aws/clickhouseDatabase.d.ts +172 -0
  32. package/dist/lib/patterns/aws/clickhouseDatabase.js +600 -0
  33. package/dist/lib/patterns/aws/compute.d.ts +4 -6
  34. package/dist/lib/patterns/aws/compute.js +7 -13
  35. package/dist/lib/patterns/aws/computeEcs.d.ts +93 -5
  36. package/dist/lib/patterns/aws/computeEcs.js +867 -37
  37. package/dist/lib/patterns/aws/computeEcsTypes.d.ts +528 -25
  38. package/dist/lib/patterns/aws/computeEcsTypes.js +10 -0
  39. package/dist/lib/patterns/aws/computeLambda.d.ts +0 -5
  40. package/dist/lib/patterns/aws/computeLambda.js +1 -2
  41. package/dist/lib/patterns/aws/database.d.ts +50 -8
  42. package/dist/lib/patterns/aws/database.js +183 -27
  43. package/dist/lib/patterns/aws/domain.js +6 -4
  44. package/dist/lib/patterns/aws/index.d.ts +1 -0
  45. package/dist/lib/patterns/aws/index.js +1 -0
  46. package/dist/lib/patterns/aws/interfaces/compute.d.ts +7 -1
  47. package/dist/lib/patterns/aws/interfaces/database.d.ts +187 -8
  48. package/dist/lib/patterns/aws/interfaces/database.js +17 -3
  49. package/dist/lib/patterns/aws/interfaces/index.d.ts +2 -1
  50. package/dist/lib/patterns/aws/interfaces/index.js +3 -1
  51. package/dist/lib/patterns/aws/interfaces/messaging.d.ts +7 -0
  52. package/dist/lib/patterns/aws/interfaces/migrationContributor.d.ts +47 -0
  53. package/dist/lib/patterns/aws/interfaces/migrationContributor.js +9 -0
  54. package/dist/lib/patterns/aws/messaging.d.ts +66 -10
  55. package/dist/lib/patterns/aws/messaging.js +115 -20
  56. package/dist/lib/patterns/aws/network.js +16 -7
  57. package/dist/lib/patterns/aws/organisation.d.ts +4 -0
  58. package/dist/lib/patterns/aws/organisation.js +22 -4
  59. package/dist/lib/patterns/aws/storage.d.ts +1 -2
  60. package/dist/lib/patterns/aws/storage.js +3 -2
  61. package/dist/lib/patterns/aws/vpcPeer.js +3 -1
  62. package/dist/lib/resources/aws/analytics/clickhouse.js +18 -9
  63. package/dist/lib/resources/aws/analytics/clickhouseAlarms.d.ts +24 -9
  64. package/dist/lib/resources/aws/analytics/clickhouseAlarms.js +61 -10
  65. package/dist/lib/resources/aws/analytics/clickhouseConstants.d.ts +3 -3
  66. package/dist/lib/resources/aws/analytics/clickhouseConstants.js +3 -3
  67. package/dist/lib/resources/aws/analytics/clickhouseTypes.d.ts +7 -1
  68. package/dist/lib/resources/aws/analytics/clickhouseUserData.d.ts +1 -1
  69. package/dist/lib/resources/aws/analytics/clickhouseUserData.js +53 -3
  70. package/dist/lib/resources/aws/base/awsStack.js +4 -2
  71. package/dist/lib/resources/aws/compute/__tmp__/regression-shape.d.ts +2 -0
  72. package/dist/lib/resources/aws/compute/__tmp__/regression-shape.js +11 -0
  73. package/dist/lib/resources/aws/compute/asgInlineLifecycleHook.d.ts +52 -0
  74. package/dist/lib/resources/aws/compute/asgInlineLifecycleHook.js +60 -0
  75. package/dist/lib/resources/aws/compute/blockDeviceVolume.d.ts +8 -0
  76. package/dist/lib/resources/aws/compute/blockDeviceVolume.js +10 -0
  77. package/dist/lib/resources/aws/compute/ec2.d.ts +132 -12
  78. package/dist/lib/resources/aws/compute/ec2.js +163 -23
  79. package/dist/lib/resources/aws/compute/ec2GracefulTerminationHandler.d.ts +41 -0
  80. package/dist/lib/resources/aws/compute/ec2GracefulTerminationHandler.js +194 -0
  81. package/dist/lib/resources/aws/compute/ec2GracefulTerminationLambda.source.cjs +458 -0
  82. package/dist/lib/resources/aws/compute/ecs.d.ts +27 -1
  83. package/dist/lib/resources/aws/compute/ecs.js +42 -2
  84. package/dist/lib/resources/aws/compute/ecsConstants.d.ts +9 -0
  85. package/dist/lib/resources/aws/compute/ecsConstants.js +16 -0
  86. package/dist/lib/resources/aws/compute/ecsImages.js +32 -20
  87. package/dist/lib/resources/aws/compute/ecsLifecycleHookMigration.d.ts +96 -0
  88. package/dist/lib/resources/aws/compute/ecsLifecycleHookMigration.js +113 -0
  89. package/dist/lib/resources/aws/compute/ecsNetworking.d.ts +2 -1
  90. package/dist/lib/resources/aws/compute/ecsNetworking.js +18 -6
  91. package/dist/lib/resources/aws/compute/ecsServiceFactory.d.ts +13 -4
  92. package/dist/lib/resources/aws/compute/ecsServiceFactory.js +155 -33
  93. package/dist/lib/resources/aws/compute/ecsTaskDefinition.d.ts +31 -1
  94. package/dist/lib/resources/aws/compute/ecsTaskDefinition.js +102 -6
  95. package/dist/lib/resources/aws/compute/ecsTypes.d.ts +173 -13
  96. package/dist/lib/resources/aws/compute/ecsValidation.d.ts +9 -0
  97. package/dist/lib/resources/aws/compute/ecsValidation.js +63 -0
  98. package/dist/lib/resources/aws/compute/index.d.ts +2 -0
  99. package/dist/lib/resources/aws/compute/index.js +2 -0
  100. package/dist/lib/resources/aws/compute/lambda.d.ts +7 -13
  101. package/dist/lib/resources/aws/compute/lambda.js +30 -38
  102. package/dist/lib/resources/aws/compute/lifecycleHookLambda.source.cjs +192 -0
  103. package/dist/lib/resources/aws/compute/persistentDataVolume.d.ts +104 -0
  104. package/dist/lib/resources/aws/compute/persistentDataVolume.js +245 -0
  105. package/dist/lib/resources/aws/compute/persistentDataVolumeLambda.source.cjs +398 -0
  106. package/dist/lib/resources/aws/compute/samApplication.d.ts +15 -0
  107. package/dist/lib/resources/aws/compute/samApplication.js +27 -0
  108. package/dist/lib/resources/aws/database/clickhouseConstants.d.ts +159 -0
  109. package/dist/lib/resources/aws/database/clickhouseConstants.js +181 -0
  110. package/dist/lib/resources/aws/database/clickhouseSchemas.d.ts +71 -0
  111. package/dist/lib/resources/aws/database/clickhouseSchemas.js +157 -0
  112. package/dist/lib/resources/aws/database/clickhouseSecurityGroup.d.ts +14 -0
  113. package/dist/lib/resources/aws/database/clickhouseSecurityGroup.js +23 -0
  114. package/dist/lib/resources/aws/database/clickhouseUserData.d.ts +69 -0
  115. package/dist/lib/resources/aws/database/clickhouseUserData.js +371 -0
  116. package/dist/lib/resources/aws/database/clickhouseXmlRenderer.d.ts +56 -0
  117. package/dist/lib/resources/aws/database/clickhouseXmlRenderer.js +112 -0
  118. package/dist/lib/resources/aws/database/rdsAurora.d.ts +8 -1
  119. package/dist/lib/resources/aws/database/rdsAurora.js +42 -32
  120. package/dist/lib/resources/aws/database/rdsAuroraGlobal.d.ts +15 -2
  121. package/dist/lib/resources/aws/database/rdsAuroraGlobal.js +39 -43
  122. package/dist/lib/resources/aws/database/rdsDefaults.d.ts +6 -0
  123. package/dist/lib/resources/aws/database/rdsDefaults.js +7 -1
  124. package/dist/lib/resources/aws/database/rdsHelpers.d.ts +3 -3
  125. package/dist/lib/resources/aws/database/rdsHelpers.js +1 -0
  126. package/dist/lib/resources/aws/database/rdsInstance.d.ts +8 -1
  127. package/dist/lib/resources/aws/database/rdsInstance.js +51 -34
  128. package/dist/lib/resources/aws/database/rdsProxyOutput.d.ts +1 -1
  129. package/dist/lib/resources/aws/database/rdsProxyOutput.js +1 -1
  130. package/dist/lib/resources/aws/iam/delegationRole.js +1 -1
  131. package/dist/lib/resources/aws/iam/identityCenter/groupMembership.d.ts +9 -0
  132. package/dist/lib/resources/aws/iam/identityCenter/groupMembership.js +12 -0
  133. package/dist/lib/resources/aws/iam/identityCenter/index.d.ts +1 -0
  134. package/dist/lib/resources/aws/iam/identityCenter/index.js +1 -0
  135. package/dist/lib/resources/aws/iam/identityCenter/permissionSet.d.ts +1 -0
  136. package/dist/lib/resources/aws/iam/identityCenter/permissionSet.js +1 -0
  137. package/dist/lib/resources/aws/logging/logGroup.d.ts +0 -8
  138. package/dist/lib/resources/aws/logging/logGroup.js +0 -11
  139. package/dist/lib/resources/aws/messaging/defaultEventBus.d.ts +7 -0
  140. package/dist/lib/resources/aws/messaging/defaultEventBus.js +21 -0
  141. package/dist/lib/resources/aws/messaging/eventBridgeRule.d.ts +96 -0
  142. package/dist/lib/resources/aws/messaging/eventBridgeRule.js +110 -0
  143. package/dist/lib/resources/aws/messaging/eventTargets.d.ts +84 -0
  144. package/dist/lib/resources/aws/messaging/eventTargets.js +152 -0
  145. package/dist/lib/resources/aws/messaging/eventbridge.d.ts +25 -2
  146. package/dist/lib/resources/aws/messaging/eventbridge.js +22 -10
  147. package/dist/lib/resources/aws/messaging/index.d.ts +5 -0
  148. package/dist/lib/resources/aws/messaging/index.js +2 -0
  149. package/dist/lib/resources/aws/messaging/schedule.d.ts +118 -0
  150. package/dist/lib/resources/aws/messaging/schedule.js +64 -0
  151. package/dist/lib/resources/aws/messaging/sns.d.ts +2 -1
  152. package/dist/lib/resources/aws/messaging/sqs.d.ts +2 -1
  153. package/dist/lib/resources/aws/messaging/subscription.d.ts +112 -0
  154. package/dist/lib/resources/aws/messaging/subscription.js +67 -0
  155. package/dist/lib/resources/aws/messaging/utils.d.ts +6 -0
  156. package/dist/lib/resources/aws/messaging/utils.js +10 -0
  157. package/dist/lib/resources/aws/monitoring/clickhouseAlarms.d.ts +60 -0
  158. package/dist/lib/resources/aws/monitoring/clickhouseAlarms.js +139 -0
  159. package/dist/lib/resources/aws/monitoring/index.d.ts +2 -0
  160. package/dist/lib/resources/aws/monitoring/index.js +2 -0
  161. package/dist/lib/resources/aws/monitoring/scheduleAlarms.d.ts +47 -0
  162. package/dist/lib/resources/aws/monitoring/scheduleAlarms.js +106 -0
  163. package/dist/lib/resources/aws/networking/crossAccountDelegationRecord.js +6 -4
  164. package/dist/lib/resources/aws/networking/crossAccountReturnRoutes.js +17 -13
  165. package/dist/lib/resources/aws/networking/dnsRecord/dnsRecordBase.js +7 -5
  166. package/dist/lib/resources/aws/networking/domainCertificate.d.ts +2 -2
  167. package/dist/lib/resources/aws/networking/domainCertificate.js +6 -4
  168. package/dist/lib/resources/aws/networking/hostedZone.js +6 -5
  169. package/dist/lib/resources/aws/networking/serviceDiscovery.d.ts +96 -0
  170. package/dist/lib/resources/aws/networking/serviceDiscovery.js +96 -0
  171. package/dist/lib/resources/aws/networking/vpc.d.ts +4 -1
  172. package/dist/lib/resources/aws/networking/vpc.js +4 -1
  173. package/dist/lib/resources/aws/networking/vpcPeeringConnection.js +21 -3
  174. package/dist/lib/resources/aws/organisation/costAllocationTagActivator.d.ts +16 -5
  175. package/dist/lib/resources/aws/organisation/costAllocationTagActivator.js +17 -3
  176. package/dist/lib/resources/aws/organisation/index.d.ts +1 -1
  177. package/dist/lib/resources/aws/organisation/organisationPolicy.d.ts +2 -0
  178. package/dist/lib/resources/aws/organisation/organisationPolicy.js +3 -2
  179. package/dist/lib/resources/aws/secrets/secret.d.ts +7 -0
  180. package/dist/lib/resources/aws/secrets/secret.js +4 -3
  181. package/dist/lib/resources/aws/storage/bucketDeployment.d.ts +16 -0
  182. package/dist/lib/resources/aws/storage/bucketDeployment.js +17 -0
  183. package/dist/lib/resources/aws/storage/ecr.js +5 -5
  184. package/dist/lib/resources/aws/storage/index.d.ts +1 -0
  185. package/dist/lib/resources/aws/storage/index.js +1 -0
  186. package/dist/lib/resources/aws/storage/s3.js +10 -3
  187. package/dist/lib/resources/aws/utilities/customResource.js +18 -9
  188. package/dist/lib/synth_dump.d.ts +1 -0
  189. package/dist/lib/synth_dump.js +42 -0
  190. package/dist/lib/utils/cdkContext.d.ts +2 -0
  191. package/dist/lib/utils/cdkContext.js +4 -2
  192. package/dist/lib/utils/connections.js +6 -0
  193. package/dist/lib/utils/connector.d.ts +12 -0
  194. package/dist/lib/utils/costAllocationTags.d.ts +9 -0
  195. package/dist/lib/utils/costAllocationTags.js +11 -1
  196. package/dist/lib/utils/databaseTypes.d.ts +14 -0
  197. package/dist/lib/utils/getConfig.d.ts +2 -0
  198. package/dist/lib/utils/getConfig.js +2 -0
  199. package/dist/lib/utils/index.d.ts +1 -0
  200. package/dist/lib/utils/index.js +1 -0
  201. package/dist/lib/utils/manifestWriter.d.ts +6 -89
  202. package/dist/lib/utils/manifestWriter.js +36 -23
  203. package/dist/lib/utils/migrationVersionResolvers.d.ts +2 -0
  204. package/dist/lib/utils/migrationVersionResolvers.js +2 -0
  205. package/dist/lib/utils/orgConfigParser.js +2 -1
  206. package/dist/lib/utils/resolveAlertsTopic.d.ts +14 -0
  207. package/dist/lib/utils/resolveAlertsTopic.js +30 -0
  208. package/dist/lib/utils/validationLogger.js +6 -3
  209. package/package.json +22 -19
@@ -4,4 +4,4 @@ import type { DatabaseProxy } from "aws-cdk-lib/aws-rds";
4
4
  * Add a CfnOutput for the RDS proxy endpoint.
5
5
  * Shared by RdsAurora and RdsInstance constructs.
6
6
  */
7
- export declare function addProxyCfnOutput(scope: Construct, constructId: string, databaseName: string | undefined, proxy: DatabaseProxy): void;
7
+ export declare function addProxyCfnOutput(scope: Construct, constructId: string, databaseName: string, proxy: DatabaseProxy): void;
@@ -5,7 +5,7 @@ import { toPascalCase } from "../../../utils/capitaliseString.js";
5
5
  * Shared by RdsAurora and RdsInstance constructs.
6
6
  */
7
7
  export function addProxyCfnOutput(scope, constructId, databaseName, proxy) {
8
- const outputName = toPascalCase(databaseName || constructId);
8
+ const outputName = toPascalCase(databaseName);
9
9
  new CfnOutput(scope, `${outputName}ProxyEndpointOutput`, {
10
10
  key: `${outputName}ProxyEndpoint`,
11
11
  exportName: `${outputName}ProxyEndpoint`,
@@ -12,7 +12,7 @@ export class DelegationRole extends Construct {
12
12
  exportName;
13
13
  constructor(scope, id, props) {
14
14
  super(scope, id);
15
- const firstLabel = props.zoneName.split(".")[0] ?? "default";
15
+ const firstLabel = props.zoneName.split(".")[0];
16
16
  const safeFirstLabel = toPascalCase(firstLabel);
17
17
  const safeZone = toPascalCase(getSafeZoneName(props.zoneName));
18
18
  this.description =
@@ -0,0 +1,9 @@
1
+ import { Construct } from "constructs";
2
+ export interface GroupMembershipProps {
3
+ identityStoreId: string;
4
+ groupId: string;
5
+ userId: string;
6
+ }
7
+ export declare class GroupMembership extends Construct {
8
+ constructor(scope: Construct, id: string, props: GroupMembershipProps);
9
+ }
@@ -0,0 +1,12 @@
1
+ import { Construct } from "constructs";
2
+ import { CfnGroupMembership } from "aws-cdk-lib/aws-identitystore";
3
+ export class GroupMembership extends Construct {
4
+ constructor(scope, id, props) {
5
+ super(scope, id);
6
+ new CfnGroupMembership(this, "Membership", {
7
+ identityStoreId: props.identityStoreId,
8
+ groupId: props.groupId,
9
+ memberId: { userId: props.userId }
10
+ });
11
+ }
12
+ }
@@ -1,3 +1,4 @@
1
1
  export * from "./assignment.js";
2
2
  export * from "./group.js";
3
+ export * from "./groupMembership.js";
3
4
  export * from "./permissionSet.js";
@@ -1,3 +1,4 @@
1
1
  export * from "./assignment.js";
2
2
  export * from "./group.js";
3
+ export * from "./groupMembership.js";
3
4
  export * from "./permissionSet.js";
@@ -7,6 +7,7 @@ export declare class PermissionSet extends Construct {
7
7
  instanceArn: string;
8
8
  description?: string;
9
9
  managedPolicies?: string[];
10
+ sessionDuration?: string;
10
11
  tags?: KeyValue[];
11
12
  });
12
13
  getPermissionSetArn(): string;
@@ -9,6 +9,7 @@ export class PermissionSet extends Construct {
9
9
  instanceArn: props.instanceArn,
10
10
  description: props.description,
11
11
  managedPolicies: props.managedPolicies,
12
+ sessionDuration: props.sessionDuration,
12
13
  tags: props.tags?.map((t) => ({ key: t.key, value: t.value }))
13
14
  });
14
15
  }
@@ -1,13 +1,5 @@
1
- import { Stack, type StackProps } from "aws-cdk-lib";
2
1
  import * as Logs from "aws-cdk-lib/aws-logs";
3
2
  import { type Construct } from "constructs";
4
- interface LogGroupStackProps extends StackProps {
5
- logGroupName: string;
6
- }
7
3
  export declare class LogGroup extends Logs.LogGroup {
8
4
  constructor(scope: Construct, id: string, props?: Logs.LogGroupProps);
9
5
  }
10
- export declare class LogGroupStack extends Stack {
11
- constructor(scope: Construct, id: string, props: LogGroupStackProps);
12
- }
13
- export {};
@@ -1,17 +1,6 @@
1
- import { Stack } from "aws-cdk-lib";
2
1
  import * as Logs from "aws-cdk-lib/aws-logs";
3
2
  export class LogGroup extends Logs.LogGroup {
4
- constructor(scope, id, props) {
5
- super(scope, id, {
6
- ...props // https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.LogGroup
7
- });
8
- }
9
- }
10
- export class LogGroupStack extends Stack {
11
3
  constructor(scope, id, props) {
12
4
  super(scope, id, props);
13
- new LogGroup(this, id, {
14
- logGroupName: props.logGroupName
15
- });
16
5
  }
17
6
  }
@@ -0,0 +1,7 @@
1
+ import { CfnOutput } from "aws-cdk-lib";
2
+ import { Construct } from "constructs";
3
+ export declare class DefaultEventBus extends Construct {
4
+ readonly defaultEventBusName: CfnOutput;
5
+ readonly defaultEventBusArn: CfnOutput;
6
+ constructor(scope: Construct, id: string);
7
+ }
@@ -0,0 +1,21 @@
1
+ import { CfnOutput } from "aws-cdk-lib";
2
+ import { EventBus } from "aws-cdk-lib/aws-events";
3
+ import { Construct } from "constructs";
4
+ export class DefaultEventBus extends Construct {
5
+ defaultEventBusName;
6
+ defaultEventBusArn;
7
+ constructor(scope, id) {
8
+ super(scope, id);
9
+ const eventBridge = EventBus.fromEventBusName(this, "DefaultEventBus", "default");
10
+ this.defaultEventBusName = new CfnOutput(this, "DefaultEventBusNameOutput", {
11
+ key: "DefaultEventBusName",
12
+ value: eventBridge.eventBusName,
13
+ exportName: "DefaultEventBusName"
14
+ });
15
+ this.defaultEventBusArn = new CfnOutput(this, "DefaultEventBusArnOutput", {
16
+ key: "DefaultEventBusArn",
17
+ value: eventBridge.eventBusArn,
18
+ exportName: "DefaultEventBusArn"
19
+ });
20
+ }
21
+ }
@@ -0,0 +1,96 @@
1
+ import { Construct } from "constructs";
2
+ import { Duration } from "aws-cdk-lib";
3
+ import { type IRule, type Schedule, type EventPattern, type IEventBus } from "aws-cdk-lib/aws-events";
4
+ import { type IRole } from "aws-cdk-lib/aws-iam";
5
+ import type { ITopic } from "aws-cdk-lib/aws-sns";
6
+ import { SQSQueue } from "./sqs.js";
7
+ import { type EventBridgeTarget } from "./eventTargets.js";
8
+ import { type ScheduleAlarmThresholds } from "../monitoring/scheduleAlarms.js";
9
+ export type { ScheduleAlarmThresholds } from "../monitoring/scheduleAlarms.js";
10
+ /**
11
+ * Retry policy applied to the rule's target. Shared between Schedule and
12
+ * Subscription — exported so users constructing overrides have a typed entry.
13
+ */
14
+ export interface EventBridgeRetryPolicy {
15
+ maxEventAge?: Duration;
16
+ retryAttempts?: number;
17
+ }
18
+ /**
19
+ * Construction-time props for the shared EventBridgeRule base. Plumbing
20
+ * surface only — Schedule and Subscription wrap this with their own
21
+ * user-facing prop shape. Internal-only per D3 (not re-exported from
22
+ * the package entry).
23
+ */
24
+ export interface EventBridgeRuleProps {
25
+ /** Mutually exclusive with `eventPattern`. */
26
+ schedule?: Schedule;
27
+ /** Mutually exclusive with `schedule`. */
28
+ eventPattern?: EventPattern;
29
+ /** Drives default retry policy and description prefix. */
30
+ kind: "schedule" | "subscription";
31
+ /** Selected target (wrapper instance). The helper resolves the underlying CDK adapter. */
32
+ target: EventBridgeTarget;
33
+ /** SQS FIFO message group id; threaded down to `resolveTarget(...)`. */
34
+ messageGroupId?: string;
35
+ description?: string;
36
+ /**
37
+ * When `{ enabled: true }` provisions a sibling DLQ; otherwise honour the
38
+ * supplied queue. Typed against the resource-layer `SQSQueue` so the
39
+ * patterns-layer `QueueMessaging` (which extends `SQSQueue`) is still
40
+ * accepted without crossing the layer boundary.
41
+ */
42
+ deadLetterQueue?: {
43
+ enabled: true;
44
+ queue?: SQSQueue;
45
+ } | {
46
+ enabled: false;
47
+ } | SQSQueue;
48
+ retryPolicy?: EventBridgeRetryPolicy;
49
+ enabled?: boolean;
50
+ /** Custom IAM role for the rule's target. */
51
+ role?: IRole;
52
+ /** Cross-stack scope for the rule (deliberate D18(h) exception). */
53
+ crossStackScope?: Construct;
54
+ /** Bind the rule to a specific event bus (custom buses, not default). */
55
+ eventBus?: IEventBus;
56
+ /** Optional SNS topic for D13 alarms (FailedInvocations / ThrottledRules / DLQ failure / missed-tick). */
57
+ alertsTopic?: ITopic;
58
+ /** Suppress alarms even when `alertsTopic` is supplied. */
59
+ alarms?: boolean;
60
+ /** Tunable alarm thresholds (see `ScheduleAlarmThresholds`). */
61
+ alarmConfig?: ScheduleAlarmThresholds;
62
+ /** Application id for alarm tagging. */
63
+ applicationId?: string;
64
+ /** Cadence in ticks/hour for the missed-tick alarm; only for `kind: "schedule"` with rate expressions. */
65
+ expectedTicksPerHour?: number;
66
+ /**
67
+ * Optional JSON payload for the target adapter (D5 — typed as
68
+ * `Record<string, unknown>` at the EventBridge boundary). Threaded through
69
+ * `resolveTarget(...)` to the SDK adapter via `RuleTargetInput.fromObject(...)`.
70
+ * For schedule kinds, `scheduledAt: EventField.time` is auto-injected.
71
+ */
72
+ payload?: Record<string, unknown>;
73
+ }
74
+ /**
75
+ * Build the default description for a Schedule.
76
+ */
77
+ export declare function buildScheduleDescription(appName: string, id: string, scheduleExpression: string): string;
78
+ /**
79
+ * Build the default description for a Subscription.
80
+ */
81
+ export declare function buildSubscriptionDescription(appName: string, id: string): string;
82
+ /**
83
+ * Shared base wrapper for `aws-cdk-lib/aws-events.Rule`. Owns description,
84
+ * DLQ provisioning, KMS-grant on CMK-encrypted DLQs, retry-policy defaults,
85
+ * and RuleProps pass-through. Plumbing — never user-facing. Schedule and
86
+ * Subscription compose this; the public re-export carve-out withholds it
87
+ * from the package entry per D3.
88
+ */
89
+ export declare class EventBridgeRule extends Construct {
90
+ #private;
91
+ readonly id: string;
92
+ readonly deadLetterQueue?: SQSQueue;
93
+ constructor(scope: Construct, id: string, props: EventBridgeRuleProps);
94
+ getRule(): IRule;
95
+ getRuleArn(): string;
96
+ }
@@ -0,0 +1,110 @@
1
+ import { Construct } from "constructs";
2
+ import { Duration } from "aws-cdk-lib";
3
+ import { Rule } from "aws-cdk-lib/aws-events";
4
+ import { ServicePrincipal } from "aws-cdk-lib/aws-iam";
5
+ import { SQSQueue } from "./sqs.js";
6
+ import { resolveTarget } from "./eventTargets.js";
7
+ import { createScheduleAlarms } from "../monitoring/scheduleAlarms.js";
8
+ /**
9
+ * Build the default description for a Schedule.
10
+ */
11
+ export function buildScheduleDescription(appName, id, scheduleExpression) {
12
+ return `Schedule ${id} for ${appName} — fires ${scheduleExpression}`;
13
+ }
14
+ /**
15
+ * Build the default description for a Subscription.
16
+ */
17
+ export function buildSubscriptionDescription(appName, id) {
18
+ return `Subscription ${id} for ${appName}`;
19
+ }
20
+ /**
21
+ * Shared base wrapper for `aws-cdk-lib/aws-events.Rule`. Owns description,
22
+ * DLQ provisioning, KMS-grant on CMK-encrypted DLQs, retry-policy defaults,
23
+ * and RuleProps pass-through. Plumbing — never user-facing. Schedule and
24
+ * Subscription compose this; the public re-export carve-out withholds it
25
+ * from the package entry per D3.
26
+ */
27
+ export class EventBridgeRule extends Construct {
28
+ id;
29
+ deadLetterQueue;
30
+ #rule;
31
+ constructor(scope, id, props) {
32
+ super(scope, id);
33
+ this.id = id;
34
+ const dlq = this.#resolveOrProvisionDlq(id, props.deadLetterQueue);
35
+ if (dlq !== undefined)
36
+ this.deadLetterQueue = dlq;
37
+ grantKmsDecryptToEventBridge(dlq);
38
+ const retryPolicy = resolveRetryPolicy(props.kind, props.retryPolicy);
39
+ const targetAdapter = resolveTarget(props.target, {
40
+ retryPolicy,
41
+ deadLetterQueue: dlq?.getQueue(),
42
+ messageGroupId: props.messageGroupId,
43
+ payload: props.payload,
44
+ kind: props.kind
45
+ });
46
+ this.#rule = new Rule(this, `${id}Rule`, {
47
+ schedule: props.schedule,
48
+ eventPattern: props.eventPattern,
49
+ description: props.description,
50
+ enabled: props.enabled,
51
+ eventBus: props.eventBus,
52
+ role: props.role,
53
+ crossStackScope: props.crossStackScope,
54
+ targets: [targetAdapter]
55
+ });
56
+ provisionAlarms(this, id, props, this.#rule, dlq);
57
+ }
58
+ #resolveOrProvisionDlq(id, prop) {
59
+ if (prop === undefined)
60
+ return undefined;
61
+ if (prop instanceof SQSQueue)
62
+ return prop;
63
+ if (prop.enabled === false)
64
+ return undefined;
65
+ if ("queue" in prop && prop.queue !== undefined)
66
+ return prop.queue;
67
+ return new SQSQueue(this, `${id}Dlq`, {
68
+ queueType: "standard"
69
+ });
70
+ }
71
+ getRule() {
72
+ return this.#rule;
73
+ }
74
+ getRuleArn() {
75
+ return this.#rule.ruleArn;
76
+ }
77
+ }
78
+ function grantKmsDecryptToEventBridge(dlq) {
79
+ if (dlq === undefined)
80
+ return;
81
+ const key = dlq.getQueue().encryptionMasterKey;
82
+ if (key === undefined)
83
+ return;
84
+ key.grant(new ServicePrincipal("events.amazonaws.com"), "kms:Decrypt", "kms:GenerateDataKey");
85
+ }
86
+ function resolveRetryPolicy(kind, override) {
87
+ if (override !== undefined)
88
+ return override;
89
+ if (kind === "schedule") {
90
+ return { maxEventAge: Duration.minutes(15), retryAttempts: 2 };
91
+ }
92
+ return undefined;
93
+ }
94
+ function provisionAlarms(scope, id, props, rule, dlq) {
95
+ if (props.alertsTopic === undefined)
96
+ return;
97
+ if (props.alarms === false)
98
+ return;
99
+ createScheduleAlarms({
100
+ scope,
101
+ ruleName: id,
102
+ rule,
103
+ kind: props.kind,
104
+ expectedTicksPerHour: props.expectedTicksPerHour,
105
+ config: props.alarmConfig,
106
+ alarmTopic: props.alertsTopic,
107
+ applicationId: props.applicationId,
108
+ dlqEnabled: dlq !== undefined
109
+ });
110
+ }
@@ -0,0 +1,84 @@
1
+ import { type IRuleTarget } from "aws-cdk-lib/aws-events";
2
+ import type { IQueue } from "aws-cdk-lib/aws-sqs";
3
+ import type { IFunction } from "aws-cdk-lib/aws-lambda";
4
+ import type { ICluster, TaskDefinition } from "aws-cdk-lib/aws-ecs";
5
+ import { SQSQueue } from "./sqs.js";
6
+ import { EventBridgeBus } from "./eventbridge.js";
7
+ import { CodeBuildProject } from "../utilities/codeBuild.js";
8
+ import type { EventBridgeRetryPolicy } from "./eventBridgeRule.js";
9
+ interface LambdaComputeShape {
10
+ readonly computeType: "lambda";
11
+ getFunction(): IFunction | undefined;
12
+ }
13
+ interface EcsComputeShape {
14
+ getCluster(): ICluster;
15
+ getTaskDefinition(serviceName: string): TaskDefinition | undefined;
16
+ }
17
+ /**
18
+ * Small target-shape for ECS — callers pass the `EcsCompute` wrapper plus the
19
+ * service name (used to resolve the underlying task definition via the T3
20
+ * accessor at `ecs.ts:237`). `taskCount?` defaults to 1.
21
+ */
22
+ export interface EcsScheduleTarget {
23
+ ecs: EcsComputeShape;
24
+ serviceName: string;
25
+ taskCount?: number;
26
+ }
27
+ /**
28
+ * Public input type for `Schedule.target`. Callers pass wrapper INSTANCES
29
+ * directly (D2 dispatch convention) — no discriminator key. ECS uses the
30
+ * small shape above so the service name can be threaded through.
31
+ */
32
+ export type ScheduleTargetInput = SQSQueue | LambdaComputeShape | EcsScheduleTarget | EventBridgeBus;
33
+ /**
34
+ * Public input type for `Subscription.target`. Same dispatch convention as
35
+ * `ScheduleTargetInput`. Subscriptions accept `CodeBuildProject` (used by
36
+ * `EcrDefaultImage`) but not `EventBridgeBus` — bus-to-bus replication is
37
+ * not a subscription shape.
38
+ */
39
+ export type SubscriptionTargetInput = SQSQueue | LambdaComputeShape | EcsScheduleTarget | CodeBuildProject;
40
+ /**
41
+ * Internal resolve input — the union of every shape `resolveTarget(...)` can
42
+ * dispatch over. `Schedule` and `Subscription` narrow this at the public
43
+ * boundary before passing it down.
44
+ */
45
+ export type EventBridgeTarget = ScheduleTargetInput | SubscriptionTargetInput;
46
+ /**
47
+ * Options applied to every target adapter (retry policy, DLQ, FIFO message
48
+ * group). FIFO `messageGroupId` validation lives here so it cannot disagree
49
+ * between Schedule and Subscription (D14, single source). `IQueueMessaging`
50
+ * does not expose `fifo` directly — we reach through `target` to the raw
51
+ * `sqs.IQueue.fifo` as a deliberate plumbing leak per D18(i).
52
+ */
53
+ export interface ResolveTargetOptions {
54
+ retryPolicy?: EventBridgeRetryPolicy;
55
+ /** Already-resolved DLQ queue from the base wrapper. */
56
+ deadLetterQueue?: IQueue;
57
+ /** SQS FIFO message group id. Required for FIFO queue targets per D14. */
58
+ messageGroupId?: string;
59
+ /**
60
+ * Optional JSON payload for the target adapter (D5 — typed as
61
+ * `Record<string, unknown>` at the EventBridge boundary). Translates to
62
+ * `message` (SQS), `event` (Lambda / EventBus / CodeBuild), or `input`
63
+ * (ECS task) on the underlying adapter via `RuleTargetInput.fromObject(...)`.
64
+ * Values may be `EventField.*` tokens for payload-template substitution.
65
+ * For schedule-kind rules, `scheduledAt: EventField.time` is auto-injected
66
+ * unless the caller already provided a `scheduledAt` key.
67
+ */
68
+ payload?: Record<string, unknown>;
69
+ /**
70
+ * Drives schedule-only behaviour — currently the `scheduledAt: EventField.time`
71
+ * auto-injection on payload. Threaded down from `EventBridgeRuleProps.kind`.
72
+ */
73
+ kind?: "schedule" | "subscription";
74
+ }
75
+ /**
76
+ * Single source of truth for `aws-cdk-lib/aws-events-targets` adapter
77
+ * construction. Dispatches via `instanceof` against lower-layer Fjall wrapper
78
+ * classes (`SQSQueue`, `EventBridgeBus`, `CodeBuildProject`) and structural
79
+ * checks against the patterns-layer wrappers that would otherwise close an
80
+ * initialisation cycle. Internal helper — never exported from the package
81
+ * entry per D3.
82
+ */
83
+ export declare function resolveTarget(target: EventBridgeTarget, options: ResolveTargetOptions): IRuleTarget;
84
+ export {};
@@ -0,0 +1,152 @@
1
+ import { EventField, RuleTargetInput } from "aws-cdk-lib/aws-events";
2
+ import { SqsQueue as SqsTarget, LambdaFunction as LambdaTarget, EventBus as EventBusTarget, CodeBuildProject as CodeBuildTarget, EcsTask as EcsTaskTarget } from "aws-cdk-lib/aws-events-targets";
3
+ import { SQSQueue } from "./sqs.js";
4
+ import { EventBridgeBus } from "./eventbridge.js";
5
+ import { CodeBuildProject } from "../utilities/codeBuild.js";
6
+ function isEcsScheduleTarget(target) {
7
+ return (typeof target === "object" &&
8
+ target !== null &&
9
+ "ecs" in target &&
10
+ target.ecs !== null &&
11
+ typeof target.ecs === "object" &&
12
+ typeof target.ecs.getCluster === "function" &&
13
+ typeof target.ecs.getTaskDefinition ===
14
+ "function");
15
+ }
16
+ function isLambdaCompute(target) {
17
+ return (typeof target === "object" &&
18
+ target !== null &&
19
+ "computeType" in target &&
20
+ target.computeType === "lambda" &&
21
+ typeof target.getFunction === "function");
22
+ }
23
+ /**
24
+ * Build the `RuleTargetInput` that wraps the adapter-specific payload. For
25
+ * schedule-kind rules, auto-injects `scheduledAt: EventField.time` so consumers
26
+ * receive the actual EventBridge delivery timestamp without having to import
27
+ * `EventField` themselves. Subscriptions don't get the injection — the
28
+ * triggering event already carries timing, and `scheduledAt` would be
29
+ * misleading.
30
+ */
31
+ function buildTargetInput(payload, kind) {
32
+ if (kind === "schedule" && !("scheduledAt" in payload)) {
33
+ return RuleTargetInput.fromObject({
34
+ ...payload,
35
+ scheduledAt: EventField.time
36
+ });
37
+ }
38
+ return RuleTargetInput.fromObject(payload);
39
+ }
40
+ /**
41
+ * Single source of truth for `aws-cdk-lib/aws-events-targets` adapter
42
+ * construction. Dispatches via `instanceof` against lower-layer Fjall wrapper
43
+ * classes (`SQSQueue`, `EventBridgeBus`, `CodeBuildProject`) and structural
44
+ * checks against the patterns-layer wrappers that would otherwise close an
45
+ * initialisation cycle. Internal helper — never exported from the package
46
+ * entry per D3.
47
+ */
48
+ export function resolveTarget(target, options) {
49
+ const baseProps = {
50
+ retryAttempts: options.retryPolicy?.retryAttempts,
51
+ maxEventAge: options.retryPolicy?.maxEventAge,
52
+ deadLetterQueue: options.deadLetterQueue
53
+ };
54
+ const targetInput = options.payload !== undefined
55
+ ? buildTargetInput(options.payload, options.kind)
56
+ : undefined;
57
+ if (target instanceof SQSQueue) {
58
+ return resolveQueueTarget(target, options.messageGroupId, baseProps, targetInput);
59
+ }
60
+ if (target instanceof EventBridgeBus) {
61
+ return resolveEventBusTarget(target, options.messageGroupId, baseProps, targetInput);
62
+ }
63
+ if (target instanceof CodeBuildProject) {
64
+ return resolveCodeBuildTarget(target, options.messageGroupId, baseProps, targetInput);
65
+ }
66
+ if (isEcsScheduleTarget(target)) {
67
+ return resolveEcsTarget(target, options.messageGroupId, baseProps, targetInput);
68
+ }
69
+ if (isLambdaCompute(target)) {
70
+ return resolveLambdaTarget(target, options.messageGroupId, baseProps, targetInput);
71
+ }
72
+ throw new Error(`Unsupported event target: expected SQSQueue/QueueMessaging, LambdaCompute, EventBridgeBus/EventBusMessaging, CodeBuildProject, or { ecs: EcsCompute, serviceName }; received ${describeTarget(target)}`);
73
+ }
74
+ function resolveQueueTarget(target, messageGroupId, baseProps, targetInput) {
75
+ const queue = target.getQueue();
76
+ const isFifo = queue.fifo === true;
77
+ if (isFifo && messageGroupId === undefined) {
78
+ throw new Error("FIFO queue target requires messageGroupId; received undefined");
79
+ }
80
+ if (!isFifo && messageGroupId !== undefined) {
81
+ throw new Error("messageGroupId only applies to FIFO queue targets");
82
+ }
83
+ return new SqsTarget(queue, {
84
+ ...baseProps,
85
+ messageGroupId,
86
+ ...(targetInput !== undefined && { message: targetInput })
87
+ });
88
+ }
89
+ function resolveLambdaTarget(target, messageGroupId, baseProps, targetInput) {
90
+ rejectMessageGroupIdOnNonQueue("lambda", messageGroupId);
91
+ const fn = target.getFunction();
92
+ if (fn === undefined) {
93
+ throw new Error("LambdaCompute target has no function to wire; pass a LambdaCompute with a default function.");
94
+ }
95
+ return new LambdaTarget(fn, {
96
+ ...baseProps,
97
+ ...(targetInput !== undefined && { event: targetInput })
98
+ });
99
+ }
100
+ function resolveEcsTarget(target, messageGroupId, baseProps, targetInput) {
101
+ rejectMessageGroupIdOnNonQueue("ecs", messageGroupId);
102
+ // CDK's `EcsTask` event-target builds its own input from `containerOverrides`
103
+ // and silently ignores any caller-supplied `input` field on its props
104
+ // (`aws-cdk-lib/aws-events-targets/lib/ecs-task.js#bind` reassigns the local
105
+ // `input` variable from `this.createInput(rule)` before constructing the
106
+ // return value). Surface this as a clear error rather than a silent drop.
107
+ if (targetInput !== undefined) {
108
+ throw new Error("payload is not supported on ECS event targets — CDK's EcsTask adapter " +
109
+ "ignores arbitrary input. Use container command/environment overrides on " +
110
+ "the task definition instead.");
111
+ }
112
+ const cluster = target.ecs.getCluster();
113
+ const taskDefinition = target.ecs.getTaskDefinition(target.serviceName);
114
+ if (taskDefinition === undefined) {
115
+ throw new Error(`EcsCompute target has no service named '${target.serviceName}'`);
116
+ }
117
+ return new EcsTaskTarget({
118
+ ...baseProps,
119
+ cluster,
120
+ taskDefinition,
121
+ taskCount: target.taskCount
122
+ });
123
+ }
124
+ function resolveEventBusTarget(target, messageGroupId, baseProps, targetInput) {
125
+ rejectMessageGroupIdOnNonQueue("eventBus", messageGroupId);
126
+ return new EventBusTarget(target.getEventBus(), {
127
+ ...baseProps,
128
+ ...(targetInput !== undefined && { event: targetInput })
129
+ });
130
+ }
131
+ function resolveCodeBuildTarget(target, messageGroupId, baseProps, targetInput) {
132
+ rejectMessageGroupIdOnNonQueue("codeBuild", messageGroupId);
133
+ return new CodeBuildTarget(target.project, {
134
+ ...baseProps,
135
+ ...(targetInput !== undefined && { event: targetInput })
136
+ });
137
+ }
138
+ function rejectMessageGroupIdOnNonQueue(kind, messageGroupId) {
139
+ if (messageGroupId !== undefined) {
140
+ throw new Error(`messageGroupId only applies to FIFO queue targets; received on '${kind}' target`);
141
+ }
142
+ }
143
+ function describeTarget(target) {
144
+ if (target === null || target === undefined)
145
+ return String(target);
146
+ if (typeof target === "object") {
147
+ const ctor = target.constructor
148
+ ?.name;
149
+ return ctor ?? "object";
150
+ }
151
+ return typeof target;
152
+ }
@@ -1,13 +1,36 @@
1
1
  import { Construct } from "constructs";
2
2
  import { type IEventBus } from "aws-cdk-lib/aws-events";
3
3
  import { type IGrantable, type Grant } from "aws-cdk-lib/aws-iam";
4
+ import { type RemovalPolicyString } from "./utils.js";
4
5
  export interface EventBridgeBusProps {
5
6
  eventBusName?: string;
6
- removalPolicy?: "DESTROY" | "RETAIN";
7
+ /**
8
+ * App name used to build the default description when `description` is not
9
+ * supplied. Injected by `App.getEventBus()` (T7) — the wrapper does not
10
+ * derive this from `Stack.of(this).stackName` because stack names like
11
+ * `WebAppMessaging` don't match the app identity.
12
+ */
13
+ appName?: string;
14
+ /** Override the default description ("EventBus <appName> — Fjall app event bus"). */
15
+ description?: string;
16
+ /**
17
+ * Removal policy. Default resolves via the `env()` helper (production →
18
+ * RETAIN; non-prod → DESTROY) — D17 explicitly rejects `process.env.NODE_ENV`
19
+ * because it is not set during CDK synth in Fjall's deployment paths.
20
+ * Buses are recreatable in non-prod; production keeps history.
21
+ */
22
+ removalPolicy?: RemovalPolicyString;
23
+ /**
24
+ * Internal: when set, the wrapper holds the supplied imported bus as the
25
+ * underlying handle and does NOT create a new `AWS::Events::EventBus`
26
+ * resource. Bus-level mutations (description, removalPolicy, CfnOutputs)
27
+ * are skipped. Used by `EventBusMessaging.fromEventBusArn(...)` per D19.
28
+ */
29
+ importedBus?: IEventBus;
7
30
  }
8
31
  export declare class EventBridgeBus extends Construct {
32
+ #private;
9
33
  readonly id: string;
10
- private eventBus;
11
34
  constructor(scope: Construct, id: string, props: EventBridgeBusProps);
12
35
  /**
13
36
  * Get the event bus ARN.