Skip to content

INTMDB-269: Fix issue with default auto_scaling_disk_gb_enabled value #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Oct 22, 2021
2 changes: 1 addition & 1 deletion mongodbatlas/data_source_mongodbatlas_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func TestAccDataSourceMongoDBAtlasCluster_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(dataSourceName, "replication_specs.#"),
resource.TestCheckResourceAttrSet(dataSourceName, "replication_specs.0.regions_config.#"),
resource.TestCheckResourceAttr(resourceName, "labels.#", "2"),
resource.TestCheckResourceAttr(resourceName, "auto_scaling_disk_gb_enabled", "true"),
),
},
},
Expand All @@ -68,7 +69,6 @@ func testAccDataSourceMongoDBAtlasClusterConfig(projectID, name, backupEnabled s
}

provider_backup_enabled = %s
auto_scaling_disk_gb_enabled = true

// Provider Settings "block"
provider_name = "AWS"
Expand Down
13 changes: 5 additions & 8 deletions mongodbatlas/resource_mongodbatlas_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func resourceMongoDBAtlasCluster() *schema.Resource {
},
"auto_scaling_disk_gb_enabled": {
Type: schema.TypeBool,
Default: true,
Optional: true,
},
"auto_scaling_compute_enabled": {
Expand Down Expand Up @@ -413,10 +414,6 @@ func resourceMongoDBAtlasClusterCreate(ctx context.Context, d *schema.ResourceDa

tenantDisksize := pointy.Float64(0)
if providerName == "TENANT" {
if diskGBEnabled := d.Get("auto_scaling_disk_gb_enabled"); diskGBEnabled.(bool) {
return diag.FromErr(fmt.Errorf("`auto_scaling_disk_gb_enabled` cannot be true when provider name is TENANT"))
}

autoScaling = nil

if instanceSizeName, ok := d.GetOk("provider_instance_size_name"); ok {
Expand Down Expand Up @@ -592,10 +589,6 @@ func resourceMongoDBAtlasClusterRead(ctx context.Context, d *schema.ResourceData
return diag.FromErr(fmt.Errorf(errorClusterSetting, "cluster_id", clusterName, err))
}

if err := d.Set("auto_scaling_disk_gb_enabled", cluster.AutoScaling.DiskGBEnabled); err != nil {
return diag.FromErr(fmt.Errorf(errorClusterSetting, "auto_scaling_disk_gb_enabled", clusterName, err))
}

if err := d.Set("auto_scaling_compute_enabled", cluster.AutoScaling.Compute.Enabled); err != nil {
return diag.FromErr(fmt.Errorf(errorClusterSetting, "auto_scaling_compute_enabled", clusterName, err))
}
Expand Down Expand Up @@ -723,6 +716,10 @@ func resourceMongoDBAtlasClusterRead(ctx context.Context, d *schema.ResourceData
if err := d.Set("container_id", getContainerID(containers, cluster)); err != nil {
return diag.FromErr(fmt.Errorf(errorClusterSetting, "container_id", clusterName, err))
}

if err := d.Set("auto_scaling_disk_gb_enabled", cluster.AutoScaling.DiskGBEnabled); err != nil {
return diag.FromErr(fmt.Errorf(errorClusterSetting, "auto_scaling_disk_gb_enabled", clusterName, err))
}
}

/*
Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ output "private_srv" {
* `auto_scaling_disk_gb_enabled` - (Optional) Specifies whether disk auto-scaling is enabled. The default is true.
- Set to `true` to enable disk auto-scaling.
- Set to `false` to disable disk auto-scaling.

-> **NOTE:** If `provider_name` is set to `TENANT`, the parameter `auto_scaling_disk_gb_enabled` will be ignored.

* `auto_scaling_compute_enabled` - (Optional) Specifies whether cluster tier auto-scaling is enabled. The default is false.
- Set to `true` to enable cluster tier auto-scaling. If enabled, you must specify a value for `providerSettings.autoScaling.compute.maxInstanceSize`.
- Set to `false` to disable cluster tier auto-scaling.
Expand Down