Skip to content

Commit

Permalink
Merge pull request #40230 from ohookins/40226-zero-capacity-aurora-se…
Browse files Browse the repository at this point in the history
…rverless-scaling

Allow Aurora Serverless scaling to zero capacity.
  • Loading branch information
ewbankkit authored Dec 4, 2024
2 parents d66c6ee + bbc3f5a commit 33689a1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .changelog/40230.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_rds_cluster: Adjust `serverlessv2_scaling_configuration.max_capacity` and `serverlessv2_scaling_configuration.min_capacity` minimum values to `0` to support Amazon Aurora Serverless v2 scaling to 0 ACUs
```
8 changes: 4 additions & 4 deletions internal/service/rds/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,12 +547,12 @@ func resourceCluster() *schema.Resource {
names.AttrMaxCapacity: {
Type: schema.TypeFloat,
Required: true,
ValidateFunc: validation.FloatBetween(0.5, 256),
ValidateFunc: validation.FloatBetween(0, 256),
},
"min_capacity": {
Type: schema.TypeFloat,
Required: true,
ValidateFunc: validation.FloatBetween(0.5, 256),
ValidateFunc: validation.FloatBetween(0, 256),
},
},
},
Expand Down Expand Up @@ -2136,11 +2136,11 @@ func expandServerlessV2ScalingConfiguration(tfMap map[string]interface{}) *types

apiObject := &types.ServerlessV2ScalingConfiguration{}

if v, ok := tfMap[names.AttrMaxCapacity].(float64); ok && v != 0.0 {
if v, ok := tfMap[names.AttrMaxCapacity].(float64); ok {
apiObject.MaxCapacity = aws.Float64(v)
}

if v, ok := tfMap["min_capacity"].(float64); ok && v != 0.0 {
if v, ok := tfMap["min_capacity"].(float64); ok {
apiObject.MinCapacity = aws.Float64(v)
}

Expand Down
8 changes: 4 additions & 4 deletions internal/service/rds/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2068,21 +2068,21 @@ func TestAccRDSCluster_serverlessV2ScalingConfiguration(t *testing.T) {
CheckDestroy: testAccCheckClusterDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccClusterConfig_serverlessV2ScalingConfiguration(rName, 64.0, 0.5),
Config: testAccClusterConfig_serverlessV2ScalingConfiguration(rName, 64.0, 2.5),
Check: resource.ComposeTestCheckFunc(
testAccCheckClusterExists(ctx, resourceName, &dbCluster),
resource.TestCheckResourceAttr(resourceName, "serverlessv2_scaling_configuration.#", "1"),
resource.TestCheckResourceAttr(resourceName, "serverlessv2_scaling_configuration.0.max_capacity", "64"),
resource.TestCheckResourceAttr(resourceName, "serverlessv2_scaling_configuration.0.min_capacity", "0.5"),
resource.TestCheckResourceAttr(resourceName, "serverlessv2_scaling_configuration.0.min_capacity", "2.5"),
),
},
{
Config: testAccClusterConfig_serverlessV2ScalingConfiguration(rName, 256.0, 8.5),
Config: testAccClusterConfig_serverlessV2ScalingConfiguration(rName, 256.0, 0),
Check: resource.ComposeTestCheckFunc(
testAccCheckClusterExists(ctx, resourceName, &dbCluster),
resource.TestCheckResourceAttr(resourceName, "serverlessv2_scaling_configuration.#", "1"),
resource.TestCheckResourceAttr(resourceName, "serverlessv2_scaling_configuration.0.max_capacity", "256"),
resource.TestCheckResourceAttr(resourceName, "serverlessv2_scaling_configuration.0.min_capacity", "8.5"),
resource.TestCheckResourceAttr(resourceName, "serverlessv2_scaling_configuration.0.min_capacity", "0"),
),
},
},
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/rds_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ resource "aws_rds_cluster" "example" {
}
```

* `max_capacity` - (Required) Maximum capacity for an Aurora DB cluster in `provisioned` DB engine mode. The maximum capacity must be greater than or equal to the minimum capacity. Valid capacity values are in a range of `0.5` up to `256` in steps of `0.5`.
* `min_capacity` - (Required) Minimum capacity for an Aurora DB cluster in `provisioned` DB engine mode. The minimum capacity must be lesser than or equal to the maximum capacity. Valid capacity values are in a range of `0.5` up to `256` in steps of `0.5`.
* `max_capacity` - (Required) Maximum capacity for an Aurora DB cluster in `provisioned` DB engine mode. The maximum capacity must be greater than or equal to the minimum capacity. Valid capacity values are in a range of `0` up to `256` in steps of `0.5`.
* `min_capacity` - (Required) Minimum capacity for an Aurora DB cluster in `provisioned` DB engine mode. The minimum capacity must be lesser than or equal to the maximum capacity. Valid capacity values are in a range of `0` up to `256` in steps of `0.5`.

## Attribute Reference

Expand Down

0 comments on commit 33689a1

Please sign in to comment.