hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.87k stars 9.21k forks source link

[Bug]: Cannot remove replicas and disable stream on dynamodb table #34450

Open tmccombs opened 1 year ago

tmccombs commented 1 year ago

Terraform Core Version

1.6.2

AWS Provider Version

5.21.0

Affected Resource(s)

Expected Behavior

If a table has replicas, then I should be able to remove the replicas and disable the stream in the same action.

Actual Behavior

If you try to disable streaming in the same apply that you remove all replicas, you get an Error saying that you can't disable streaming for a global table.

Relevant Error/Panic Output Snippet

│ Error: updating Amazon DynamoDB Table (oauth-request-tokens): ValidationException: One or more parameter values were invalid: Disabling Stream is not allowed for a Global Table replica.
│       status code: 400, request id: <redacted>
│ 
│   with module.oauth_request_tokens.module.table.aws_dynamodb_table.table,
│   on ../modules/environment_dynamodb_table/main.tf line 1, in resource "aws_dynamodb_table" "table":
│    1: resource "aws_dynamodb_table" "table" {
│ 
╵

Terraform Configuration Files

resource "aws_dynamodb_table" "table" {
  name             = var.name
  billing_mode     = "PAY_PER_REQUEST"
  hash_key         = var.hash_key
  range_key        = var.range_key
  stream_enabled   = local.stream_enabled
  stream_view_type = local.stream_enabled ? "NEW_AND_OLD_IMAGES" : null

  dynamic "attribute" {
    for_each = var.attributes
    content {
      name = attribute.value.name
      type = attribute.value.type
    }
  }

  dynamic "ttl" {
    for_each = var.ttl_attr_name != null ? [var.ttl_attr_name] : []
    content {
      attribute_name = ttl.value
      enabled        = true
    }
  }

  tags = {
    Name        = var.name
    Environment = var.env
  }

  dynamic "replica" {
    for_each = var.replica_regions
    content {
      region_name = replica.value
    }
  }
}

Usage of the module:

module "table" {
  source = "./table"

  account_arns = var.account_arns
  replica_regions = [] # previously had one or more regions specified

  name = "example"
  hash_key = "sampleKey"
  ttl_attr_name = "ttl"
  attributes = [{
    name = "sampleKey"
    type = "S"
  }]
}

Steps to Reproduce

Create a table that has one or more replicas, with streaming enabled. Then try to delete the replicas and disable streaming.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

This was previously reported as https://github.com/hashicorp/terraform-provider-aws/issues/19342, but that was closed due to inactivity.

p.s. it is super annoying to search for a bug I encounter only to find that it has been reported, but closed due to inactivity.

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 1 year ago

Hey @tmccombs 👋 Thank you for taking the time to raise this, and for providing a solid description of the issue (as always)! I'm seeing this while triaging issues, but wanted to take the time to acknowledge the sentiment around the previous report on this. I can absolutely see where you're coming from, and (as the project's community manager) am thinking about that experience a lot right now. Hopefully I'll have some more news for you around that before too long. One thing I do want to note is that linking to the previous issue like you did is immensely helpful, and is something that we take into consideration when working on prioritizing efforts, so thank you very much for doing so.

As an aside, you've been contributing to the provider for quite a while now, so I'm not sure how long it's been since you've needed to review our contribution guide. With that in mind, I wanted to make sure you were aware of a relatively new section we've added regarding Slack, in case you'd be interested 🙂.

kunal-gohrani commented 10 months ago

Hello, Is there been any investigation/fix on this issue? this seems like a very big issue in the provider.

VivekElumalai commented 1 month ago

Hello Team !!

I am still facing the same issue whether any fix for this ?