terraform-provider-aws: DynamoDB On-Demand doesn't work with GSIs

Community Note

  • Please vote on this issue by adding a πŸ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave β€œ+1” or β€œme too” comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.10
+ provider.aws v1.51.0

Affected Resource(s)

  • aws_dynamodb_table

Terraform Configuration Files

resource "aws_dynamodb_table" "lvs" {
  name = "lvs-${var.environment}"
  tags = "${var.tags}"

  hash_key  = "Account"
  range_key = "SortKey"

  billing_mode = "PAY_PER_REQUEST"

  # Streams have to be enabled for DynamoDB global table
  # https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables_reqs_bestpractices.html
  stream_enabled = true

  stream_view_type = "NEW_AND_OLD_IMAGES"

  attribute {
    name = "Account"
    type = "S"
  }

  attribute {
    name = "SortKey"
    type = "S"
  }

  attribute {
    name = "AccountOffering"
    type = "S"
  }

  attribute {
    name = "CancelStatus"
    type = "S"
  }

  global_secondary_index {
    name            = "GSI"
    hash_key        = "CancelStatus"
    range_key       = "AccountOffering"
    projection_type = "KEYS_ONLY"
  }
}

Expected Behavior

I expected to be able to create a DynamoDB table with the new PAY_PER_REQUEST billing option set, and use the table with GSIs.

Actual Behavior

I tried to not specify the read and write capacity units for my GSIs, but that led to the following error at the plan phase, since the schema marks the provisioned throughput arguments as required:

Error: module.lvs.module.lvs_table_region1.aws_dynamodb_table.lvs: "global_secondary_index.0.read_capacity": required field is not set

When I tried to specify a dummy value, it fails the call to the AWS DynamoDB API:

* module.lvs.module.lvs_table_region3.aws_dynamodb_table.lvs: 1 error(s) occurred:

* aws_dynamodb_table.lvs: ValidationException: One or more parameter values were invalid: ProvisionedThroughput should not be specified for index: GSI when BillingMode is PAY_PER_REQUEST
	status code: 400, request id: 1IVRLJOG48QHPG3FO4UAJUV347VV4KQNSO5AEMVJF66Q9ASUAAJG

Steps to Reproduce

With no capacity specified in the GSI it fails at plan time.

With dummy capacity values specified it fails at apply time.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 24
  • Comments: 15 (8 by maintainers)

Most upvoted comments

@bflad I don’t understand why this issue is not labelled as a bug and not prioritized accordingly. It essentially makes billing_mode feature impossible to use.

Support for on-demand billing with global secondary indices has been merged and will release with version 1.52.0 of the AWS provider, likely later today. πŸ‘

Same issue, and it should be a high prioritized defect.