You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/instructions/languages/cdk.instructions.md
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,40 @@ This file provides instructions for generating, reviewing, and maintaining AWS C
23
23
- Suppress warnings with `nagSuppressions.ts` only when justified and documented
24
24
- Use `bin/` for entrypoint apps, `constructs/` for reusable components, and `stacks/` for stack definitions
25
25
- Prefer `props` interfaces for construct configuration
26
+
- For Step Functions definitions, prefer a chain-centric style where states are defined inline within `Chain.start(...).next(...)` so the execution flow reads top-to-bottom in one place. Avoid mixing a chain with many separately declared state `const`s; instead embed calls to helper functions directly in the chain when needed.
27
+
- For Step Functions chain formatting, place `.start`, `.next`, `.when`, and `.otherwise` on their own lines, and give helper calls such as `.jsonata(...)` the same line-break weight so nested flow blocks are visually aligned and easy to scan.
28
+
- For construct props that group resources (for example lambda functions or state machines), prefer explicit named object shapes (e.g. `{status: TypescriptLambdaFunction}`) over generic index signatures or broad maps so consumers are strongly typed to only the supported resources.
29
+
- For construct props that consume grouped resources, prefer inline explicit object shapes in the props contract (for example `functions: { status: TypescriptLambdaFunction }`) over `Pick<...>` or generic map types.
@@ -88,11 +123,26 @@ export class CptsApiAppStack extends Stack {
88
123
- Prefer VPC endpoints for private connectivity
89
124
- Minimize resource creation in test environments
90
125
126
+
## Unit Testing
127
+
128
+
- Write unit tests for CDK stacks and constructs using synthesis-based assertions.
129
+
- Prefer in-process tests that instantiate CDK `App` and `Stack` objects directly and assert on synthesized templates.
130
+
- Keep assertions light-touch and stable, such as resource counts and a small number of important properties.
131
+
- Avoid mocking AWS resources or writing tests that attempt to exercise live AWS behaviour.
132
+
- CDK constructs suitable for reuse should be placed in `eps-cdk-utils` repo.
133
+
- Do not test AWS implementation details owned by the CDK library. Test the resources and properties your code is responsible for declaring.
134
+
135
+
### Recommended Test Styles
136
+
137
+
- Smoke tests for `bin/` files: execute the entrypoint and assert that synthesis completes without throwing.
138
+
- In-process synth tests for stacks and constructs: instantiate the stack directly and assert resource counts or key CloudFormation properties with `Template.fromStack(...)`.
0 commit comments