I'm working with an RDS Aurora Postgres Serverless V2 instance, and I thought I could set the minimum capacity to zero to save on costs when it's not in use. However, I keep running into an issue. My resource configuration looks like this:
```hcl
resource "aws_rds_cluster" "operational-postgresql-cluster-dev" {
cluster_identifier = "operational-postgresql-cluster-dev"
engine = "aurora-postgresql"
engine_version = "16.6"
engine_mode = "provisioned"
availability_zones = ["eu-central-1a", "eu-central-1b", "eu-central-1c"]
vpc_security_group_ids = [aws_security_group.dev_v1_security_group_rds.id]
db_subnet_group_name = aws_db_subnet_group.operational_db_dev_subnet_group.name
database_name = "operational_db_dev_v1"
master_username = "db_admin"
master_password = aws_secretsmanager_secret_version.operational_dev_db_password_v1.secret_string
skip_final_snapshot = false
final_snapshot_identifier = "aurora-postgres-dev-cluster-backup-v1"
backup_retention_period = 14
enable_http_endpoint = true
serverlessv2_scaling_configuration {
max_capacity = 1.0
min_capacity = 0.5
}
}
```
The article I read from AWS suggests that scaling down to zero is possible, but when I try to set `min_capacity` to 0.0, I get the following error:
*Error: expected serverlessv2_scaling_configuration.0.min_capacity to be in the range (0.500000 - 128.000000), got 0.000000*
Is this a bug, or do I need to use AWS CLI commands to enable this feature? Any help would be appreciated!
4 Answers
It looks like you're not actually using Aurora Serverless. You'll need to double-check your engine configuration because it's set to `provisioned`, which is why you can't scale down to zero. Switch to the right engine mode for Serverless and try again!
What version of the Terraform AWS Provider are you using? There might be limits on the specific version, so check for updates in the changelog.
You're right about needing to configure instances. You can define serverless instances in `aws_rds_cluster_instance` using `instance_class = "db.serverless"`. Ensure that you have the right settings at both the cluster and instance levels.
I had a similar issue with mine, where it seemed like it was configured correctly but never scaled down to zero during idle time. I set a timeout of 10 minutes, but it still didn't work as expected. Maybe it's something with the version or the timeout settings?
I'm using the v5.80.0 version right now. Maybe I should look into updating it!