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

[Bug]: aws_rds_cluster with engine_mode = "serverless", cloning a provisioned cluster with restore_to_point_in_time creates a provisioned cluster #31769

Open draoncc opened 1 year ago

draoncc commented 1 year ago

Terraform Core Version

1.4.6

AWS Provider Version

5.1.0

Affected Resource(s)

Expected Behavior

aws_rds_cluster with engine_mode = "serverless" and restore_to_point_in_time with restore_type = "copy-on-write" should always create an Aurora Serverless v1 cluster.

Actual Behavior

If restore_to_point_in_time.source_cluster_identifier points to a provisioned, regional cluster, the aws_rds_cluster resource attempts to create a provisioned, regional cluster instead.

The creation will fail with an InvalidParameterCombination: You can only specify scaling configuration for an Aurora Serverless v1 cluster.

Future applies will always try to replace the resource and set the engine_mode from "provisioned" to "serverless".

Relevant Error/Panic Output Snippet

╷
│ Error: updating RDS Cluster (staging-postgres-cluster): InvalidParameterCombination: You can only specify scaling configuration for an Aurora Serverless v1 cluster.
│   status code: 400, request id: 40c4a45c-85a7-4ae0-a277-f88091d220da
│ 
│   with module.this["postgres"].aws_rds_cluster.this[0],
│   on .terraform/modules/this/main.tf line 39, in resource "aws_rds_cluster" "this":
│   39: resource "aws_rds_cluster" "this" {
│ 
╵

Terraform Configuration Files

resource "aws_rds_cluster" "this" {
  cluster_identifier = "example"
  engine             = "aurora-postgresql"
  engine_mode        = "serverless"
  engine_version     = "13.9"
  master_username    = "root"
  master_password    = "root"

  db_subnet_group_name = data.aws_db_subnet_group.main.name

  apply_immediately   = true
  skip_final_snapshot = true

  scaling_configuration {
    min_capacity = 2
    max_capacity = 16

    auto_pause               = true
    seconds_until_auto_pause = 300
    timeout_action           = "ForceApplyCapacityChange"
  }

  restore_to_point_in_time {
    source_cluster_identifier  = "production-cluster" # <- this must point to a provisioned cluster
    restore_type               = "copy-on-write"
    use_latest_restorable_time = true
  }
}

data "aws_db_subnet_group" "main" {
  name = "prod"
}

Steps to Reproduce

  1. Create a provisioned Aurora cluster
  2. Attempt to create a serverless Aurora cluster as a clone from the provisioned Aurora cluster created in 1. with the above Terraform configuration file

Debug Output

https://gist.github.com/draoncc/cc2ecbef90ba3466f37ba36116ce31d0

Panic Output

No response

Important Factoids

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue