@fjall/components-infrastructure 0.86.0 → 0.87.3

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 (112) hide show
  1. package/README.md +3 -3
  2. package/dist/lib/app.d.ts +166 -6
  3. package/dist/lib/app.js +212 -20
  4. package/dist/lib/aspects/resourceInventory.d.ts +4 -4
  5. package/dist/lib/aspects/resourceInventory.js +3 -3
  6. package/dist/lib/config/aws/backupGlobalSettings.js +1 -2
  7. package/dist/lib/config/aws/identityCenter.js +1 -5
  8. package/dist/lib/config/aws/organisation.js +1 -4
  9. package/dist/lib/index.d.ts +1 -0
  10. package/dist/lib/index.js +7 -1
  11. package/dist/lib/patterns/aws/buildkite.js +3 -2
  12. package/dist/lib/patterns/aws/cdn.d.ts +164 -0
  13. package/dist/lib/patterns/aws/cdn.js +264 -0
  14. package/dist/lib/patterns/aws/compute.d.ts +278 -59
  15. package/dist/lib/patterns/aws/compute.js +384 -188
  16. package/dist/lib/patterns/aws/connections.d.ts +46 -0
  17. package/dist/lib/patterns/aws/connections.js +159 -0
  18. package/dist/lib/patterns/aws/database.d.ts +124 -11
  19. package/dist/lib/patterns/aws/database.js +188 -66
  20. package/dist/lib/patterns/aws/hostedZone.js +1 -1
  21. package/dist/lib/patterns/aws/index.d.ts +3 -0
  22. package/dist/lib/patterns/aws/index.js +4 -1
  23. package/dist/lib/patterns/aws/interfaces/compute.d.ts +121 -0
  24. package/dist/lib/patterns/aws/interfaces/compute.js +48 -0
  25. package/dist/lib/patterns/aws/interfaces/connector.d.ts +183 -0
  26. package/dist/lib/patterns/aws/interfaces/connector.js +117 -0
  27. package/dist/lib/patterns/aws/interfaces/database.d.ts +136 -0
  28. package/dist/lib/patterns/aws/interfaces/database.js +65 -0
  29. package/dist/lib/patterns/aws/interfaces/index.d.ts +12 -0
  30. package/dist/lib/patterns/aws/interfaces/index.js +49 -0
  31. package/dist/lib/patterns/aws/interfaces/messaging.d.ts +146 -0
  32. package/dist/lib/patterns/aws/interfaces/messaging.js +56 -0
  33. package/dist/lib/patterns/aws/interfaces/pattern.d.ts +403 -0
  34. package/dist/lib/patterns/aws/interfaces/pattern.js +36 -0
  35. package/dist/lib/patterns/aws/interfaces/storage.d.ts +136 -0
  36. package/dist/lib/patterns/aws/interfaces/storage.js +48 -0
  37. package/dist/lib/patterns/aws/messaging.d.ts +183 -0
  38. package/dist/lib/patterns/aws/messaging.js +239 -0
  39. package/dist/lib/patterns/aws/network.js +4 -4
  40. package/dist/lib/patterns/aws/pattern.d.ts +67 -0
  41. package/dist/lib/patterns/aws/pattern.js +69 -0
  42. package/dist/lib/patterns/aws/payload.d.ts +87 -0
  43. package/dist/lib/patterns/aws/payload.js +526 -0
  44. package/dist/lib/patterns/aws/storage.d.ts +127 -15
  45. package/dist/lib/patterns/aws/storage.js +234 -38
  46. package/dist/lib/resources/aws/backup/backupPlan.js +1 -6
  47. package/dist/lib/resources/aws/backup/backupVault.js +1 -2
  48. package/dist/lib/resources/aws/base/awsStack.d.ts +0 -2
  49. package/dist/lib/resources/aws/base/awsStack.js +1 -7
  50. package/dist/lib/resources/aws/cdn/cloudFront.d.ts +71 -0
  51. package/dist/lib/resources/aws/cdn/cloudFront.js +176 -0
  52. package/dist/lib/resources/aws/cdn/index.d.ts +1 -0
  53. package/dist/lib/resources/aws/cdn/index.js +18 -0
  54. package/dist/lib/resources/aws/compute/ec2.d.ts +5 -0
  55. package/dist/lib/resources/aws/compute/ec2.js +33 -6
  56. package/dist/lib/resources/aws/compute/ecs.d.ts +32 -25
  57. package/dist/lib/resources/aws/compute/ecs.js +31 -115
  58. package/dist/lib/resources/aws/compute/lambda.d.ts +94 -5
  59. package/dist/lib/resources/aws/compute/lambda.js +209 -32
  60. package/dist/lib/resources/aws/database/database.js +1 -1
  61. package/dist/lib/resources/aws/database/dynamodb.d.ts +70 -0
  62. package/dist/lib/resources/aws/database/dynamodb.js +181 -0
  63. package/dist/lib/resources/aws/database/index.d.ts +1 -0
  64. package/dist/lib/resources/aws/database/index.js +2 -1
  65. package/dist/lib/resources/aws/database/migrationLambda.d.ts +80 -0
  66. package/dist/lib/resources/aws/database/migrationLambda.js +119 -0
  67. package/dist/lib/resources/aws/database/rdsAurora.d.ts +15 -0
  68. package/dist/lib/resources/aws/database/rdsAurora.js +41 -18
  69. package/dist/lib/resources/aws/database/rdsAuroraGlobal.js +12 -8
  70. package/dist/lib/resources/aws/database/rdsInstance.js +2 -2
  71. package/dist/lib/resources/aws/index.d.ts +2 -0
  72. package/dist/lib/resources/aws/index.js +3 -1
  73. package/dist/lib/resources/aws/messaging/eventbridge.d.ts +28 -0
  74. package/dist/lib/resources/aws/messaging/eventbridge.js +53 -0
  75. package/dist/lib/resources/aws/messaging/index.d.ts +3 -0
  76. package/dist/lib/resources/aws/messaging/index.js +20 -0
  77. package/dist/lib/resources/aws/messaging/sns.d.ts +35 -0
  78. package/dist/lib/resources/aws/messaging/sns.js +70 -0
  79. package/dist/lib/resources/aws/messaging/sqs.d.ts +105 -0
  80. package/dist/lib/resources/aws/messaging/sqs.js +231 -0
  81. package/dist/lib/resources/aws/messaging/utils.d.ts +3 -0
  82. package/dist/lib/resources/aws/messaging/utils.js +7 -0
  83. package/dist/lib/resources/aws/networking/ipam.js +1 -2
  84. package/dist/lib/resources/aws/networking/ipamPool.js +3 -2
  85. package/dist/lib/resources/aws/networking/vpc.js +1 -2
  86. package/dist/lib/resources/aws/storage/ecr.js +8 -5
  87. package/dist/lib/resources/aws/storage/s3.js +1 -2
  88. package/dist/lib/resources/aws/utilities/awsCustomResource.js +1 -1
  89. package/dist/lib/resources/aws/utilities/customResource.js +1 -1
  90. package/dist/lib/utils/getConfig.js +3 -2
  91. package/dist/lib/utils/index.d.ts +1 -0
  92. package/dist/lib/utils/index.js +2 -1
  93. package/dist/lib/utils/manifestWriter.d.ts +174 -0
  94. package/dist/lib/utils/manifestWriter.js +233 -0
  95. package/dist/lib/utils/standardTagsAspect.js +1 -8
  96. package/dist/lib/utils/validationLogger.d.ts +34 -0
  97. package/dist/lib/utils/validationLogger.js +83 -0
  98. package/package.json +3 -3
  99. package/dist/lib/__tests__/setup.d.ts +0 -48
  100. package/dist/lib/__tests__/setup.js +0 -1
  101. package/dist/lib/patterns/aws/cicdRole.d.ts +0 -67
  102. package/dist/lib/patterns/aws/cicdRole.js +0 -68
  103. package/dist/lib/resources/aws/cicd/cicdRole.d.ts +0 -65
  104. package/dist/lib/resources/aws/cicd/cicdRole.js +0 -191
  105. package/dist/lib/resources/aws/compute/ecsFreeTier.d.ts +0 -75
  106. package/dist/lib/resources/aws/compute/ecsFreeTier.js +0 -1
  107. package/dist/lib/resources/aws/compute/ecsSpot.d.ts +0 -75
  108. package/dist/lib/resources/aws/compute/ecsSpot.js +0 -1
  109. package/dist/lib/resources/aws/compute/utilities/capacityProviderDrainWaiter.d.ts +0 -20
  110. package/dist/lib/resources/aws/compute/utilities/capacityProviderDrainWaiter.js +0 -1
  111. package/dist/lib/resources/aws/utilities/cfnOutput.d.ts +0 -5
  112. package/dist/lib/resources/aws/utilities/cfnOutput.js +0 -1
package/README.md CHANGED
@@ -26,7 +26,7 @@ When a VPC is created in the same stack resources that rely on it will automatic
26
26
  ```typescript
27
27
  new AwsStack(`${id}App`)
28
28
  .addNetwork(FjallVpc.build(`${id}Vpc`))
29
- .addResource(Fargate.build(`${id}Fargate`));
29
+ .addConstruct(Fargate.build(`${id}Fargate`));
30
30
  ```
31
31
 
32
32
  2. In the same CDK Application but different stack
@@ -41,7 +41,7 @@ const vpcStack = new AwsStack(`${id}Network`).addNetwork(
41
41
 
42
42
  const newStack = new AwsStack(`${id}Compute`, { dependencies: [vpcStack] })
43
43
  .addNetwork(vpcStack.getNetwork())
44
- .addResource(Fargate.build(`${id}Fargate`));
44
+ .addConstruct(Fargate.build(`${id}Fargate`));
45
45
  ```
46
46
 
47
47
  3. Different CDK Applications
@@ -64,7 +64,7 @@ const newStack = new AwsStack(`${id}Compute`, {
64
64
  dependencies: [vpcStack]
65
65
  })
66
66
  .addNetwork(FjallVpc.import(`${id}Vpc`, `${id}Network`))
67
- .addResource(Fargate.build(`${id}Fargate`));
67
+ .addConstruct(Fargate.build(`${id}Fargate`));
68
68
  ```
69
69
 
70
70
  ## Publishing package to npm
package/dist/lib/app.d.ts CHANGED
@@ -5,9 +5,15 @@ import { type IVpc } from "aws-cdk-lib/aws-ec2";
5
5
  import { type Role } from "aws-cdk-lib/aws-iam";
6
6
  import { AwsStack } from "./resources";
7
7
  import { type Ecr } from "./resources/aws/storage/ecr";
8
- import { type Database } from "./patterns/aws/database";
8
+ import { type AnyDatabase } from "./patterns/aws/database";
9
9
  import { type INetworkProps, type Network } from "./patterns/aws/network";
10
+ import { type Cdn } from "./patterns/aws/cdn";
11
+ import { type AnyMessaging } from "./patterns/aws/messaging";
12
+ import { type AnyCompute } from "./patterns/aws/compute";
13
+ import { type AnyStorage } from "./patterns/aws/storage";
14
+ import { type AnyPattern } from "./patterns/aws/pattern";
10
15
  import { type ResourceInventory } from "./aspects/resourceInventory";
16
+ import { type ManifestCollector } from "./utils/manifestWriter";
11
17
  /**
12
18
  * Configuration options for App.getApp().
13
19
  *
@@ -57,6 +63,7 @@ export declare class App extends CdkApp {
57
63
  private globalTags;
58
64
  private aspectApplied;
59
65
  private resourceInventory;
66
+ private manifestCollector;
60
67
  private constructor();
61
68
  /**
62
69
  * Initialise the network (VPC) for this application.
@@ -131,6 +138,25 @@ export declare class App extends CdkApp {
131
138
  * @returns {AwsStack}
132
139
  */
133
140
  getDefaultStorageStack(): AwsStack;
141
+ /**
142
+ * Retrieve default CDN stack - named as `${this.name}Cdn`
143
+ *
144
+ * Depends on Network. Compute/Storage dependencies are added automatically
145
+ * by CDK when CDN resources reference ALB or S3 bucket resources.
146
+ *
147
+ * @returns {AwsStack}
148
+ */
149
+ getDefaultCdnStack(): AwsStack;
150
+ /**
151
+ * Retrieve default messaging stack - named as `${this.name}Messaging`
152
+ *
153
+ * Used for SQS queues, SNS topics, and EventBridge event buses.
154
+ * Depends on Network only. These are regional services that don't
155
+ * require VPC, but we maintain consistent stack dependency patterns.
156
+ *
157
+ * @returns {AwsStack}
158
+ */
159
+ getDefaultMessagingStack(): AwsStack;
134
160
  /**
135
161
  * Get a VPC by name. If no name is provided, returns the default VPC.
136
162
  *
@@ -187,21 +213,150 @@ export declare class App extends CdkApp {
187
213
  * Add a compute resource to the default compute stack using the factory pattern.
188
214
  * Automatically creates monitoring role if not already created.
189
215
  *
190
- * Supports ComputeFactory (ECS, EC2, Lambda).
216
+ * Returns the appropriate compute type based on the factory configuration:
217
+ * - EcsCompute for type: "ecs"
218
+ * - LambdaCompute for type: "lambda"
219
+ * - Ec2Compute for type: "ec2"
220
+ *
221
+ * @example
222
+ * // ECS compute - returns EcsCompute
223
+ * const api = app.addCompute(ComputeFactory.build("Api", {
224
+ * type: "ecs",
225
+ * services: [{ name: "api", ... }]
226
+ * }));
227
+ * api.getLoadBalancer(); // Available on EcsCompute
228
+ *
229
+ * @example
230
+ * // Lambda compute - returns LambdaCompute
231
+ * const worker = app.addCompute(ComputeFactory.build("Worker", {
232
+ * type: "lambda",
233
+ * functions: [{ name: "process", ... }]
234
+ * }));
235
+ * worker.getFunction("process"); // Available on LambdaCompute
191
236
  */
192
- addCompute<T extends Construct>(fn: (app: App, scope: Construct) => T): T;
237
+ addCompute<T extends AnyCompute>(fn: (app: App, scope: Construct) => T): T;
193
238
  /**
194
239
  * Manually add a resource to the default compute stack.
195
240
  */
196
241
  addComputeResource(resource: Construct): void;
197
242
  /**
198
243
  * Add a database resource to the default database stack using the factory pattern.
244
+ * Returns the appropriate database type based on the factory used.
245
+ *
246
+ * @example
247
+ * // Aurora database - returns RelationalDatabase
248
+ * const db = app.addDatabase(DatabaseFactory.build("Main", {
249
+ * type: "Aurora",
250
+ * databaseName: "myapp"
251
+ * }));
252
+ * db.getHostEndpoint(); // Available
253
+ *
254
+ * @example
255
+ * // DynamoDB table - returns DynamoDBDatabase
256
+ * const cache = app.addDatabase(DatabaseFactory.build("Cache", {
257
+ * type: "DynamoDB",
258
+ * partitionKey: { name: "id", type: "S" }
259
+ * }));
260
+ * cache.getTableName(); // Available
199
261
  */
200
- addDatabase(fn: (app: App, scope: Construct) => Construct): Database;
262
+ addDatabase<T extends AnyDatabase>(fn: (app: App, scope: Construct) => T): T;
201
263
  /**
202
264
  * Add a storage resource (S3) to the default storage stack using the factory pattern.
265
+ *
266
+ * Returns the appropriate storage type based on the factory configuration:
267
+ * - PrivateStorage for bucketType: "private"
268
+ * - WebsiteStorage for bucketType: "website"
269
+ * - PublicStorage for bucketType: "publicRead"
270
+ *
271
+ * @example
272
+ * // Private storage - returns PrivateStorage
273
+ * const assets = app.addStorage(StorageFactory.build("Assets", {
274
+ * bucketType: "private"
275
+ * }));
276
+ * assets.grantPublicAccess("public/*"); // Available on PrivateStorage
277
+ *
278
+ * @example
279
+ * // Website storage - returns WebsiteStorage
280
+ * const site = app.addStorage(StorageFactory.build("Site", {
281
+ * bucketType: "website"
282
+ * }));
283
+ * site.getWebsiteUrl(); // Available on WebsiteStorage
203
284
  */
204
- addStorage(fn: (app: App, scope: Construct) => Construct): Construct;
285
+ addStorage<T extends AnyStorage>(fn: (app: App, scope: Construct) => T): T;
286
+ /**
287
+ * Add a CDN resource (CloudFront) to the default CDN stack using the factory pattern.
288
+ *
289
+ * @example
290
+ * // S3 origin
291
+ * const assets = app.addStorage(StorageFactory.build("Assets", { bucketType: "private" }));
292
+ * app.addCdn(CdnFactory.build("AssetsCdn", {
293
+ * originType: "s3",
294
+ * bucket: assets
295
+ * }));
296
+ *
297
+ * @example
298
+ * // ALB origin (ECS)
299
+ * const api = app.addCompute(ComputeFactory.build("Api", { type: "ecs", ... }));
300
+ * app.addCdn(CdnFactory.build("ApiCdn", {
301
+ * originType: "alb",
302
+ * loadBalancer: api
303
+ * }));
304
+ */
305
+ addCdn(fn: (app: App, scope: Construct) => Cdn): Cdn;
306
+ /**
307
+ * Add a messaging resource to the default queue stack using the factory pattern.
308
+ *
309
+ * Returns the appropriate messaging type based on the factory configuration.
310
+ * Currently supports queue (SQS), with future support planned for
311
+ * topic (SNS), eventbus (EventBridge), and stream (Kinesis).
312
+ *
313
+ * @example
314
+ * // Queue messaging - returns QueueMessaging
315
+ * const notifications = app.addMessaging(MessagingFactory.build("Notifications", {
316
+ * type: "queue",
317
+ * queueType: "standard",
318
+ * deadLetterQueue: { enabled: true, maxReceiveCount: 3 }
319
+ * }));
320
+ * notifications.grantSendMessages(apiFunction);
321
+ *
322
+ * @example
323
+ * // FIFO queue for OpenNext revalidation
324
+ * const revalidation = app.addMessaging(MessagingFactory.build("Revalidation", {
325
+ * type: "queue",
326
+ * queueType: "fifo",
327
+ * visibilityTimeout: 300,
328
+ * contentBasedDeduplication: true
329
+ * }));
330
+ */
331
+ addMessaging<T extends AnyMessaging>(fn: (app: App, scope: Construct) => T): T;
332
+ /**
333
+ * Add a high-level infrastructure pattern to the application.
334
+ *
335
+ * Patterns are composite constructs that create multiple related resources
336
+ * as a single, cohesive unit. They encapsulate best practices and reduce
337
+ * boilerplate for common deployment scenarios.
338
+ *
339
+ * Currently supported patterns:
340
+ * - `payload`: Payload CMS deployment with OpenNext
341
+ *
342
+ * Returns the appropriate pattern interface based on the factory configuration,
343
+ * providing access to all underlying resources via escape hatches.
344
+ *
345
+ * @example
346
+ * // Payload CMS pattern - returns Payload
347
+ * const payload = app.addPattern(PatternFactory.build("PayloadApp", {
348
+ * type: "payload",
349
+ * name: "my-cms",
350
+ * source: "../.."
351
+ * }));
352
+ *
353
+ * @example
354
+ * // Escape hatches - access underlying resources
355
+ * payload.getDatabase().grantConnect(otherLambda);
356
+ * payload.getServer().getLambdaFunction().addEnvironment("CUSTOM", "value");
357
+ * payload.getCdn().getDistribution().addBehavior("/custom/*", customOrigin);
358
+ */
359
+ addPattern<T extends AnyPattern>(fn: (app: App, scope: Construct) => T): T;
205
360
  /**
206
361
  * Add an additional network (VPC) to the application.
207
362
  *
@@ -254,7 +409,12 @@ export declare class App extends CdkApp {
254
409
  */
255
410
  exportResourceInventory(): ResourceInventory;
256
411
  /**
257
- * Override synth to automatically export resource inventory
412
+ * Get the manifest collector for registering services and patterns.
413
+ * Used by ComputeFactory and PatternFactory to register their configurations.
414
+ */
415
+ getManifestCollector(): ManifestCollector;
416
+ /**
417
+ * Override synth to automatically export resource inventory and manifest
258
418
  */
259
419
  synth(options?: StageSynthesisOptions): CloudAssembly;
260
420
  }