diff --git a/.changelog/38451.txt b/.changelog/38451.txt new file mode 100644 index 000000000000..01831689d666 --- /dev/null +++ b/.changelog/38451.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_rds_cluster: Add `scaling_configuration.seconds_before_timeout` argument +``` \ No newline at end of file diff --git a/internal/service/rds/cluster.go b/internal/service/rds/cluster.go index 70bb734c71f5..339e0cfb45f4 100644 --- a/internal/service/rds/cluster.go +++ b/internal/service/rds/cluster.go @@ -481,6 +481,12 @@ func resourceCluster() *schema.Resource { Optional: true, Default: clusterScalingConfiguration_DefaultMinCapacity, }, + "seconds_before_timeout": { + Type: schema.TypeInt, + Optional: true, + Default: 300, + ValidateFunc: validation.IntBetween(60, 600), + }, "seconds_until_auto_pause": { Type: schema.TypeInt, Optional: true, diff --git a/internal/service/rds/cluster_test.go b/internal/service/rds/cluster_test.go index 8087b8a694bd..0ac88d054692 100644 --- a/internal/service/rds/cluster_test.go +++ b/internal/service/rds/cluster_test.go @@ -1841,25 +1841,27 @@ func TestAccRDSCluster_scaling(t *testing.T) { CheckDestroy: testAccCheckClusterDestroy(ctx), Steps: []resource.TestStep{ { - Config: testAccClusterConfig_scalingConfiguration(rName, false, 128, 4, 301, "RollbackCapacityChange"), + Config: testAccClusterConfig_scalingConfiguration(rName, false, 128, 4, 301, 301, "RollbackCapacityChange"), Check: resource.ComposeTestCheckFunc( testAccCheckClusterExists(ctx, resourceName, &dbCluster), resource.TestCheckResourceAttr(resourceName, "scaling_configuration.#", acctest.Ct1), resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.auto_pause", acctest.CtFalse), resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.max_capacity", "128"), resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.min_capacity", acctest.Ct4), + resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.seconds_before_timeout", "301"), resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.seconds_until_auto_pause", "301"), resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.timeout_action", "RollbackCapacityChange"), ), }, { - Config: testAccClusterConfig_scalingConfiguration(rName, true, 256, 8, 86400, "ForceApplyCapacityChange"), + Config: testAccClusterConfig_scalingConfiguration(rName, true, 256, 8, 600, 86400, "ForceApplyCapacityChange"), Check: resource.ComposeTestCheckFunc( testAccCheckClusterExists(ctx, resourceName, &dbCluster), resource.TestCheckResourceAttr(resourceName, "scaling_configuration.#", acctest.Ct1), resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.auto_pause", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.max_capacity", "256"), resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.min_capacity", "8"), + resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.seconds_before_timeout", "600"), resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.seconds_until_auto_pause", "86400"), resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.timeout_action", "ForceApplyCapacityChange"), ), @@ -4582,7 +4584,7 @@ resource "aws_rds_cluster_instance" "secondary" { `, tfrds.ClusterEngineAuroraPostgreSQL, mainInstanceClasses, rName)) } -func testAccClusterConfig_scalingConfiguration(rName string, autoPause bool, maxCapacity, minCapacity, secondsUntilAutoPause int, timeoutAction string) string { +func testAccClusterConfig_scalingConfiguration(rName string, autoPause bool, maxCapacity, minCapacity, secondsBeforeTimeout, secondsUntilAutoPause int, timeoutAction string) string { return fmt.Sprintf(` resource "aws_rds_cluster" "test" { cluster_identifier = %[1]q @@ -4596,11 +4598,12 @@ resource "aws_rds_cluster" "test" { auto_pause = %[3]t max_capacity = %[4]d min_capacity = %[5]d - seconds_until_auto_pause = %[6]d - timeout_action = %[7]q + seconds_before_timeout = %[6]d + seconds_until_auto_pause = %[7]d + timeout_action = %[8]q } } -`, rName, tfrds.ClusterEngineAuroraMySQL, autoPause, maxCapacity, minCapacity, secondsUntilAutoPause, timeoutAction) +`, rName, tfrds.ClusterEngineAuroraMySQL, autoPause, maxCapacity, minCapacity, secondsBeforeTimeout, secondsUntilAutoPause, timeoutAction) } func testAccClusterConfig_serverlessV2ScalingConfiguration(rName string, maxCapacity, minCapacity float64) string { diff --git a/internal/service/rds/flex.go b/internal/service/rds/flex.go index d0a6039a0fb8..892118e908c5 100644 --- a/internal/service/rds/flex.go +++ b/internal/service/rds/flex.go @@ -32,6 +32,10 @@ func expandScalingConfiguration(tfMap map[string]interface{}) *rds.ScalingConfig apiObject.MinCapacity = aws.Int64(int64(v)) } + if v, ok := tfMap["seconds_before_timeout"].(int); ok { + apiObject.SecondsBeforeTimeout = aws.Int64(int64(v)) + } + if v, ok := tfMap["seconds_until_auto_pause"].(int); ok { apiObject.SecondsUntilAutoPause = aws.Int64(int64(v)) } @@ -85,6 +89,10 @@ func flattenScalingConfigurationInfo(apiObject *rds.ScalingConfigurationInfo) ma tfMap["min_capacity"] = aws.Int64Value(v) } + if v := apiObject.SecondsBeforeTimeout; v != nil { + tfMap["seconds_before_timeout"] = aws.Int64Value(v) + } + if v := apiObject.SecondsUntilAutoPause; v != nil { tfMap["seconds_until_auto_pause"] = aws.Int64Value(v) } diff --git a/website/docs/r/rds_cluster.html.markdown b/website/docs/r/rds_cluster.html.markdown index 47db023a5b9a..adb052d1df15 100644 --- a/website/docs/r/rds_cluster.html.markdown +++ b/website/docs/r/rds_cluster.html.markdown @@ -329,6 +329,7 @@ resource "aws_rds_cluster" "example" { auto_pause = true max_capacity = 256 min_capacity = 2 + seconds_before_timeout = 360 seconds_until_auto_pause = 300 timeout_action = "ForceApplyCapacityChange" } @@ -338,6 +339,7 @@ resource "aws_rds_cluster" "example" { * `auto_pause` - (Optional) Whether to enable automatic pause. A DB cluster can be paused only when it's idle (it has no connections). If a DB cluster is paused for more than seven days, the DB cluster might be backed up with a snapshot. In this case, the DB cluster is restored when there is a request to connect to it. Defaults to `true`. * `max_capacity` - (Optional) Maximum capacity for an Aurora DB cluster in `serverless` DB engine mode. The maximum capacity must be greater than or equal to the minimum 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 `16`. * `min_capacity` - (Optional) 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`. +* `seconds_before_timeout` - (Optional) Amount of time, in seconds, that Aurora Serverless v1 tries to find a scaling point to perform seamless scaling before enforcing the timeout action. Valid values are `60` through `600`. Defaults to `300`. * `seconds_until_auto_pause` - (Optional) Time, in seconds, before an Aurora DB cluster in serverless mode is paused. Valid values are `300` through `86400`. Defaults to `300`. * `timeout_action` - (Optional) Action to take when the timeout is reached. Valid values: `ForceApplyCapacityChange`, `RollbackCapacityChange`. Defaults to `RollbackCapacityChange`. See [documentation](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless-v1.how-it-works.html#aurora-serverless.how-it-works.timeout-action).