Repository navigation
Description
Service
CloudFormation (AWS::DynamoDB::Table), DynamoDbCfnProvisioner.
AWS API Action
CreateStack, UpdateStack, ContinueUpdateRollback
Follow-up to #4951 (closes #4950). Copilot raised both findings in its second review of #4951 (snapshot, non-object block). #4951 merged as a5228a0 before the fix was pushed, so main still has both bugs.
Expected behavior
-
A committed table update is never rolled back. After an update commits, a later rollback of the stack, including a retried one through
ContinueUpdateRollback, leaves the table as that update left it. -
A
TimeToLiveSpecificationthat is not an object fails model validation. Measured in eu-west-1 on 2026-10-14, aCreateStackfails pre-deployment withVALIDATION_ERRORand the stack endsROLLBACK_COMPLETEwith no table:- YAML
TimeToLiveSpecification: false: "Property [TimeToLiveSpecification] expected type: JSONObject, found: String". - JSON
"TimeToLiveSpecification": true: the same message, "found: String". AWS types every scalar as String here. - A list: "Property [TimeToLiveSpecification] expected type: JSONObject, found: JSONArray".
{"Ref": "AWS::NoValue"}is not a value; it removes the property. - YAML
Actual behavior
- The snapshot of a committed update stays on the resource and is replayed.
- An in-place update records the table's tags, stream and TTL in
CfnRollback.DYNAMODB_TABLE_UPDATE_SNAPSHOT_ATTR, so a failed update can restore them. - Nothing removes that record when the update commits.
- In one sequence the committed resource is put back with the stale record still on it: a later replacing update whose new table cannot be deleted.
- The rollback walker (
CloudFormationService.rollbackUpdatedResources, line 2412) reportsUPDATE_FAILEDonce. - Then
ContinueUpdateRollbackcallsrollbackUpdateon the committed resource. - That restores the stale record: the table's tags go back to their values before the committed update, and the stack reports
UPDATE_ROLLBACK_COMPLETE.
- The rollback walker (
- An in-place update records the table's tags, stream and TTL in
- A non-object block is treated as removed.
provisionTable(line 126) reads the block withengine.resolveNodeand setsttlDeclared = ttlSpec != null && ttlSpec.isObject().- A boolean, a string or a list therefore counts as "not declared":
- On create, the stack reaches
CREATE_COMPLETEwithout TTL. - On an update from a template that declared the block,
ctx.previouslyDeclared("TimeToLiveSpecification")makes the provisioner disable TTL, and the stack reachesUPDATE_COMPLETE.
- On create, the stack reaches
Reproduction
Non-object block, against main:
Resources:
Orders:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions: [{AttributeName: pk, AttributeType: S}]
KeySchema: [{AttributeName: pk, KeyType: HASH}]
BillingMode: PAY_PER_REQUEST
TimeToLiveSpecification: falseaws --endpoint-url http://localhost:4566 cloudformation create-stack --stack-name ttl-nonobj --template-body file://nonobject.yaml
aws --endpoint-url http://localhost:4566 cloudformation describe-stacks --stack-name ttl-nonobj --query 'Stacks[0].StackStatus'
# Floci: CREATE_COMPLETE. AWS: ROLLBACK_COMPLETE with the VALIDATION_ERROR above.Deploying first with TimeToLiveSpecification: {AttributeName: expiresAt, Enabled: true} and then updating to false gives UPDATE_COMPLETE, and describe-time-to-live then answers DISABLED.
The stale snapshot needs a replacement table that cannot be deleted, so the reproduction is a fault-injected integration test (the second test under "Fix"). It runs:
- Create the table with tag
env=dev. - Update the tag to
env=prod. This is in place and commits. - Make a replacing update (a new
TableName, with TTL). The new table is created, then its TTL call fails and the cleanupDeleteTablefails. The stack endsUPDATE_ROLLBACK_FAILED, which is correct. - Run
ContinueUpdateRollback. Today the stack endsUPDATE_ROLLBACK_COMPLETEand the table's tags are back toenv=dev.
Environment
- Floci version / image tag:
mainata5228a0(fix(cloudformation): apply TimeToLiveSpecification on DynamoDB tables #4951 merged). - Java SDK version (if applicable): n/a.
- How you're running Floci (Docker / native /
mvn quarkus:dev): any. The provisioner is the same on the native and the DynamoDB Local backend.
Fix
The fix is commit 00daf8d on mariotoffia:fix/cfn-dynamodb-table-ttl. It applies cleanly onto a5228a0 and touches only the three files below.
1. Drop the snapshot when the update commits
The engine calls completeUpdate on every resource after a commit (CloudFormationService, line 2121), and calls clearUpdate only when the result is applicable. CognitoCfnProvisioner.completeUpdate drops its snapshot the same way; the table has no replacement cleanup to run, so it returns notApplicable(). Add an override to DynamoDbCfnProvisioner, after retainsFailedUpdateState:
/**
* The engine calls this for every resource once a stack update commits. A committed update is
* never rolled back, so its snapshot is dropped here: left on the resource, a later failed update
* would restore it and a retried rollback would put the table back to its state before this one.
*/
@Override
public UpdateCleanupResult completeUpdate(StackResource resource) {
resource.getAttributes().remove(CfnRollback.DYNAMODB_TABLE_UPDATE_SNAPSHOT_ATTR);
return UpdateCleanupResult.notApplicable();
}Not part of this fix:
- No
clearUpdateoverride: the engine never calls it after a not-applicable result. - No
ReplacementCleanup.recordOrphan: rolling back a replacing table update is still unsupported. After the fix,ContinueUpdateRollbackin step 4 endsUPDATE_ROLLBACK_FAILEDagain with "Rollback is not implemented for AWS::DynamoDB::Table", with the committed tags kept.ContinueUpdateRollback --resources-to-skip Orderscompletes it. AWS instead retries the delete of the new table.
2. Reject a block that is not an object
In provisionTable, replace lines 126-127:
- JsonNode ttlSpec = props != null ? engine.resolveNode(props.get("TimeToLiveSpecification")) : null;
- boolean ttlDeclared = ttlSpec != null && ttlSpec.isObject();
+ JsonNode ttlSpec = props != null
+ ? engine.resolveNodeOmittingNoValue(props.get("TimeToLiveSpecification")) : null;
+ boolean ttlDeclared = ttlSpec != null && !ttlSpec.isMissingNode() && !ttlSpec.isNull();
+ if (ttlDeclared && !ttlSpec.isObject()) {
+ // As AWS reports it: scalars are typed String, so a boolean is "found: String" too.
+ throw new AwsException("InvalidRequest", "Model validation failed (#/TimeToLiveSpecification:"
+ + " expected type: JSONObject, found: " + (ttlSpec.isArray() ? "JSONArray" : "String") + ")",
+ 400);
+ }Why each piece is there:
resolveNodeOmittingNoValueis required.resolveNodeleaves{"Ref": "AWS::NoValue"}as a non-object, which would now be rejected.resolveNodeOmittingNoValuereturns aMissingNodefor it, including insideFn::Ifbranches, soAWS::NoValuekeeps meaning "removed".- The check sits before any DynamoDB call, so nothing on the table changes.
- A JSON
nullis treated as omitted. This was not probed on AWS.
Tests
DynamoDbCfnProvisionerTest:
- In the
ctx()mock, stubengine.resolveNodeOmittingNoValue(any())as identity, as the S3 and Scheduler provisioner tests do. nonObjectTimeToLiveFailsModelValidationInsteadOfDisablingIt: a@ParameterizedTestwith@CsvSourcecasesfalse/String,"invalid"/String, and a list/JSONArray.- It runs on an update context whose previous template declared TTL.
- It asserts the message and
verifyNoInteractions(dynamoDb).
committedUpdateLeavesNoSnapshotToRollBackTo: after an in-place tag update,completeUpdateis not applicable and a followingrollbackUpdatereturnsfalse.
CloudFormationDynamoDbTimeToLiveIntegrationTest:
removingTheTimeToLiveBlockDisablesItbecomes@ParameterizedTest @ValueSource(strings = {"", TTL_NO_VALUE}), withTTL_NO_VALUE = {"Ref": "AWS::NoValue"}, soAWS::NoValuekeeps disabling.retryingAFailedReplacementRollbackKeepsTheCommittedTags: the four steps above.- It uses the existing
failNextUpdateTimeToLive, and a one-shotdeleteTable(anyString(), anyString())failure on theDynamoDbServicespy, with the real methods restored infinally. - Then it asserts:
UPDATE_ROLLBACK_FAILEDafter the continue.- Tags still
env=prod. UPDATE_ROLLBACK_COMPLETEaftercontinueUpdateRollback(stack, "Orders").
- Then it deletes the orphaned replacement table and the stack.
- It uses the existing
- Helper
continueUpdateRollback(String stack, String... resourcesToSkip).
Before the fix, five of these fail; after it, all pass. Gates run on 00daf8d:
./mvnw -q checkstyle:check: passed../mvnw test -Dtest='io.github.hectorvent.floci.services.cloudformation.**,io.github.hectorvent.floci.services.dynamodb.backend.**': 3485 tests, 0 failures, 12 skipped.- Against
amazon/dynamodb-local:3.3.1:DynamoDbLocalBackendIntegrationTest12 tests andCloudFormationDynamoDbTimeToLiveIntegrationTest11 tests, 0 failures. make partition-checkandmake docs-check: passed.
Activity
fix(cloudformation): apply DynamoDB index and billing changes on stac…
fix(cloudformation): forward a DynamoDB table to its KinesisStreamSpe…
fix(cloudformation): drop the DynamoDB update snapshot once the updat…
AndreKurait commentedon Nov 4, 2026
The invalid TTL block finding is fixed by merged #7286. The committed-snapshot finding remains on main at 27057e2: a fresh provisioner regression performs a successful tag update, calls completeUpdate, then confirms rollback still restores the earlier state.
Existing #7448 implements the missing commit cleanup and includes the reported retried-stack-rollback sequence. Keep this issue open until that fix lands; no duplicate implementation is needed. This new reproduction is a local unit test, not a live AWS or current-PR runtime qualification.
pgermosen commentedon Nov 10, 2026
Both findings are fixed on
main: #7286 refuses aTimeToLiveSpecificationthat is not an object, and #7448 drops the update snapshot once the update commits, so a retried rollback no longer replays it.