Skip to content

fix(provisioning): clear SQS attributes removed on UPDATE (Fn::If -> AWS::NoValue) - #850

Merged
go-to-k merged 1 commit into
mainfrom
test/conditions-update-2
Jun 14, 2026
Merged

fix(provisioning): clear SQS attributes removed on UPDATE (Fn::If -> AWS::NoValue)#850
go-to-k merged 1 commit into
mainfrom
test/conditions-update-2

Conversation

@go-to-k

@go-to-k go-to-k commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes a real cdkd UPDATE bug: a property whose value resolves away via Fn::If -> AWS::NoValue was NOT removed from the live AWS resource. Concretely, an SQS RedrivePolicy set on a prior deploy lingered on the queue after a subsequent deploy in which the Fn::If branch resolved to AWS::NoValue.

Root cause

SQSQueueProvider.update() only acted on keys PRESENT in the desired (new) properties. cdkd's diff layer correctly classifies a property that is present in current state but absent from the desired template as a change, but the provider's update loop never iterated over removed keys, so the stale attribute value was left on AWS.

Fix

src/provisioning/providers/sqs-queue-provider.ts adds clear-on-removal: when a CDK-managed attribute was set on a previous deploy (previousProperties[cdkKey] !== undefined) but is absent from the desired properties, it is reset to its documented SetQueueAttributes default (mirroring CloudFormation's reset-removed-property-to-default behavior).

  • JSON policy attributes (RedrivePolicy / RedriveAllowPolicy) and KmsMasterKeyId are cleared with the empty string the SQS API documents for removal.
  • Numeric attributes reset to their documented defaults (VisibilityTimeout=30, MaximumMessageSize=262144, MessageRetentionPeriod=345600, DelaySeconds=0, ReceiveMessageWaitTimeSeconds=0, KmsDataKeyReusePeriodSeconds=300).
  • Immutable / FIFO-discriminated attributes (FifoQueue / DeduplicationScope / FifoThroughputLimit) are intentionally excluded from the reset map; the diff/replacement layer handles those separately.

Tests

  • New unit tests: tests/unit/provisioning/sqs-queue-provider-update.test.ts cover the removal-reset path.
  • New integration fixture: tests/integration/conditions-update-2/ deploys an SQS queue with a RedrivePolicy behind an Fn::If, then re-deploys with the condition flipped so the policy resolves to AWS::NoValue, asserting the attribute is cleared on AWS.

Validation

Validated green against real AWS (the conditions-update-2 integ deploy + update + destroy completed cleanly, RedrivePolicy confirmed removed post-update).

… UPDATE (Fn::If -> AWS::NoValue) instead of leaving the stale value

The new conditions-update-2 integ fixture surfaced a real cdkd UPDATE-path
bug: when an SQS Queue property whose value is Fn::If(cond, <value>,
AWS::NoValue) flips from <value> (phase a, condition true) to AWS::NoValue
(phase b, condition false), the resolved desired properties OMIT the
property entirely. cdkd's diff layer correctly classifies that as a change
(compareProperties unions current + desired keys, so a key present in state
but absent from the resolved template is detected), but SQSQueueProvider.update()
only acted on keys PRESENT in the new properties -- so the stale value (e.g.
RedrivePolicy) was never cleared on AWS. The fixture's phase-b assertion
(WorkQueue RedrivePolicy GONE) failed.

This is the "providers only act on keys present in newProperties" gap
(feedback_internal_contract_audit_first). The fix adds a removal branch to
SQSQueueProvider.update(): a CDK-managed attribute present in
previousProperties but absent from the resolved desired properties is reset
to its default via SetQueueAttributes, mirroring CloudFormation's
reset-to-default-on-removal behavior. The new SQS_ATTRIBUTE_REMOVAL_RESET map
clears the JSON policy attributes (RedrivePolicy / RedriveAllowPolicy) and
KmsMasterKeyId to the empty string SQS documents for removal, and resets the
numeric attributes to their documented SetQueueAttributes defaults.

The branch is gated on the attribute being present in previousProperties AND
in the reset map, so it never spuriously clears an attribute that was never
set (a tag-only update issues no SetQueueAttributes), and immutable /
FIFO-discriminated attributes (FifoQueue / DeduplicationScope /
FifoThroughputLimit) are deliberately excluded. The change is confined to the
SQS provider -- no shared / cross-provider code path changed, so other
providers' update semantics are untouched.

Unit tests (tests/unit/provisioning/sqs-queue-provider-update.test.ts):
clear-on-removal (RedrivePolicy -> ""), numeric-reset-on-removal
(VisibilityTimeout -> 30), and the no-over-clear guard (attribute absent on
both sides -> no SetQueueAttributes).

Also adds the conditions-update-2 integ fixture that stresses the harder
CloudFormation-Conditions-on-UPDATE semantics the simple #840 flip does not
cover (moved-condition resources, condition-gated outputs, dangling DependsOn
on a pruned resource, Ref into a pruned resource, and the Fn::If ->
AWS::NoValue property-removal case above).

NOTE: needs /run-integ conditions-update-2 against real AWS before merge.
@go-to-k
go-to-k force-pushed the test/conditions-update-2 branch from aa4fe94 to 1b32fbb Compare June 14, 2026 00:53
@go-to-k
go-to-k merged commit dd91172 into main Jun 14, 2026
5 checks passed
@go-to-k
go-to-k deleted the test/conditions-update-2 branch June 14, 2026 00:56
github-actions Bot pushed a commit that referenced this pull request Jun 14, 2026
## [0.221.6](v0.221.5...v0.221.6) (2026-06-14)

### Bug Fixes

* **provisioning:** clear SQS attributes removed on UPDATE (Fn::If -> AWS::NoValue) ([#850](#850)) ([dd91172](dd91172))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.221.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant