Skip to content

Commit

Permalink
r/aws_memorydb_multi_region_cluster: remove provider default for `tls…
Browse files Browse the repository at this point in the history
…_enabled`

The argument is now changed to optional and computed to allow for the default value to be configured by AWS when omitted, rather than set explicitly to a hardcoded value in the provider.

```console
% make testacc PKG=memorydb TESTS="TestAccMemoryDBMultiRegionCluster_"
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.3 test ./internal/service/memorydb/... -v -count 1 -parallel 20 -run='TestAccMemoryDBMultiRegionCluster_'  -timeout 360m
2024/12/17 13:24:43 Initializing Terraform AWS Provider...

--- PASS: TestAccMemoryDBMultiRegionCluster_disappears (57.02s)
--- PASS: TestAccMemoryDBMultiRegionCluster_parameterGroup (65.62s)
--- PASS: TestAccMemoryDBMultiRegionCluster_description (66.54s)
--- PASS: TestAccMemoryDBMultiRegionCluster_engineVersion (66.80s)
--- PASS: TestAccMemoryDBMultiRegionCluster_basic (66.90s)
--- PASS: TestAccMemoryDBMultiRegionCluster_engine (66.97s)
--- PASS: TestAccMemoryDBMultiRegionCluster_tags (88.16s)
--- PASS: TestAccMemoryDBMultiRegionCluster_numShards (116.65s)
--- PASS: TestAccMemoryDBMultiRegionCluster_tlsEnabled (117.55s)
--- PASS: TestAccMemoryDBMultiRegionCluster_nodeType (122.02s)
--- PASS: TestAccMemoryDBMultiRegionCluster_updateStrategy (165.72s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/memorydb   171.075s
```
  • Loading branch information
jar-b committed Dec 17, 2024
1 parent f679b45 commit 67d34f5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
7 changes: 5 additions & 2 deletions internal/service/memorydb/multi_region_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
Expand Down Expand Up @@ -131,7 +131,10 @@ func (r *multiRegionClusterResource) Schema(ctx context.Context, request resourc
"tls_enabled": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
PlanModifiers: []planmodifier.Bool{
boolplanmodifier.UseStateForUnknown(),
boolplanmodifier.RequiresReplace(),
},
},
"update_strategy": schema.StringAttribute{
Optional: true,
Expand Down
17 changes: 12 additions & 5 deletions internal/service/memorydb/multi_region_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,24 @@ func TestAccMemoryDBMultiRegionCluster_tlsEnabled(t *testing.T) {
CheckDestroy: testAccCheckMultiRegionClusterDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccMultiRegionClusterConfig_tlsEnabled(rName),
Config: testAccMultiRegionClusterConfig_tlsEnabled(rName, true),
Check: resource.ComposeTestCheckFunc(
testAccCheckMultiRegionClusterExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "tls_enabled", acctest.CtFalse),
resource.TestCheckResourceAttr(resourceName, "tls_enabled", acctest.CtTrue),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccMultiRegionClusterConfig_tlsEnabled(rName, false),
Check: resource.ComposeTestCheckFunc(
testAccCheckMultiRegionClusterExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "tls_enabled", acctest.CtFalse),
),
},
},
})
}
Expand Down Expand Up @@ -473,14 +480,14 @@ resource "aws_memorydb_multi_region_cluster" "test" {
`, rName)
}

func testAccMultiRegionClusterConfig_tlsEnabled(rName string) string {
func testAccMultiRegionClusterConfig_tlsEnabled(rName string, tlsEnabled bool) string {
return fmt.Sprintf(`
resource "aws_memorydb_multi_region_cluster" "test" {
multi_region_cluster_name_suffix = %[1]q
node_type = "db.r7g.xlarge"
tls_enabled = false
tls_enabled = %[2]t
}
`, rName)
`, rName, tlsEnabled)
}

func testAccMultiRegionClusterConfig_engine(rName, engine string) string {
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/memorydb_multi_region_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ The following arguments are required:
The following arguments are optional:

* `description` - (Optional) description for the multi-region cluster.
* `engine` - (Optional) The name of the engine to be used for the multi-region cluster. Supported values are `redis` and `valkey`.
* `engine` - (Optional) The name of the engine to be used for the multi-region cluster. Valid values are `redis` and `valkey`.
* `engine_version` - (Optional) The version of the engine to be used for the multi-region cluster. Downgrades are not supported.
* `multi_region_parameter_group_name` - (Optional) The name of the multi-region parameter group to be associated with the cluster.
* `num_shards` - (Optional) The number of shards for the multi-region cluster.
* `tags` - (Optional) A map of tags to assign to the resource. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.
* `tls_enabled` - (Optional, Forces new resource) A flag to enable in-transit encryption on the cluster. Defaults to `true`.
* `tls_enabled` - (Optional, Forces new resource) A flag to enable in-transit encryption on the cluster.

## Attribute Reference

Expand Down

0 comments on commit 67d34f5

Please sign in to comment.