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

aws_rds_cluster.scaling_configuration.min_capacity default value is invalid #18813

Open WhyNotHugo opened 3 years ago

WhyNotHugo commented 3 years ago

Community Note

Issue description

From the documentation:

min_capacity - (Optional) The minimum capacity for an Aurora DB cluster in serverless DB engine mode. The minimum capacity must be lesser than or equal to the maximum capacity. Valid Aurora MySQL capacity values are 1, 2, 4, 8, 16, 32, 64, 128, 256. Valid Aurora PostgreSQL capacity values are (2, 4, 8, 16, 32, 64, 192, and 384). Defaults to 1.

(sorry about the formatting, GitHub strips it automatically)

As you can see, valid values does not always include 1 for postgres, but the default is 1.

Terraform CLI and Terraform AWS Provider Version

$ terraform -v
Terraform v0.14.10
+ provider registry.terraform.io/hashicorp/aws v3.36.0
+ provider registry.terraform.io/hashicorp/random v3.1.0

Affected Resource(s)

aws_rds_cluster

Terraform Configuration Files

resource "aws_rds_cluster" "test" {
  database_name       = "test"
  engine_mode         = "serverless"
  engine              = "aurora-postgresql"
  master_username     = "postgres"
  master_password     = "test"
}

Debug Output

Error: Failed to modify RDS Cluster (tf-20210413111830430300000001): InvalidParameterValue: Capacity value 1 is not valid. The valid scaling range for this cluster is 2 to 384. To change the clusters scaling range use the ModifyDBCluster call.
    status code: 400, request id: 767bf261-1fe3-4a95-b581-cd501c935f19

  on rds.tf line 1, in resource "aws_rds_cluster" "test":
   1: resource "aws_rds_cluster" "test" {

Expected Behavior

The default value should be one of the valid values.

Actual Behavior

The default value is not a valid values and is rejected by AWS.

Steps to Reproduce

With the above:

  1. terraform apply

Important Factoids

Nope, even the docs point out the inconsistency.

YakDriver commented 3 years ago

@WhyNotHugo Thank you for bringing this to our attention and providing excellent, clear information!! While we're not able to fix everything we would like, hopefully we can address this problem. Are there problems with the workaround of explicitly providing min_capacity? Do you know of an easy way to query the API to find the actual min_capacity or is it pretty static? If it's static, it wouldn't be too hard to make the default a little smarter based on the engine.

github-actions[bot] commented 1 year ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

WhyNotHugo commented 1 year ago

These seem to be static values mentioned in the documentation (I don't see any API to query them):

    // The DB cluster capacity. When you change the capacity of a paused Aurora
    // Serverless v1 DB cluster, it automatically resumes. Constraints:
    //
    // * For Aurora
    // MySQL, valid capacity values are 1, 2, 4, 8, 16, 32, 64, 128, and 256.
    //
    // * For
    // Aurora PostgreSQL, valid capacity values are 2, 4, 8, 16, 32, 64, 192, and 384.