aws / aws/aws-cdk-cli

(watch) `cdk watch` hangs indefinitely (no error) on a stack with a `CfnParameter` that has no default

Open
#1,648 0 comments 0 reactions 0 assignees View on GitHub
aws-cdk p1
Dominant language
TypeScript
Stars
105
Forks
122
Avg merge
1d 17h
Merged PRs (30d)
71

Description

### Summary

`cdk watch` hangs indefinitely — with no error, progress, or fallback — when a watched stack declares a `CfnParameter` that has no `default`. The hotswap template evaluator can't resolve the parameter, and instead of erroring or falling back, watch silently sits at `deploying...` forever.

**Environment**
- `aws-cdk` (CLI): `2.1128.0` (build 7daa104)
- `aws-cdk-lib`: `2.258.1`
- node: `v24.12.0`
- OS: macOS `26.5.1` (Darwin)

### Reproduction

A stack that declares a parameter without a `default`, plus a hotswappable resource:

```ts
new cdk.CfnParameter(this, 'Foo', { type: 'String' }); // no default
new lambda.Function(this, 'Fn', { /* inline code */ });
```

`cdk watch` (after the stack already exists, so watch attempts a hotswap) prints `MyStack: deploying...` and then **hangs forever** — no progress, no error, no hotswap, no fallback. CPU idle, no network.

- `cdk deploy --hotswap MyStack` of the **same** stack does **not** hang.
- Adding `default: ''` to the parameter, or removing the parameter, fixes the hang.
- Passing `--parameters` does **not** help (hotswap's read-only template evaluation appears to resolve from template defaults, not CLI `--parameters`).

### Analysis

This looks like the hotswap template evaluator failing to resolve a parameter with no default (cf. [aws/aws-cdk#22323](https://github.com/aws/aws-cdk/issues/22323)), but in `watch` it manifests as a silent infinite hang rather than an error or fallback.

### Expected

Error out (or fall back to a full CloudFormation deployment), not hang silently.

### Workaround

Give every `CfnParameter` a `default` so the hotswap evaluator can resolve it; the real value is still supplied at deploy via `--parameters` (which overrides the default), and `cdk deploy` falls back correctly when there's a non-hotswappable change:

```ts
new cdk.CfnParameter(this, 'Foo', { type: 'String', default: '' }); // unblocks watch
```

Better still (AWS [recommends against `CfnParameter` with CDK](https://docs.aws.amazon.com/cdk/v2/guide/parameters.html)): avoid the parameter entirely — resolve the value at synth (context/env) or, for secrets, via a CloudFormation dynamic reference such as `cdk.SecretValue.secretsManager(...)` / `{{resolve:secretsmanager:...}}`, which keeps the value out of the template and leaves no `CfnParameter` for the evaluator to choke on. (Note: Cognito `UserPoolIdentityProvider.ProviderDetails` accepts `secretsmanager` dynamic references but **not** `ssm-secure` ones.)

### Related

- [aws/aws-cdk#22323](https://github.com/aws/aws-cdk/issues/22323) — hotswap deploy fails on `CfnEvaluationException` (same template-evaluator root cause; here it surfaces as a silent hang in `watch` rather than an error).

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with `cdk watch` on a stack containing a `CfnParameter` without a default and a hotswappable Lambda, then trace the watch hotswap deployment path and template evaluator. Compare it with `cdk deploy --hotswap` and the behavior described in aws/aws-cdk#22323; done means the watch command reports an error or falls back to a full deployment instead of hanging indefinitely.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.