Skip to content

Commit 707de42

Browse files
authored
fix: overrides to attribute behavior for resource elems. (#1572)
* fix: overrides to attribute behavior for resource elems. * addresses comments. * fixes error. * fixes test name. * fixes test.
1 parent c3ff8a0 commit 707de42

File tree

2 files changed

+55
-8
lines changed

2 files changed

+55
-8
lines changed

mongodbatlas/resource_mongodbatlas_cluster.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ func resourceMongoDBAtlasCluster() *schema.Resource {
8888
Description: "Flag that indicates whether to retain backup snapshots for the deleted dedicated cluster",
8989
},
9090
"bi_connector_config": {
91-
Type: schema.TypeList,
92-
Optional: true,
93-
Computed: true,
94-
MaxItems: 1,
91+
Type: schema.TypeList,
92+
Optional: true,
93+
ConfigMode: schema.SchemaConfigModeAttr,
94+
Computed: true,
95+
MaxItems: 1,
9596
Elem: &schema.Resource{
9697
Schema: map[string]*schema.Schema{
9798
"enabled": {
@@ -1606,10 +1607,11 @@ func isEqualProviderAutoScalingMaxInstanceSize(k, old, newStr string, d *schema.
16061607

16071608
func clusterAdvancedConfigurationSchema() *schema.Schema {
16081609
return &schema.Schema{
1609-
Type: schema.TypeList,
1610-
Optional: true,
1611-
Computed: true,
1612-
MaxItems: 1,
1610+
Type: schema.TypeList,
1611+
Optional: true,
1612+
Computed: true,
1613+
ConfigMode: schema.SchemaConfigModeAttr,
1614+
MaxItems: 1,
16131615
Elem: &schema.Resource{
16141616
Schema: map[string]*schema.Schema{
16151617
"default_read_concern": {

mongodbatlas/resource_mongodbatlas_cluster_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import (
1010

1111
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
1212
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
13+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
1314
"github.com/hashicorp/terraform-plugin-testing/terraform"
15+
"github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/testutils"
1416
"github.com/mwielbut/pointy"
1517
matlas "go.mongodb.org/atlas/mongodbatlas"
1618
)
@@ -1410,6 +1412,49 @@ func TestAccClusterRSCluster_basicAWS_PausedToUnpaused(t *testing.T) {
14101412
})
14111413
}
14121414

1415+
func TestAccClusterRSCluster_withDefaultBiConnectorAndAdvancedConfiguration_maintainsBackwardCompatibility(t *testing.T) {
1416+
var (
1417+
cluster matlas.Cluster
1418+
resourceName = "mongodbatlas_cluster.test"
1419+
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
1420+
projectName = acctest.RandomWithPrefix("test-acc")
1421+
name = fmt.Sprintf("test-acc-%s", acctest.RandString(10))
1422+
config = testAccMongoDBAtlasClusterConfigAWS(orgID, projectName, name, true, true)
1423+
)
1424+
1425+
resource.ParallelTest(t, resource.TestCase{
1426+
PreCheck: func() { testAccPreCheckBasic(t) },
1427+
CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy,
1428+
Steps: []resource.TestStep{
1429+
{
1430+
ExternalProviders: map[string]resource.ExternalProvider{
1431+
"mongodbatlas": {
1432+
VersionConstraint: "1.11.0",
1433+
Source: "mongodb/mongodbatlas",
1434+
},
1435+
},
1436+
Config: config,
1437+
Check: resource.ComposeTestCheckFunc(
1438+
testAccCheckMongoDBAtlasClusterExists(resourceName, &cluster),
1439+
testAccCheckMongoDBAtlasClusterAttributes(&cluster, name),
1440+
resource.TestCheckResourceAttrSet(resourceName, "project_id"),
1441+
resource.TestCheckResourceAttr(resourceName, "name", name),
1442+
),
1443+
},
1444+
{
1445+
ProtoV6ProviderFactories: testAccProviderV6Factories,
1446+
Config: config,
1447+
ConfigPlanChecks: resource.ConfigPlanChecks{
1448+
PostApplyPreRefresh: []plancheck.PlanCheck{
1449+
testutils.DebugPlan(),
1450+
},
1451+
},
1452+
PlanOnly: true,
1453+
},
1454+
},
1455+
})
1456+
}
1457+
14131458
func testAccCheckMongoDBAtlasClusterImportStateIDFunc(resourceName string) resource.ImportStateIdFunc {
14141459
return func(s *terraform.State) (string, error) {
14151460
rs, ok := s.RootModule().Resources[resourceName]

0 commit comments

Comments
 (0)