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

[Bug]: `storage_type` incorrectly applied when creating Aurora cluster from snapshot #39935

Open Indigenuity opened 5 hours ago

Indigenuity commented 5 hours ago

Terraform Core Version

1.9.2

AWS Provider Version

5.61.0

Affected Resource(s)

aws_rds_cluster

Expected Behavior

New Aurora cluster created matches the plan described by terraform apply. Either the cluster should be created with storage_type = "aurora-iopt1", or if that's impossible when restoring from snapshot, then the plan should reflect as much.

Actual Behavior

terraform apply outputs a plan which will create an Aurora cluster with IO Optimized storage:

# module.green.module.my_cluster[0].aws_rds_cluster.cluster will be created
+ resource "aws_rds_cluster" "cluster" {
  + allocated_storage                     = (known after apply)
  + allow_major_version_upgrade           = false
  + apply_immediately                     = true
  + arn                                   = (known after apply)
  + availability_zones                    = (known after apply)
  + backtrack_window                      = 0
  + backup_retention_period               = 7
  + ca_certificate_identifier             = (known after apply)
  + ca_certificate_valid_till             = (known after apply)
  + cluster_identifier                    = "redacted-my-cluster"
  + cluster_identifier_prefix             = (known after apply)
  + cluster_members                       = (known after apply)
  + cluster_resource_id                   = (known after apply)
  + copy_tags_to_snapshot                 = true
  + database_name                         = "redacted-my-db"
  + db_cluster_parameter_group_name       = (known after apply)
  + db_instance_parameter_group_name      = "default.aurora-postgresql16"
  + db_subnet_group_name                  = "redacted-my-cluster-group"
  + db_system_id                          = (known after apply)
  + delete_automated_backups              = true
  + deletion_protection                   = false
  + enable_global_write_forwarding        = false
  + enable_http_endpoint                  = false
  + enable_local_write_forwarding         = false
  + enabled_cloudwatch_logs_exports       = [
      + "postgresql",
    ]
  + endpoint                              = (known after apply)
  + engine                                = "aurora-postgresql"
  + engine_lifecycle_support              = (known after apply)
  + engine_mode                           = "provisioned"
  + engine_version                        = "16"
  + engine_version_actual                 = (known after apply)
  + final_snapshot_identifier             = "redacted-my-cluster-final-snapshot"
  + hosted_zone_id                        = (known after apply)
  + iam_database_authentication_enabled   = false
  + iam_roles                             = (known after apply)
  + id                                    = (known after apply)
  + kms_key_id                            = (known after apply)
  + master_password                       = (sensitive value)
  + master_user_secret                    = (known after apply)
  + master_user_secret_kms_key_id         = (known after apply)
  + master_username                       = "us_geo_user"
  + network_type                          = (known after apply)
  + performance_insights_kms_key_id       = (known after apply)
  + performance_insights_retention_period = (known after apply)
  + port                                  = 5432
  + preferred_backup_window               = "06:00-07:00"
  + preferred_maintenance_window          = "sun:07:00-sun:08:00"
  + reader_endpoint                       = (known after apply)
  + skip_final_snapshot                   = true
  + snapshot_identifier                   = "redacted-my-cluster-2024-10-28-06-04"
  + storage_encrypted                     = false
  + storage_type                          = "aurora-iopt1"
  + tags_all                              = {}
  + vpc_security_group_ids                = (known after apply)
}

Instead, after applying the plan, the cluster is created with Standard storage: Screenshot 2024-10-29 at 3 04 36 PM

In terraform state, the relevant resource shows storage_type = null. When running terraform apply a second time, the storage type is noted as an addition, not a change:

# module.main.aws_rds_cluster.cluster will be updated in-place
~ resource "aws_rds_cluster" "cluster" {
    id                                    = "my-cluster"
  + storage_type                          = "aurora-iopt1"

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

data "aws_db_cluster_snapshot" "example" {
  db_cluster_identifier = "example-original-cluster"
  most_recent           = true
}

resource "aws_rds_cluster" "example" {
  # Because the global cluster is sourced from this cluster, the initial
  # engine and engine_version values are defined here and automatically
  # inherited by the global cluster.
  engine         = "aurora-postgresql"
  engine_version = "16"

  cluster_identifier  = "example"
  snapshot_identifier = data.aws_db_cluster_snapshot.example.id
  storage_type = "aurora-iopt1"
}

Steps to Reproduce

Attempt to create a new aurora cluster from a cluster snapshot, setting storage_type = "aurora-iopt1".

Debug Output

No response

Panic Output

No response

Important Factoids

Aurora snapshots always have a storage type of "Aurora Standard", even if the source cluster has storage type of "I/O Optimized"

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 5 hours ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue