@@ -461,13 +461,39 @@ func TestAccResourceMongoDBAtlasCluster_MultiRegion(t *testing.T) {
461
461
name = fmt .Sprintf ("test-acc-multi-%s" , acctest .RandString (10 ))
462
462
)
463
463
464
+ createRegionsConfig := `regions_config {
465
+ region_name = "US_EAST_1"
466
+ electable_nodes = 3
467
+ priority = 7
468
+ read_only_nodes = 0
469
+ }`
470
+
471
+ updatedRegionsConfig := `regions_config {
472
+ region_name = "US_WEST_2"
473
+ electable_nodes = 3
474
+ priority = 6
475
+ read_only_nodes = 0
476
+ }
477
+ regions_config {
478
+ region_name = "US_WEST_1"
479
+ electable_nodes = 1
480
+ priority = 5
481
+ read_only_nodes = 0
482
+ }
483
+ regions_config {
484
+ region_name = "US_EAST_1"
485
+ electable_nodes = 3
486
+ priority = 7
487
+ read_only_nodes = 0
488
+ }`
489
+
464
490
resource .ParallelTest (t , resource.TestCase {
465
491
PreCheck : func () { testAccPreCheck (t ) },
466
492
ProviderFactories : testAccProviderFactories ,
467
493
CheckDestroy : testAccCheckMongoDBAtlasClusterDestroy ,
468
494
Steps : []resource.TestStep {
469
495
{
470
- Config : testAccMongoDBAtlasClusterConfigMultiRegion (projectID , name , "true" ),
496
+ Config : testAccMongoDBAtlasClusterConfigMultiRegion (projectID , name , "true" , createRegionsConfig ),
471
497
Check : resource .ComposeTestCheckFunc (
472
498
testAccCheckMongoDBAtlasClusterExists (resourceName , & cluster ),
473
499
testAccCheckMongoDBAtlasClusterAttributes (& cluster , name ),
@@ -479,11 +505,11 @@ func TestAccResourceMongoDBAtlasCluster_MultiRegion(t *testing.T) {
479
505
resource .TestCheckResourceAttr (resourceName , "disk_size_gb" , "100" ),
480
506
resource .TestCheckResourceAttr (resourceName , "cluster_type" , "REPLICASET" ),
481
507
resource .TestCheckResourceAttr (resourceName , "replication_specs.#" , "1" ),
482
- resource .TestCheckResourceAttr (resourceName , "replication_specs.0.regions_config.#" , "3 " ),
508
+ resource .TestCheckResourceAttr (resourceName , "replication_specs.0.regions_config.#" , "1 " ),
483
509
),
484
510
},
485
511
{
486
- Config : testAccMongoDBAtlasClusterConfigMultiRegion (projectID , name , "false" ),
512
+ Config : testAccMongoDBAtlasClusterConfigMultiRegion (projectID , name , "false" , updatedRegionsConfig ),
487
513
Check : resource .ComposeTestCheckFunc (
488
514
testAccCheckMongoDBAtlasClusterExists (resourceName , & cluster ),
489
515
testAccCheckMongoDBAtlasClusterAttributes (& cluster , name ),
@@ -1458,7 +1484,7 @@ func testAccMongoDBAtlasClusterConfigGCPWithBiConnector(projectID, name, backupE
1458
1484
` , projectID , name , backupEnabled , biConnectorEnabled )
1459
1485
}
1460
1486
1461
- func testAccMongoDBAtlasClusterConfigMultiRegion (projectID , name , backupEnabled string ) string {
1487
+ func testAccMongoDBAtlasClusterConfigMultiRegion (projectID , name , backupEnabled , regionsConfig string ) string {
1462
1488
return fmt .Sprintf (`
1463
1489
resource "mongodbatlas_cluster" "multi_region" {
1464
1490
project_id = "%s"
@@ -1475,27 +1501,10 @@ func testAccMongoDBAtlasClusterConfigMultiRegion(projectID, name, backupEnabled
1475
1501
replication_specs {
1476
1502
num_shards = 1
1477
1503
1478
- regions_config {
1479
- region_name = "US_WEST_2"
1480
- electable_nodes = 3
1481
- priority = 7
1482
- read_only_nodes = 0
1483
- }
1484
- regions_config {
1485
- region_name = "EU_CENTRAL_1"
1486
- electable_nodes = 2
1487
- priority = 6
1488
- read_only_nodes = 0
1489
- }
1490
- regions_config {
1491
- region_name = "US_WEST_1"
1492
- electable_nodes = 2
1493
- priority = 5
1494
- read_only_nodes = 2
1495
- }
1504
+ %s
1496
1505
}
1497
1506
}
1498
- ` , projectID , name , backupEnabled )
1507
+ ` , projectID , name , backupEnabled , regionsConfig )
1499
1508
}
1500
1509
1501
1510
func testAccMongoDBAtlasClusterConfigGlobal (projectID , name , backupEnabled string ) string {
0 commit comments