@composurecdk/cloudformation 0.1.3 → 0.3.2

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 (2) hide show
  1. package/README.md +107 -0
  2. package/package.json +6 -6
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # @composurecdk/cloudformation
2
+
3
+ CloudFormation builders for [ComposureCDK](../../README.md).
4
+
5
+ This package provides a fluent builder for CloudFormation Stacks, convenience stack strategies, and a post-build hook for creating CloudFormation outputs from composed systems.
6
+
7
+ ## Stack Builder
8
+
9
+ ```ts
10
+ import { createStackBuilder } from "@composurecdk/cloudformation";
11
+
12
+ const { stack } = createStackBuilder()
13
+ .description("Network infrastructure")
14
+ .terminationProtection(true)
15
+ .build(app, "NetworkStack");
16
+ ```
17
+
18
+ Every [StackProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.StackProps.html) property is available as a fluent setter on the builder.
19
+
20
+ ### Tags
21
+
22
+ Add tags that propagate to all resources within the stack:
23
+
24
+ ```ts
25
+ const { stack } = createStackBuilder()
26
+ .tag("team", "platform")
27
+ .tag("environment", "production")
28
+ .build(app, "ServiceStack");
29
+ ```
30
+
31
+ ### Scope factory
32
+
33
+ Convert a configured builder into a `ScopeFactory` for use with stack strategies:
34
+
35
+ ```ts
36
+ const factory = createStackBuilder()
37
+ .terminationProtection(true)
38
+ .tag("team", "platform")
39
+ .toScopeFactory();
40
+
41
+ compose({ ... }, { ... })
42
+ .withStackStrategy(singleStack(factory))
43
+ .build(app, "MySystem");
44
+ ```
45
+
46
+ ## Stack Strategies
47
+
48
+ Convenience wrappers around `@composurecdk/core`'s strategy primitives that default to creating Stacks via `createStackBuilder`. Pass an optional `ScopeFactory` to customise the Stack configuration.
49
+
50
+ ### singleStack
51
+
52
+ Places all components in a single auto-created Stack:
53
+
54
+ ```ts
55
+ import { singleStack } from "@composurecdk/cloudformation";
56
+
57
+ compose({ handler, api }, { handler: [], api: ["handler"] })
58
+ .withStackStrategy(singleStack())
59
+ .build(app, "MySystem");
60
+ ```
61
+
62
+ ### groupedStacks
63
+
64
+ Groups components into named Stacks by a classifier function:
65
+
66
+ ```ts
67
+ import { groupedStacks } from "@composurecdk/cloudformation";
68
+
69
+ compose({ handler, api, table }, { ... })
70
+ .withStackStrategy(
71
+ groupedStacks((key) => (key === "table" ? "persistence" : "service")),
72
+ )
73
+ .build(app, "MySystem");
74
+ ```
75
+
76
+ ## outputs
77
+
78
+ A post-build hook that creates CloudFormation stack outputs from a composed system's build results. Output values can be concrete strings or `Ref`s that resolve against the system's results.
79
+
80
+ ```ts
81
+ import { compose, ref } from "@composurecdk/core";
82
+ import { outputs } from "@composurecdk/cloudformation";
83
+
84
+ compose(
85
+ { site: createBucketBuilder(), cdn: createDistributionBuilder() },
86
+ { site: [], cdn: ["site"] },
87
+ )
88
+ .afterBuild(
89
+ outputs({
90
+ DistributionUrl: {
91
+ value: ref("cdn", (r) => `https://${r.distribution.distributionDomainName}`),
92
+ description: "CloudFront distribution URL",
93
+ },
94
+ BucketName: {
95
+ value: ref("site", (r) => r.bucket.bucketName),
96
+ description: "S3 bucket name for site content",
97
+ },
98
+ }),
99
+ )
100
+ .build(stack, "StaticWebsite");
101
+ ```
102
+
103
+ ## Examples
104
+
105
+ - [MultiStackApp](../examples/src/multi-stack-app.ts) — REST API + Lambda split across stacks via `.withStacks()`
106
+ - [StrategyStackApp](../examples/src/strategy-stack-app.ts) — REST API + Lambda split across stacks via `.withStackStrategy()`
107
+ - [StaticWebsiteStack](../examples/src/static-website/app.ts) — CloudFormation outputs with `afterBuild` and `outputs`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composurecdk/cloudformation",
3
- "version": "0.1.3",
3
+ "version": "0.3.2",
4
4
  "description": "Composable CloudFormation stack builder and stack assignment strategies",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,15 +35,15 @@
35
35
  },
36
36
  "type": "module",
37
37
  "peerDependencies": {
38
- "@composurecdk/core": "^0.1.0",
38
+ "@composurecdk/core": "^0.3.0",
39
39
  "aws-cdk-lib": "^2.0.0",
40
40
  "constructs": "^10.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@types/node": "^25.5.0",
44
- "aws-cdk-lib": "^2.245.0",
43
+ "@types/node": "^25.6.0",
44
+ "aws-cdk-lib": "^2.250.0",
45
45
  "constructs": "^10.6.0",
46
- "typescript": "^6.0.2",
47
- "vitest": "^4.1.2"
46
+ "typescript": "^6.0.3",
47
+ "vitest": "^4.1.4"
48
48
  }
49
49
  }