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.77k stars 9.12k forks source link

[Bug]: Changing to IO2 storage on RDS instance fails #36648

Open nhenjes opened 6 months ago

nhenjes commented 6 months ago

Terraform Core Version

1.4.6

AWS Provider Version

5.40.0

Affected Resource(s)

Expected Behavior

We should be able to switch from gp3 with provisioned iops to io2 without changing the allocated storage

Actual Behavior

When changing from gp3 to io2, AWS expects the allocated storage to be passed. Because this value didn't change however, the call to the AWS API excludes the allocated storage value and produces the error

│ Error: updating RDS DB Instance (<database-name>): operation error RDS: ModifyDBInstance, https response error StatusCode: 400, RequestID: <request-id>, api error InvalidParameterCombination: You must specify both the storage size and iops when modifying the storage size or iops on a DB instance that has iops.

Creating a new database with io2 works however because it's a new value that Terraform passes to the API

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

data "aws_rds_orderable_db_instance" "custom-sqlserver" {
  engine                     = "custom-sqlserver-se"
  engine_version             = "15.00.4249.2.v1"
  storage_type               = "gp3"
  preferred_instance_classes = ["db.r5.xlarge", "db.r5.2xlarge", "db.r5.4xlarge"]
}

# The RDS instance resource requires an ARN. Look up the ARN of the KMS key.
data "aws_kms_key" "by_id" {
  key_id = "example-ef278353ceba4a5a97de6784565b9f78" # KMS key
}

resource "aws_db_instance" "example" {
  allocated_storage                     = 500
  auto_minor_version_upgrade  = false
  custom_iam_instance_profile = "AWSRDSCustomSQLServerInstanceProfile"
  backup_retention_period        = 7
  db_subnet_group_name          = local.db_subnet_group_name # Copy the subnet group from the RDS Console
  engine                                        = data.aws_rds_orderable_db_instance.custom-sqlserver.engine
  engine_version                          = data.aws_rds_orderable_db_instance.custom-sqlserver.engine_version
  identifier                                     = "sql-instance-demo"
  instance_class                           = data.aws_rds_orderable_db_instance.custom-sqlserver.instance_class
  kms_key_id                                = data.aws_kms_key.by_id.arn
  multi_az                                      = false # Custom for SQL Server does support multi-az
  password                                    = "avoid-plaintext-passwords"
  storage_encrypted                    = true
  storage_type.                             = "gp3"
  username                                    = "test"

  timeouts {
    create = "3h"
    delete = "3h"
    update = "3h"
  }
}

Steps to Reproduce

Create an RDS instance with gp3, then change only the storage type from gp3 to io2

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

Yes

github-actions[bot] commented 6 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue