Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/aws_rds_cluster: Add TimeoutAction support #9374

Merged
merged 1 commit into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions aws/resource_aws_rds_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@ func resourceAwsRDSCluster() *schema.Resource {
Default: 300,
ValidateFunc: validation.IntBetween(300, 86400),
},
"timeout_action": {
Type: schema.TypeString,
Optional: true,
Default: "RollbackCapacityChange",
ValidateFunc: validation.StringInSlice([]string{
"ForceApplyCapacityChange",
"RollbackCapacityChange",
}, false),
},
},
},
},
Expand Down
11 changes: 7 additions & 4 deletions aws/resource_aws_rds_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1038,25 +1038,27 @@ func TestAccAWSRDSCluster_ScalingConfiguration(t *testing.T) {
CheckDestroy: testAccCheckAWSClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSRDSClusterConfig_ScalingConfiguration(rName, false, 128, 4, 301),
Config: testAccAWSRDSClusterConfig_ScalingConfiguration(rName, false, 128, 4, 301, "RollbackCapacityChange"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSClusterExists(resourceName, &dbCluster),
resource.TestCheckResourceAttr(resourceName, "scaling_configuration.#", "1"),
resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.auto_pause", "false"),
resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.max_capacity", "128"),
resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.min_capacity", "4"),
resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.seconds_until_auto_pause", "301"),
resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.timeout_action", "RollbackCapacityChange"),
),
},
{
Config: testAccAWSRDSClusterConfig_ScalingConfiguration(rName, true, 256, 8, 86400),
Config: testAccAWSRDSClusterConfig_ScalingConfiguration(rName, true, 256, 8, 86400, "ForceApplyCapacityChange"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSClusterExists(resourceName, &dbCluster),
resource.TestCheckResourceAttr(resourceName, "scaling_configuration.#", "1"),
resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.auto_pause", "true"),
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_until_auto_pause", "86400"),
resource.TestCheckResourceAttr(resourceName, "scaling_configuration.0.timeout_action", "ForceApplyCapacityChange"),
),
},
{
Expand Down Expand Up @@ -2534,7 +2536,7 @@ resource "aws_rds_cluster" "test" {
`, rName, rName, globalClusterIdentifierResourceName)
}

func testAccAWSRDSClusterConfig_ScalingConfiguration(rName string, autoPause bool, maxCapacity, minCapacity, secondsUntilAutoPause int) string {
func testAccAWSRDSClusterConfig_ScalingConfiguration(rName string, autoPause bool, maxCapacity, minCapacity, secondsUntilAutoPause int, timeoutAction string) string {
return fmt.Sprintf(`
resource "aws_rds_cluster" "test" {
cluster_identifier = %q
Expand All @@ -2548,9 +2550,10 @@ resource "aws_rds_cluster" "test" {
max_capacity = %d
min_capacity = %d
seconds_until_auto_pause = %d
timeout_action = "%s"
}
}
`, rName, autoPause, maxCapacity, minCapacity, secondsUntilAutoPause)
`, rName, autoPause, maxCapacity, minCapacity, secondsUntilAutoPause, timeoutAction)
}

func testAccAWSRDSClusterConfig_SnapshotIdentifier(rName string) string {
Expand Down
5 changes: 5 additions & 0 deletions aws/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -4770,6 +4770,10 @@ func expandRdsScalingConfiguration(l []interface{}) *rds.ScalingConfiguration {
SecondsUntilAutoPause: aws.Int64(int64(m["seconds_until_auto_pause"].(int))),
}

if vTimeoutAction, ok := m["timeout_action"].(string); ok && vTimeoutAction != "" {
scalingConfiguration.TimeoutAction = aws.String(vTimeoutAction)
}

return scalingConfiguration
}

Expand All @@ -4783,6 +4787,7 @@ func flattenRdsScalingConfigurationInfo(scalingConfigurationInfo *rds.ScalingCon
"max_capacity": aws.Int64Value(scalingConfigurationInfo.MaxCapacity),
"min_capacity": aws.Int64Value(scalingConfigurationInfo.MinCapacity),
"seconds_until_auto_pause": aws.Int64Value(scalingConfigurationInfo.SecondsUntilAutoPause),
"timeout_action": aws.StringValue(scalingConfigurationInfo.TimeoutAction),
}

return []interface{}{m}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/rds_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ resource "aws_rds_cluster" "example" {
max_capacity = 256
min_capacity = 2
seconds_until_auto_pause = 300
timeout_action = "ForceApplyCapacityChange"
}
}
```
Expand All @@ -177,6 +178,7 @@ resource "aws_rds_cluster" "example" {
* `max_capacity` - (Optional) The maximum capacity. The maximum capacity must be greater than or equal to the minimum capacity. Valid capacity values are `1`, `2`, `4`, `8`, `16`, `32`, `64`, `128`, and `256`. Defaults to `16`.
* `min_capacity` - (Optional) The minimum capacity. The minimum capacity must be lesser than or equal to the maximum capacity. Valid capacity values are `1`, `2`, `4`, `8`, `16`, `32`, `64`, `128`, and `256`. Defaults to `2`.
* `seconds_until_auto_pause` - (Optional) The 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) The 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.how-it-works.html#aurora-serverless.how-it-works.timeout-action).

## Attributes Reference

Expand Down