Repository navigation
Conversation
The 1024-character AlarmDescription guard walked only ObservabilityStack, so EventBridgeStack's ten -errors alarms (createWorkerLambda) could pass synth and fail mid-deploy. The guard moves to alarm-guards.ts and runs once over the whole App in createApp, before app.synth(). Templates unchanged.
stkrolikiewicz
left a comment
There was a problem hiding this comment.
Read the whole diff. Correct for today's tree: the walk over the App reaches every stack and runs before app.synth(). Three non-blocking comments inline; the first is about the moved code, not something this PR introduced.
| const description = cdk.Stack.of(alarm).resolve( | ||
| cfn.alarmDescription, | ||
| ) as unknown; | ||
| const length = typeof description === 'string' ? description.length : 0; |
There was a problem hiding this comment.
suggestion (non-blocking): not new in this PR, but the doc comment above (L22) now promises more than this does. A description with a token resolves to an { 'Fn::Join': … } object, typeof isn't 'string', and the length counts as 0, so it always passes. Every description is a plain string today. Either measure the joined literal parts (an upper bound) or throw on a non-string, or reword the comment.
There was a problem hiding this comment.
Good catch, confirmed: a 1025-char Fn.join description passed as length 0. The guard now throws on any description that does not resolve to a plain string, naming the alarm, and the doc comment says so instead of promising a measurement. Production synth with it: 90 alarms, all plain strings, longest 1018. 1a7a63b
| const MAX = 1024; | ||
| const tooLong = scope.node | ||
| .findAll() | ||
| .filter((c): c is cloudwatch.Alarm => c instanceof cloudwatch.Alarm) |
There was a problem hiding this comment.
nit: only L2 cloudwatch.Alarm is walked. A raw CfnAlarm or a CompositeAlarm (same 1024 limit) slips through, so "any stack added later" holds for L2 alarms only. Filtering on CfnAlarm / CfnCompositeAlarm and reading alarmDescription from them would cover all three.
There was a problem hiding this comment.
Done: the walk filters on CfnAlarm / CfnCompositeAlarm and reads alarmDescription from them, so L2, raw and composite alarms are all measured. 1a7a63b
| observability.addDependency(compute); | ||
|
|
||
| // Every stack's alarms, measured before anything is synthesized (task 0288). | ||
| assertAlarmDescriptionsFitCloudWatch(app); |
There was a problem hiding this comment.
suggestion (non-blocking): the negative test from the description isn't committed, and nothing in infra runs createApp or the guard in a test. Dropping this line, or moving it below app.synth(), would stay green. A tiny spec with one over-long alarm in a non-Observability stack would pin it.
There was a problem hiding this comment.
Added tools/scripts/alarm-guards.test.mjs on the existing infra node --test target: over-long in a non-Observability stack fails with the guard's message, exactly 1024 passes, a token description is refused, raw CfnAlarm and composite alarms are measured. The last two fail against the previous guard. I left the app.ts call itself unpinned on purpose: createApp imports the stacks as ./stacks/*.js, which only resolve after an infra build, so pinning it needs a built-infra test harness, a bigger step than this PR. The test header says so. 1a7a63b
A description built from a token resolves to an Fn::Join object, which the guard counted as length 0, so an over-long one passed synth and failed mid-deploy. It is now refused at synth. The walk also moves from L2 cloudwatch.Alarm to CfnAlarm + CfnCompositeAlarm, so raw and composite alarms (same 1024 limit) are measured too. tools/scripts/alarm-guards.test.mjs pins the guard: over-long fails, 1024 passes, a token is refused, raw and composite alarms are measured. The last two fail against the previous guard. The production synth passes: 90 alarms, all plain strings, longest 1018. Spotted in review of PR #435.
All four PRs merged into develop on 2026-11-30 after Stan's review: - 0253: #432 (d3bee99) - 0302: #433 (ef601af), writer probe on production recorded - 0211: #434 (638beb8), overview revision row now links the archive - 0288: #435 (9ea7b6c) Each task records the review fixes, status completed, and moves to archive/.
Summary
AlarmDescriptionguard walked only ObservabilityStack, so EventBridgeStack's ten-errorsalarms (createWorkerLambda) could pass synth and fail in CloudFormation mid-deploy.infra/src/lib/alarm-guards.ts(same check, same message) and runs once over the wholeAppincreateApp, beforeapp.synth(). Every stack is covered, including ones added later.prices-production-asset-discovery-errors — 1491 chars; the same edit ondevelopsynthesizes without complaint.nx testandinfra:verify-dashboardpass.Task: lore 0288.