App¶
An App is the root of every cdkx program. It owns the construct tree, drives the synthesis pipeline, and writes the cloud assembly to disk.
What it does¶
- Acts as the parent scope for all
Stackinstances - Caches one resolver pipeline per provider (built lazily on first use)
- When
app.synth()is called, it traverses all stacks, synthesizes each one, and writesmanifest.json
Basic usage¶
| src/main.ts | |
|---|---|
- Creates the root of the construct tree.
outdirdefaults tocdkx.out/relative to the working directory. - Stacks are added as direct children of the App.
- Triggers synthesis — writes all stack files and
manifest.json. Must be the last call in every entrypoint.
Custom output directory¶
Global resolvers¶
Resolvers transform token values during synthesis (e.g. turning a SecretRef into a provider-specific string). Global resolvers run before any provider-specific resolver — useful for cross-provider tokens:
Constructor props¶
| Prop | Type | Default | Description |
|---|---|---|---|
outdir |
string |
'cdkx.out' |
Output directory for the cloud assembly |
resolvers |
IResolver[] |
[] |
Global resolvers prepended to every stack's pipeline |
Static helpers¶
// Walk up the construct tree to find the root App. Throws if the construct
// is not rooted in an App.
const app = App.of(someNestedConstruct);
// Type guard
App.isApp(x); // true | false
What app.synth() produces¶
cdkx.out/
├── manifest.json # index of all stacks and their artifact IDs
├── MyStack.json # synthesized resources for MyStack
└── OtherStack.json # synthesized resources for OtherStack
See Cloud Assembly for the full output format.
See also
- Stack — a deployment unit that lives inside an App
- Cloud Assembly — what
app.synth()writes to disk - Tokens — how cross-resource references are resolved during synthesis