diff --git a/mongodbatlas/resource_mongodbatlas_advanced_cluster.go b/mongodbatlas/resource_mongodbatlas_advanced_cluster.go index 5787698028..44ac01fc59 100644 --- a/mongodbatlas/resource_mongodbatlas_advanced_cluster.go +++ b/mongodbatlas/resource_mongodbatlas_advanced_cluster.go @@ -1134,9 +1134,7 @@ func getUpgradeRequest(d *schema.ResourceData) *matlas.Cluster { updatedRegion := updatedSpecs[0].RegionConfigs[0] currentSize := currentRegion.ElectableSpecs.InstanceSize - if currentRegion.ElectableSpecs.InstanceSize == updatedRegion.ElectableSpecs.InstanceSize || !(currentSize == "M0" || - currentSize == "M2" || - currentSize == "M5") { + if currentRegion.ElectableSpecs.InstanceSize == updatedRegion.ElectableSpecs.InstanceSize || !isSharedTier(currentSize) { return nil } diff --git a/mongodbatlas/resource_mongodbatlas_cluster.go b/mongodbatlas/resource_mongodbatlas_cluster.go index 47d208c5c2..0836eb98b4 100644 --- a/mongodbatlas/resource_mongodbatlas_cluster.go +++ b/mongodbatlas/resource_mongodbatlas_cluster.go @@ -900,8 +900,6 @@ func resourceMongoDBAtlasClusterUpdate(ctx context.Context, d *schema.ResourceDa } } - var didUnpauseCluster = false - if isUpgradeRequired(d) { updatedCluster, _, err := upgradeCluster(ctx, conn, cluster, projectID, clusterName) @@ -925,8 +923,6 @@ func resourceMongoDBAtlasClusterUpdate(ctx context.Context, d *schema.ResourceDa } _, _, err = updateCluster(ctx, conn, clusterRequest, projectID, clusterName) - - didUnpauseCluster = true } if err != nil { @@ -957,7 +953,7 @@ func resourceMongoDBAtlasClusterUpdate(ctx context.Context, d *schema.ResourceDa } } - if didUnpauseCluster { + if d.Get("paused").(bool) && !isSharedTier(d.Get("provider_instance_size_name").(string)) { clusterRequest := &matlas.Cluster{ Paused: pointy.Bool(true), } @@ -1240,14 +1236,14 @@ func flattenProviderSettings(d *schema.ResourceData, settings *matlas.ProviderSe } } +func isSharedTier(instanceSize string) bool { + return instanceSize == "M0" || instanceSize == "M2" || instanceSize == "M5" +} + func isUpgradeRequired(d *schema.ResourceData) bool { currentSize, updatedSize := d.GetChange("provider_instance_size_name") - if currentSize == updatedSize { - return false - } - - return currentSize == "M0" || currentSize == "M2" || currentSize == "M5" + return currentSize != updatedSize && isSharedTier(currentSize.(string)) } func expandReplicationSpecs(d *schema.ResourceData) ([]matlas.ReplicationSpec, error) {