Skip to content

fix(dynamodb): propagate billing-mode changes through GSIs#400

Merged
vieiralucas merged 1 commit intomainfrom
worktree-dynamodb-billing-gsi
Apr 15, 2026
Merged

fix(dynamodb): propagate billing-mode changes through GSIs#400
vieiralucas merged 1 commit intomainfrom
worktree-dynamodb-billing-gsi

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 15, 2026

Summary

DynamoDB's UpdateTable zeroes every GSI's ProvisionedThroughput when a table flips to PAY_PER_REQUEST, and CreateTable returns {0, 0} for GSIs on PAY_PER_REQUEST tables regardless of whether the caller sent a ProvisionedThroughput block. fakecloud previously left stale capacity numbers on GSIs, defaulted missing throughput to {5, 5}, and dropped AttributeDefinitions sent alongside a GSI Create op. The Terraform provider's post-apply refresh plan then reported drift, which blocked four upstream TestAcc tests behind the "billing-mode transitions with GSI" gap.

Fix:

  • parse_gsi / CreateTable: zero GSI ProvisionedThroughput when billing mode is PAY_PER_REQUEST; keep {5, 5} default only for PROVISIONED.
  • UpdateTable: on PROVISIONED -> PAY_PER_REQUEST transition, zero the table and every GSI's throughput before applying index updates.
  • UpdateTable GSI Create op: pick throughput based on the table's current billing mode, matching real AWS semantics.
  • UpdateTable: merge new AttributeDefinitions into the table schema so a follow-up DescribeTable reflects GSI hash/range keys that were added alongside the Create op.

Removes these four entries from the DynamoDB tfacc deny list:

  • TestAccDynamoDBTable_BillingMode_payPerRequestBasic
  • TestAccDynamoDBTable_BillingModeGSI_payPerRequestToProvisioned
  • TestAccDynamoDBTable_BillingModeGSI_provisionedToPayPerRequest
  • TestAccDynamoDBTable_Disappears_payPerRequestWithGSI

Test plan

  • Three new e2e regression tests in crates/fakecloud-e2e/tests/dynamodb.rs cover create + update paths (dynamodb_create_pay_per_request_with_gsi_zeroes_throughput, dynamodb_update_table_provisioned_to_pay_per_request_zeroes_gsi, dynamodb_update_table_gsi_create_on_pay_per_request_zeroes_throughput).
  • Full cargo test -p fakecloud-e2e --test dynamodb passes (41/41).
  • cargo test -p fakecloud-conformance --test dynamodb passes (30/30).
  • All four previously-denied upstream TestAccDynamoDBTable_BillingMode* tests pass locally against fakecloud via go test ./internal/service/dynamodb/ -run ....
  • cargo clippy --workspace --all-targets -- -D warnings clean.

Summary by cubic

Fixes DynamoDB billing-mode transitions so GSIs and table throughput follow AWS semantics, preventing Terraform drift. Unblocks four upstream TestAccDynamoDBTable_BillingMode* tests.

  • Bug Fixes
    • CreateTable: zero GSI throughput on PAY_PER_REQUEST; keep {5,5} default only for PROVISIONED.
    • UpdateTable: on PROVISIONED → PAY_PER_REQUEST, zero table and all GSIs before index updates.
    • GSI Create (UpdateTable): set throughput based on current table billing mode; return {0,0} on PAY_PER_REQUEST.
    • Merge AttributeDefinitions provided with GSI Create into the table schema so DescribeTable shows new keys.
    • Added 3 e2e tests in fakecloud-e2e and removed 4 denylist entries in fakecloud-tfacc.

Written for commit 479ce56. Summary will update on new commits.

DynamoDB's UpdateTable zeroes every GSI's ProvisionedThroughput when a
table flips to PAY_PER_REQUEST, and CreateTable returns {0, 0} for GSIs
on PAY_PER_REQUEST tables regardless of whether the caller sent a
ProvisionedThroughput block. fakecloud previously left stale capacity
numbers on GSIs, defaulted missing throughput to {5, 5}, and dropped
AttributeDefinitions sent alongside a GSI Create op. The Terraform
provider's post-apply refresh plan then reported drift, blocking four
upstream TestAcc tests.

- parse_gsi / CreateTable: zero GSI ProvisionedThroughput when billing
  mode is PAY_PER_REQUEST; keep {5, 5} default only for PROVISIONED.
- UpdateTable: on PROVISIONED -> PAY_PER_REQUEST transition, zero the
  table and every GSI's throughput before applying index updates.
- UpdateTable GSI Create op: pick throughput based on the table's
  current billing mode, matching real AWS semantics.
- UpdateTable: merge new AttributeDefinitions into the table schema so
  a follow-up DescribeTable reflects GSI hash/range keys that were
  added alongside the Create op.

Removes the four upstream tests from the DynamoDB deny list and adds
three e2e regression tests covering create + update paths.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

@vieiralucas vieiralucas merged commit 6330a29 into main Apr 15, 2026
37 checks passed
@vieiralucas vieiralucas deleted the worktree-dynamodb-billing-gsi branch April 15, 2026 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant