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.82k stars 9.16k forks source link

[Bug]: aws_msk_cluster error out updating ebs_volume_info though there is no change #37043

Open mr92752 opened 6 months ago

mr92752 commented 6 months ago

Terraform Core Version

1.5.3

AWS Provider Version

5.46.0

Affected Resource(s)

aws_msk_cluster

Expected Behavior

aws_msk_cluster broker_node_group_info storage_info ebs_storage_info should not be updated if there is no change

Actual Behavior

terraform is adding provisioned_throughput to eb_storage_info though it is null and eventually error out

Relevant Error/Panic Output Snippet

broker storage: operation error Kafka: UpdateBrokerStorage, https response error StatusCode: 400, RequestID: a58ed9fd-5102-462c-a77e-d5972fc821cf, BadRequestException: The request does not include any updates to the EBS volumes of the cluster. Verify the request, then try again.

If voulme_storage variable value is increased and reapplied, this error doesn't occur

Terraform Configuration Files

resource "aws_msk_cluster" "this" {
  count = var.create ? 1 : 0

  cluster_name           = var.cluster_name
  kafka_version          = var.kafka_version
  number_of_broker_nodes = var.number_of_broker_nodes
  broker_node_group_info {
    az_distribution = var.broker_node_az_distribution
    client_subnets  = var.broker_node_client_subnets
    instance_type   = var.broker_node_instance_type
    security_groups = var.broker_node_security_groups

   dynamic "storage_info" {
      for_each = length(var.broker_node_storage_info) > 0 ? [var.broker_node_storage_info] : []
      content {
        dynamic "ebs_storage_info" {
          for_each = try([storage_info.value.ebs_storage_info], [])

          content {
            dynamic "provisioned_throughput" {
              for_each = try([ebs_storage_info.value.provisioned_throughput], [])

              content {
                enabled           = try(provisioned_throughput.value.enabled, null)
                volume_throughput = try(provisioned_throughput.value.volume_throughput, null)
              }
            }
            volume_size = try(ebs_storage_info.value.volume_size, 100)
          }
        }
      }
    }
}
# variable definition
# --------------------
variable "broker_node_storage_info" {
  description = "A block that contains information about storage volumes attached to MSK broker nodes"
  type = object({
    ebs_storage_info = optional(object({
      provisioned_throughput = object({
        enabled           = optional(bool, false)
        volume_throughput = optional(number,250)
      })
      volume_size = optional(number, 100)
    }))
  })
  default = {}
  nullable = false
}

Steps to Reproduce

  1. pass the varibles to the configuration
  2. terraform init
  3. terraform plan/apply
  4. Once the cluster is created, rerun the terraform
  5. terraform plan/apply
  6. input yes

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 6 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 6 months ago

Maybe similar #20327

afireinside09 commented 5 months ago

confirmed same problem while trying to upgrade from 4.20.1 -> 5.47.0 of the AWS provider. this makes me nervous to update to any 5.xx.xx of the AWS provider now.

ayoh1 commented 3 months ago

looks like this is related to #26031