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

feat: Add enable_local_write_forwarding arg to aws_rds_cluster #34370

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/34370.txt
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_rds_cluster: Add `enable_local_write_forwarding` argument to support Aurora MySQL local write forwarding
```
23 changes: 18 additions & 5 deletions internal/service/rds/cluster.go
Expand Up @@ -188,6 +188,16 @@ func ResourceCluster() *schema.Resource {
Optional: true,
Default: false,
},
"enable_http_endpoint": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"enable_local_write_forwarding": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"enabled_cloudwatch_logs_exports": {
Type: schema.TypeSet,
Optional: true,
Expand All @@ -196,11 +206,6 @@ func ResourceCluster() *schema.Resource {
ValidateFunc: validation.StringInSlice(ClusterExportableLogType_Values(), false),
},
},
"enable_http_endpoint": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"endpoint": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -1014,6 +1019,10 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int
input.EnableHttpEndpoint = aws.Bool(v.(bool))
}

if v, ok := d.GetOk("enable_local_write_forwarding"); ok {
input.EnableLocalWriteForwarding = aws.Bool(v.(bool))
}

if v, ok := d.GetOk("enabled_cloudwatch_logs_exports"); ok && v.(*schema.Set).Len() > 0 {
input.EnableCloudwatchLogsExports = flex.ExpandStringSet(v.(*schema.Set))
}
Expand Down Expand Up @@ -1347,6 +1356,10 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, meta int
input.EnableHttpEndpoint = aws.Bool(d.Get("enable_http_endpoint").(bool))
}

if d.HasChange("enable_local_write_forwarding") {
input.EnableLocalWriteForwarding = aws.Bool(d.Get("enable_local_write_forwarding").(bool))
}

if d.HasChange("enabled_cloudwatch_logs_exports") {
oraw, nraw := d.GetChange("enabled_cloudwatch_logs_exports")
o := oraw.(*schema.Set)
Expand Down
42 changes: 42 additions & 0 deletions internal/service/rds/cluster_test.go
Expand Up @@ -40,6 +40,7 @@ func testAccClusterImportStep(n string) resource.TestStep {
"cluster_members",
"db_instance_parameter_group_name",
"enable_global_write_forwarding",
"enable_local_write_forwarding",
"manage_master_user_password",
"master_password",
"master_user_secret_kms_key_id",
Expand Down Expand Up @@ -411,6 +412,7 @@ func TestAccRDSCluster_onlyMajorVersion(t *testing.T) {
"cluster_members",
"db_instance_parameter_group_name",
"enable_global_write_forwarding",
"enable_local_write_forwarding",
"engine_version",
"master_password",
"skip_final_snapshot",
Expand Down Expand Up @@ -2708,6 +2710,31 @@ func testAccCheckClusterNotRecreated(i, j *rds.DBCluster) resource.TestCheckFunc
}
}

func TestAccRDSCluster_localWriteForwarding(t *testing.T) {
ctx := acctest.Context(t)
var dbCluster rds.DBCluster
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_rds_cluster.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.RDSServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckClusterDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccClusterConfig_localWriteForwarding(rName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckClusterExists(ctx, resourceName, &dbCluster),
acctest.CheckResourceAttrRegionalARN(resourceName, "arn", "rds", fmt.Sprintf("cluster:%s", rName)),
resource.TestCheckResourceAttr(resourceName, "enable_local_write_forwarding", "true"),
),
},
testAccClusterImportStep(resourceName),
},
})
}

func testAccClusterConfig_basic(rName string) string {
return fmt.Sprintf(`
resource "aws_rds_cluster" "test" {
Expand Down Expand Up @@ -5083,3 +5110,18 @@ resource "aws_rds_cluster" "test" {
}
`, rName, tfrds.ClusterEngineAuroraMySQL, preferredBackupWindow)
}

func testAccClusterConfig_localWriteForwarding(rName string) string {
return fmt.Sprintf(`
resource "aws_rds_cluster" "test" {
cluster_identifier = %[1]q
database_name = "test"
engine = "aurora-mysql"
engine_version = "8.0.mysql_aurora.3.04.0"
enable_local_write_forwarding = true
master_username = "tfacctest"
master_password = "avoid-plaintext-passwords"
skip_final_snapshot = true
}
`, rName)
}
3 changes: 2 additions & 1 deletion website/docs/r/rds_cluster.html.markdown
Expand Up @@ -234,8 +234,9 @@ This argument supports the following arguments:
The default is `false`.
* `domain` - (Optional) The ID of the Directory Service Active Directory domain to create the cluster in.
* `domain_iam_role_name` - (Optional, but required if `domain` is provided) The name of the IAM role to be used when making API calls to the Directory Service.
* `enable_global_write_forwarding` - (Optional) Whether cluster should forward writes to an associated global cluster. Applied to secondary clusters to enable them to forward writes to an [`aws_rds_global_cluster`](/docs/providers/aws/r/rds_global_cluster.html)'s primary cluster. See the [Aurora Userguide documentation](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-global-database-write-forwarding.html) for more information.
* `enable_global_write_forwarding` - (Optional) Whether cluster should forward writes to an associated global cluster. Applied to secondary clusters to enable them to forward writes to an [`aws_rds_global_cluster`](/docs/providers/aws/r/rds_global_cluster.html)'s primary cluster. See the [User Guide for Aurora](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-global-database-write-forwarding.html) for more information.
* `enable_http_endpoint` - (Optional) Enable HTTP endpoint (data API). Only valid when `engine_mode` is set to `serverless`.
* `enable_local_write_forwarding` - (Optional) Whether read replicas can forward write operations to the writer DB instance in the DB cluster. By default, write operations aren't allowed on reader DB instances.. See the [User Guide for Aurora](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-mysql-write-forwarding.html) for more information. **NOTE:** Local write forwarding requires Aurora MySQL version 3.04 or higher.
* `enabled_cloudwatch_logs_exports` - (Optional) Set of log types to export to cloudwatch. If omitted, no logs will be exported. The following log types are supported: `audit`, `error`, `general`, `slowquery`, `postgresql` (PostgreSQL).
* `engine_mode` - (Optional) Database engine mode. Valid values: `global` (only valid for Aurora MySQL 1.21 and earlier), `parallelquery`, `provisioned`, `serverless`. Defaults to: `provisioned`. See the [RDS User Guide](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/aurora-serverless.html) for limitations when using `serverless`.
* `engine_version` - (Optional) Database engine version. Updating this argument results in an outage. See the [Aurora MySQL](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Updates.html) and [Aurora Postgres](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Updates.html) documentation for your configured engine to determine this value, or by running `aws rds describe-db-engine-versions`. For example with Aurora MySQL 2, a potential value for this argument is `5.7.mysql_aurora.2.03.2`. The value can contain a partial version where supported by the API. The actual engine version used is returned in the attribute `engine_version_actual`, , see [Attribute Reference](#attribute-reference) below.
Expand Down