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.72k stars 9.08k forks source link

[Bug]: aws_rds_cluster change in storage_type causes forced replacement #37754

Open malatep opened 3 months ago

malatep commented 3 months ago

Terraform Core Version

1.7.5

AWS Provider Version

4.41.0

Affected Resource(s)

aws_rds_cluster

Expected Behavior

storage_type modifications should be done in place with no replacement

As per the docs https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster#storage_type

For Aurora DB clusters, storage_type modifications can be done in-place

Actual Behavior

Terraform destroys the existing DB cluster and creates a new one with the specified storage_type

+ storage_type = "aurora" # forces replacement

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files


resource "aws_rds_cluster" "main" {
  count              = var.db_enabled == true ? 1 : 0
  cluster_identifier = var.name

  engine         = "aurora-postgresql"
  engine_version = var.engine_version
  engine_mode    = "provisioned"

  database_name                = var.database_name
  master_username              = var.username
  master_password              = var.password
  preferred_backup_window      = var.preferred_backup_window
  preferred_maintenance_window = var.preferred_maintenance_window

  allow_major_version_upgrade         = var.allow_major_version_upgrade
  apply_immediately                   = var.apply_immediately_flag
  backup_retention_period             = var.backup_retention_period
  copy_tags_to_snapshot               = true
  db_cluster_parameter_group_name     = aws_rds_cluster_parameter_group.main[0].name
  db_subnet_group_name                = aws_db_subnet_group.main[0].name
  deletion_protection                 = var.rds_deletion_protection
  enabled_cloudwatch_logs_exports     = ["postgresql"]
  kms_key_id                          = var.kms_key_id
  skip_final_snapshot                 = true
  storage_encrypted                   = true
  vpc_security_group_ids              = [aws_security_group.main[0].id]
  iam_database_authentication_enabled = true
  snapshot_identifier                 = var.snapshot_identifier
  storage_type                        = var.storage_type

}
variable "engine_version" {
  description = "Engine version to use for the Aurora DB cluster"
  default     = "11.9"
  type        = string
}

variable "name" {
  description = "Name of the Aurora DB cluster"
  type        = string
}

variable "rds_deletion_protection" {
  description = "Should RDS deletion protection be enabled"
  default     = true
  type        = bool
}

variable "backup_retention_period" {
  description = "The amount of days to keep the backups"
  default     = 0
  type        = number
}

variable "database_name" {
  description = "Master DB name"
  default     = ""
  type        = string
}

variable "username" {
  description = "Master DB username"
  default     = "user"
  type        = string
}

variable "password" {
  description = "Master DB password"
  type        = string
}

variable "preferred_backup_window" {
  description = "The preferred backup window (UTC)"
  default     = "03:00-04:00"
  type        = string
}

variable "preferred_maintenance_window" {
  description = "The preferred maintenance window (UTC)"
  default     = "Tue:21:00-Tue:22:00"
  type        = string
}

variable "kms_key_id" {
  description = "KMS key to be used for encrypting the storage"
}

variable "allow_major_version_upgrade" {
  default = false
  type    = bool
}

variable "apply_immediately_flag" {
  description = "Flag to apply immediately for aurora/rds"
  default     = false
  type        = bool
}

variable "db_enabled" {
  description = "Activate or deactivate a database cluster resource in a specific environment"
  default     = true
}

variable "snapshot_identifier" {
  description = "Specifies whether or not to create a database from a snapshot"
  default     = ""
}

variable "storage_type" {
  description = "The storage type of the aurora cluster"
  type        = string
  default     = ""
}

Steps to Reproduce

  1. create an aurora cluster with aws_rds_cluster
  2. modify the definition of the aws_rds_cluster and add storage_type
  3. run terraform plan and you will see a forces replacement on the cluster

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Modifying.html#Aurora.Modifying.Settings https://github.com/hashicorp/terraform-provider-aws/issues/31431#issuecomment-1572168022

Would you like to implement a fix?

No

github-actions[bot] commented 3 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 1 month ago

Hey @malatep 👋 Thank you for taking the time to raise this! You mentioned in your original report that you're using version 4.41.0. When reviewing the documentation for that version of the provider, the note regarding in-place updates was not present. Can you try again on a more recent version of the provider to verify that the issue does not persist?