@@ -599,6 +599,44 @@ func TestAccClusterAdvancedClusterConfig_ReplicationSpecsAnalyticsAutoScaling(t
599
599
})
600
600
}
601
601
602
+ func TestAccClusterAdvancedClusterConfig_ReplicationSpecsAndShardUpdating (t * testing.T ) {
603
+ var (
604
+ cluster matlas.AdvancedCluster
605
+ resourceName = "mongodbatlas_advanced_cluster.test"
606
+ orgID = os .Getenv ("MONGODB_ATLAS_ORG_ID" )
607
+ projectName = acctest .RandomWithPrefix ("test-acc" )
608
+ rName = acctest .RandomWithPrefix ("test-acc" )
609
+ numShards = "1"
610
+ numShardsUpdated = "2"
611
+ )
612
+
613
+ resource .ParallelTest (t , resource.TestCase {
614
+ PreCheck : func () { acc .PreCheckBasic (t ) },
615
+ ProtoV6ProviderFactories : acc .TestAccProviderV6Factories ,
616
+ CheckDestroy : acc .CheckDestroyTeamAdvancedCluster ,
617
+ Steps : []resource.TestStep {
618
+ {
619
+ Config : testAccMongoDBAtlasAdvancedClusterConfigMultiZoneWithShards (orgID , projectName , rName , numShards , numShards ),
620
+ Check : resource .ComposeTestCheckFunc (
621
+ testAccCheckMongoDBAtlasAdvancedClusterExists (resourceName , & cluster ),
622
+ testAccCheckMongoDBAtlasAdvancedClusterAttributes (& cluster , rName ),
623
+ resource .TestCheckResourceAttr (resourceName , "replication_specs.0.num_shards" , "1" ),
624
+ resource .TestCheckResourceAttr (resourceName , "replication_specs.1.num_shards" , "1" ),
625
+ ),
626
+ },
627
+ {
628
+ Config : testAccMongoDBAtlasAdvancedClusterConfigMultiZoneWithShards (orgID , projectName , rName , numShardsUpdated , numShards ),
629
+ Check : resource .ComposeTestCheckFunc (
630
+ testAccCheckMongoDBAtlasAdvancedClusterExists (resourceName , & cluster ),
631
+ testAccCheckMongoDBAtlasAdvancedClusterAttributes (& cluster , rName ),
632
+ resource .TestCheckResourceAttr (resourceName , "replication_specs.0.num_shards" , "2" ),
633
+ resource .TestCheckResourceAttr (resourceName , "replication_specs.1.num_shards" , "1" ),
634
+ ),
635
+ },
636
+ },
637
+ })
638
+ }
639
+
602
640
func TestAccClusterAdvancedCluster_WithTags (t * testing.T ) {
603
641
var (
604
642
cluster matlas.AdvancedCluster
@@ -1142,3 +1180,59 @@ resource "mongodbatlas_advanced_cluster" "test" {
1142
1180
1143
1181
` , orgID , projectName , name , * p .Compute .Enabled , * p .DiskGBEnabled , p .Compute .MaxInstanceSize )
1144
1182
}
1183
+
1184
+ func testAccMongoDBAtlasAdvancedClusterConfigMultiZoneWithShards (orgID , projectName , name , numShardsFirstZone , numShardsSecondZone string ) string {
1185
+ return fmt .Sprintf (`
1186
+
1187
+ resource "mongodbatlas_project" "cluster_project" {
1188
+ name = %[2]q
1189
+ org_id = %[1]q
1190
+ }
1191
+
1192
+ resource "mongodbatlas_advanced_cluster" "test" {
1193
+ project_id = mongodbatlas_project.cluster_project.id
1194
+ name = %[3]q
1195
+ backup_enabled = false
1196
+ mongo_db_major_version = "6.0"
1197
+ cluster_type = "GEOSHARDED"
1198
+
1199
+ replication_specs {
1200
+ zone_name = "zone n1"
1201
+ num_shards = %[4]q
1202
+
1203
+ region_configs {
1204
+ electable_specs {
1205
+ instance_size = "M10"
1206
+ node_count = 3
1207
+ }
1208
+ analytics_specs {
1209
+ instance_size = "M10"
1210
+ node_count = 0
1211
+ }
1212
+ provider_name = "AWS"
1213
+ priority = 7
1214
+ region_name = "US_EAST_1"
1215
+ }
1216
+ }
1217
+
1218
+ replication_specs {
1219
+ zone_name = "zone n2"
1220
+ num_shards = %[5]q
1221
+
1222
+ region_configs {
1223
+ electable_specs {
1224
+ instance_size = "M10"
1225
+ node_count = 3
1226
+ }
1227
+ analytics_specs {
1228
+ instance_size = "M10"
1229
+ node_count = 0
1230
+ }
1231
+ provider_name = "AWS"
1232
+ priority = 7
1233
+ region_name = "EU_WEST_1"
1234
+ }
1235
+ }
1236
+ }
1237
+ ` , orgID , projectName , name , numShardsFirstZone , numShardsSecondZone )
1238
+ }
0 commit comments