From 42003859c43eb05757c46611f508a7bcb18eaa25 Mon Sep 17 00:00:00 2001 From: cveticm <119604954+cveticm@users.noreply.github.com> Date: Fri, 22 Nov 2024 10:18:44 +0000 Subject: [PATCH 01/12] feat: Adjust `mongodbatlas_advanced_cluster` update operation to use latest sdk (#2814) * change API call version * removed temporary 20240805 functions and adjust create operation * added changelog * adjusted comments * Implements review feedback --- .changelog/2814.txt | 3 + internal/common/conversion/flatten_expand.go | 14 --- .../advancedcluster/model_advanced_cluster.go | 45 ++++---- .../model_advanced_cluster_test.go | 5 +- .../model_sdk_version_conversion.go | 19 ++-- .../resource_advanced_cluster.go | 31 +++--- .../advancedcluster/resource_update_logic.go | 13 ++- .../resource_update_logic_test.go | 101 +++++++++--------- 8 files changed, 106 insertions(+), 125 deletions(-) create mode 100644 .changelog/2814.txt diff --git a/.changelog/2814.txt b/.changelog/2814.txt new file mode 100644 index 0000000000..71ab0a867c --- /dev/null +++ b/.changelog/2814.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/mongodbatlas_advanced_cluster: Adjusts update operation to support cluster tier auto scaling per shard. +``` diff --git a/internal/common/conversion/flatten_expand.go b/internal/common/conversion/flatten_expand.go index a9ecb6b727..a28e5ec6fa 100644 --- a/internal/common/conversion/flatten_expand.go +++ b/internal/common/conversion/flatten_expand.go @@ -3,7 +3,6 @@ package conversion import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin" "go.mongodb.org/atlas-sdk/v20241023002/admin" ) @@ -29,19 +28,6 @@ func FlattenTags(tags []admin.ResourceTag) []map[string]string { return ret } -func ExpandTagsFromSetSchemaV220240805(d *schema.ResourceData) *[]admin20240805.ResourceTag { - list := d.Get("tags").(*schema.Set) - ret := make([]admin20240805.ResourceTag, list.Len()) - for i, item := range list.List() { - tag := item.(map[string]any) - ret[i] = admin20240805.ResourceTag{ - Key: tag["key"].(string), - Value: tag["value"].(string), - } - } - return &ret -} - func ExpandTagsFromSetSchema(d *schema.ResourceData) *[]admin.ResourceTag { list := d.Get("tags").(*schema.Set) ret := make([]admin.ResourceTag, list.Len()) diff --git a/internal/service/advancedcluster/model_advanced_cluster.go b/internal/service/advancedcluster/model_advanced_cluster.go index abb32a1c8b..10b95389b3 100644 --- a/internal/service/advancedcluster/model_advanced_cluster.go +++ b/internal/service/advancedcluster/model_advanced_cluster.go @@ -12,7 +12,6 @@ import ( "strings" admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" - admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin" "go.mongodb.org/atlas-sdk/v20241023002/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -401,7 +400,7 @@ func flattenTags(tags *[]admin.ResourceTag) []map[string]string { } // CheckRegionConfigsPriorityOrder will be deleted in CLOUDP-275825 -func CheckRegionConfigsPriorityOrder(regionConfigs []admin20240805.ReplicationSpec20240805) error { +func CheckRegionConfigsPriorityOrder(regionConfigs []admin.ReplicationSpec20240805) error { for _, spec := range regionConfigs { configs := spec.GetRegionConfigs() for i := 0; i < len(configs)-1; i++ { @@ -473,11 +472,11 @@ func flattenBiConnectorConfig(biConnector *admin.BiConnector) []map[string]any { } } -func expandBiConnectorConfig(d *schema.ResourceData) *admin20240805.BiConnector { +func expandBiConnectorConfig(d *schema.ResourceData) *admin.BiConnector { if v, ok := d.GetOk("bi_connector_config"); ok { if biConn := v.([]any); len(biConn) > 0 { biConnMap := biConn[0].(map[string]any) - return &admin20240805.BiConnector{ + return &admin.BiConnector{ Enabled: conversion.Pointer(cast.ToBool(biConnMap["enabled"])), ReadPreference: conversion.StringPtr(cast.ToString(biConnMap["read_preference"])), } @@ -695,11 +694,11 @@ func hwSpecToDedicatedHwSpec(apiObject *admin.HardwareSpec20240805) *admin.Dedic } } -func dedicatedHwSpecToHwSpec(apiObject *admin20240805.DedicatedHardwareSpec20240805) *admin20240805.HardwareSpec20240805 { +func dedicatedHwSpecToHwSpec(apiObject *admin.DedicatedHardwareSpec20240805) *admin.HardwareSpec20240805 { if apiObject == nil { return nil } - return &admin20240805.HardwareSpec20240805{ + return &admin.HardwareSpec20240805{ DiskSizeGB: apiObject.DiskSizeGB, NodeCount: apiObject.NodeCount, DiskIOPS: apiObject.DiskIOPS, @@ -872,16 +871,16 @@ func IsChangeStreamOptionsMinRequiredMajorVersion(input *string) bool { return value >= minVersionForChangeStreamOptions } -func expandLabelSliceFromSetSchema(d *schema.ResourceData) ([]admin20240805.ComponentLabel, diag.Diagnostics) { +func expandLabelSliceFromSetSchema(d *schema.ResourceData) ([]admin.ComponentLabel, diag.Diagnostics) { list := d.Get("labels").(*schema.Set) - res := make([]admin20240805.ComponentLabel, list.Len()) + res := make([]admin.ComponentLabel, list.Len()) for i, val := range list.List() { v := val.(map[string]any) key := v["key"].(string) if key == ignoreLabel { return nil, diag.FromErr(fmt.Errorf("you should not set `Infrastructure Tool` label, it is used for internal purposes")) } - res[i] = admin20240805.ComponentLabel{ + res[i] = admin.ComponentLabel{ Key: conversion.StringPtr(key), Value: conversion.StringPtr(v["value"].(string)), } @@ -889,8 +888,8 @@ func expandLabelSliceFromSetSchema(d *schema.ResourceData) ([]admin20240805.Comp return res, nil } -func expandAdvancedReplicationSpecs(tfList []any, rootDiskSizeGB *float64) *[]admin20240805.ReplicationSpec20240805 { - var apiObjects []admin20240805.ReplicationSpec20240805 +func expandAdvancedReplicationSpecs(tfList []any, rootDiskSizeGB *float64) *[]admin.ReplicationSpec20240805 { + var apiObjects []admin.ReplicationSpec20240805 for _, tfMapRaw := range tfList { tfMap, ok := tfMapRaw.(map[string]any) if !ok || tfMap == nil { @@ -927,8 +926,8 @@ func expandAdvancedReplicationSpecsOldSDK(tfList []any) *[]admin20240530.Replica return &apiObjects } -func expandAdvancedReplicationSpec(tfMap map[string]any, rootDiskSizeGB *float64) *admin20240805.ReplicationSpec20240805 { - apiObject := &admin20240805.ReplicationSpec20240805{ +func expandAdvancedReplicationSpec(tfMap map[string]any, rootDiskSizeGB *float64) *admin.ReplicationSpec20240805 { + apiObject := &admin.ReplicationSpec20240805{ ZoneName: conversion.StringPtr(tfMap["zone_name"].(string)), RegionConfigs: expandRegionConfigs(tfMap["region_configs"].([]any), rootDiskSizeGB), } @@ -950,8 +949,8 @@ func expandAdvancedReplicationSpecOldSDK(tfMap map[string]any) *admin20240530.Re return apiObject } -func expandRegionConfigs(tfList []any, rootDiskSizeGB *float64) *[]admin20240805.CloudRegionConfig20240805 { - var apiObjects []admin20240805.CloudRegionConfig20240805 +func expandRegionConfigs(tfList []any, rootDiskSizeGB *float64) *[]admin.CloudRegionConfig20240805 { + var apiObjects []admin.CloudRegionConfig20240805 for _, tfMapRaw := range tfList { tfMap, ok := tfMapRaw.(map[string]any) if !ok || tfMap == nil { @@ -966,9 +965,9 @@ func expandRegionConfigs(tfList []any, rootDiskSizeGB *float64) *[]admin20240805 return &apiObjects } -func expandRegionConfig(tfMap map[string]any, rootDiskSizeGB *float64) *admin20240805.CloudRegionConfig20240805 { +func expandRegionConfig(tfMap map[string]any, rootDiskSizeGB *float64) *admin.CloudRegionConfig20240805 { providerName := tfMap["provider_name"].(string) - apiObject := &admin20240805.CloudRegionConfig20240805{ + apiObject := &admin.CloudRegionConfig20240805{ Priority: conversion.Pointer(cast.ToInt(tfMap["priority"])), ProviderName: conversion.StringPtr(providerName), RegionName: conversion.StringPtr(tfMap["region_name"].(string)), @@ -995,9 +994,9 @@ func expandRegionConfig(tfMap map[string]any, rootDiskSizeGB *float64) *admin202 return apiObject } -func expandRegionConfigSpec(tfList []any, providerName string, rootDiskSizeGB *float64) *admin20240805.DedicatedHardwareSpec20240805 { +func expandRegionConfigSpec(tfList []any, providerName string, rootDiskSizeGB *float64) *admin.DedicatedHardwareSpec20240805 { tfMap, _ := tfList[0].(map[string]any) - apiObject := new(admin20240805.DedicatedHardwareSpec20240805) + apiObject := new(admin.DedicatedHardwareSpec20240805) if providerName == constant.AWS || providerName == constant.AZURE { if v, ok := tfMap["disk_iops"]; ok && v.(int) > 0 { apiObject.DiskIOPS = conversion.Pointer(v.(int)) @@ -1027,11 +1026,11 @@ func expandRegionConfigSpec(tfList []any, providerName string, rootDiskSizeGB *f return apiObject } -func expandRegionConfigAutoScaling(tfList []any) *admin20240805.AdvancedAutoScalingSettings { +func expandRegionConfigAutoScaling(tfList []any) *admin.AdvancedAutoScalingSettings { tfMap, _ := tfList[0].(map[string]any) - settings := admin20240805.AdvancedAutoScalingSettings{ - DiskGB: new(admin20240805.DiskGBAutoScaling), - Compute: new(admin20240805.AdvancedComputeAutoScaling), + settings := admin.AdvancedAutoScalingSettings{ + DiskGB: new(admin.DiskGBAutoScaling), + Compute: new(admin.AdvancedComputeAutoScaling), } if v, ok := tfMap["disk_gb_enabled"]; ok { diff --git a/internal/service/advancedcluster/model_advanced_cluster_test.go b/internal/service/advancedcluster/model_advanced_cluster_test.go index ecef34a418..7dd517c469 100644 --- a/internal/service/advancedcluster/model_advanced_cluster_test.go +++ b/internal/service/advancedcluster/model_advanced_cluster_test.go @@ -8,7 +8,6 @@ import ( "testing" admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" - admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin" "go.mongodb.org/atlas-sdk/v20241023002/admin" "go.mongodb.org/atlas-sdk/v20241023002/mockadmin" @@ -451,13 +450,13 @@ func TestCheckRegionConfigsPriorityOrder(t *testing.T) { for name, tc := range testCases { t.Run(name, func(t *testing.T) { - configs := make([]admin20240805.CloudRegionConfig20240805, len(tc.priorities)) + configs := make([]admin.CloudRegionConfig20240805, len(tc.priorities)) configsOld := make([]admin20240530.CloudRegionConfig, len(tc.priorities)) for i, priority := range tc.priorities { configs[i].Priority = conversion.IntPtr(priority) configsOld[i].Priority = conversion.IntPtr(priority) } - err := advancedcluster.CheckRegionConfigsPriorityOrder([]admin20240805.ReplicationSpec20240805{{RegionConfigs: &configs}}) + err := advancedcluster.CheckRegionConfigsPriorityOrder([]admin.ReplicationSpec20240805{{RegionConfigs: &configs}}) assert.Equal(t, tc.errorExpected, err != nil) err = advancedcluster.CheckRegionConfigsPriorityOrderOld([]admin20240530.ReplicationSpec{{RegionConfigs: &configsOld}}) assert.Equal(t, tc.errorExpected, err != nil) diff --git a/internal/service/advancedcluster/model_sdk_version_conversion.go b/internal/service/advancedcluster/model_sdk_version_conversion.go index 8226efb633..292cc71136 100644 --- a/internal/service/advancedcluster/model_sdk_version_conversion.go +++ b/internal/service/advancedcluster/model_sdk_version_conversion.go @@ -2,7 +2,6 @@ package advancedcluster import ( admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" - admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin" "go.mongodb.org/atlas-sdk/v20241023002/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -20,7 +19,7 @@ func convertTagsPtrToLatest(tags *[]admin20240530.ResourceTag) *[]admin.Resource return &result } -func convertTagsPtrToOldSDK(tags *[]admin20240805.ResourceTag) *[]admin20240530.ResourceTag { +func convertTagsPtrToOldSDK(tags *[]admin.ResourceTag) *[]admin20240530.ResourceTag { if tags == nil { return nil } @@ -48,7 +47,7 @@ func convertTagsToLatest(tags []admin20240530.ResourceTag) []admin.ResourceTag { return results } -func convertBiConnectToOldSDK(biconnector *admin20240805.BiConnector) *admin20240530.BiConnector { +func convertBiConnectToOldSDK(biconnector *admin.BiConnector) *admin20240530.BiConnector { if biconnector == nil { return nil } @@ -126,7 +125,7 @@ func convertLabelsToLatest(labels *[]admin20240530.ComponentLabel) *[]admin.Comp return &results } -func convertLabelSliceToOldSDK(slice []admin20240805.ComponentLabel, err diag.Diagnostics) ([]admin20240530.ComponentLabel, diag.Diagnostics) { +func convertLabelSliceToOldSDK(slice []admin.ComponentLabel, err diag.Diagnostics) ([]admin20240530.ComponentLabel, diag.Diagnostics) { if err != nil { return nil, err } @@ -141,7 +140,7 @@ func convertLabelSliceToOldSDK(slice []admin20240805.ComponentLabel, err diag.Di return results, nil } -func convertRegionConfigSliceToOldSDK(slice *[]admin20240805.CloudRegionConfig20240805) *[]admin20240530.CloudRegionConfig { +func convertRegionConfigSliceToOldSDK(slice *[]admin.CloudRegionConfig20240805) *[]admin20240530.CloudRegionConfig { if slice == nil { return nil } @@ -164,7 +163,7 @@ func convertRegionConfigSliceToOldSDK(slice *[]admin20240805.CloudRegionConfig20 return &results } -func convertHardwareSpecToOldSDK(hwspec *admin20240805.HardwareSpec20240805) *admin20240530.HardwareSpec { +func convertHardwareSpecToOldSDK(hwspec *admin.HardwareSpec20240805) *admin20240530.HardwareSpec { if hwspec == nil { return nil } @@ -176,7 +175,7 @@ func convertHardwareSpecToOldSDK(hwspec *admin20240805.HardwareSpec20240805) *ad } } -func convertAdvancedAutoScalingSettingsToOldSDK(settings *admin20240805.AdvancedAutoScalingSettings) *admin20240530.AdvancedAutoScalingSettings { +func convertAdvancedAutoScalingSettingsToOldSDK(settings *admin.AdvancedAutoScalingSettings) *admin20240530.AdvancedAutoScalingSettings { if settings == nil { return nil } @@ -186,7 +185,7 @@ func convertAdvancedAutoScalingSettingsToOldSDK(settings *admin20240805.Advanced } } -func convertAdvancedComputeAutoScalingToOldSDK(settings *admin20240805.AdvancedComputeAutoScaling) *admin20240530.AdvancedComputeAutoScaling { +func convertAdvancedComputeAutoScalingToOldSDK(settings *admin.AdvancedComputeAutoScaling) *admin20240530.AdvancedComputeAutoScaling { if settings == nil { return nil } @@ -198,7 +197,7 @@ func convertAdvancedComputeAutoScalingToOldSDK(settings *admin20240805.AdvancedC } } -func convertDiskGBAutoScalingToOldSDK(settings *admin20240805.DiskGBAutoScaling) *admin20240530.DiskGBAutoScaling { +func convertDiskGBAutoScalingToOldSDK(settings *admin.DiskGBAutoScaling) *admin20240530.DiskGBAutoScaling { if settings == nil { return nil } @@ -207,7 +206,7 @@ func convertDiskGBAutoScalingToOldSDK(settings *admin20240805.DiskGBAutoScaling) } } -func convertDedicatedHardwareSpecToOldSDK(spec *admin20240805.DedicatedHardwareSpec20240805) *admin20240530.DedicatedHardwareSpec { +func convertDedicatedHardwareSpecToOldSDK(spec *admin.DedicatedHardwareSpec20240805) *admin20240530.DedicatedHardwareSpec { if spec == nil { return nil } diff --git a/internal/service/advancedcluster/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index 5e12803397..38b53ab5cc 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -416,7 +416,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. rootDiskSizeGB = conversion.Pointer(v.(float64)) } - params := &admin20240805.ClusterDescription20240805{ + params := &admin.ClusterDescription20240805{ Name: conversion.StringPtr(cast.ToString(d.Get("name"))), ClusterType: conversion.StringPtr(cast.ToString(d.Get("cluster_type"))), ReplicationSpecs: expandAdvancedReplicationSpecs(d.Get("replication_specs").([]any), rootDiskSizeGB), @@ -442,7 +442,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. } if _, ok := d.GetOk("tags"); ok { - params.Tags = conversion.ExpandTagsFromSetSchemaV220240805(d) + params.Tags = conversion.ExpandTagsFromSetSchema(d) } if v, ok := d.GetOk("mongo_db_major_version"); ok { params.MongoDBMajorVersion = conversion.StringPtr(FormatMongoDBMajorVersion(v.(string))) @@ -482,8 +482,8 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. if err := CheckRegionConfigsPriorityOrder(params.GetReplicationSpecs()); err != nil { return diag.FromErr(err) } - // cannot call latest API (2024-10-23 or newer) as it can enable ISS autoscaling - cluster, _, err := connV220240805.ClustersApi.CreateCluster(ctx, projectID, params).Execute() + + cluster, _, err := connV2.ClustersApi.CreateCluster(ctx, projectID, params).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorCreate, err)) } @@ -821,7 +821,6 @@ func resourceUpgrade(ctx context.Context, upgradeRequest *admin.LegacyAtlasTenan func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { connV220240530 := meta.(*config.MongoDBClient).AtlasV220240530 - connV220240805 := meta.(*config.MongoDBClient).AtlasV220240805 connV2 := meta.(*config.MongoDBClient).AtlasV2 ids := conversion.DecodeStateID(d.Id()) projectID := ids["project_id"] @@ -850,7 +849,7 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. waitOnUpdate = true } if d.HasChange("replica_set_scaling_strategy") || d.HasChange("redact_client_log_data") || d.HasChange("config_server_management_mode") { - request := new(admin20240805.ClusterDescription20240805) + request := new(admin.ClusterDescription20240805) if d.HasChange("replica_set_scaling_strategy") { request.ReplicaSetScalingStrategy = conversion.Pointer(d.Get("replica_set_scaling_strategy").(string)) } @@ -860,8 +859,8 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. if d.HasChange("config_server_management_mode") { request.ConfigServerManagementMode = conversion.StringPtr(d.Get("config_server_management_mode").(string)) } - // can call latest API (2024-10-23 or newer) as autoscaling property is not specified, using older version just for caution until iss autoscaling epic is done - if _, _, err := connV220240805.ClustersApi.UpdateCluster(ctx, projectID, clusterName, request).Execute(); err != nil { + // can call latest API (2024-10-23 or newer) as replications specs with autoscaling property is not specified + if _, _, err := connV2.ClustersApi.UpdateCluster(ctx, projectID, clusterName, request).Execute(); err != nil { return diag.FromErr(fmt.Errorf(errorUpdate, clusterName, err)) } waitOnUpdate = true @@ -881,8 +880,7 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. if err := CheckRegionConfigsPriorityOrder(req.GetReplicationSpecs()); err != nil { return diag.FromErr(err) } - // cannot call latest API (2024-10-23 or newer) as it can enable ISS autoscaling - if _, _, err := connV220240805.ClustersApi.UpdateCluster(ctx, projectID, clusterName, req).Execute(); err != nil { + if _, _, err := connV2.ClustersApi.UpdateCluster(ctx, projectID, clusterName, req).Execute(); err != nil { return diag.FromErr(fmt.Errorf(errorUpdate, clusterName, err)) } if err := waitForUpdateToFinish(ctx, connV2, projectID, clusterName, timeout); err != nil { @@ -916,11 +914,10 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. } if d.Get("paused").(bool) { - clusterRequest := &admin20240805.ClusterDescription20240805{ + clusterRequest := &admin.ClusterDescription20240805{ Paused: conversion.Pointer(true), } - // can call latest API (2024-10-23 or newer) as autoscaling property is not specified, using older version just for caution until iss autoscaling epic is done - if _, _, err := connV220240805.ClustersApi.UpdateCluster(ctx, projectID, clusterName, clusterRequest).Execute(); err != nil { + if _, _, err := connV2.ClustersApi.UpdateCluster(ctx, projectID, clusterName, clusterRequest).Execute(); err != nil { return diag.FromErr(fmt.Errorf(errorUpdate, clusterName, err)) } if err := waitForUpdateToFinish(ctx, connV2, projectID, clusterName, timeout); err != nil { @@ -931,8 +928,8 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. return resourceRead(ctx, d, meta) } -func updateRequest(ctx context.Context, d *schema.ResourceData, projectID, clusterName string, connV2 *admin.APIClient) (*admin20240805.ClusterDescription20240805, diag.Diagnostics) { - cluster := new(admin20240805.ClusterDescription20240805) +func updateRequest(ctx context.Context, d *schema.ResourceData, projectID, clusterName string, connV2 *admin.APIClient) (*admin.ClusterDescription20240805, diag.Diagnostics) { + cluster := new(admin.ClusterDescription20240805) if d.HasChange("replication_specs") || d.HasChange("disk_size_gb") { var updatedDiskSizeGB *float64 @@ -979,7 +976,7 @@ func updateRequest(ctx context.Context, d *schema.ResourceData, projectID, clust } if d.HasChange("tags") { - cluster.Tags = conversion.ExpandTagsFromSetSchemaV220240805(d) + cluster.Tags = conversion.ExpandTagsFromSetSchema(d) } if d.HasChange("mongo_db_major_version") { @@ -1073,7 +1070,7 @@ func updateRequestOldAPI(d *schema.ResourceData, clusterName string) (*admin2024 } if d.HasChange("tags") { - cluster.Tags = convertTagsPtrToOldSDK(conversion.ExpandTagsFromSetSchemaV220240805(d)) + cluster.Tags = convertTagsPtrToOldSDK(conversion.ExpandTagsFromSetSchema(d)) } if d.HasChange("mongo_db_major_version") { diff --git a/internal/service/advancedcluster/resource_update_logic.go b/internal/service/advancedcluster/resource_update_logic.go index 1e643ab581..8caa468583 100644 --- a/internal/service/advancedcluster/resource_update_logic.go +++ b/internal/service/advancedcluster/resource_update_logic.go @@ -6,11 +6,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin" "go.mongodb.org/atlas-sdk/v20241023002/admin" ) -func noIDsPopulatedInReplicationSpecs(replicationSpecs *[]admin20240805.ReplicationSpec20240805) bool { +func noIDsPopulatedInReplicationSpecs(replicationSpecs *[]admin.ReplicationSpec20240805) bool { if replicationSpecs == nil || len(*replicationSpecs) == 0 { return false } @@ -22,7 +21,7 @@ func noIDsPopulatedInReplicationSpecs(replicationSpecs *[]admin20240805.Replicat return true } -func populateIDValuesUsingNewAPI(ctx context.Context, projectID, clusterName string, connV2ClusterAPI admin.ClustersApi, replicationSpecs *[]admin20240805.ReplicationSpec20240805) (*[]admin20240805.ReplicationSpec20240805, diag.Diagnostics) { +func populateIDValuesUsingNewAPI(ctx context.Context, projectID, clusterName string, connV2ClusterAPI admin.ClustersApi, replicationSpecs *[]admin.ReplicationSpec20240805) (*[]admin.ReplicationSpec20240805, diag.Diagnostics) { if replicationSpecs == nil || len(*replicationSpecs) == 0 { return replicationSpecs, nil } @@ -36,7 +35,7 @@ func populateIDValuesUsingNewAPI(ctx context.Context, projectID, clusterName str return &result, nil } -func AddIDsToReplicationSpecs(replicationSpecs []admin20240805.ReplicationSpec20240805, zoneToReplicationSpecsIDs map[string][]string) []admin20240805.ReplicationSpec20240805 { +func AddIDsToReplicationSpecs(replicationSpecs []admin.ReplicationSpec20240805, zoneToReplicationSpecsIDs map[string][]string) []admin.ReplicationSpec20240805 { for zoneName, availableIDs := range zoneToReplicationSpecsIDs { var indexOfIDToUse = 0 for i := range replicationSpecs { @@ -65,12 +64,12 @@ func groupIDsByZone(specs []admin.ReplicationSpec20240805) map[string][]string { // - Existing replication specs can have the autoscaling values present in the state with default values even if not defined in the config (case when cluster is imported) // - API expects autoScaling and analyticsAutoScaling aligned cross all region configs in the PATCH request // This function is needed to avoid errors if a new replication spec is added, ensuring the PATCH request will have the auto scaling aligned with other replication specs when not present in config. -func SyncAutoScalingConfigs(replicationSpecs *[]admin20240805.ReplicationSpec20240805) { +func SyncAutoScalingConfigs(replicationSpecs *[]admin.ReplicationSpec20240805) { if replicationSpecs == nil || len(*replicationSpecs) == 0 { return } - var defaultAnalyticsAutoScaling, defaultAutoScaling *admin20240805.AdvancedAutoScalingSettings + var defaultAnalyticsAutoScaling, defaultAutoScaling *admin.AdvancedAutoScalingSettings for _, spec := range *replicationSpecs { for i := range *spec.RegionConfigs { @@ -86,7 +85,7 @@ func SyncAutoScalingConfigs(replicationSpecs *[]admin20240805.ReplicationSpec202 applyDefaultAutoScaling(replicationSpecs, defaultAutoScaling, defaultAnalyticsAutoScaling) } -func applyDefaultAutoScaling(replicationSpecs *[]admin20240805.ReplicationSpec20240805, defaultAutoScaling, defaultAnalyticsAutoScaling *admin20240805.AdvancedAutoScalingSettings) { +func applyDefaultAutoScaling(replicationSpecs *[]admin.ReplicationSpec20240805, defaultAutoScaling, defaultAnalyticsAutoScaling *admin.AdvancedAutoScalingSettings) { for _, spec := range *replicationSpecs { for i := range *spec.RegionConfigs { regionConfig := &(*spec.RegionConfigs)[i] diff --git a/internal/service/advancedcluster/resource_update_logic_test.go b/internal/service/advancedcluster/resource_update_logic_test.go index 1528450bbc..a53cbce6fd 100644 --- a/internal/service/advancedcluster/resource_update_logic_test.go +++ b/internal/service/advancedcluster/resource_update_logic_test.go @@ -5,18 +5,17 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster" "github.com/stretchr/testify/assert" - admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin" "go.mongodb.org/atlas-sdk/v20241023002/admin" ) func TestAddIDsToReplicationSpecs(t *testing.T) { testCases := map[string]struct { - ReplicationSpecs []admin20240805.ReplicationSpec20240805 + ReplicationSpecs []admin.ReplicationSpec20240805 ZoneToReplicationSpecsIDs map[string][]string - ExpectedReplicationSpecs []admin20240805.ReplicationSpec20240805 + ExpectedReplicationSpecs []admin.ReplicationSpec20240805 }{ "two zones with same amount of available ids and replication specs to populate": { - ReplicationSpecs: []admin20240805.ReplicationSpec20240805{ + ReplicationSpecs: []admin.ReplicationSpec20240805{ { ZoneName: admin.PtrString("Zone 1"), }, @@ -34,7 +33,7 @@ func TestAddIDsToReplicationSpecs(t *testing.T) { "Zone 1": {"zone1-id1", "zone1-id2"}, "Zone 2": {"zone2-id1", "zone2-id2"}, }, - ExpectedReplicationSpecs: []admin20240805.ReplicationSpec20240805{ + ExpectedReplicationSpecs: []admin.ReplicationSpec20240805{ { ZoneName: admin.PtrString("Zone 1"), Id: admin.PtrString("zone1-id1"), @@ -54,7 +53,7 @@ func TestAddIDsToReplicationSpecs(t *testing.T) { }, }, "less available ids than replication specs to populate": { - ReplicationSpecs: []admin20240805.ReplicationSpec20240805{ + ReplicationSpecs: []admin.ReplicationSpec20240805{ { ZoneName: admin.PtrString("Zone 1"), }, @@ -72,7 +71,7 @@ func TestAddIDsToReplicationSpecs(t *testing.T) { "Zone 1": {"zone1-id1"}, "Zone 2": {"zone2-id1"}, }, - ExpectedReplicationSpecs: []admin20240805.ReplicationSpec20240805{ + ExpectedReplicationSpecs: []admin.ReplicationSpec20240805{ { ZoneName: admin.PtrString("Zone 1"), Id: admin.PtrString("zone1-id1"), @@ -92,7 +91,7 @@ func TestAddIDsToReplicationSpecs(t *testing.T) { }, }, "more available ids than replication specs to populate": { - ReplicationSpecs: []admin20240805.ReplicationSpec20240805{ + ReplicationSpecs: []admin.ReplicationSpec20240805{ { ZoneName: admin.PtrString("Zone 1"), }, @@ -104,7 +103,7 @@ func TestAddIDsToReplicationSpecs(t *testing.T) { "Zone 1": {"zone1-id1", "zone1-id2"}, "Zone 2": {"zone2-id1", "zone2-id2"}, }, - ExpectedReplicationSpecs: []admin20240805.ReplicationSpec20240805{ + ExpectedReplicationSpecs: []admin.ReplicationSpec20240805{ { ZoneName: admin.PtrString("Zone 1"), Id: admin.PtrString("zone1-id1"), @@ -127,23 +126,23 @@ func TestAddIDsToReplicationSpecs(t *testing.T) { func TestSyncAutoScalingConfigs(t *testing.T) { testCases := map[string]struct { - ReplicationSpecs []admin20240805.ReplicationSpec20240805 - ExpectedReplicationSpecs []admin20240805.ReplicationSpec20240805 + ReplicationSpecs []admin.ReplicationSpec20240805 + ExpectedReplicationSpecs []admin.ReplicationSpec20240805 }{ "apply same autoscaling options for new replication spec which does not have autoscaling defined": { - ReplicationSpecs: []admin20240805.ReplicationSpec20240805{ + ReplicationSpecs: []admin.ReplicationSpec20240805{ { Id: admin.PtrString("id-1"), - RegionConfigs: &[]admin20240805.CloudRegionConfig20240805{ + RegionConfigs: &[]admin.CloudRegionConfig20240805{ { - AutoScaling: &admin20240805.AdvancedAutoScalingSettings{ - Compute: &admin20240805.AdvancedComputeAutoScaling{ + AutoScaling: &admin.AdvancedAutoScalingSettings{ + Compute: &admin.AdvancedComputeAutoScaling{ Enabled: admin.PtrBool(false), ScaleDownEnabled: admin.PtrBool(false), }, }, - AnalyticsAutoScaling: &admin20240805.AdvancedAutoScalingSettings{ - Compute: &admin20240805.AdvancedComputeAutoScaling{ + AnalyticsAutoScaling: &admin.AdvancedAutoScalingSettings{ + Compute: &admin.AdvancedComputeAutoScaling{ Enabled: admin.PtrBool(false), ScaleDownEnabled: admin.PtrBool(false), }, @@ -153,7 +152,7 @@ func TestSyncAutoScalingConfigs(t *testing.T) { }, { Id: admin.PtrString("id-2"), - RegionConfigs: &[]admin20240805.CloudRegionConfig20240805{ + RegionConfigs: &[]admin.CloudRegionConfig20240805{ { AutoScaling: nil, AnalyticsAutoScaling: nil, @@ -161,19 +160,19 @@ func TestSyncAutoScalingConfigs(t *testing.T) { }, }, }, - ExpectedReplicationSpecs: []admin20240805.ReplicationSpec20240805{ + ExpectedReplicationSpecs: []admin.ReplicationSpec20240805{ { Id: admin.PtrString("id-1"), - RegionConfigs: &[]admin20240805.CloudRegionConfig20240805{ + RegionConfigs: &[]admin.CloudRegionConfig20240805{ { - AutoScaling: &admin20240805.AdvancedAutoScalingSettings{ - Compute: &admin20240805.AdvancedComputeAutoScaling{ + AutoScaling: &admin.AdvancedAutoScalingSettings{ + Compute: &admin.AdvancedComputeAutoScaling{ Enabled: admin.PtrBool(false), ScaleDownEnabled: admin.PtrBool(false), }, }, - AnalyticsAutoScaling: &admin20240805.AdvancedAutoScalingSettings{ - Compute: &admin20240805.AdvancedComputeAutoScaling{ + AnalyticsAutoScaling: &admin.AdvancedAutoScalingSettings{ + Compute: &admin.AdvancedComputeAutoScaling{ Enabled: admin.PtrBool(false), ScaleDownEnabled: admin.PtrBool(false), }, @@ -183,16 +182,16 @@ func TestSyncAutoScalingConfigs(t *testing.T) { }, { Id: admin.PtrString("id-2"), - RegionConfigs: &[]admin20240805.CloudRegionConfig20240805{ + RegionConfigs: &[]admin.CloudRegionConfig20240805{ { - AutoScaling: &admin20240805.AdvancedAutoScalingSettings{ - Compute: &admin20240805.AdvancedComputeAutoScaling{ + AutoScaling: &admin.AdvancedAutoScalingSettings{ + Compute: &admin.AdvancedComputeAutoScaling{ Enabled: admin.PtrBool(false), ScaleDownEnabled: admin.PtrBool(false), }, }, - AnalyticsAutoScaling: &admin20240805.AdvancedAutoScalingSettings{ - Compute: &admin20240805.AdvancedComputeAutoScaling{ + AnalyticsAutoScaling: &admin.AdvancedAutoScalingSettings{ + Compute: &admin.AdvancedComputeAutoScaling{ Enabled: admin.PtrBool(false), ScaleDownEnabled: admin.PtrBool(false), }, @@ -204,19 +203,19 @@ func TestSyncAutoScalingConfigs(t *testing.T) { }, // for this case the API will respond with an error and guide the user to align autoscaling options cross all nodes "when different autoscaling options are defined values will not be changed": { - ReplicationSpecs: []admin20240805.ReplicationSpec20240805{ + ReplicationSpecs: []admin.ReplicationSpec20240805{ { Id: admin.PtrString("id-1"), - RegionConfigs: &[]admin20240805.CloudRegionConfig20240805{ + RegionConfigs: &[]admin.CloudRegionConfig20240805{ { - AutoScaling: &admin20240805.AdvancedAutoScalingSettings{ - Compute: &admin20240805.AdvancedComputeAutoScaling{ + AutoScaling: &admin.AdvancedAutoScalingSettings{ + Compute: &admin.AdvancedComputeAutoScaling{ Enabled: admin.PtrBool(false), ScaleDownEnabled: admin.PtrBool(false), }, }, - AnalyticsAutoScaling: &admin20240805.AdvancedAutoScalingSettings{ - Compute: &admin20240805.AdvancedComputeAutoScaling{ + AnalyticsAutoScaling: &admin.AdvancedAutoScalingSettings{ + Compute: &admin.AdvancedComputeAutoScaling{ Enabled: admin.PtrBool(true), ScaleDownEnabled: admin.PtrBool(true), }, @@ -226,15 +225,15 @@ func TestSyncAutoScalingConfigs(t *testing.T) { }, { Id: admin.PtrString("id-2"), - RegionConfigs: &[]admin20240805.CloudRegionConfig20240805{ + RegionConfigs: &[]admin.CloudRegionConfig20240805{ { - AutoScaling: &admin20240805.AdvancedAutoScalingSettings{ - Compute: &admin20240805.AdvancedComputeAutoScaling{ + AutoScaling: &admin.AdvancedAutoScalingSettings{ + Compute: &admin.AdvancedComputeAutoScaling{ Enabled: admin.PtrBool(true), }, }, - AnalyticsAutoScaling: &admin20240805.AdvancedAutoScalingSettings{ - Compute: &admin20240805.AdvancedComputeAutoScaling{ + AnalyticsAutoScaling: &admin.AdvancedAutoScalingSettings{ + Compute: &admin.AdvancedComputeAutoScaling{ Enabled: admin.PtrBool(false), }, }, @@ -242,19 +241,19 @@ func TestSyncAutoScalingConfigs(t *testing.T) { }, }, }, - ExpectedReplicationSpecs: []admin20240805.ReplicationSpec20240805{ + ExpectedReplicationSpecs: []admin.ReplicationSpec20240805{ { Id: admin.PtrString("id-1"), - RegionConfigs: &[]admin20240805.CloudRegionConfig20240805{ + RegionConfigs: &[]admin.CloudRegionConfig20240805{ { - AutoScaling: &admin20240805.AdvancedAutoScalingSettings{ - Compute: &admin20240805.AdvancedComputeAutoScaling{ + AutoScaling: &admin.AdvancedAutoScalingSettings{ + Compute: &admin.AdvancedComputeAutoScaling{ Enabled: admin.PtrBool(false), ScaleDownEnabled: admin.PtrBool(false), }, }, - AnalyticsAutoScaling: &admin20240805.AdvancedAutoScalingSettings{ - Compute: &admin20240805.AdvancedComputeAutoScaling{ + AnalyticsAutoScaling: &admin.AdvancedAutoScalingSettings{ + Compute: &admin.AdvancedComputeAutoScaling{ Enabled: admin.PtrBool(true), ScaleDownEnabled: admin.PtrBool(true), }, @@ -264,15 +263,15 @@ func TestSyncAutoScalingConfigs(t *testing.T) { }, { Id: admin.PtrString("id-2"), - RegionConfigs: &[]admin20240805.CloudRegionConfig20240805{ + RegionConfigs: &[]admin.CloudRegionConfig20240805{ { - AutoScaling: &admin20240805.AdvancedAutoScalingSettings{ - Compute: &admin20240805.AdvancedComputeAutoScaling{ + AutoScaling: &admin.AdvancedAutoScalingSettings{ + Compute: &admin.AdvancedComputeAutoScaling{ Enabled: admin.PtrBool(true), }, }, - AnalyticsAutoScaling: &admin20240805.AdvancedAutoScalingSettings{ - Compute: &admin20240805.AdvancedComputeAutoScaling{ + AnalyticsAutoScaling: &admin.AdvancedAutoScalingSettings{ + Compute: &admin.AdvancedComputeAutoScaling{ Enabled: admin.PtrBool(false), }, }, From 249c4251787032c1fa6b10693495baec04755672 Mon Sep 17 00:00:00 2001 From: Oriol Date: Mon, 2 Dec 2024 14:56:46 +0100 Subject: [PATCH 02/12] feat: Ensures asymmetric auto-scaling is not defined in the cluster when using the old sharding configuration in `mongodbatlas_advanced_cluster` (#2836) * use old API when the old schema structure is used * changelog * changelog fix * add feature to adv_cluster tpf todo * pr comments --- .changelog/2836.txt | 3 + .../model_sdk_version_conversion.go | 155 ++++++++++++++ .../model_sdk_version_conversion_test.go | 193 ++++++++++++++++++ .../resource_advanced_cluster.go | 40 ++-- internal/service/advancedclustertpf/README.md | 1 + .../advancedclustertpf/resource_schema.go | 18 +- 6 files changed, 389 insertions(+), 21 deletions(-) create mode 100644 .changelog/2836.txt create mode 100644 internal/service/advancedcluster/model_sdk_version_conversion_test.go diff --git a/.changelog/2836.txt b/.changelog/2836.txt new file mode 100644 index 0000000000..5cc1efb27f --- /dev/null +++ b/.changelog/2836.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/mongodbatlas_advanced_cluster: Adjusts create operation to support cluster tier auto scaling per shard. +``` diff --git a/internal/service/advancedcluster/model_sdk_version_conversion.go b/internal/service/advancedcluster/model_sdk_version_conversion.go index 292cc71136..151b6c2a40 100644 --- a/internal/service/advancedcluster/model_sdk_version_conversion.go +++ b/internal/service/advancedcluster/model_sdk_version_conversion.go @@ -2,6 +2,7 @@ package advancedcluster import ( admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" + admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin" "go.mongodb.org/atlas-sdk/v20241023002/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -324,3 +325,157 @@ func convertClusterDescToLatestExcludeRepSpecs(oldClusterDesc *admin20240530.Adv Labels: convertLabelsToLatest(oldClusterDesc.Labels), } } + +func ConvertClusterDescription20241023to20240805(clusterDescription *admin.ClusterDescription20240805) *admin20240805.ClusterDescription20240805 { + return &admin20240805.ClusterDescription20240805{ + Name: clusterDescription.Name, + ClusterType: clusterDescription.ClusterType, + ReplicationSpecs: convertReplicationSpecs20241023to20240805(clusterDescription.ReplicationSpecs), + BackupEnabled: clusterDescription.BackupEnabled, + BiConnector: convertBiConnector20241023to20240805(clusterDescription.BiConnector), + EncryptionAtRestProvider: clusterDescription.EncryptionAtRestProvider, + Labels: convertLabels20241023to20240805(clusterDescription.Labels), + Tags: convertTag20241023to20240805(clusterDescription.Tags), + MongoDBMajorVersion: clusterDescription.MongoDBMajorVersion, + PitEnabled: clusterDescription.PitEnabled, + RootCertType: clusterDescription.RootCertType, + TerminationProtectionEnabled: clusterDescription.TerminationProtectionEnabled, + VersionReleaseSystem: clusterDescription.VersionReleaseSystem, + GlobalClusterSelfManagedSharding: clusterDescription.GlobalClusterSelfManagedSharding, + ReplicaSetScalingStrategy: clusterDescription.ReplicaSetScalingStrategy, + RedactClientLogData: clusterDescription.RedactClientLogData, + ConfigServerManagementMode: clusterDescription.ConfigServerManagementMode, + } +} + +func convertReplicationSpecs20241023to20240805(replicationSpecs *[]admin.ReplicationSpec20240805) *[]admin20240805.ReplicationSpec20240805 { + if replicationSpecs == nil { + return nil + } + result := make([]admin20240805.ReplicationSpec20240805, len(*replicationSpecs)) + for i, replicationSpec := range *replicationSpecs { + result[i] = admin20240805.ReplicationSpec20240805{ + Id: replicationSpec.Id, + ZoneName: replicationSpec.ZoneName, + ZoneId: replicationSpec.ZoneId, + RegionConfigs: convertCloudRegionConfig20241023to20240805(replicationSpec.RegionConfigs), + } + } + return &result +} + +func convertCloudRegionConfig20241023to20240805(cloudRegionConfig *[]admin.CloudRegionConfig20240805) *[]admin20240805.CloudRegionConfig20240805 { + if cloudRegionConfig == nil { + return nil + } + result := make([]admin20240805.CloudRegionConfig20240805, len(*cloudRegionConfig)) + for i, regionConfig := range *cloudRegionConfig { + result[i] = admin20240805.CloudRegionConfig20240805{ + ProviderName: regionConfig.ProviderName, + RegionName: regionConfig.RegionName, + BackingProviderName: regionConfig.BackingProviderName, + Priority: regionConfig.Priority, + ElectableSpecs: convertHardwareSpec20241023to20240805(regionConfig.ElectableSpecs), + ReadOnlySpecs: convertDedicatedHardwareSpec20241023to20240805(regionConfig.ReadOnlySpecs), + AnalyticsSpecs: convertDedicatedHardwareSpec20241023to20240805(regionConfig.AnalyticsSpecs), + AutoScaling: convertAdvancedAutoScalingSettings20241023to20240805(regionConfig.AutoScaling), + AnalyticsAutoScaling: convertAdvancedAutoScalingSettings20241023to20240805(regionConfig.AnalyticsAutoScaling), + } + } + return &result +} + +func convertAdvancedAutoScalingSettings20241023to20240805(advancedAutoScalingSettings *admin.AdvancedAutoScalingSettings) *admin20240805.AdvancedAutoScalingSettings { + if advancedAutoScalingSettings == nil { + return nil + } + return &admin20240805.AdvancedAutoScalingSettings{ + Compute: convertAdvancedComputeAutoScaling20241023to20240805(advancedAutoScalingSettings.Compute), + DiskGB: convertDiskGBAutoScaling20241023to20240805(advancedAutoScalingSettings.DiskGB), + } +} + +func convertDiskGBAutoScaling20241023to20240805(diskGBAutoScaling *admin.DiskGBAutoScaling) *admin20240805.DiskGBAutoScaling { + if diskGBAutoScaling == nil { + return nil + } + return &admin20240805.DiskGBAutoScaling{ + Enabled: diskGBAutoScaling.Enabled, + } +} + +func convertAdvancedComputeAutoScaling20241023to20240805(advancedComputeAutoScaling *admin.AdvancedComputeAutoScaling) *admin20240805.AdvancedComputeAutoScaling { + if advancedComputeAutoScaling == nil { + return nil + } + return &admin20240805.AdvancedComputeAutoScaling{ + Enabled: advancedComputeAutoScaling.Enabled, + MaxInstanceSize: advancedComputeAutoScaling.MaxInstanceSize, + MinInstanceSize: advancedComputeAutoScaling.MinInstanceSize, + ScaleDownEnabled: advancedComputeAutoScaling.ScaleDownEnabled, + } +} + +func convertHardwareSpec20241023to20240805(hardwareSpec *admin.HardwareSpec20240805) *admin20240805.HardwareSpec20240805 { + if hardwareSpec == nil { + return nil + } + return &admin20240805.HardwareSpec20240805{ + DiskSizeGB: hardwareSpec.DiskSizeGB, + NodeCount: hardwareSpec.NodeCount, + DiskIOPS: hardwareSpec.DiskIOPS, + EbsVolumeType: hardwareSpec.EbsVolumeType, + InstanceSize: hardwareSpec.InstanceSize, + } +} + +func convertDedicatedHardwareSpec20241023to20240805(hardwareSpec *admin.DedicatedHardwareSpec20240805) *admin20240805.DedicatedHardwareSpec20240805 { + if hardwareSpec == nil { + return nil + } + return &admin20240805.DedicatedHardwareSpec20240805{ + DiskSizeGB: hardwareSpec.DiskSizeGB, + NodeCount: hardwareSpec.NodeCount, + DiskIOPS: hardwareSpec.DiskIOPS, + EbsVolumeType: hardwareSpec.EbsVolumeType, + InstanceSize: hardwareSpec.InstanceSize, + } +} + +func convertBiConnector20241023to20240805(biConnector *admin.BiConnector) *admin20240805.BiConnector { + if biConnector == nil { + return nil + } + return &admin20240805.BiConnector{ + ReadPreference: biConnector.ReadPreference, + Enabled: biConnector.Enabled, + } +} + +func convertLabels20241023to20240805(labels *[]admin.ComponentLabel) *[]admin20240805.ComponentLabel { + if labels == nil { + return &[]admin20240805.ComponentLabel{} + } + result := make([]admin20240805.ComponentLabel, len(*labels)) + for i, label := range *labels { + result[i] = admin20240805.ComponentLabel{ + Key: label.Key, + Value: label.Value, + } + } + return &result +} + +func convertTag20241023to20240805(tags *[]admin.ResourceTag) *[]admin20240805.ResourceTag { + if tags == nil { + return &[]admin20240805.ResourceTag{} + } + result := make([]admin20240805.ResourceTag, len(*tags)) + for i, tag := range *tags { + result[i] = admin20240805.ResourceTag{ + Key: tag.Key, + Value: tag.Value, + } + } + return &result +} diff --git a/internal/service/advancedcluster/model_sdk_version_conversion_test.go b/internal/service/advancedcluster/model_sdk_version_conversion_test.go new file mode 100644 index 0000000000..b496ccbba6 --- /dev/null +++ b/internal/service/advancedcluster/model_sdk_version_conversion_test.go @@ -0,0 +1,193 @@ +package advancedcluster_test + +import ( + "testing" + + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster" + "github.com/stretchr/testify/assert" + admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin" + "go.mongodb.org/atlas-sdk/v20241023002/admin" +) + +func TestConvertClusterDescription20241023to20240805(t *testing.T) { + var ( + clusterName = "clusterName" + clusterType = "REPLICASET" + earProvider = "AWS" + booleanValue = true + mongoDBMajorVersion = "7.0" + rootCertType = "rootCertType" + replicaSetScalingStrategy = "WORKLOAD_TYPE" + configServerManagementMode = "ATLAS_MANAGED" + readPreference = "primary" + zoneName = "z1" + id = "id1" + regionConfigProvider = "AWS" + region = "EU_WEST_1" + priority = 7 + instanceSize = "M10" + nodeCount = 3 + diskSizeGB = 30.3 + ebsVolumeType = "STANDARD" + diskIOPS = 100 + ) + testCases := []struct { + input *admin.ClusterDescription20240805 + expectedOutput *admin20240805.ClusterDescription20240805 + name string + }{ + { + name: "Converts cluster description from 20241023 to 20240805", + input: &admin.ClusterDescription20240805{ + Name: conversion.StringPtr(clusterName), + ClusterType: conversion.StringPtr(clusterType), + ReplicationSpecs: &[]admin.ReplicationSpec20240805{ + { + Id: conversion.StringPtr(id), + ZoneName: conversion.StringPtr(zoneName), + RegionConfigs: &[]admin.CloudRegionConfig20240805{ + { + ProviderName: conversion.StringPtr(regionConfigProvider), + RegionName: conversion.StringPtr(region), + BackingProviderName: conversion.StringPtr(regionConfigProvider), + Priority: conversion.IntPtr(priority), + AnalyticsSpecs: &admin.DedicatedHardwareSpec20240805{ + InstanceSize: conversion.StringPtr(instanceSize), + NodeCount: conversion.IntPtr(nodeCount), + DiskSizeGB: conversion.Pointer(diskSizeGB), + EbsVolumeType: conversion.StringPtr(ebsVolumeType), + DiskIOPS: conversion.IntPtr(diskIOPS), + }, + ElectableSpecs: &admin.HardwareSpec20240805{ + InstanceSize: conversion.StringPtr(instanceSize), + NodeCount: conversion.IntPtr(nodeCount), + DiskSizeGB: conversion.Pointer(diskSizeGB), + EbsVolumeType: conversion.StringPtr(ebsVolumeType), + DiskIOPS: conversion.IntPtr(diskIOPS), + }, + AutoScaling: &admin.AdvancedAutoScalingSettings{ + Compute: &admin.AdvancedComputeAutoScaling{ + Enabled: conversion.Pointer(booleanValue), + MaxInstanceSize: conversion.Pointer(instanceSize), + MinInstanceSize: conversion.Pointer(instanceSize), + ScaleDownEnabled: conversion.Pointer(booleanValue), + }, + DiskGB: &admin.DiskGBAutoScaling{ + Enabled: conversion.Pointer(booleanValue), + }, + }, + }, + }, + }, + }, + BackupEnabled: conversion.Pointer(booleanValue), + BiConnector: &admin.BiConnector{ + Enabled: conversion.Pointer(booleanValue), + ReadPreference: conversion.StringPtr(readPreference), + }, + EncryptionAtRestProvider: conversion.StringPtr(earProvider), + Labels: &[]admin.ComponentLabel{ + {Key: conversion.StringPtr("key1"), Value: conversion.StringPtr("value1")}, + {Key: conversion.StringPtr("key2"), Value: conversion.StringPtr("value2")}, + }, + Tags: &[]admin.ResourceTag{ + {Key: "key1", Value: "value1"}, + {Key: "key2", Value: "value2"}, + }, + MongoDBMajorVersion: conversion.StringPtr(mongoDBMajorVersion), + PitEnabled: conversion.Pointer(booleanValue), + RootCertType: conversion.StringPtr(rootCertType), + TerminationProtectionEnabled: conversion.Pointer(booleanValue), + VersionReleaseSystem: conversion.StringPtr(""), + GlobalClusterSelfManagedSharding: conversion.Pointer(booleanValue), + ReplicaSetScalingStrategy: conversion.StringPtr(replicaSetScalingStrategy), + RedactClientLogData: conversion.Pointer(booleanValue), + ConfigServerManagementMode: conversion.StringPtr(configServerManagementMode), + }, + expectedOutput: &admin20240805.ClusterDescription20240805{ + Name: conversion.StringPtr(clusterName), + ClusterType: conversion.StringPtr(clusterType), + ReplicationSpecs: &[]admin20240805.ReplicationSpec20240805{ + { + Id: conversion.StringPtr(id), + ZoneName: conversion.StringPtr(zoneName), + RegionConfigs: &[]admin20240805.CloudRegionConfig20240805{ + { + ProviderName: conversion.StringPtr(regionConfigProvider), + RegionName: conversion.StringPtr(region), + BackingProviderName: conversion.StringPtr(regionConfigProvider), + Priority: conversion.IntPtr(priority), + AnalyticsSpecs: &admin20240805.DedicatedHardwareSpec20240805{ + InstanceSize: conversion.StringPtr(instanceSize), + NodeCount: conversion.IntPtr(nodeCount), + DiskSizeGB: conversion.Pointer(diskSizeGB), + EbsVolumeType: conversion.StringPtr(ebsVolumeType), + DiskIOPS: conversion.IntPtr(diskIOPS), + }, + ElectableSpecs: &admin20240805.HardwareSpec20240805{ + InstanceSize: conversion.StringPtr(instanceSize), + NodeCount: conversion.IntPtr(nodeCount), + DiskSizeGB: conversion.Pointer(diskSizeGB), + EbsVolumeType: conversion.StringPtr(ebsVolumeType), + DiskIOPS: conversion.IntPtr(diskIOPS), + }, + AutoScaling: &admin20240805.AdvancedAutoScalingSettings{ + Compute: &admin20240805.AdvancedComputeAutoScaling{ + Enabled: conversion.Pointer(booleanValue), + MaxInstanceSize: conversion.Pointer(instanceSize), + MinInstanceSize: conversion.Pointer(instanceSize), + ScaleDownEnabled: conversion.Pointer(booleanValue), + }, + DiskGB: &admin20240805.DiskGBAutoScaling{ + Enabled: conversion.Pointer(booleanValue), + }, + }, + }, + }, + }, + }, + BackupEnabled: conversion.Pointer(booleanValue), + BiConnector: &admin20240805.BiConnector{ + Enabled: conversion.Pointer(booleanValue), + ReadPreference: conversion.StringPtr(readPreference), + }, + EncryptionAtRestProvider: conversion.StringPtr(earProvider), + Labels: &[]admin20240805.ComponentLabel{ + {Key: conversion.StringPtr("key1"), Value: conversion.StringPtr("value1")}, + {Key: conversion.StringPtr("key2"), Value: conversion.StringPtr("value2")}, + }, + Tags: &[]admin20240805.ResourceTag{ + {Key: "key1", Value: "value1"}, + {Key: "key2", Value: "value2"}, + }, + MongoDBMajorVersion: conversion.StringPtr(mongoDBMajorVersion), + PitEnabled: conversion.Pointer(booleanValue), + RootCertType: conversion.StringPtr(rootCertType), + TerminationProtectionEnabled: conversion.Pointer(booleanValue), + VersionReleaseSystem: conversion.StringPtr(""), + GlobalClusterSelfManagedSharding: conversion.Pointer(booleanValue), + ReplicaSetScalingStrategy: conversion.StringPtr(replicaSetScalingStrategy), + RedactClientLogData: conversion.Pointer(booleanValue), + ConfigServerManagementMode: conversion.StringPtr(configServerManagementMode), + }, + }, + { + name: "Converts cluster description from 20241023 to 20240805 with nil values", + input: &admin.ClusterDescription20240805{}, + expectedOutput: &admin20240805.ClusterDescription20240805{ + ReplicationSpecs: nil, + BiConnector: nil, + Labels: &[]admin20240805.ComponentLabel{}, + Tags: &[]admin20240805.ResourceTag{}, + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + result := advancedcluster.ConvertClusterDescription20241023to20240805(tc.input) + assert.Equal(t, tc.expectedOutput, result) + }) + } +} diff --git a/internal/service/advancedcluster/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index 38b53ab5cc..2b35fcf397 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -483,9 +483,25 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. return diag.FromErr(err) } - cluster, _, err := connV2.ClustersApi.CreateCluster(ctx, projectID, params).Execute() - if err != nil { - return diag.FromErr(fmt.Errorf(errorCreate, err)) + var clusterName string + var clusterID string + var err error + if isUsingOldShardingConfiguration(d) { + var cluster20240805 *admin20240805.ClusterDescription20240805 + cluster20240805, _, err = connV220240805.ClustersApi.CreateCluster(ctx, projectID, ConvertClusterDescription20241023to20240805(params)).Execute() + if err != nil { + return diag.FromErr(fmt.Errorf(errorCreate, err)) + } + clusterName = cluster20240805.GetName() + clusterID = cluster20240805.GetId() + } else { + var cluster *admin.ClusterDescription20240805 + cluster, _, err = connV2.ClustersApi.CreateCluster(ctx, projectID, params).Execute() + if err != nil { + return diag.FromErr(fmt.Errorf(errorCreate, err)) + } + clusterName = cluster.GetName() + clusterID = cluster.GetId() } timeout := d.Timeout(schema.TimeoutCreate) @@ -498,13 +514,13 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. if ac, ok := d.GetOk("advanced_configuration"); ok { if aclist, ok := ac.([]any); ok && len(aclist) > 0 { params20240530, params := expandProcessArgs(d, aclist[0].(map[string]any), params.MongoDBMajorVersion) - _, _, err := connV220240530.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, cluster.GetName(), ¶ms20240530).Execute() + _, _, err := connV220240530.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, clusterName, ¶ms20240530).Execute() if err != nil { - return diag.FromErr(fmt.Errorf(errorConfigUpdate, cluster.GetName(), err)) + return diag.FromErr(fmt.Errorf(errorConfigUpdate, clusterName, err)) } - _, _, err = connV2.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, cluster.GetName(), ¶ms).Execute() + _, _, err = connV2.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, clusterName, ¶ms).Execute() if err != nil { - return diag.FromErr(fmt.Errorf(errorConfigUpdate, cluster.GetName(), err)) + return diag.FromErr(fmt.Errorf(errorConfigUpdate, clusterName, err)) } } } @@ -523,9 +539,9 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. } d.SetId(conversion.EncodeStateID(map[string]string{ - "cluster_id": cluster.GetId(), + "cluster_id": clusterID, "project_id": projectID, - "cluster_name": cluster.GetName(), + "cluster_name": clusterName, })) return resourceRead(ctx, d, meta) @@ -552,7 +568,7 @@ func resourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Di var clusterResp *admin.ClusterDescription20240805 var replicationSpecs []map[string]any - if isUsingOldAPISchemaStructure(d) { + if isUsingOldShardingConfiguration(d) { clusterOldSDK, resp, err := connV220240530.ClustersApi.GetCluster(ctx, projectID, clusterName).Execute() if err != nil { if resp != nil && resp.StatusCode == http.StatusNotFound { @@ -776,7 +792,7 @@ func setRootFields(d *schema.ResourceData, cluster *admin.ClusterDescription2024 } // For both read and update operations if old sharding schema structure is used (at least one replication spec with numShards > 1) we continue to invoke the old API -func isUsingOldAPISchemaStructure(d *schema.ResourceData) bool { +func isUsingOldShardingConfiguration(d *schema.ResourceData) bool { tfList := d.Get("replication_specs").([]any) for _, tfMapRaw := range tfList { tfMap, ok := tfMapRaw.(map[string]any) @@ -832,7 +848,7 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. timeout := d.Timeout(schema.TimeoutUpdate) - if isUsingOldAPISchemaStructure(d) { + if isUsingOldShardingConfiguration(d) { req, diags := updateRequestOldAPI(d, clusterName) if diags != nil { return diags diff --git a/internal/service/advancedclustertpf/README.md b/internal/service/advancedclustertpf/README.md index 8275f6fd58..7d712dafb4 100644 --- a/internal/service/advancedclustertpf/README.md +++ b/internal/service/advancedclustertpf/README.md @@ -7,3 +7,4 @@ This package contains the WIP for `mongodbatlas_advanced_cluster` in TPF. Curren ## Changes in advancedcluster that needs to be added here (list changes done in advancedcluster which couldn't also be done here at that moment) +- feat: Ensures asymmetric auto-scaling is not defined in the cluster when using the old sharding configuration in mongodbatlas_advanced_cluster (https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2836) \ No newline at end of file diff --git a/internal/service/advancedclustertpf/resource_schema.go b/internal/service/advancedclustertpf/resource_schema.go index 424a6fa666..4bee9a8782 100644 --- a/internal/service/advancedclustertpf/resource_schema.go +++ b/internal/service/advancedclustertpf/resource_schema.go @@ -497,8 +497,8 @@ type TFModel struct { Labels types.Set `tfsdk:"labels"` ReplicationSpecs types.List `tfsdk:"replication_specs"` Tags types.Set `tfsdk:"tags"` - StateName types.String `tfsdk:"state_name"` - ConnectionStrings types.Object `tfsdk:"connection_strings"` + MongoDBVersion types.String `tfsdk:"mongo_db_version"` + BiConnectorConfig types.Object `tfsdk:"bi_connector_config"` CreateDate types.String `tfsdk:"create_date"` AcceptDataRisksAndForceReplicaSetReconfig types.String `tfsdk:"accept_data_risks_and_force_replica_set_reconfig"` EncryptionAtRestProvider types.String `tfsdk:"encryption_at_rest_provider"` @@ -507,22 +507,22 @@ type TFModel struct { ClusterID types.String `tfsdk:"cluster_id"` ConfigServerManagementMode types.String `tfsdk:"config_server_management_mode"` MongoDBMajorVersion types.String `tfsdk:"mongo_db_major_version"` - MongoDBVersion types.String `tfsdk:"mongo_db_version"` + StateName types.String `tfsdk:"state_name"` Name types.String `tfsdk:"name"` VersionReleaseSystem types.String `tfsdk:"version_release_system"` - BiConnectorConfig types.Object `tfsdk:"bi_connector_config"` + ConnectionStrings types.Object `tfsdk:"connection_strings"` ConfigServerType types.String `tfsdk:"config_server_type"` ReplicaSetScalingStrategy types.String `tfsdk:"replica_set_scaling_strategy"` ClusterType types.String `tfsdk:"cluster_type"` RootCertType types.String `tfsdk:"root_cert_type"` - RedactClientLogData types.Bool `tfsdk:"redact_client_log_data"` + AdvancedConfiguration types.Object `tfsdk:"advanced_configuration"` PitEnabled types.Bool `tfsdk:"pit_enabled"` TerminationProtectionEnabled types.Bool `tfsdk:"termination_protection_enabled"` Paused types.Bool `tfsdk:"paused"` RetainBackupsEnabled types.Bool `tfsdk:"retain_backups_enabled"` BackupEnabled types.Bool `tfsdk:"backup_enabled"` GlobalClusterSelfManagedSharding types.Bool `tfsdk:"global_cluster_self_managed_sharding"` - AdvancedConfiguration types.Object `tfsdk:"advanced_configuration"` + RedactClientLogData types.Bool `tfsdk:"redact_client_log_data"` } type TFBiConnectorModel struct { @@ -590,13 +590,13 @@ var LabelsObjType = types.ObjectType{AttrTypes: map[string]attr.Type{ }} type TFReplicationSpecsModel struct { - Id types.String `tfsdk:"id"` + RegionConfigs types.List `tfsdk:"region_configs"` ContainerId types.Map `tfsdk:"container_id"` + Id types.String `tfsdk:"id"` ExternalId types.String `tfsdk:"external_id"` - NumShards types.Int64 `tfsdk:"num_shards"` - RegionConfigs types.List `tfsdk:"region_configs"` ZoneId types.String `tfsdk:"zone_id"` ZoneName types.String `tfsdk:"zone_name"` + NumShards types.Int64 `tfsdk:"num_shards"` } var ReplicationSpecsObjType = types.ObjectType{AttrTypes: map[string]attr.Type{ From cfc513dce35db2f543c8d4134eb2b8e2d6e39f9c Mon Sep 17 00:00:00 2001 From: Oriol Date: Wed, 4 Dec 2024 11:41:43 +0100 Subject: [PATCH 03/12] test: Add tests for `mongodb_advanced_cluster` covering transitions to auto-scaling mode (#2851) * implement GetIndependentShardScalingMode * add tests * add comment on fixed version * use base url from env variable to make tests work in QA --- ...esource_advanced_cluster_migration_test.go | 30 +++- .../resource_advanced_cluster_test.go | 139 +++++++++++++++++- .../testutil/acc/independent_shard_scaling.go | 49 ++++++ 3 files changed, 212 insertions(+), 6 deletions(-) create mode 100644 internal/testutil/acc/independent_shard_scaling.go diff --git a/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go b/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go index 5b8afe8189..5fd9989952 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go @@ -109,12 +109,12 @@ func TestMigAdvancedCluster_shardedMigrationFromOldToNewSchema(t *testing.T) { Steps: []resource.TestStep{ { ExternalProviders: acc.ExternalProviders(versionBeforeISSRelease), - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, false), + Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, false, false), Check: checkShardedTransitionOldToNewSchema(false), }, { ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true), + Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, false), Check: checkShardedTransitionOldToNewSchema(true), }, }, @@ -228,6 +228,32 @@ func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) { }) } +func TestMigAdvancedCluster_newSchemaFromAutoscalingDisabledToEnabled(t *testing.T) { + acc.SkipIfTPFAdvancedCluster(t) + var ( + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acc.RandomProjectName() + clusterName = acc.RandomClusterName() + ) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: acc.PreCheckBasicSleep(t, nil, orgID, projectName), + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + ExternalProviders: acc.ExternalProviders("1.22.0"), // last version before cluster tier auto-scaling per shard was introduced + Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, false), + Check: checkIndependentShardScalingMode(clusterName, "CLUSTER"), + }, + { + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, true), + Check: checkIndependentShardScalingMode(clusterName, "SHARD"), + }, + }, + }) +} + func configPartialAdvancedConfig(projectID, clusterName, extraArgs, autoScaling string) string { return fmt.Sprintf(` resource "mongodbatlas_advanced_cluster" "test" { diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index a53a3dac52..a6332855ae 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -1,6 +1,7 @@ package advancedcluster_test import ( + "context" "fmt" "os" "regexp" @@ -708,11 +709,11 @@ func TestAccClusterAdvancedClusterConfig_shardedTransitionFromOldToNewSchema(t * CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, false), + Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, false, false), Check: checkShardedTransitionOldToNewSchema(false), }, { - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true), + Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, false), Check: checkShardedTransitionOldToNewSchema(true), }, }, @@ -866,6 +867,127 @@ func TestAccClusterAdvancedCluster_priorityNewSchema(t *testing.T) { }) } +func TestAccAdvancedCluster_oldToNewSchemaWithAutoscalingDisabled(t *testing.T) { + acc.SkipIfTPFAdvancedCluster(t) + var ( + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acc.RandomProjectName() + clusterName = acc.RandomClusterName() + ) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: acc.PreCheckBasicSleep(t, nil, orgID, projectName), + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, false, false), + Check: checkIndependentShardScalingMode(clusterName, "CLUSTER"), + }, + { + Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, false), + Check: checkIndependentShardScalingMode(clusterName, "CLUSTER"), + }, + }, + }) +} + +func TestAccAdvancedCluster_oldToNewSchemaWithAutoscalingEnabled(t *testing.T) { + acc.SkipIfTPFAdvancedCluster(t) + var ( + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acc.RandomProjectName() + clusterName = acc.RandomClusterName() + ) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: acc.PreCheckBasicSleep(t, nil, orgID, projectName), + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, false, true), + Check: checkIndependentShardScalingMode(clusterName, "CLUSTER"), + }, + { + Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, true), + Check: checkIndependentShardScalingMode(clusterName, "SHARD"), + }, + }, + }) +} + +func TestAccAdvancedCluster_oldToNewSchemaWithAutoscalingDisabledToEnabled(t *testing.T) { + acc.SkipIfTPFAdvancedCluster(t) + var ( + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acc.RandomProjectName() + clusterName = acc.RandomClusterName() + ) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: acc.PreCheckBasicSleep(t, nil, orgID, projectName), + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, false, false), + Check: checkIndependentShardScalingMode(clusterName, "CLUSTER"), + }, + { + Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, false), + Check: checkIndependentShardScalingMode(clusterName, "CLUSTER"), + }, + { + Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, true), + Check: checkIndependentShardScalingMode(clusterName, "SHARD"), + }, + }, + }) +} + +func TestAccAdvancedCluster_newSchema(t *testing.T) { + acc.SkipIfTPFAdvancedCluster(t) + var ( + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acc.RandomProjectName() + clusterName = acc.RandomClusterName() + ) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: acc.PreCheckBasicSleep(t, nil, orgID, projectName), + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, false), + Check: checkIndependentShardScalingMode(clusterName, "SHARD"), + }, + }, + }) +} + +func checkIndependentShardScalingMode(clusterName, expectedMode string) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("not found: %s", resourceName) + } + if rs.Primary.ID == "" { + return fmt.Errorf("no ID is set") + } + ids := conversion.DecodeStateID(rs.Primary.ID) + issMode, _, err := acc.GetIndependentShardScalingMode(context.Background(), ids["project_id"], clusterName) + if err != nil { + return fmt.Errorf("error getting independent shard scaling mode: %w", err) + } + if *issMode != expectedMode { + return fmt.Errorf("expected independent shard scaling mode to be %s, got %s", expectedMode, *issMode) + } + return nil + } +} + func checkAggr(attrsSet []string, attrsMap map[string]string, extra ...resource.TestCheckFunc) resource.TestCheckFunc { checks := []resource.TestCheckFunc{checkExists(resourceName)} checks = acc.AddAttrChecks(resourceName, checks, attrsMap) @@ -1908,11 +2030,19 @@ func checkGeoShardedNewSchema(includeThirdShardInFirstZone bool) resource.TestCh ) } -func configShardedTransitionOldToNewSchema(orgID, projectName, name string, useNewSchema bool) string { +func configShardedTransitionOldToNewSchema(orgID, projectName, name string, useNewSchema, autoscaling bool) string { var numShardsStr string if !useNewSchema { numShardsStr = `num_shards = 2` } + var autoscalingStr string + if autoscaling { + autoscalingStr = `auto_scaling { + compute_enabled = true + disk_gb_enabled = true + compute_max_instance_size = "M20" + }` + } replicationSpec := fmt.Sprintf(` replication_specs { %[1]s @@ -1928,9 +2058,10 @@ func configShardedTransitionOldToNewSchema(orgID, projectName, name string, useN provider_name = "AWS" priority = 7 region_name = "EU_WEST_1" + %[2]s } } - `, numShardsStr) + `, numShardsStr, autoscalingStr) var replicationSpecs string if useNewSchema { diff --git a/internal/testutil/acc/independent_shard_scaling.go b/internal/testutil/acc/independent_shard_scaling.go new file mode 100644 index 0000000000..7dc3f1e544 --- /dev/null +++ b/internal/testutil/acc/independent_shard_scaling.go @@ -0,0 +1,49 @@ +package acc + +import ( + "context" + "io" + "net/http" + "os" + + "github.com/mongodb-forks/digest" +) + +func GetIndependentShardScalingMode(ctx context.Context, projectID, clusterName string) (*string, *http.Response, error) { + baseURL := os.Getenv("MONGODB_ATLAS_BASE_URL") + req, err := http.NewRequestWithContext(ctx, http.MethodGet, baseURL+"test/utils/auth/groups/"+projectID+"/clusters/"+clusterName+"/independentShardScalingMode", http.NoBody) + if err != nil { + return nil, nil, err + } + + req.Header.Add("Accept", "*/*") + + transport := digest.NewTransport(os.Getenv("MONGODB_ATLAS_PUBLIC_KEY"), os.Getenv("MONGODB_ATLAS_PRIVATE_KEY")) + httpClient, err := transport.Client() + if err != nil { + return nil, nil, err + } + + resp, err := httpClient.Do(req) + if err != nil || resp == nil { + return nil, resp, err + } + + var result *string + result, err = decode(resp.Body) + if err != nil { + return nil, resp, err + } + + return result, resp, nil +} + +func decode(body io.ReadCloser) (*string, error) { + buf, err := io.ReadAll(body) + _ = body.Close() + if err != nil { + return nil, err + } + result := string(buf) + return &result, nil +} From 4a42192cd96abad67b39fddad1f84e66b02ff378 Mon Sep 17 00:00:00 2001 From: cveticm <119604954+cveticm@users.noreply.github.com> Date: Wed, 4 Dec 2024 15:28:12 +0000 Subject: [PATCH 04/12] chore: Refactor read operation in 'mongodb_advanced_cluster' (#2839) * Initial implementation * Removes redundant comments * Moves old shard config flatten logic to keep generic flatten function * Removes redundant comments * Adds testing to GetReplicationSpecAttributesFromOldAPI * Adds unit testing and fixes comments * Fixes lint * Changes names OldShardConfig to OldShardingConfig and removes redundant DS function * Adds comments * Changes test name * move OldShardConfigMeta to model file --------- Co-authored-by: Oriol Arbusi --- .../advancedcluster/model_advanced_cluster.go | 79 ++++++++++- .../model_advanced_cluster_test.go | 131 ++++++++++++++++++ .../resource_advanced_cluster.go | 109 ++++++--------- .../resource_advanced_cluster_test.go | 60 ++++++++ 4 files changed, 314 insertions(+), 65 deletions(-) diff --git a/internal/service/advancedcluster/model_advanced_cluster.go b/internal/service/advancedcluster/model_advanced_cluster.go index 10b95389b3..0e759eafcf 100644 --- a/internal/service/advancedcluster/model_advanced_cluster.go +++ b/internal/service/advancedcluster/model_advanced_cluster.go @@ -25,6 +25,11 @@ import ( const minVersionForChangeStreamOptions = 6.0 +type OldShardConfigMeta struct { + ID string + NumShard int +} + var ( DSTagsSchema = schema.Schema{ Type: schema.TypeSet, @@ -514,6 +519,7 @@ func flattenProcessArgs(p20240530 *admin20240530.ClusterDescriptionProcessArgs, return flattenedProcessArgs } +// This function is untilised by DS read which still uses the old API and will be removed when refactor to DS read operation is implemented. func FlattenAdvancedReplicationSpecsOldSDK(ctx context.Context, apiObjects []admin20240530.ReplicationSpec, zoneNameToZoneIDs map[string]string, rootDiskSizeGB float64, tfMapObjects []any, d *schema.ResourceData, connV2 *admin.APIClient) ([]map[string]any, error) { // for flattening old model we need information of value defined at root disk_size_gb so we set the value in new location under hardware specs @@ -524,6 +530,16 @@ func FlattenAdvancedReplicationSpecsOldSDK(ctx context.Context, apiObjects []adm doesAdvancedReplicationSpecMatchAPIOldSDK, replicationSpecFlattener, connV2) } +func FlattenAdvancedReplicationSpecsOldShardingConfig(ctx context.Context, apiObjects []admin.ReplicationSpec20240805, zoneNameToOldReplicationSpecMeta map[string]OldShardConfigMeta, tfMapObjects []any, + d *schema.ResourceData, connV2 *admin.APIClient) ([]map[string]any, error) { + replicationSpecFlattener := func(ctx context.Context, sdkModel *admin.ReplicationSpec20240805, tfModel map[string]any, resourceData *schema.ResourceData, client *admin.APIClient) (map[string]any, error) { + return flattenAdvancedReplicationSpecOldShardingConfig(ctx, sdkModel, zoneNameToOldReplicationSpecMeta, tfModel, resourceData, connV2) + } + compressedAPIObjects := compressAPIObjectList(apiObjects) + return flattenAdvancedReplicationSpecsLogic[admin.ReplicationSpec20240805](ctx, compressedAPIObjects, tfMapObjects, d, + doesAdvancedReplicationSpecMatchAPIOldShardConfig, replicationSpecFlattener, connV2) +} + func flattenAdvancedReplicationSpecs(ctx context.Context, apiObjects []admin.ReplicationSpec20240805, zoneNameToOldReplicationSpecIDs map[string]string, tfMapObjects []any, d *schema.ResourceData, connV2 *admin.APIClient) ([]map[string]any, error) { // for flattening new model we need information of replication spec ids associated to old API to avoid breaking changes for users referencing replication_specs.*.id @@ -534,6 +550,30 @@ func flattenAdvancedReplicationSpecs(ctx context.Context, apiObjects []admin.Rep doesAdvancedReplicationSpecMatchAPI, replicationSpecFlattener, connV2) } +// compressAPIObjectList returns an array of ReplicationSpec20240805. The input array is reduced from all shards to only one shard per zoneName +func compressAPIObjectList(apiObjects []admin.ReplicationSpec20240805) []admin.ReplicationSpec20240805 { + var compressedAPIObjectList []admin.ReplicationSpec20240805 + wasZoneNameUsed := populateZoneNameMap(apiObjects) + for _, apiObject := range apiObjects { + if !wasZoneNameUsed[apiObject.GetZoneName()] { + compressedAPIObjectList = append(compressedAPIObjectList, apiObject) + wasZoneNameUsed[apiObject.GetZoneName()] = true + } + } + return compressedAPIObjectList +} + +// populateZoneNameMap returns a map of zoneNames and initializes all keys to false. +func populateZoneNameMap(apiObjects []admin.ReplicationSpec20240805) map[string]bool { + zoneNames := make(map[string]bool) + for _, apiObject := range apiObjects { + if _, exists := zoneNames[apiObject.GetZoneName()]; !exists { + zoneNames[apiObject.GetZoneName()] = false + } + } + return zoneNames +} + type ReplicationSpecSDKModel interface { admin20240530.ReplicationSpec | admin.ReplicationSpec20240805 } @@ -556,7 +596,6 @@ func flattenAdvancedReplicationSpecsLogic[T ReplicationSpecSDKModel]( if len(tfMapObjects) > i { tfMapObject = tfMapObjects[i].(map[string]any) } - for j := 0; j < len(apiObjects); j++ { if wasAPIObjectUsed[j] || !tfModelWithSDKMatcher(tfMapObject, &apiObjects[j]) { continue @@ -599,10 +638,15 @@ func flattenAdvancedReplicationSpecsLogic[T ReplicationSpecSDKModel]( return tfList, nil } +// This function is untilised by DS read which still uses the old API and will be removed when refactor to DS read operation is implemented. func doesAdvancedReplicationSpecMatchAPIOldSDK(tfObject map[string]any, apiObject *admin20240530.ReplicationSpec) bool { return tfObject["id"] == apiObject.GetId() || (tfObject["id"] == nil && tfObject["zone_name"] == apiObject.GetZoneName()) } +func doesAdvancedReplicationSpecMatchAPIOldShardConfig(tfObject map[string]any, apiObject *admin.ReplicationSpec20240805) bool { + return tfObject["zone_name"] == apiObject.GetZoneName() +} + func doesAdvancedReplicationSpecMatchAPI(tfObject map[string]any, apiObject *admin.ReplicationSpec20240805) bool { return tfObject["external_id"] == apiObject.GetId() } @@ -1111,6 +1155,7 @@ func flattenAdvancedReplicationSpec(ctx context.Context, apiObject *admin.Replic return tfMap, nil } +// This function is untilised by DS read which still uses the old API and will be removed when refactor to DS read operation is implemented. func flattenAdvancedReplicationSpecOldSDK(ctx context.Context, apiObject *admin20240530.ReplicationSpec, zoneNameToZoneIDs map[string]string, rootDiskSizeGB float64, tfMapObject map[string]any, d *schema.ResourceData, connV2 *admin.APIClient) (map[string]any, error) { if apiObject == nil { @@ -1142,3 +1187,35 @@ func flattenAdvancedReplicationSpecOldSDK(ctx context.Context, apiObject *admin2 return tfMap, nil } + +func flattenAdvancedReplicationSpecOldShardingConfig(ctx context.Context, apiObject *admin.ReplicationSpec20240805, zoneNameToOldShardConfigMeta map[string]OldShardConfigMeta, tfMapObject map[string]any, + d *schema.ResourceData, connV2 *admin.APIClient) (map[string]any, error) { + if apiObject == nil { + return nil, nil + } + + tfMap := map[string]any{} + if oldShardConfigData, ok := zoneNameToOldShardConfigMeta[apiObject.GetZoneName()]; ok { + tfMap["num_shards"] = oldShardConfigData.NumShard + tfMap["id"] = oldShardConfigData.ID + } + if tfMapObject != nil { + object, containerIDs, err := flattenAdvancedReplicationSpecRegionConfigs(ctx, apiObject.GetRegionConfigs(), tfMapObject["region_configs"].([]any), d, connV2) + if err != nil { + return nil, err + } + tfMap["region_configs"] = object + tfMap["container_id"] = containerIDs + } else { + object, containerIDs, err := flattenAdvancedReplicationSpecRegionConfigs(ctx, apiObject.GetRegionConfigs(), nil, d, connV2) + if err != nil { + return nil, err + } + tfMap["region_configs"] = object + tfMap["container_id"] = containerIDs + } + tfMap["zone_name"] = apiObject.GetZoneName() + tfMap["zone_id"] = apiObject.GetZoneId() + + return tfMap, nil +} diff --git a/internal/service/advancedcluster/model_advanced_cluster_test.go b/internal/service/advancedcluster/model_advanced_cluster_test.go index 7dd517c469..1a9cb6a12d 100644 --- a/internal/service/advancedcluster/model_advanced_cluster_test.go +++ b/internal/service/advancedcluster/model_advanced_cluster_test.go @@ -149,6 +149,137 @@ func TestFlattenReplicationSpecs(t *testing.T) { } } +func TestFlattenAdvancedReplicationSpecsOldShardingConfig(t *testing.T) { + var ( + regionName = "EU_WEST_1" + providerName = "AWS" + expectedID = "id1" + unexpectedID = "id2" + expectedZoneName = "z1" + unexpectedZoneName = "z2" + regionConfigAdmin = []admin.CloudRegionConfig20240805{{ + ProviderName: &providerName, + RegionName: ®ionName, + }} + regionConfigTfSameZone = map[string]any{ + "provider_name": "AWS", + "region_name": regionName, + } + regionConfigTfDiffZone = map[string]any{ + "provider_name": "AWS", + "region_name": regionName, + "zone_name": unexpectedZoneName, + } + apiSpecExpected = admin.ReplicationSpec20240805{Id: &expectedID, ZoneName: &expectedZoneName, RegionConfigs: ®ionConfigAdmin} + apiSpecDifferent = admin.ReplicationSpec20240805{Id: &unexpectedID, ZoneName: &unexpectedZoneName, RegionConfigs: ®ionConfigAdmin} + testSchema = map[string]*schema.Schema{ + "project_id": {Type: schema.TypeString}, + } + tfSameIDSameZone = map[string]any{ + "id": expectedID, + "num_shards": 1, + "region_configs": []any{regionConfigTfSameZone}, + "zone_name": expectedZoneName, + } + tfNoIDSameZone = map[string]any{ + "id": nil, + "num_shards": 1, + "region_configs": []any{regionConfigTfSameZone}, + "zone_name": expectedZoneName, + } + tfNoIDDiffZone = map[string]any{ + "id": nil, + "num_shards": 1, + "region_configs": []any{regionConfigTfDiffZone}, + "zone_name": unexpectedZoneName, + } + tfdiffIDDiffZone = map[string]any{ + "id": "unique", + "num_shards": 1, + "region_configs": []any{regionConfigTfDiffZone}, + "zone_name": unexpectedZoneName, + } + ) + testCases := map[string]struct { + adminSpecs []admin.ReplicationSpec20240805 + zoneNameToOldReplicationSpecMeta map[string]advancedcluster.OldShardConfigMeta + tfInputSpecs []any + expectedLen int + }{ + "empty admin spec should return empty list": { + []admin.ReplicationSpec20240805{}, + map[string]advancedcluster.OldShardConfigMeta{}, + []any{tfSameIDSameZone}, + 0, + }, + "existing id, should match admin": { + []admin.ReplicationSpec20240805{apiSpecExpected}, + map[string]advancedcluster.OldShardConfigMeta{expectedZoneName: {expectedID, 1}}, + []any{tfSameIDSameZone}, + 1, + }, + "existing different id, should change to admin spec": { + []admin.ReplicationSpec20240805{apiSpecExpected}, + map[string]advancedcluster.OldShardConfigMeta{expectedZoneName: {expectedID, 1}}, + []any{tfdiffIDDiffZone}, + 1, + }, + "missing id, should be set when zone_name matches": { + []admin.ReplicationSpec20240805{apiSpecExpected}, + map[string]advancedcluster.OldShardConfigMeta{expectedZoneName: {expectedID, 1}}, + []any{tfNoIDSameZone}, + 1, + }, + "missing id and diff zone, should change to admin spec": { + []admin.ReplicationSpec20240805{apiSpecExpected}, + map[string]advancedcluster.OldShardConfigMeta{expectedZoneName: {expectedID, 1}}, + []any{tfNoIDDiffZone}, + 1, + }, + "existing id, should match correct api spec using `id` and extra api spec added": { + []admin.ReplicationSpec20240805{apiSpecDifferent, apiSpecExpected}, + map[string]advancedcluster.OldShardConfigMeta{unexpectedZoneName: {unexpectedID, 1}, expectedZoneName: {expectedID, 1}}, + []any{tfSameIDSameZone}, + 2, + }, + "missing id, should match correct api spec using `zone_name` and extra api spec added": { + []admin.ReplicationSpec20240805{apiSpecDifferent, apiSpecExpected}, + map[string]advancedcluster.OldShardConfigMeta{unexpectedZoneName: {unexpectedID, 1}, expectedZoneName: {expectedID, 1}}, + []any{tfNoIDSameZone}, + 2, + }, + "two matching specs should be set to api specs": { + []admin.ReplicationSpec20240805{apiSpecExpected, apiSpecDifferent}, + map[string]advancedcluster.OldShardConfigMeta{expectedZoneName: {expectedID, 1}, unexpectedZoneName: {unexpectedID, 1}}, + []any{tfSameIDSameZone, tfdiffIDDiffZone}, + 2, + }, + } + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + peeringAPI := mockadmin.NetworkPeeringApi{} + + peeringAPI.EXPECT().ListPeeringContainerByCloudProviderWithParams(mock.Anything, mock.Anything).Return(admin.ListPeeringContainerByCloudProviderApiRequest{ApiService: &peeringAPI}) + containerResult := []admin.CloudProviderContainer{{Id: conversion.StringPtr("c1"), RegionName: ®ionName, ProviderName: &providerName}} + peeringAPI.EXPECT().ListPeeringContainerByCloudProviderExecute(mock.Anything).Return(&admin.PaginatedCloudProviderContainer{Results: &containerResult}, nil, nil) + + client := &admin.APIClient{ + NetworkPeeringApi: &peeringAPI, + } + resourceData := schema.TestResourceDataRaw(t, testSchema, map[string]any{"project_id": "p1"}) + + tfOutputSpecs, err := advancedcluster.FlattenAdvancedReplicationSpecsOldShardingConfig(context.Background(), tc.adminSpecs, tc.zoneNameToOldReplicationSpecMeta, tc.tfInputSpecs, resourceData, client) + + require.NoError(t, err) + assert.Len(t, tfOutputSpecs, tc.expectedLen) + if tc.expectedLen != 0 { + assert.Equal(t, expectedID, tfOutputSpecs[0]["id"]) + assert.Equal(t, expectedZoneName, tfOutputSpecs[0]["zone_name"]) + } + }) + } +} + func TestGetDiskSizeGBFromReplicationSpec(t *testing.T) { diskSizeGBValue := 40.0 diff --git a/internal/service/advancedcluster/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index 2b35fcf397..6bc75d16e6 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -565,84 +565,37 @@ func resourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Di projectID := ids["project_id"] clusterName := ids["cluster_name"] - var clusterResp *admin.ClusterDescription20240805 - var replicationSpecs []map[string]any - if isUsingOldShardingConfiguration(d) { - clusterOldSDK, resp, err := connV220240530.ClustersApi.GetCluster(ctx, projectID, clusterName).Execute() - if err != nil { - if resp != nil && resp.StatusCode == http.StatusNotFound { - d.SetId("") - return nil - } - return diag.FromErr(fmt.Errorf(errorRead, clusterName, err)) - } - if err := d.Set("disk_size_gb", clusterOldSDK.GetDiskSizeGB()); err != nil { - return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "disk_size_gb", clusterName, err)) - } - cluster, resp, err := connV2.ClustersApi.GetCluster(ctx, projectID, clusterName).Execute() - if err != nil { - if resp != nil && resp.StatusCode == http.StatusNotFound { - d.SetId("") - return nil - } - return diag.FromErr(fmt.Errorf(errorRead, clusterName, err)) - } - if err := d.Set("replica_set_scaling_strategy", cluster.GetReplicaSetScalingStrategy()); err != nil { - return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "replica_set_scaling_strategy", clusterName, err)) - } - if err := d.Set("redact_client_log_data", cluster.GetRedactClientLogData()); err != nil { - return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "redact_client_log_data", clusterName, err)) + cluster, resp, err := connV2.ClustersApi.GetCluster(ctx, projectID, clusterName).Execute() + if err != nil { + if resp != nil && resp.StatusCode == http.StatusNotFound { + d.SetId("") + return nil } - zoneNameToZoneIDs, err := getZoneIDsFromNewAPI(cluster) + return diag.FromErr(fmt.Errorf(errorRead, clusterName, err)) + } + + if isUsingOldShardingConfiguration(d) { + zoneNameToOldReplicationSpecMeta, err := GetReplicationSpecAttributesFromOldAPI(ctx, projectID, clusterName, connV220240530.ClustersApi) if err != nil { return diag.FromErr(err) } - - replicationSpecs, err = FlattenAdvancedReplicationSpecsOldSDK(ctx, clusterOldSDK.GetReplicationSpecs(), zoneNameToZoneIDs, clusterOldSDK.GetDiskSizeGB(), d.Get("replication_specs").([]any), d, connV2) + replicationSpecs, err = FlattenAdvancedReplicationSpecsOldShardingConfig(ctx, cluster.GetReplicationSpecs(), zoneNameToOldReplicationSpecMeta, d.Get("replication_specs").([]any), d, connV2) if err != nil { return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "replication_specs", clusterName, err)) } - - clusterResp = convertClusterDescToLatestExcludeRepSpecs(clusterOldSDK) - clusterResp.ConfigServerManagementMode = cluster.ConfigServerManagementMode - clusterResp.ConfigServerType = cluster.ConfigServerType } else { - cluster, resp, err := connV2.ClustersApi.GetCluster(ctx, projectID, clusterName).Execute() - if err != nil { - if resp != nil && resp.StatusCode == http.StatusNotFound { - d.SetId("") - return nil - } - return diag.FromErr(fmt.Errorf(errorRead, clusterName, err)) - } - - // root disk_size_gb defined for backwards compatibility avoiding breaking changes - if err := d.Set("disk_size_gb", GetDiskSizeGBFromReplicationSpec(cluster)); err != nil { - return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "disk_size_gb", clusterName, err)) - } - if err := d.Set("replica_set_scaling_strategy", cluster.GetReplicaSetScalingStrategy()); err != nil { - return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "replica_set_scaling_strategy", clusterName, err)) - } - if err := d.Set("redact_client_log_data", cluster.GetRedactClientLogData()); err != nil { - return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "redact_client_log_data", clusterName, err)) - } - - zoneNameToOldReplicationSpecIDs, err := getReplicationSpecIDsFromOldAPI(ctx, projectID, clusterName, connV220240530) + zoneNameToOldReplicationSpecID, err := getReplicationSpecIDsFromOldAPI(ctx, projectID, clusterName, connV220240530) if err != nil { return diag.FromErr(err) } - - replicationSpecs, err = flattenAdvancedReplicationSpecs(ctx, cluster.GetReplicationSpecs(), zoneNameToOldReplicationSpecIDs, d.Get("replication_specs").([]any), d, connV2) + replicationSpecs, err = flattenAdvancedReplicationSpecs(ctx, cluster.GetReplicationSpecs(), zoneNameToOldReplicationSpecID, d.Get("replication_specs").([]any), d, connV2) if err != nil { return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "replication_specs", clusterName, err)) } - - clusterResp = cluster } - - diags := setRootFields(d, clusterResp, true) + diags := setRootFields(d, cluster, true) if diags.HasError() { return diags } @@ -667,15 +620,31 @@ func resourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Di return nil } +// GetReplicationSpecAttributesFromOldAPI returns the id and num shard values of replication specs coming from old API. This is used to populate replication_specs.*.id and replication_specs.*.num_shard attributes for old sharding confirgurations. +// In the old API, each replications spec has a 1:1 relation with each zone, so ids and num shards are stored in a struct oldShardConfigMeta and are returned in a map from zoneName to oldShardConfigMeta. +func GetReplicationSpecAttributesFromOldAPI(ctx context.Context, projectID, clusterName string, client20240530 admin20240530.ClustersApi) (map[string]OldShardConfigMeta, error) { + clusterOldAPI, _, err := client20240530.GetCluster(ctx, projectID, clusterName).Execute() + if err != nil { + readErrorMsg := "error reading advanced cluster with 2023-02-01 API (%s): %s" + return nil, fmt.Errorf(readErrorMsg, clusterName, err) + } + specs := clusterOldAPI.GetReplicationSpecs() + result := make(map[string]OldShardConfigMeta, len(specs)) + for _, spec := range specs { + result[spec.GetZoneName()] = OldShardConfigMeta{spec.GetId(), spec.GetNumShards()} + } + return result, nil +} + // getReplicationSpecIDsFromOldAPI returns the id values of replication specs coming from old API. This is used to populate old replication_specs.*.id attribute avoiding breaking changes. // In the old API each replications spec has a 1:1 relation with each zone, so ids are returned in a map from zoneName to id. func getReplicationSpecIDsFromOldAPI(ctx context.Context, projectID, clusterName string, connV220240530 *admin20240530.APIClient) (map[string]string, error) { clusterOldAPI, _, err := connV220240530.ClustersApi.GetCluster(ctx, projectID, clusterName).Execute() if apiError, ok := admin20240530.AsError(err); ok { if apiError.GetErrorCode() == "ASYMMETRIC_SHARD_UNSUPPORTED" { - return nil, nil // if its the case of an asymmetric shard an error is expected in old API, replication_specs.*.id attribute will not be populated + return nil, nil // If it is the case of an asymmetric shard, an error is expected in old API and replication_specs.*.id attribute will not be populated. } - readErrorMsg := "error reading advanced cluster with 2023-02-01 API (%s): %s" + readErrorMsg := "error reading advanced cluster with 2023-02-01 API (%s): %s" return nil, fmt.Errorf(readErrorMsg, clusterName, err) } specs := clusterOldAPI.GetReplicationSpecs() @@ -686,7 +655,7 @@ func getReplicationSpecIDsFromOldAPI(ctx context.Context, projectID, clusterName return result, nil } -// getZoneIDsFromNewAPI returns the zone id values of replication specs coming from new API. This is used to populate zone_id when old API is called in the read. +// getZoneIDsFromNewAPI returns the zone id values of replication specs coming from new API. This is used to populate zone_id when old API is called in DS read. func getZoneIDsFromNewAPI(cluster *admin.ClusterDescription20240805) (map[string]string, error) { specs := cluster.GetReplicationSpecs() result := make(map[string]string, len(specs)) @@ -729,6 +698,11 @@ func setRootFields(d *schema.ResourceData, cluster *admin.ClusterDescription2024 return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "create_date", clusterName, err)) } + // root disk_size_gb defined for backwards compatibility avoiding breaking changes + if err := d.Set("disk_size_gb", GetDiskSizeGBFromReplicationSpec(cluster)); err != nil { + return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "disk_size_gb", clusterName, err)) + } + if err := d.Set("encryption_at_rest_provider", cluster.GetEncryptionAtRestProvider()); err != nil { return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "encryption_at_rest_provider", clusterName, err)) } @@ -781,6 +755,13 @@ func setRootFields(d *schema.ResourceData, cluster *admin.ClusterDescription2024 return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "global_cluster_self_managed_sharding", clusterName, err)) } + if err := d.Set("replica_set_scaling_strategy", cluster.GetReplicaSetScalingStrategy()); err != nil { + return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "replica_set_scaling_strategy", clusterName, err)) + } + if err := d.Set("redact_client_log_data", cluster.GetRedactClientLogData()); err != nil { + return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "redact_client_log_data", clusterName, err)) + } + if err := d.Set("config_server_type", cluster.GetConfigServerType()); err != nil { return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "config_server_type", clusterName, err)) } diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index a6332855ae..14e474cd21 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -2,17 +2,22 @@ package advancedcluster_test import ( "context" + "errors" "fmt" + "net/http" "os" "regexp" "strconv" "testing" admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" + mockadmin20240530 "go.mongodb.org/atlas-sdk/v20240530005/mockadmin" "go.mongodb.org/atlas-sdk/v20241023002/admin" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster" @@ -30,6 +35,61 @@ var ( configServerManagementModeAtlasManaged = "ATLAS_MANAGED" ) +func TestGetReplicationSpecAttributesFromOldAPI(t *testing.T) { + var ( + projectID = "11111" + clusterName = "testCluster" + ID = "111111" + numShard = 2 + zoneName = "ZoneName managed by Terraform" + ) + + testCases := map[string]struct { + mockCluster *admin20240530.AdvancedClusterDescription + mockResponse *http.Response + mockError error + expectedResult map[string]advancedcluster.OldShardConfigMeta + expectedError error + }{ + "Error in the API call": { + mockCluster: &admin20240530.AdvancedClusterDescription{}, + mockResponse: &http.Response{StatusCode: 400}, + mockError: errGeneric, + expectedError: errors.New("error reading advanced cluster with 2023-02-01 API (testCluster): generic"), + expectedResult: nil, + }, + "Successful": { + mockCluster: &admin20240530.AdvancedClusterDescription{ + ReplicationSpecs: &[]admin20240530.ReplicationSpec{ + { + NumShards: &numShard, + Id: &ID, + ZoneName: &zoneName, + }, + }, + }, + mockResponse: &http.Response{}, + mockError: nil, + expectedError: nil, + expectedResult: map[string]advancedcluster.OldShardConfigMeta{ + zoneName: {ID: ID, NumShard: numShard}, + }, + }, + } + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + testObject := mockadmin20240530.NewClustersApi(t) + + testObject.EXPECT().GetCluster(mock.Anything, mock.Anything, mock.Anything).Return(admin20240530.GetClusterApiRequest{ApiService: testObject}).Once() + testObject.EXPECT().GetClusterExecute(mock.Anything).Return(tc.mockCluster, tc.mockResponse, tc.mockError).Once() + + result, err := advancedcluster.GetReplicationSpecAttributesFromOldAPI(context.Background(), projectID, clusterName, testObject) + assert.Equal(t, tc.expectedError, err) + assert.Equal(t, tc.expectedResult, result) + }) + } +} + func TestAccClusterAdvancedCluster_basicTenant(t *testing.T) { acc.SkipIfTPFAdvancedCluster(t) var ( From 3cb08c3055047df302b3a31c8dcb64fca1982731 Mon Sep 17 00:00:00 2001 From: Oriol Date: Mon, 9 Dec 2024 15:53:13 +0100 Subject: [PATCH 05/12] test: Refactor tests for `mongodb_advanced_cluster` covering transitions to auto-scaling mode (#2863) * refactor tests * cover geo sharded case * temp: change to run tests in CI --- .../resource_advanced_cluster.go | 1 + .../resource_advanced_cluster_test.go | 66 +++++-------------- 2 files changed, 16 insertions(+), 51 deletions(-) diff --git a/internal/service/advancedcluster/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index 6bc75d16e6..965f0f4329 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -1346,5 +1346,6 @@ func waitForUpdateToFinish(ctx context.Context, connV2 *admin.APIClient, project } _, err := stateConf.WaitForStateContext(ctx) + return err } diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index 14e474cd21..a84e7a5f5d 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -636,11 +636,15 @@ func symmetricGeoShardedOldSchemaTestCase(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configGeoShardedOldSchema(orgID, projectName, clusterName, 2, 2, false), - Check: checkGeoShardedOldSchema(clusterName, 2, 2, true, false), + Check: resource.ComposeAggregateTestCheckFunc( + checkGeoShardedOldSchema(clusterName, 2, 2, true, false), + checkIndependentShardScalingMode(clusterName, "CLUSTER")), }, { Config: configGeoShardedOldSchema(orgID, projectName, clusterName, 3, 3, false), - Check: checkGeoShardedOldSchema(clusterName, 3, 3, true, false), + Check: resource.ComposeAggregateTestCheckFunc( + checkGeoShardedOldSchema(clusterName, 3, 3, true, false), + checkIndependentShardScalingMode(clusterName, "CLUSTER")), }, }, } @@ -720,7 +724,9 @@ func asymmetricShardedNewSchemaTestCase(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configShardedNewSchema(orgID, projectName, clusterName, 50, "M30", "M40", admin.PtrInt(2000), admin.PtrInt(2500), false), - Check: checkShardedNewSchema(50, "M30", "M40", admin.PtrInt(2000), admin.PtrInt(2500), true, false), + Check: resource.ComposeAggregateTestCheckFunc( + checkShardedNewSchema(50, "M30", "M40", admin.PtrInt(2000), admin.PtrInt(2500), true, false), + checkIndependentShardScalingMode(clusterName, "SHARD")), }, }, } @@ -770,11 +776,15 @@ func TestAccClusterAdvancedClusterConfig_shardedTransitionFromOldToNewSchema(t * Steps: []resource.TestStep{ { Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, false, false), - Check: checkShardedTransitionOldToNewSchema(false), + Check: resource.ComposeAggregateTestCheckFunc( + checkShardedTransitionOldToNewSchema(false), + checkIndependentShardScalingMode(clusterName, "CLUSTER")), }, { Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, false), - Check: checkShardedTransitionOldToNewSchema(true), + Check: resource.ComposeAggregateTestCheckFunc( + checkShardedTransitionOldToNewSchema(true), + checkIndependentShardScalingMode(clusterName, "CLUSTER")), }, }, }) @@ -927,31 +937,6 @@ func TestAccClusterAdvancedCluster_priorityNewSchema(t *testing.T) { }) } -func TestAccAdvancedCluster_oldToNewSchemaWithAutoscalingDisabled(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) - var ( - orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") - projectName = acc.RandomProjectName() - clusterName = acc.RandomClusterName() - ) - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: acc.PreCheckBasicSleep(t, nil, orgID, projectName), - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: acc.CheckDestroyCluster, - Steps: []resource.TestStep{ - { - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, false, false), - Check: checkIndependentShardScalingMode(clusterName, "CLUSTER"), - }, - { - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, false), - Check: checkIndependentShardScalingMode(clusterName, "CLUSTER"), - }, - }, - }) -} - func TestAccAdvancedCluster_oldToNewSchemaWithAutoscalingEnabled(t *testing.T) { acc.SkipIfTPFAdvancedCluster(t) var ( @@ -1006,27 +991,6 @@ func TestAccAdvancedCluster_oldToNewSchemaWithAutoscalingDisabledToEnabled(t *te }) } -func TestAccAdvancedCluster_newSchema(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) - var ( - orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") - projectName = acc.RandomProjectName() - clusterName = acc.RandomClusterName() - ) - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: acc.PreCheckBasicSleep(t, nil, orgID, projectName), - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: acc.CheckDestroyCluster, - Steps: []resource.TestStep{ - { - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, false), - Check: checkIndependentShardScalingMode(clusterName, "SHARD"), - }, - }, - }) -} - func checkIndependentShardScalingMode(clusterName, expectedMode string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[resourceName] From faff9c036388afec7c7a05401862940f84da06e4 Mon Sep 17 00:00:00 2001 From: Oriol Date: Wed, 11 Dec 2024 15:06:03 +0100 Subject: [PATCH 06/12] chore: Refactors read operation of `mongodbatlas_advanced_cluster` data sources (#2859) * refactor read operation of data sources to be like the resource read operation * wip:fix test * Revert "wip:fix test" This reverts commit 990d88cd0bb0785289b5068be0ea94d6db5903a6. * small cleanup * fix * handle ASYMMETRIC_SHARD_UNSUPPORTED * fix unit test * simplify if * handle ASYMMETRIC_SHARD_UNSUPPORTED in singular data source as was done in previous implementation * Revert "handle ASYMMETRIC_SHARD_UNSUPPORTED in singular data source as was done in previous implementation" This reverts commit 439f7fe7d32022f3de510bdcdc4d95a2b3f1e2be. * fix error handling * adapt test * final changes * pr comments * pr * fix test * typo * test check * mig test skip --- .../data_source_advanced_cluster.go | 99 +++------ .../data_source_advanced_clusters.go | 128 +++--------- .../advancedcluster/model_advanced_cluster.go | 67 +----- .../model_advanced_cluster_test.go | 122 ----------- .../model_sdk_version_conversion.go | 195 ------------------ .../resource_advanced_cluster.go | 48 +---- ...esource_advanced_cluster_migration_test.go | 1 + .../resource_advanced_cluster_test.go | 9 +- 8 files changed, 83 insertions(+), 586 deletions(-) diff --git a/internal/service/advancedcluster/data_source_advanced_cluster.go b/internal/service/advancedcluster/data_source_advanced_cluster.go index 40e58fee9d..69c6623586 100644 --- a/internal/service/advancedcluster/data_source_advanced_cluster.go +++ b/internal/service/advancedcluster/data_source_advanced_cluster.go @@ -5,10 +5,9 @@ import ( "fmt" "net/http" - admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) @@ -272,95 +271,43 @@ func dataSourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag. clusterName := d.Get("name").(string) useReplicationSpecPerShard := false var replicationSpecs []map[string]any - var clusterID string if v, ok := d.GetOk("use_replication_spec_per_shard"); ok { useReplicationSpecPerShard = v.(bool) } - if !useReplicationSpecPerShard { - clusterDescOld, resp, err := connV220240530.ClustersApi.GetCluster(ctx, projectID, clusterName).Execute() - if err != nil { - if resp != nil { - if resp.StatusCode == http.StatusNotFound { - return nil - } - if admin20240530.IsErrorCode(err, "ASYMMETRIC_SHARD_UNSUPPORTED") { - return diag.FromErr(fmt.Errorf("please add `use_replication_spec_per_shard = true` to your data source configuration to enable asymmetric shard support. Refer to documentation for more details. %s", err)) - } - } - return diag.FromErr(fmt.Errorf(errorRead, clusterName, err)) - } - - clusterID = clusterDescOld.GetId() - - if err := d.Set("disk_size_gb", clusterDescOld.GetDiskSizeGB()); err != nil { - return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "disk_size_gb", clusterName, err)) - } - clusterDescNew, _, err := connV2.ClustersApi.GetCluster(ctx, projectID, clusterName).Execute() - if err != nil { - return diag.FromErr(fmt.Errorf(errorRead, clusterName, err)) - } - if err := d.Set("replica_set_scaling_strategy", clusterDescNew.GetReplicaSetScalingStrategy()); err != nil { - return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "replica_set_scaling_strategy", clusterName, err)) - } - if err := d.Set("redact_client_log_data", clusterDescNew.GetRedactClientLogData()); err != nil { - return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "redact_client_log_data", clusterName, err)) + clusterDesc, resp, err := connV2.ClustersApi.GetCluster(ctx, projectID, clusterName).Execute() + if err != nil { + if resp != nil && resp.StatusCode == http.StatusNotFound { + return nil } - - zoneNameToZoneIDs, err := getZoneIDsFromNewAPI(clusterDescNew) - if err != nil { + return diag.FromErr(fmt.Errorf(errorRead, clusterName, err)) + } + zoneNameToOldReplicationSpecMeta, err := GetReplicationSpecAttributesFromOldAPI(ctx, projectID, clusterName, connV220240530.ClustersApi) + if err != nil { + if apiError, ok := admin20240530.AsError(err); !ok { return diag.FromErr(err) + } else if apiError.GetErrorCode() == "ASYMMETRIC_SHARD_UNSUPPORTED" && !useReplicationSpecPerShard { + return diag.FromErr(fmt.Errorf("please add `use_replication_spec_per_shard = true` to your data source configuration to enable asymmetric shard support. Refer to documentation for more details. %s", err)) + } else if apiError.GetErrorCode() != "ASYMMETRIC_SHARD_UNSUPPORTED" { + return diag.FromErr(fmt.Errorf(errorRead, clusterName, err)) } + } + diags := setRootFields(d, clusterDesc, false) + if diags.HasError() { + return diags + } - replicationSpecs, err = FlattenAdvancedReplicationSpecsOldSDK(ctx, clusterDescOld.GetReplicationSpecs(), zoneNameToZoneIDs, clusterDescOld.GetDiskSizeGB(), d.Get("replication_specs").([]any), d, connV2) + if !useReplicationSpecPerShard { + replicationSpecs, err = FlattenAdvancedReplicationSpecsOldShardingConfig(ctx, clusterDesc.GetReplicationSpecs(), zoneNameToOldReplicationSpecMeta, d.Get("replication_specs").([]any), d, connV2) if err != nil { return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "replication_specs", clusterName, err)) } - - clusterDesc := convertClusterDescToLatestExcludeRepSpecs(clusterDescOld) - clusterDesc.ConfigServerManagementMode = clusterDescNew.ConfigServerManagementMode - clusterDesc.ConfigServerType = clusterDescNew.ConfigServerType - diags := setRootFields(d, clusterDesc, false) - if diags.HasError() { - return diags - } } else { - clusterDescLatest, resp, err := connV2.ClustersApi.GetCluster(ctx, projectID, clusterName).Execute() - if err != nil { - if resp != nil && resp.StatusCode == http.StatusNotFound { - return nil - } - return diag.FromErr(fmt.Errorf(errorRead, clusterName, err)) - } - - clusterID = clusterDescLatest.GetId() - - // root disk_size_gb defined for backwards compatibility avoiding breaking changes - if err := d.Set("disk_size_gb", GetDiskSizeGBFromReplicationSpec(clusterDescLatest)); err != nil { - return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "disk_size_gb", clusterName, err)) - } - if err := d.Set("replica_set_scaling_strategy", clusterDescLatest.GetReplicaSetScalingStrategy()); err != nil { - return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "replica_set_scaling_strategy", clusterName, err)) - } - if err := d.Set("redact_client_log_data", clusterDescLatest.GetRedactClientLogData()); err != nil { - return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "redact_client_log_data", clusterName, err)) - } - - zoneNameToOldReplicationSpecIDs, err := getReplicationSpecIDsFromOldAPI(ctx, projectID, clusterName, connV220240530) - if err != nil { - return diag.FromErr(err) - } - - replicationSpecs, err = flattenAdvancedReplicationSpecsDS(ctx, clusterDescLatest.GetReplicationSpecs(), zoneNameToOldReplicationSpecIDs, d, connV2) + replicationSpecs, err = flattenAdvancedReplicationSpecsDS(ctx, clusterDesc.GetReplicationSpecs(), zoneNameToOldReplicationSpecMeta, d, connV2) if err != nil { return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "replication_specs", clusterName, err)) } - - diags := setRootFields(d, clusterDescLatest, false) - if diags.HasError() { - return diags - } } if err := d.Set("replication_specs", replicationSpecs); err != nil { @@ -380,6 +327,6 @@ func dataSourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag. return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "advanced_configuration", clusterName, err)) } - d.SetId(clusterID) + d.SetId(clusterDesc.GetId()) return nil } diff --git a/internal/service/advancedcluster/data_source_advanced_clusters.go b/internal/service/advancedcluster/data_source_advanced_clusters.go index edfc32c59a..9e456350f1 100644 --- a/internal/service/advancedcluster/data_source_advanced_clusters.go +++ b/internal/service/advancedcluster/data_source_advanced_clusters.go @@ -292,41 +292,25 @@ func dataSourcePluralRead(ctx context.Context, d *schema.ResourceData, meta any) useReplicationSpecPerShard = v.(bool) } - if !useReplicationSpecPerShard { - list, resp, err := connV220240530.ClustersApi.ListClusters(ctx, projectID).Execute() - if err != nil { - if resp != nil && resp.StatusCode == http.StatusNotFound { - return nil - } - return diag.FromErr(fmt.Errorf(errorListRead, projectID, err)) - } - results, diags := flattenAdvancedClustersOldSDK(ctx, connV220240530, connV2, list.GetResults(), d) - if len(diags) > 0 { - return diags - } - if err := d.Set("results", results); err != nil { - return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "results", d.Id(), err)) - } - } else { - list, resp, err := connV2.ClustersApi.ListClusters(ctx, projectID).Execute() - if err != nil { - if resp != nil && resp.StatusCode == http.StatusNotFound { - return nil - } - return diag.FromErr(fmt.Errorf(errorListRead, projectID, err)) - } - results, diags := flattenAdvancedClusters(ctx, connV220240530, connV2, list.GetResults(), d) - if len(diags) > 0 { - return diags - } - if err := d.Set("results", results); err != nil { - return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "results", d.Id(), err)) + list, resp, err := connV2.ClustersApi.ListClusters(ctx, projectID).Execute() + if err != nil { + if resp != nil && resp.StatusCode == http.StatusNotFound { + return nil } + return diag.FromErr(fmt.Errorf(errorListRead, projectID, err)) + } + results, diags := flattenAdvancedClusters(ctx, connV220240530, connV2, list.GetResults(), d, useReplicationSpecPerShard) + if len(diags) > 0 { + return diags } + if err := d.Set("results", results); err != nil { + return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "results", d.Id(), err)) + } + return nil } -func flattenAdvancedClusters(ctx context.Context, connV220240530 *admin20240530.APIClient, connV2 *admin.APIClient, clusters []admin.ClusterDescription20240805, d *schema.ResourceData) ([]map[string]any, diag.Diagnostics) { +func flattenAdvancedClusters(ctx context.Context, connV220240530 *admin20240530.APIClient, connV2 *admin.APIClient, clusters []admin.ClusterDescription20240805, d *schema.ResourceData, useReplicationSpecPerShard bool) ([]map[string]any, diag.Diagnostics) { results := make([]map[string]any, 0, len(clusters)) for i := range clusters { cluster := &clusters[i] @@ -339,14 +323,29 @@ func flattenAdvancedClusters(ctx context.Context, connV220240530 *admin20240530. log.Printf("[WARN] Error setting `advanced_configuration` for the cluster(%s): %s", cluster.GetId(), err) } - zoneNameToOldReplicationSpecIDs, err := getReplicationSpecIDsFromOldAPI(ctx, cluster.GetGroupId(), cluster.GetName(), connV220240530) + zoneNameToOldReplicationSpecMeta, err := GetReplicationSpecAttributesFromOldAPI(ctx, cluster.GetGroupId(), cluster.GetName(), connV220240530.ClustersApi) if err != nil { - return nil, diag.FromErr(err) + if apiError, ok := admin20240530.AsError(err); !ok { + return nil, diag.FromErr(err) + } else if apiError.GetErrorCode() == "ASYMMETRIC_SHARD_UNSUPPORTED" && !useReplicationSpecPerShard { + continue + } else if apiError.GetErrorCode() != "ASYMMETRIC_SHARD_UNSUPPORTED" { + return nil, diag.FromErr(err) + } } - replicationSpecs, err := flattenAdvancedReplicationSpecsDS(ctx, cluster.GetReplicationSpecs(), zoneNameToOldReplicationSpecIDs, d, connV2) - if err != nil { - log.Printf("[WARN] Error setting `replication_specs` for the cluster(%s): %s", cluster.GetId(), err) + var replicationSpecs []map[string]any + + if !useReplicationSpecPerShard { + replicationSpecs, err = FlattenAdvancedReplicationSpecsOldShardingConfig(ctx, cluster.GetReplicationSpecs(), zoneNameToOldReplicationSpecMeta, nil, d, connV2) + if err != nil { + log.Printf("[WARN] Error setting `replication_specs` for the cluster(%s): %s", cluster.GetId(), err) + } + } else { + replicationSpecs, err = flattenAdvancedReplicationSpecsDS(ctx, cluster.GetReplicationSpecs(), zoneNameToOldReplicationSpecMeta, d, connV2) + if err != nil { + log.Printf("[WARN] Error setting `replication_specs` for the cluster(%s): %s", cluster.GetId(), err) + } } result := map[string]any{ @@ -380,62 +379,3 @@ func flattenAdvancedClusters(ctx context.Context, connV220240530 *admin20240530. } return results, nil } - -func flattenAdvancedClustersOldSDK(ctx context.Context, connV20240530 *admin20240530.APIClient, connV2 *admin.APIClient, clusters []admin20240530.AdvancedClusterDescription, d *schema.ResourceData) ([]map[string]any, diag.Diagnostics) { - results := make([]map[string]any, 0, len(clusters)) - for i := range clusters { - cluster := &clusters[i] - processArgs20240530, _, err := connV20240530.ClustersApi.GetClusterAdvancedConfiguration(ctx, cluster.GetGroupId(), cluster.GetName()).Execute() - if err != nil { - log.Printf("[WARN] Error setting `advanced_configuration` for the cluster(%s): %s", cluster.GetId(), err) - } - processArgs, _, err := connV2.ClustersApi.GetClusterAdvancedConfiguration(ctx, cluster.GetGroupId(), cluster.GetName()).Execute() - if err != nil { - log.Printf("[WARN] Error setting `advanced_configuration` for the cluster(%s): %s", cluster.GetId(), err) - } - - clusterDescNew, _, err := connV2.ClustersApi.GetCluster(ctx, cluster.GetGroupId(), cluster.GetName()).Execute() - if err != nil { - return nil, diag.FromErr(err) - } - zoneNameToZoneIDs, err := getZoneIDsFromNewAPI(clusterDescNew) - if err != nil { - return nil, diag.FromErr(err) - } - - replicationSpecs, err := FlattenAdvancedReplicationSpecsOldSDK(ctx, cluster.GetReplicationSpecs(), zoneNameToZoneIDs, cluster.GetDiskSizeGB(), nil, d, connV2) - if err != nil { - log.Printf("[WARN] Error setting `replication_specs` for the cluster(%s): %s", cluster.GetId(), err) - } - - result := map[string]any{ - "advanced_configuration": flattenProcessArgs(processArgs20240530, processArgs), - "backup_enabled": cluster.GetBackupEnabled(), - "bi_connector_config": flattenBiConnectorConfig(convertBiConnectToLatest(cluster.BiConnector)), - "cluster_type": cluster.GetClusterType(), - "create_date": conversion.TimePtrToStringPtr(cluster.CreateDate), - "connection_strings": flattenConnectionStrings(*convertConnectionStringToLatest(cluster.ConnectionStrings)), - "disk_size_gb": cluster.GetDiskSizeGB(), - "encryption_at_rest_provider": cluster.GetEncryptionAtRestProvider(), - "labels": flattenLabels(*convertLabelsToLatest(cluster.Labels)), - "tags": conversion.FlattenTags(convertTagsToLatest(cluster.GetTags())), - "mongo_db_major_version": cluster.GetMongoDBMajorVersion(), - "mongo_db_version": cluster.GetMongoDBVersion(), - "name": cluster.GetName(), - "paused": cluster.GetPaused(), - "pit_enabled": cluster.GetPitEnabled(), - "replication_specs": replicationSpecs, - "root_cert_type": cluster.GetRootCertType(), - "state_name": cluster.GetStateName(), - "termination_protection_enabled": cluster.GetTerminationProtectionEnabled(), - "version_release_system": cluster.GetVersionReleaseSystem(), - "global_cluster_self_managed_sharding": cluster.GetGlobalClusterSelfManagedSharding(), - "replica_set_scaling_strategy": clusterDescNew.GetReplicaSetScalingStrategy(), - "redact_client_log_data": clusterDescNew.GetRedactClientLogData(), - "config_server_management_mode": clusterDescNew.GetConfigServerManagementMode(), - "config_server_type": clusterDescNew.GetConfigServerType(), - } - results = append(results, result) - } - return results, nil -} diff --git a/internal/service/advancedcluster/model_advanced_cluster.go b/internal/service/advancedcluster/model_advanced_cluster.go index 0e759eafcf..744c889be0 100644 --- a/internal/service/advancedcluster/model_advanced_cluster.go +++ b/internal/service/advancedcluster/model_advanced_cluster.go @@ -519,34 +519,23 @@ func flattenProcessArgs(p20240530 *admin20240530.ClusterDescriptionProcessArgs, return flattenedProcessArgs } -// This function is untilised by DS read which still uses the old API and will be removed when refactor to DS read operation is implemented. -func FlattenAdvancedReplicationSpecsOldSDK(ctx context.Context, apiObjects []admin20240530.ReplicationSpec, zoneNameToZoneIDs map[string]string, rootDiskSizeGB float64, tfMapObjects []any, - d *schema.ResourceData, connV2 *admin.APIClient) ([]map[string]any, error) { - // for flattening old model we need information of value defined at root disk_size_gb so we set the value in new location under hardware specs - replicationSpecFlattener := func(ctx context.Context, sdkModel *admin20240530.ReplicationSpec, tfModel map[string]any, resourceData *schema.ResourceData, client *admin.APIClient) (map[string]any, error) { - return flattenAdvancedReplicationSpecOldSDK(ctx, sdkModel, zoneNameToZoneIDs, rootDiskSizeGB, tfModel, resourceData, connV2) - } - return flattenAdvancedReplicationSpecsLogic[admin20240530.ReplicationSpec](ctx, apiObjects, tfMapObjects, d, - doesAdvancedReplicationSpecMatchAPIOldSDK, replicationSpecFlattener, connV2) -} - func FlattenAdvancedReplicationSpecsOldShardingConfig(ctx context.Context, apiObjects []admin.ReplicationSpec20240805, zoneNameToOldReplicationSpecMeta map[string]OldShardConfigMeta, tfMapObjects []any, d *schema.ResourceData, connV2 *admin.APIClient) ([]map[string]any, error) { replicationSpecFlattener := func(ctx context.Context, sdkModel *admin.ReplicationSpec20240805, tfModel map[string]any, resourceData *schema.ResourceData, client *admin.APIClient) (map[string]any, error) { return flattenAdvancedReplicationSpecOldShardingConfig(ctx, sdkModel, zoneNameToOldReplicationSpecMeta, tfModel, resourceData, connV2) } compressedAPIObjects := compressAPIObjectList(apiObjects) - return flattenAdvancedReplicationSpecsLogic[admin.ReplicationSpec20240805](ctx, compressedAPIObjects, tfMapObjects, d, + return flattenAdvancedReplicationSpecsLogic(ctx, compressedAPIObjects, tfMapObjects, d, doesAdvancedReplicationSpecMatchAPIOldShardConfig, replicationSpecFlattener, connV2) } -func flattenAdvancedReplicationSpecs(ctx context.Context, apiObjects []admin.ReplicationSpec20240805, zoneNameToOldReplicationSpecIDs map[string]string, tfMapObjects []any, +func flattenAdvancedReplicationSpecs(ctx context.Context, apiObjects []admin.ReplicationSpec20240805, zoneNameToOldReplicationSpecMeta map[string]OldShardConfigMeta, tfMapObjects []any, d *schema.ResourceData, connV2 *admin.APIClient) ([]map[string]any, error) { // for flattening new model we need information of replication spec ids associated to old API to avoid breaking changes for users referencing replication_specs.*.id replicationSpecFlattener := func(ctx context.Context, sdkModel *admin.ReplicationSpec20240805, tfModel map[string]any, resourceData *schema.ResourceData, client *admin.APIClient) (map[string]any, error) { - return flattenAdvancedReplicationSpec(ctx, sdkModel, zoneNameToOldReplicationSpecIDs, tfModel, resourceData, connV2) + return flattenAdvancedReplicationSpec(ctx, sdkModel, zoneNameToOldReplicationSpecMeta, tfModel, resourceData, connV2) } - return flattenAdvancedReplicationSpecsLogic[admin.ReplicationSpec20240805](ctx, apiObjects, tfMapObjects, d, + return flattenAdvancedReplicationSpecsLogic(ctx, apiObjects, tfMapObjects, d, doesAdvancedReplicationSpecMatchAPI, replicationSpecFlattener, connV2) } @@ -638,11 +627,6 @@ func flattenAdvancedReplicationSpecsLogic[T ReplicationSpecSDKModel]( return tfList, nil } -// This function is untilised by DS read which still uses the old API and will be removed when refactor to DS read operation is implemented. -func doesAdvancedReplicationSpecMatchAPIOldSDK(tfObject map[string]any, apiObject *admin20240530.ReplicationSpec) bool { - return tfObject["id"] == apiObject.GetId() || (tfObject["id"] == nil && tfObject["zone_name"] == apiObject.GetZoneName()) -} - func doesAdvancedReplicationSpecMatchAPIOldShardConfig(tfObject map[string]any, apiObject *admin.ReplicationSpec20240805) bool { return tfObject["zone_name"] == apiObject.GetZoneName() } @@ -1101,7 +1085,7 @@ func expandRegionConfigAutoScaling(tfList []any) *admin.AdvancedAutoScalingSetti return &settings } -func flattenAdvancedReplicationSpecsDS(ctx context.Context, apiRepSpecs []admin.ReplicationSpec20240805, zoneNameToOldReplicationSpecIDs map[string]string, d *schema.ResourceData, connV2 *admin.APIClient) ([]map[string]any, error) { +func flattenAdvancedReplicationSpecsDS(ctx context.Context, apiRepSpecs []admin.ReplicationSpec20240805, zoneNameToOldReplicationSpecMeta map[string]OldShardConfigMeta, d *schema.ResourceData, connV2 *admin.APIClient) ([]map[string]any, error) { if len(apiRepSpecs) == 0 { return nil, nil } @@ -1109,7 +1093,7 @@ func flattenAdvancedReplicationSpecsDS(ctx context.Context, apiRepSpecs []admin. tfList := make([]map[string]any, len(apiRepSpecs)) for i, apiRepSpec := range apiRepSpecs { - tfReplicationSpec, err := flattenAdvancedReplicationSpec(ctx, &apiRepSpec, zoneNameToOldReplicationSpecIDs, nil, d, connV2) + tfReplicationSpec, err := flattenAdvancedReplicationSpec(ctx, &apiRepSpec, zoneNameToOldReplicationSpecMeta, nil, d, connV2) if err != nil { return nil, err } @@ -1118,7 +1102,7 @@ func flattenAdvancedReplicationSpecsDS(ctx context.Context, apiRepSpecs []admin. return tfList, nil } -func flattenAdvancedReplicationSpec(ctx context.Context, apiObject *admin.ReplicationSpec20240805, zoneNameToOldReplicationSpecIDs map[string]string, tfMapObject map[string]any, +func flattenAdvancedReplicationSpec(ctx context.Context, apiObject *admin.ReplicationSpec20240805, zoneNameToOldReplicationSpecMeta map[string]OldShardConfigMeta, tfMapObject map[string]any, d *schema.ResourceData, connV2 *admin.APIClient) (map[string]any, error) { if apiObject == nil { return nil, nil @@ -1127,8 +1111,8 @@ func flattenAdvancedReplicationSpec(ctx context.Context, apiObject *admin.Replic tfMap := map[string]any{} tfMap["external_id"] = apiObject.GetId() - if oldID, ok := zoneNameToOldReplicationSpecIDs[apiObject.GetZoneName()]; ok { - tfMap["id"] = oldID // replicationSpecs.*.id stores value associated to old cluster API (2023-02-01) + if oldShardConfig, ok := zoneNameToOldReplicationSpecMeta[apiObject.GetZoneName()]; ok { + tfMap["id"] = oldShardConfig.ID // replicationSpecs.*.id stores value associated to old cluster API (2023-02-01) } // define num_shards for backwards compatibility as this attribute has default value of 1. @@ -1155,39 +1139,6 @@ func flattenAdvancedReplicationSpec(ctx context.Context, apiObject *admin.Replic return tfMap, nil } -// This function is untilised by DS read which still uses the old API and will be removed when refactor to DS read operation is implemented. -func flattenAdvancedReplicationSpecOldSDK(ctx context.Context, apiObject *admin20240530.ReplicationSpec, zoneNameToZoneIDs map[string]string, rootDiskSizeGB float64, tfMapObject map[string]any, - d *schema.ResourceData, connV2 *admin.APIClient) (map[string]any, error) { - if apiObject == nil { - return nil, nil - } - - tfMap := map[string]any{} - tfMap["num_shards"] = apiObject.GetNumShards() - tfMap["id"] = apiObject.GetId() - if tfMapObject != nil { - object, containerIDs, err := flattenAdvancedReplicationSpecRegionConfigs(ctx, *convertRegionConfigSliceToLatest(apiObject.RegionConfigs, rootDiskSizeGB), tfMapObject["region_configs"].([]any), d, connV2) - if err != nil { - return nil, err - } - tfMap["region_configs"] = object - tfMap["container_id"] = containerIDs - } else { - object, containerIDs, err := flattenAdvancedReplicationSpecRegionConfigs(ctx, *convertRegionConfigSliceToLatest(apiObject.RegionConfigs, rootDiskSizeGB), nil, d, connV2) - if err != nil { - return nil, err - } - tfMap["region_configs"] = object - tfMap["container_id"] = containerIDs - } - tfMap["zone_name"] = apiObject.GetZoneName() - if zoneID, ok := zoneNameToZoneIDs[apiObject.GetZoneName()]; ok { // zone id is not present on old API SDK, so we fetch values from new API and map them using zone name - tfMap["zone_id"] = zoneID - } - - return tfMap, nil -} - func flattenAdvancedReplicationSpecOldShardingConfig(ctx context.Context, apiObject *admin.ReplicationSpec20240805, zoneNameToOldShardConfigMeta map[string]OldShardConfigMeta, tfMapObject map[string]any, d *schema.ResourceData, connV2 *admin.APIClient) (map[string]any, error) { if apiObject == nil { diff --git a/internal/service/advancedcluster/model_advanced_cluster_test.go b/internal/service/advancedcluster/model_advanced_cluster_test.go index 1a9cb6a12d..92835f6df9 100644 --- a/internal/service/advancedcluster/model_advanced_cluster_test.go +++ b/internal/service/advancedcluster/model_advanced_cluster_test.go @@ -27,128 +27,6 @@ var ( advancedClusters = []admin.ClusterDescription20240805{{StateName: conversion.StringPtr("NOT IDLE")}} ) -func TestFlattenReplicationSpecs(t *testing.T) { - var ( - regionName = "EU_WEST_1" - providerName = "AWS" - expectedID = "id1" - unexpectedID = "id2" - expectedZoneName = "z1" - unexpectedZoneName = "z2" - regionConfigAdmin = []admin20240530.CloudRegionConfig{{ - ProviderName: &providerName, - RegionName: ®ionName, - }} - regionConfigTfSameZone = map[string]any{ - "provider_name": "AWS", - "region_name": regionName, - } - regionConfigTfDiffZone = map[string]any{ - "provider_name": "AWS", - "region_name": regionName, - "zone_name": unexpectedZoneName, - } - apiSpecExpected = admin20240530.ReplicationSpec{Id: &expectedID, ZoneName: &expectedZoneName, RegionConfigs: ®ionConfigAdmin} - apiSpecDifferent = admin20240530.ReplicationSpec{Id: &unexpectedID, ZoneName: &unexpectedZoneName, RegionConfigs: ®ionConfigAdmin} - testSchema = map[string]*schema.Schema{ - "project_id": {Type: schema.TypeString}, - } - tfSameIDSameZone = map[string]any{ - "id": expectedID, - "num_shards": 1, - "region_configs": []any{regionConfigTfSameZone}, - "zone_name": expectedZoneName, - } - tfNoIDSameZone = map[string]any{ - "id": nil, - "num_shards": 1, - "region_configs": []any{regionConfigTfSameZone}, - "zone_name": expectedZoneName, - } - tfNoIDDiffZone = map[string]any{ - "id": nil, - "num_shards": 1, - "region_configs": []any{regionConfigTfDiffZone}, - "zone_name": unexpectedZoneName, - } - tfdiffIDDiffZone = map[string]any{ - "id": "unique", - "num_shards": 1, - "region_configs": []any{regionConfigTfDiffZone}, - "zone_name": unexpectedZoneName, - } - ) - testCases := map[string]struct { - adminSpecs []admin20240530.ReplicationSpec - tfInputSpecs []any - expectedLen int - }{ - "empty admin spec should return empty list": { - []admin20240530.ReplicationSpec{}, - []any{tfSameIDSameZone}, - 0, - }, - "existing id, should match admin": { - []admin20240530.ReplicationSpec{apiSpecExpected}, - []any{tfSameIDSameZone}, - 1, - }, - "existing different id, should change to admin spec": { - []admin20240530.ReplicationSpec{apiSpecExpected}, - []any{tfdiffIDDiffZone}, - 1, - }, - "missing id, should be set when zone_name matches": { - []admin20240530.ReplicationSpec{apiSpecExpected}, - []any{tfNoIDSameZone}, - 1, - }, - "missing id and diff zone, should change to admin spec": { - []admin20240530.ReplicationSpec{apiSpecExpected}, - []any{tfNoIDDiffZone}, - 1, - }, - "existing id, should match correct api spec using `id` and extra api spec added": { - []admin20240530.ReplicationSpec{apiSpecDifferent, apiSpecExpected}, - []any{tfSameIDSameZone}, - 2, - }, - "missing id, should match correct api spec using `zone_name` and extra api spec added": { - []admin20240530.ReplicationSpec{apiSpecDifferent, apiSpecExpected}, - []any{tfNoIDSameZone}, - 2, - }, - "two matching specs should be set to api specs": { - []admin20240530.ReplicationSpec{apiSpecExpected, apiSpecDifferent}, - []any{tfSameIDSameZone, tfdiffIDDiffZone}, - 2, - }, - } - for name, tc := range testCases { - t.Run(name, func(t *testing.T) { - peeringAPI := mockadmin.NetworkPeeringApi{} - - peeringAPI.EXPECT().ListPeeringContainerByCloudProviderWithParams(mock.Anything, mock.Anything).Return(admin.ListPeeringContainerByCloudProviderApiRequest{ApiService: &peeringAPI}) - containerResult := []admin.CloudProviderContainer{{Id: conversion.StringPtr("c1"), RegionName: ®ionName, ProviderName: &providerName}} - peeringAPI.EXPECT().ListPeeringContainerByCloudProviderExecute(mock.Anything).Return(&admin.PaginatedCloudProviderContainer{Results: &containerResult}, nil, nil) - - client := &admin.APIClient{ - NetworkPeeringApi: &peeringAPI, - } - resourceData := schema.TestResourceDataRaw(t, testSchema, map[string]any{"project_id": "p1"}) - - tfOutputSpecs, err := advancedcluster.FlattenAdvancedReplicationSpecsOldSDK(context.Background(), tc.adminSpecs, nil, 0, tc.tfInputSpecs, resourceData, client) - - require.NoError(t, err) - assert.Len(t, tfOutputSpecs, tc.expectedLen) - if tc.expectedLen != 0 { - assert.Equal(t, expectedID, tfOutputSpecs[0]["id"]) - assert.Equal(t, expectedZoneName, tfOutputSpecs[0]["zone_name"]) - } - }) - } -} - func TestFlattenAdvancedReplicationSpecsOldShardingConfig(t *testing.T) { var ( regionName = "EU_WEST_1" diff --git a/internal/service/advancedcluster/model_sdk_version_conversion.go b/internal/service/advancedcluster/model_sdk_version_conversion.go index 151b6c2a40..7628a71bad 100644 --- a/internal/service/advancedcluster/model_sdk_version_conversion.go +++ b/internal/service/advancedcluster/model_sdk_version_conversion.go @@ -12,14 +12,6 @@ import ( // - These functions must not contain any business logic. // - All will be removed once we rely on a single API version. -func convertTagsPtrToLatest(tags *[]admin20240530.ResourceTag) *[]admin.ResourceTag { - if tags == nil { - return nil - } - result := convertTagsToLatest(*tags) - return &result -} - func convertTagsPtrToOldSDK(tags *[]admin.ResourceTag) *[]admin20240530.ResourceTag { if tags == nil { return nil @@ -36,18 +28,6 @@ func convertTagsPtrToOldSDK(tags *[]admin.ResourceTag) *[]admin20240530.Resource return &results } -func convertTagsToLatest(tags []admin20240530.ResourceTag) []admin.ResourceTag { - results := make([]admin.ResourceTag, len(tags)) - for i := range len(tags) { - tag := tags[i] - results[i] = admin.ResourceTag{ - Key: tag.Key, - Value: tag.Value, - } - } - return results -} - func convertBiConnectToOldSDK(biconnector *admin.BiConnector) *admin20240530.BiConnector { if biconnector == nil { return nil @@ -58,74 +38,6 @@ func convertBiConnectToOldSDK(biconnector *admin.BiConnector) *admin20240530.BiC } } -func convertBiConnectToLatest(biconnector *admin20240530.BiConnector) *admin.BiConnector { - return &admin.BiConnector{ - Enabled: biconnector.Enabled, - ReadPreference: biconnector.ReadPreference, - } -} - -func convertConnectionStringToLatest(connStrings *admin20240530.ClusterConnectionStrings) *admin.ClusterConnectionStrings { - return &admin.ClusterConnectionStrings{ - AwsPrivateLink: connStrings.AwsPrivateLink, - AwsPrivateLinkSrv: connStrings.AwsPrivateLinkSrv, - Private: connStrings.Private, - PrivateEndpoint: convertPrivateEndpointToLatest(connStrings.PrivateEndpoint), - PrivateSrv: connStrings.PrivateSrv, - Standard: connStrings.Standard, - StandardSrv: connStrings.StandardSrv, - } -} - -func convertPrivateEndpointToLatest(privateEndpoints *[]admin20240530.ClusterDescriptionConnectionStringsPrivateEndpoint) *[]admin.ClusterDescriptionConnectionStringsPrivateEndpoint { - if privateEndpoints == nil { - return nil - } - peSlice := *privateEndpoints - results := make([]admin.ClusterDescriptionConnectionStringsPrivateEndpoint, len(peSlice)) - for i := range len(peSlice) { - pe := peSlice[i] - results[i] = admin.ClusterDescriptionConnectionStringsPrivateEndpoint{ - ConnectionString: pe.ConnectionString, - Endpoints: convertEndpointsToLatest(pe.Endpoints), - SrvConnectionString: pe.SrvConnectionString, - SrvShardOptimizedConnectionString: pe.SrvShardOptimizedConnectionString, - Type: pe.Type, - } - } - return &results -} - -func convertEndpointsToLatest(privateEndpoints *[]admin20240530.ClusterDescriptionConnectionStringsPrivateEndpointEndpoint) *[]admin.ClusterDescriptionConnectionStringsPrivateEndpointEndpoint { - if privateEndpoints == nil { - return nil - } - peSlice := *privateEndpoints - results := make([]admin.ClusterDescriptionConnectionStringsPrivateEndpointEndpoint, len(peSlice)) - for i := range len(peSlice) { - pe := peSlice[i] - results[i] = admin.ClusterDescriptionConnectionStringsPrivateEndpointEndpoint{ - EndpointId: pe.EndpointId, - ProviderName: pe.ProviderName, - Region: pe.Region, - } - } - return &results -} - -func convertLabelsToLatest(labels *[]admin20240530.ComponentLabel) *[]admin.ComponentLabel { - labelSlice := *labels - results := make([]admin.ComponentLabel, len(labelSlice)) - for i := range len(labelSlice) { - label := labelSlice[i] - results[i] = admin.ComponentLabel{ - Key: label.Key, - Value: label.Value, - } - } - return &results -} - func convertLabelSliceToOldSDK(slice []admin.ComponentLabel, err diag.Diagnostics) ([]admin20240530.ComponentLabel, diag.Diagnostics) { if err != nil { return nil, err @@ -219,113 +131,6 @@ func convertDedicatedHardwareSpecToOldSDK(spec *admin.DedicatedHardwareSpec20240 } } -func convertDedicatedHwSpecToLatest(spec *admin20240530.DedicatedHardwareSpec, rootDiskSizeGB float64) *admin.DedicatedHardwareSpec20240805 { - if spec == nil { - return nil - } - return &admin.DedicatedHardwareSpec20240805{ - NodeCount: spec.NodeCount, - DiskIOPS: spec.DiskIOPS, - EbsVolumeType: spec.EbsVolumeType, - InstanceSize: spec.InstanceSize, - DiskSizeGB: &rootDiskSizeGB, - } -} - -func convertAdvancedAutoScalingSettingsToLatest(settings *admin20240530.AdvancedAutoScalingSettings) *admin.AdvancedAutoScalingSettings { - if settings == nil { - return nil - } - return &admin.AdvancedAutoScalingSettings{ - Compute: convertAdvancedComputeAutoScalingToLatest(settings.Compute), - DiskGB: convertDiskGBAutoScalingToLatest(settings.DiskGB), - } -} - -func convertAdvancedComputeAutoScalingToLatest(settings *admin20240530.AdvancedComputeAutoScaling) *admin.AdvancedComputeAutoScaling { - if settings == nil { - return nil - } - return &admin.AdvancedComputeAutoScaling{ - Enabled: settings.Enabled, - MaxInstanceSize: settings.MaxInstanceSize, - MinInstanceSize: settings.MinInstanceSize, - ScaleDownEnabled: settings.ScaleDownEnabled, - } -} - -func convertDiskGBAutoScalingToLatest(settings *admin20240530.DiskGBAutoScaling) *admin.DiskGBAutoScaling { - if settings == nil { - return nil - } - return &admin.DiskGBAutoScaling{ - Enabled: settings.Enabled, - } -} - -func convertHardwareSpecToLatest(hwspec *admin20240530.HardwareSpec, rootDiskSizeGB float64) *admin.HardwareSpec20240805 { - if hwspec == nil { - return nil - } - return &admin.HardwareSpec20240805{ - DiskIOPS: hwspec.DiskIOPS, - EbsVolumeType: hwspec.EbsVolumeType, - InstanceSize: hwspec.InstanceSize, - NodeCount: hwspec.NodeCount, - DiskSizeGB: &rootDiskSizeGB, - } -} - -func convertRegionConfigSliceToLatest(slice *[]admin20240530.CloudRegionConfig, rootDiskSizeGB float64) *[]admin.CloudRegionConfig20240805 { - if slice == nil { - return nil - } - cloudRegionSlice := *slice - results := make([]admin.CloudRegionConfig20240805, len(cloudRegionSlice)) - for i := range len(cloudRegionSlice) { - cloudRegion := cloudRegionSlice[i] - results[i] = admin.CloudRegionConfig20240805{ - ElectableSpecs: convertHardwareSpecToLatest(cloudRegion.ElectableSpecs, rootDiskSizeGB), - Priority: cloudRegion.Priority, - ProviderName: cloudRegion.ProviderName, - RegionName: cloudRegion.RegionName, - AnalyticsAutoScaling: convertAdvancedAutoScalingSettingsToLatest(cloudRegion.AnalyticsAutoScaling), - AnalyticsSpecs: convertDedicatedHwSpecToLatest(cloudRegion.AnalyticsSpecs, rootDiskSizeGB), - AutoScaling: convertAdvancedAutoScalingSettingsToLatest(cloudRegion.AutoScaling), - ReadOnlySpecs: convertDedicatedHwSpecToLatest(cloudRegion.ReadOnlySpecs, rootDiskSizeGB), - BackingProviderName: cloudRegion.BackingProviderName, - } - } - return &results -} - -func convertClusterDescToLatestExcludeRepSpecs(oldClusterDesc *admin20240530.AdvancedClusterDescription) *admin.ClusterDescription20240805 { - return &admin.ClusterDescription20240805{ - BackupEnabled: oldClusterDesc.BackupEnabled, - AcceptDataRisksAndForceReplicaSetReconfig: oldClusterDesc.AcceptDataRisksAndForceReplicaSetReconfig, - ClusterType: oldClusterDesc.ClusterType, - CreateDate: oldClusterDesc.CreateDate, - DiskWarmingMode: oldClusterDesc.DiskWarmingMode, - EncryptionAtRestProvider: oldClusterDesc.EncryptionAtRestProvider, - GlobalClusterSelfManagedSharding: oldClusterDesc.GlobalClusterSelfManagedSharding, - GroupId: oldClusterDesc.GroupId, - Id: oldClusterDesc.Id, - MongoDBMajorVersion: oldClusterDesc.MongoDBMajorVersion, - MongoDBVersion: oldClusterDesc.MongoDBVersion, - Name: oldClusterDesc.Name, - Paused: oldClusterDesc.Paused, - PitEnabled: oldClusterDesc.PitEnabled, - RootCertType: oldClusterDesc.RootCertType, - StateName: oldClusterDesc.StateName, - TerminationProtectionEnabled: oldClusterDesc.TerminationProtectionEnabled, - VersionReleaseSystem: oldClusterDesc.VersionReleaseSystem, - Tags: convertTagsPtrToLatest(oldClusterDesc.Tags), - BiConnector: convertBiConnectToLatest(oldClusterDesc.BiConnector), - ConnectionStrings: convertConnectionStringToLatest(oldClusterDesc.ConnectionStrings), - Labels: convertLabelsToLatest(oldClusterDesc.Labels), - } -} - func ConvertClusterDescription20241023to20240805(clusterDescription *admin.ClusterDescription20240805) *admin20240805.ClusterDescription20240805 { return &admin20240805.ClusterDescription20240805{ Name: clusterDescription.Name, diff --git a/internal/service/advancedcluster/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index 965f0f4329..720bd9cd3b 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -576,21 +576,21 @@ func resourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Di return diag.FromErr(fmt.Errorf(errorRead, clusterName, err)) } - if isUsingOldShardingConfiguration(d) { - zoneNameToOldReplicationSpecMeta, err := GetReplicationSpecAttributesFromOldAPI(ctx, projectID, clusterName, connV220240530.ClustersApi) - if err != nil { + zoneNameToOldReplicationSpecMeta, err := GetReplicationSpecAttributesFromOldAPI(ctx, projectID, clusterName, connV220240530.ClustersApi) + if err != nil { + if apiError, ok := admin20240530.AsError(err); !ok { return diag.FromErr(err) + } else if apiError.GetErrorCode() != "ASYMMETRIC_SHARD_UNSUPPORTED" || (apiError.GetErrorCode() == "ASYMMETRIC_SHARD_UNSUPPORTED" && isUsingOldShardingConfiguration(d)) { + return diag.FromErr(fmt.Errorf(errorRead, clusterName, err)) } + } + if isUsingOldShardingConfiguration(d) { replicationSpecs, err = FlattenAdvancedReplicationSpecsOldShardingConfig(ctx, cluster.GetReplicationSpecs(), zoneNameToOldReplicationSpecMeta, d.Get("replication_specs").([]any), d, connV2) if err != nil { return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "replication_specs", clusterName, err)) } } else { - zoneNameToOldReplicationSpecID, err := getReplicationSpecIDsFromOldAPI(ctx, projectID, clusterName, connV220240530) - if err != nil { - return diag.FromErr(err) - } - replicationSpecs, err = flattenAdvancedReplicationSpecs(ctx, cluster.GetReplicationSpecs(), zoneNameToOldReplicationSpecID, d.Get("replication_specs").([]any), d, connV2) + replicationSpecs, err = flattenAdvancedReplicationSpecs(ctx, cluster.GetReplicationSpecs(), zoneNameToOldReplicationSpecMeta, d.Get("replication_specs").([]any), d, connV2) if err != nil { return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "replication_specs", clusterName, err)) } @@ -625,8 +625,7 @@ func resourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Di func GetReplicationSpecAttributesFromOldAPI(ctx context.Context, projectID, clusterName string, client20240530 admin20240530.ClustersApi) (map[string]OldShardConfigMeta, error) { clusterOldAPI, _, err := client20240530.GetCluster(ctx, projectID, clusterName).Execute() if err != nil { - readErrorMsg := "error reading advanced cluster with 2023-02-01 API (%s): %s" - return nil, fmt.Errorf(readErrorMsg, clusterName, err) + return nil, err } specs := clusterOldAPI.GetReplicationSpecs() result := make(map[string]OldShardConfigMeta, len(specs)) @@ -636,35 +635,6 @@ func GetReplicationSpecAttributesFromOldAPI(ctx context.Context, projectID, clus return result, nil } -// getReplicationSpecIDsFromOldAPI returns the id values of replication specs coming from old API. This is used to populate old replication_specs.*.id attribute avoiding breaking changes. -// In the old API each replications spec has a 1:1 relation with each zone, so ids are returned in a map from zoneName to id. -func getReplicationSpecIDsFromOldAPI(ctx context.Context, projectID, clusterName string, connV220240530 *admin20240530.APIClient) (map[string]string, error) { - clusterOldAPI, _, err := connV220240530.ClustersApi.GetCluster(ctx, projectID, clusterName).Execute() - if apiError, ok := admin20240530.AsError(err); ok { - if apiError.GetErrorCode() == "ASYMMETRIC_SHARD_UNSUPPORTED" { - return nil, nil // If it is the case of an asymmetric shard, an error is expected in old API and replication_specs.*.id attribute will not be populated. - } - readErrorMsg := "error reading advanced cluster with 2023-02-01 API (%s): %s" - return nil, fmt.Errorf(readErrorMsg, clusterName, err) - } - specs := clusterOldAPI.GetReplicationSpecs() - result := make(map[string]string, len(specs)) - for _, spec := range specs { - result[spec.GetZoneName()] = spec.GetId() - } - return result, nil -} - -// getZoneIDsFromNewAPI returns the zone id values of replication specs coming from new API. This is used to populate zone_id when old API is called in DS read. -func getZoneIDsFromNewAPI(cluster *admin.ClusterDescription20240805) (map[string]string, error) { - specs := cluster.GetReplicationSpecs() - result := make(map[string]string, len(specs)) - for _, spec := range specs { - result[spec.GetZoneName()] = spec.GetZoneId() - } - return result, nil -} - func setRootFields(d *schema.ResourceData, cluster *admin.ClusterDescription20240805, isResourceSchema bool) diag.Diagnostics { clusterName := *cluster.Name diff --git a/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go b/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go index 5fd9989952..82933fbef7 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go @@ -40,6 +40,7 @@ func TestMigAdvancedCluster_symmetricGeoShardedOldSchema(t *testing.T) { func TestMigAdvancedCluster_asymmetricShardedNewSchema(t *testing.T) { acc.SkipIfTPFAdvancedCluster(t) + mig.SkipIfVersionBelow(t, "1.23.0") // version where sharded cluster tier auto-scaling was introduced testCase := asymmetricShardedNewSchemaTestCase(t) mig.CreateAndRunTest(t, &testCase) } diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index a84e7a5f5d..244dab7f2b 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -2,7 +2,6 @@ package advancedcluster_test import ( "context" - "errors" "fmt" "net/http" "os" @@ -55,7 +54,7 @@ func TestGetReplicationSpecAttributesFromOldAPI(t *testing.T) { mockCluster: &admin20240530.AdvancedClusterDescription{}, mockResponse: &http.Response{StatusCode: 400}, mockError: errGeneric, - expectedError: errors.New("error reading advanced cluster with 2023-02-01 API (testCluster): generic"), + expectedError: errGeneric, expectedResult: nil, }, "Successful": { @@ -726,6 +725,7 @@ func asymmetricShardedNewSchemaTestCase(t *testing.T) resource.TestCase { Config: configShardedNewSchema(orgID, projectName, clusterName, 50, "M30", "M40", admin.PtrInt(2000), admin.PtrInt(2500), false), Check: resource.ComposeAggregateTestCheckFunc( checkShardedNewSchema(50, "M30", "M40", admin.PtrInt(2000), admin.PtrInt(2500), true, false), + resource.TestCheckResourceAttr("data.mongodbatlas_advanced_clusters.test-replication-specs-per-shard-false", "results.#", "0"), checkIndependentShardScalingMode(clusterName, "SHARD")), }, }, @@ -1908,6 +1908,11 @@ func configShardedNewSchema(orgID, projectName, name string, diskSizeGB int, fir use_replication_spec_per_shard = true } + data "mongodbatlas_advanced_clusters" "test-replication-specs-per-shard-false" { + project_id = mongodbatlas_advanced_cluster.test.project_id + use_replication_spec_per_shard = false + } + data "mongodbatlas_advanced_clusters" "test" { project_id = mongodbatlas_advanced_cluster.test.project_id use_replication_spec_per_shard = true From 6fad9d7b026f629a47c13c81ab595491a7fdcea9 Mon Sep 17 00:00:00 2001 From: Agustin Bettati Date: Wed, 11 Dec 2024 17:00:15 +0100 Subject: [PATCH 07/12] doc: Adjusting `advanced_cluster` documentation reflecting changes in how auto scaling properties work (#2873) * auto_scaling doc improvements * add mention of independent shard scaling in autoscaling attribute * add mention for replication_spec id * unify note on automatic changes to reduce verbosity * wording change * clarify that empty string is encountered --- docs/data-sources/advanced_cluster.md | 2 +- docs/data-sources/advanced_clusters.md | 2 +- docs/resources/advanced_cluster.md | 56 +++++++++++--------------- 3 files changed, 25 insertions(+), 35 deletions(-) diff --git a/docs/data-sources/advanced_cluster.md b/docs/data-sources/advanced_cluster.md index 0b69cd8796..fb1619f01c 100644 --- a/docs/data-sources/advanced_cluster.md +++ b/docs/data-sources/advanced_cluster.md @@ -136,7 +136,7 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le ### replication_specs -* `id` - **(DEPRECATED)** Unique identifer of the replication document for a zone in a Global Cluster. This value corresponds to the legacy sharding schema (no independent shard scaling) and is different from the Shard ID you may see in the Atlas UI. +* `id` - **(DEPRECATED)** Unique identifer of the replication document for a zone in a Global Cluster. This value corresponds to the legacy sharding schema (no independent shard scaling) and is different from the Shard ID you may see in the Atlas UI. This value is not populated (empty string) when a sharded cluster has independently scaled shards. * `external_id` - Unique 24-hexadecimal digit string that identifies the replication object for a shard in a Cluster. This value corresponds to Shard ID displayed in the UI. When using old sharding configuration (replication spec with `num_shards` greater than 1) this value is not populated. * `num_shards` - Provide this value if you set a `cluster_type` of `SHARDED` or `GEOSHARDED`. **(DEPRECATED.)** To learn more, see the [Migration Guide](../guides/1.18.0-upgrade-guide.html.markdown). * `region_configs` - Configuration for the hardware specifications for nodes set for a given regionEach `region_configs` object describes the region's priority in elections and the number and type of MongoDB nodes that Atlas deploys to the region. Each `region_configs` object must have either an `analytics_specs` object, `electable_specs` object, or `read_only_specs` object. See [below](#region_configs) diff --git a/docs/data-sources/advanced_clusters.md b/docs/data-sources/advanced_clusters.md index c1d26b12e3..5fe861a771 100644 --- a/docs/data-sources/advanced_clusters.md +++ b/docs/data-sources/advanced_clusters.md @@ -138,7 +138,7 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le ### replication_specs -* `id` - **(DEPRECATED)** Unique identifer of the replication document for a zone in a Global Cluster. This value corresponds to the legacy sharding schema (no independent shard scaling) and is different from the Shard ID you may see in the Atlas UI. +* `id` - **(DEPRECATED)** Unique identifer of the replication document for a zone in a Global Cluster. This value corresponds to the legacy sharding schema (no independent shard scaling) and is different from the Shard ID you may see in the Atlas UI. This value is not populated (empty string) when a sharded cluster has independently scaled shards. * `external_id` - Unique 24-hexadecimal digit string that identifies the replication object for a shard in a Cluster. This value corresponds to Shard ID displayed in the UI. When using old sharding configuration (replication spec with `num_shards` greater than 1) this value is not populated. * `num_shards` - Provide this value if you set a `cluster_type` of SHARDED or GEOSHARDED. **(DEPRECATED.)** To learn more, see the [Migration Guide](../guides/1.18.0-upgrade-guide.html.markdown) for more details. * `region_configs` - Configuration for the hardware specifications for nodes set for a given regionEach `region_configs` object describes the region's priority in elections and the number and type of MongoDB nodes that Atlas deploys to the region. Each `region_configs` object must have either an `analytics_specs` object, `electable_specs` object, or `read_only_specs` object. See [below](#region_configs) diff --git a/docs/resources/advanced_cluster.md b/docs/resources/advanced_cluster.md index a69410b922..40b738a11d 100644 --- a/docs/resources/advanced_cluster.md +++ b/docs/resources/advanced_cluster.md @@ -533,7 +533,7 @@ replication_specs { } ``` -* `id` - **(DEPRECATED)** Unique identifer of the replication document for a zone in a Global Cluster. This value corresponds to the legacy sharding schema (no independent shard scaling) and is different from the Shard ID you may see in the Atlas UI. +* `id` - **(DEPRECATED)** Unique identifer of the replication document for a zone in a Global Cluster. This value corresponds to the legacy sharding schema (no independent shard scaling) and is different from the Shard ID you may see in the Atlas UI. This value is not populated (empty string) when a sharded cluster has independently scaled shards. * `external_id` - Unique 24-hexadecimal digit string that identifies the replication object for a shard in a Cluster. This value corresponds to Shard ID displayed in the UI. When using old sharding configuration (replication spec with `num_shards` greater than 1) this value is not populated. * `num_shards` - (Optional) Provide this value if you set a `cluster_type` of SHARDED or GEOSHARDED. Omit this value if you selected a `cluster_type` of REPLICASET. This API resource accepts 1 through 50, inclusive. This parameter defaults to 1. If you specify a `num_shards` value of 1 and a `cluster_type` of SHARDED, Atlas deploys a single-shard [sharded cluster](https://docs.atlas.mongodb.com/reference/glossary/#std-term-sharded-cluster). Don't create a sharded cluster with a single shard for production environments. Single-shard sharded clusters don't provide the same benefits as multi-shard configurations. If you are upgrading a replica set to a sharded cluster, you cannot increase the number of shards in the same update request. You should wait until after the cluster has completed upgrading to sharded and you have reconnected all application clients to the MongoDB router before adding additional shards. Otherwise, your data might become inconsistent once MongoDB Cloud begins distributing data across shards. To learn more, see [Convert a replica set to a sharded cluster documentation](https://www.mongodb.com/docs/atlas/scale-cluster/#convert-a-replica-set-to-a-sharded-cluster) and [Convert a replica set to a sharded cluster tutorial](https://www.mongodb.com/docs/upcoming/tutorial/convert-replica-set-to-replicated-shard-cluster). **(DEPRECATED)** To learn more, see the [1.18.0 Upgrade Guide](../guides/1.18.0-upgrade-guide.html.markdown). @@ -545,8 +545,8 @@ If you are upgrading a replica set to a sharded cluster, you cannot increase the ### region_configs * `analytics_specs` - (Optional) Hardware specifications for [analytics nodes](https://docs.atlas.mongodb.com/reference/faq/deployment/#std-label-analytics-nodes-overview) needed in the region. Analytics nodes handle analytic data such as reporting queries from BI Connector for Atlas. Analytics nodes are read-only and can never become the [primary](https://docs.atlas.mongodb.com/reference/glossary/#std-term-primary). If you don't specify this parameter, no analytics nodes deploy to this region. See [below](#specs) -* `auto_scaling` - (Optional) Configuration for the Collection of settings that configures auto-scaling information for the cluster. The values for the `auto_scaling` parameter must be the same for all `region_configs` in all `replication_specs`. See [below](#auto_scaling) -* `analytics_auto_scaling` - (Optional) Configuration for the Collection of settings that configures analytics-auto-scaling information for the cluster. The values for the `analytics_auto_scaling` parameter must be the same for all `region_configs` in all `replication_specs`. See [below](#analytics_auto_scaling) +* `auto_scaling` - (Optional) Configuration for the collection of settings that configures auto-scaling information for the cluster. The values for the `auto_scaling` attribute must be the same for all `region_configs` of a cluster. See [below](#auto_scaling) +* `analytics_auto_scaling` - (Optional) Configuration for the Collection of settings that configures analytics-auto-scaling information for the cluster. The values for the `analytics_auto_scaling` attribute must be the same for all `region_configs` of a cluster. See [below](#analytics_auto_scaling) * `backing_provider_name` - (Optional) Cloud service provider on which you provision the host for a multi-tenant cluster. Use this only when a `provider_name` is `TENANT` and `instance_size` of a specs is `M2` or `M5`. * `electable_specs` - (Optional) Hardware specifications for electable nodes in the region. Electable nodes can become the [primary](https://docs.atlas.mongodb.com/reference/glossary/#std-term-primary) and can enable local reads. If you do not specify this option, no electable nodes are deployed to the region. See [below](#specs) * `priority` - (Optional) Election priority of the region. For regions with only read-only nodes, set this value to 0. @@ -596,16 +596,12 @@ If you are upgrading a replica set to a sharded cluster, you cannot increase the ### auto_scaling * `disk_gb_enabled` - (Optional) Flag that indicates whether this cluster enables disk auto-scaling. This parameter defaults to false. - - Set to `true` to enable disk auto-scaling. - - Set to `false` to disable disk auto-scaling. -~> **IMPORTANT:** If `disk_gb_enabled` is true, Atlas automatically scales the cluster up or down. -This will cause the value of `replication_specs.#.region_config.#.(analytics_specs|electable_specs|read_only_specs).disk_size_gb` returned to potentially be different than what is specified in the Terraform config and if you use, and then apply, not noting this, Terraform will scale the cluster disk size back to the original `disk_size_gb` value. -To prevent disk scaling use a lifecycle customization: -`lifecycle { - ignore_changes = [replication_specs.#.region_config.#.electable_specs.disk_size_gb] -}` -After adding the `lifecycle` block to explicitly change `replication_specs.#.region_config.#.(analytics_specs|electable_specs|read_only_specs).disk_size_gb` comment out the `lifecycle` block and run `terraform apply`. Please be sure to uncomment the `lifecycle` block once done to prevent any accidental changes. +* `compute_enabled` - (Optional) Flag that indicates whether instance size auto-scaling is enabled. This parameter defaults to false. If a sharded cluster is making use of the [New Sharding Configuration](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/advanced-cluster-new-sharding-schema), auto-scaling of the instance size will be independent for each individual shard. On the contrary, if a sharded cluster makes use of deprecated `num_shards` attribute (with values > 1), instance size auto-scaling will be performed uniformily across all shards in the cluster. + +~> **IMPORTANT:** If `disk_gb_enabled` or `compute_enabled` is true, Atlas automatically scales the cluster up or down. +This will cause the value of `replication_specs.#.region_config.#.(electable_specs|read_only_specs).disk_size_gb` or `replication_specs.#.region_config.#.(electable_specs|read_only_specs).instance_size` returned to potentially be different than what is specified in the Terraform config. If you then apply a plan, not noting this, Terraform will scale the cluster back to the original values in the config. +To prevent unintended changes when enabling autoscaling, use a lifecycle ignore customization as shown in the example below. To explicitly change `disk_size_gb` or `instance_size` values, comment out the `lifecycle` block and run `terraform apply`. Please be sure to uncomment the `lifecycle` block once done to prevent any accidental changes. ```terraform // Example: ignore disk_size_gb and instance_size changes in a replica set @@ -613,22 +609,10 @@ lifecycle { ignore_changes = [ replication_specs[0].region_configs[0].electable_specs[0].disk_size_gb, replication_specs[0].region_configs[0].electable_specs[0].instance_size, - replication_specs[0].region_configs[1].electable_specs[0].instance_size, - replication_specs[0].region_configs[2].electable_specs[0].instance_size, ] } ``` -* `compute_enabled` - (Optional) Flag that indicates whether instance size auto-scaling is enabled. This parameter defaults to false. - -~> **IMPORTANT:** If `compute_enabled` is true, Atlas automatically scales the cluster to the maximum provided and down to the minimum, if provided. -This will cause the value of `instance_size` returned to potentially be different than what is specified in the Terraform config and if you then apply a plan, not noting this, Terraform will scale the cluster back to the original `instance_size` value. -To prevent disk scaling, use a lifecycle customization, as in the following example: -`lifecycle { - ignore_changes = [instance_size] -}` -After adding the `lifecycle` block to explicitly change `instance_size` comment out the `lifecycle` block and run `terraform apply`. Please be sure to uncomment the `lifecycle` block once done to prevent any accidental changes. - * `compute_scale_down_enabled` - (Optional) Flag that indicates whether the instance size may scale down. Atlas requires this parameter if `replication_specs.#.region_configs.#.auto_scaling.0.compute_enabled` : true. If you enable this option, specify a value for `replication_specs.#.region_configs.#.auto_scaling.0.compute_min_instance_size`. * `compute_min_instance_size` - (Optional) Minimum instance size to which your cluster can automatically scale (such as M10). Atlas requires this parameter if `replication_specs.#.region_configs.#.auto_scaling.0.compute_scale_down_enabled` is true. * `compute_max_instance_size` - (Optional) Maximum instance size to which your cluster can automatically scale (such as M40). Atlas requires this parameter if `replication_specs.#.region_configs.#.auto_scaling.0.compute_enabled` is true. @@ -636,15 +620,21 @@ After adding the `lifecycle` block to explicitly change `instance_size` comment ### analytics_auto_scaling * `disk_gb_enabled` - (Optional) Flag that indicates whether this cluster enables disk auto-scaling. This parameter defaults to false. -* `compute_enabled` - (Optional) Flag that indicates whether instance size auto-scaling is enabled. This parameter defaults to false. - -~> **IMPORTANT:** If `compute_enabled` is true, then Atlas will automatically scale up to the maximum provided and down to the minimum, if provided. -This will cause the value of `instance_size` returned to potential be different than what is specified in the Terraform config and if you then apply a plan, not noting this, Terraform will scale the cluster back down to the original `instance_size` value. -To prevent compute scaling, use a lifecycle customization, as in the following example: -`lifecycle { - ignore_changes = [instance_size] -}` -After adding the `lifecycle` block to explicitly change `instance_size` comment out the `lifecycle` block and run `terraform apply`. Please be sure to uncomment the `lifecycle` block once done to prevent any accidental changes. +* `compute_enabled` - (Optional) Flag that indicates whether analytics instance size auto-scaling is enabled. This parameter defaults to false. If a sharded cluster is making use of the [New Sharding Configuration](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/advanced-cluster-new-sharding-schema), auto-scaling of analytics instance size will be independent for each individual shard. On the contrary, if a sharded cluster makes use of deprecated `num_shards` attribute (with values > 1), analytics instance size auto-scaling will be performed uniformily across all shards in the cluster. + +~> **IMPORTANT:** If `disk_gb_enabled` or `compute_enabled` is true, Atlas automatically scales the cluster up or down. +This will cause the value of `replication_specs.#.region_config.#.analytics_specs.0.disk_size_gb` or `replication_specs.#.region_config.#.analytics_specs.0.instance_size` returned to potentially be different than what is specified in the Terraform config. If you then apply a plan, not noting this, Terraform will scale the cluster back to the original values in the config. +To prevent unintended changes when enabling autoscaling, use a lifecycle ignore customization as shown in the example below. To explicitly change `disk_size_gb` or `instance_size` values, comment out the `lifecycle` block and run `terraform apply`. Please be sure to uncomment the `lifecycle` block once done to prevent any accidental changes. + +```terraform +// Example: ignore disk_size_gb and instance_size changes in a replica set +lifecycle { + ignore_changes = [ + replication_specs[0].region_configs[0].analytics_specs[0].disk_size_gb, + replication_specs[0].region_configs[0].analytics_specs[0].instance_size, + ] +} +``` * `compute_scale_down_enabled` - (Optional) Flag that indicates whether the instance size may scale down. Atlas requires this parameter if `replication_specs.#.region_configs.#.analytics_auto_scaling.0.compute_enabled` : true. If you enable this option, specify a value for `replication_specs.#.region_configs.#.analytics_auto_scaling.0.compute_min_instance_size`. * `compute_min_instance_size` - (Optional) Minimum instance size to which your cluster can automatically scale (such as M10). Atlas requires this parameter if `replication_specs.#.region_configs.#.analytics_auto_scaling.0.compute_scale_down_enabled` is true. From 724da94b96c9007cbe34e0af6e9421961c67ddd8 Mon Sep 17 00:00:00 2001 From: Agustin Bettati Date: Thu, 12 Dec 2024 16:35:21 +0100 Subject: [PATCH 08/12] doc: Adjusting new sharding configuration migration guide with auto-scaling considerations + examples (#2879) * adjust new sharding configuration migration guide with autoscaling considerations, as well as an example * minor working fix * fmt fix * minor edit * apply doc review changes --- .../advanced-cluster-new-sharding-schema.md | 86 ++++++++++++++++++- docs/resources/advanced_cluster.md | 4 +- .../auto-scaling-per-shard/README.md | 63 ++++++++++++++ .../auto-scaling-per-shard/main.tf | 71 +++++++++++++++ .../auto-scaling-per-shard/variables.tf | 12 +++ .../auto-scaling-per-shard/versions.tf | 9 ++ 6 files changed, 239 insertions(+), 6 deletions(-) create mode 100644 examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/README.md create mode 100644 examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/main.tf create mode 100644 examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/variables.tf create mode 100644 examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/versions.tf diff --git a/docs/guides/advanced-cluster-new-sharding-schema.md b/docs/guides/advanced-cluster-new-sharding-schema.md index 3f7a18c5d7..1eefd70bd4 100644 --- a/docs/guides/advanced-cluster-new-sharding-schema.md +++ b/docs/guides/advanced-cluster-new-sharding-schema.md @@ -4,7 +4,7 @@ page_title: "Migration Guide: Advanced Cluster New Sharding Configurations" # Migration Guide: Advanced Cluster New Sharding Configurations -**Objective**: Use this guide to migrate your existing `advanced_cluster` resources to support new sharding configurations introduced in version 1.18.0. The new sharding configurations allow you to scale shards independently. Existing sharding configurations continue to work, but you will receive deprecation messages if you continue to use them. +**Objective**: Use this guide to migrate your existing `advanced_cluster` resources to support new sharding configurations introduced in version 1.18.0. The new sharding configurations allow you to scale shards independently. Additionally, as of version 1.23.0, compute auto-scaling supports scaling instance sizes independently for each shard when using the new sharding configuration. Existing sharding configurations continue to work, but you will receive deprecation messages if you continue to use them. Note: Once applied, the `advanced_cluster` resource making use of the new sharding configuration will not be able to transition back to the old sharding configuration. @@ -13,7 +13,8 @@ Note: Once applied, the `advanced_cluster` resource making use of the new shardi - [Migrate advanced\_cluster type `SHARDED`](#migrate-advanced_cluster-type-sharded) - [Migrate advanced\_cluster type `GEOSHARDED`](#migrate-advanced_cluster-type-geosharded) - [Migrate advanced\_cluster type `REPLICASET`](#migrate-advanced_cluster-type-replicaset) - - [Use Independent Shard Scaling](#use-independent-shard-scaling) +- [Use Independent Shard Scaling](#use-independent-shard-scaling) +- [Use Auto-Scaling Per Shard](#use-auto-scaling-per-shard) ## Changes Overview @@ -287,7 +288,7 @@ resource "mongodbatlas_advanced_cluster" "test" { Note: The first time `terraform apply` command is run **after** updating the configuration, you may receive a `500 Internal Server Error (Error code: "SERVICE_UNAVAILABLE")` error. This is a known temporary issue. If you encounter this, please re-run `terraform apply` and this time the update should succeed. -### Use Independent Shard Scaling +## Use Independent Shard Scaling Use the new sharding configurations. Each shard must be represented with a unique `replication_specs` element and `num_shards` must not be used, as illustrated in the following example. @@ -323,7 +324,7 @@ resource "mongodbatlas_advanced_cluster" "test" { } ``` -With each shard's `replication_specs` defined independently, we can now define distinct `instance_size`, and `disk_iops` (only for AWS) values for each shard in the cluster. In the following example, we define an upgraded instance size of M40 only for the first shard in the cluster. +With each shard's `replication_specs` defined independently, we can now define distinct `instance_size` and `disk_iops` values for each shard in the cluster. Note that independent `disk_iops` values are only supported for AWS provisioned IOPS, or Azure regions that support Extended IOPS. In the following example, we define an upgraded instance size of M40 only for the first shard in the cluster. Consider reviewing the Metrics Dashboard in the MongoDB Atlas UI (e.g. https://cloud.mongodb.com/v2/#/clusters/detail/ShardedCluster) for insight into how each shard within your cluster is currently performing, which will inform any shard-specific resource allocation changes you might require. @@ -360,3 +361,80 @@ resource "mongodbatlas_advanced_cluster" "test" { ``` -> **NOTE:** For any cluster leveraging the new sharding configurations and defining independently scaled shards, users should also update corresponding `mongodbatlas_cloud_backup_schedule` resource & data sources. This involves updating any existing Terraform configurations of the resource to use `copy_settings.#.zone_id` instead of `copy_settings.#.replication_spec_id`. This is needed as `mongodbatlas_advanced_cluster` resource and data source will no longer have `replication_specs.#.id` present when shards are scaled independently. To learn more, review the [1.18.0 Migration Guide](1.18.0-upgrade-guide.md#transition-cloud-backup-schedules-for-clusters-to-use-zones). + + +## Use Auto-Scaling Per Shard + +As of version 1.23.0, enabled `compute` auto-scaling (either `auto_scaling` or `analytics_auto_scaling`) will scale the `instance_size` of each shard independently. Each shard must be represented with a unique `replication_specs` element and `num_shards` must not be used. On the contrary, if using deprecated `num_shards` or a lower version, enabled compute auto-scaling will scale uniformily across all shards in the cluster. + +The following example illustrates a configuration that has compute auto-scaling per shard for electable and analytic nodes. + +``` +resource "mongodbatlas_advanced_cluster" "test" { + project_id = var.project_id + name = "AutoScalingCluster" + cluster_type = "SHARDED" + replication_specs { # first shard + region_configs { + electable_specs { + instance_size = "M40" + node_count = 3 + } + analytics_specs { + instance_size = "M40" + node_count = 1 + } + auto_scaling { + compute_enabled = true + compute_max_instance_size = "M60" + } + analytics_auto_scaling { + compute_enabled = true + compute_max_instance_size = "M60" + } + provider_name = "AWS" + priority = 7 + region_name = "EU_WEST_1" + } + zone_name = "Zone 1" + } + replication_specs { # second shard + region_configs { + electable_specs { + instance_size = "M40" + node_count = 3 + } + analytics_specs { + instance_size = "M40" + node_count = 1 + } + auto_scaling { + compute_enabled = true + compute_max_instance_size = "M60" + } + analytics_auto_scaling { + compute_enabled = true + compute_max_instance_size = "M60" + } + provider_name = "AWS" + priority = 7 + region_name = "EU_WEST_1" + } + zone_name = "Zone 1" + } + lifecycle { # avoids future non-empty plans as instance size start to scale from initial values + ignore_changes = [ + replication_specs[0].region_configs[0].electable_specs[0].instance_size, + replication_specs[0].region_configs[0].analytics_specs[0].instance_size, + replication_specs[1].region_configs[0].electable_specs[0].instance_size, + replication_specs[1].region_configs[0].analytics_specs[0].instance_size + ] + } +} +``` + +While the example initially defines 2 symmetric shards, auto-scaling of `electable_specs` or `analytic_specs` can lead to asymmetric shards due to changes in `instance_size`. + +-> **NOTE:** After you upgrade to version 1.23.0 of the provider, you must update the cluster configuration to activate the auto-scaling per shard feature. + +-> **NOTE:** When auto-scaling per shard, it is possible that the cluster will transition to having asymmetric shards. This will impact the computed attribute `replication_specs.#.id`, which is not populated when shards are scaled independently. Please make sure to update the corresponding `mongodbatlas_cloud_backup_schedule` resource & data sources. This involves updating any existing Terraform configurations of the resource to use `copy_settings.#.zone_id` instead of `copy_settings.#.replication_spec_id`. To learn more, review the [1.18.0 Migration Guide](1.18.0-upgrade-guide.md#transition-cloud-backup-schedules-for-clusters-to-use-zones). diff --git a/docs/resources/advanced_cluster.md b/docs/resources/advanced_cluster.md index 40b738a11d..b153901cc2 100644 --- a/docs/resources/advanced_cluster.md +++ b/docs/resources/advanced_cluster.md @@ -597,7 +597,7 @@ If you are upgrading a replica set to a sharded cluster, you cannot increase the * `disk_gb_enabled` - (Optional) Flag that indicates whether this cluster enables disk auto-scaling. This parameter defaults to false. -* `compute_enabled` - (Optional) Flag that indicates whether instance size auto-scaling is enabled. This parameter defaults to false. If a sharded cluster is making use of the [New Sharding Configuration](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/advanced-cluster-new-sharding-schema), auto-scaling of the instance size will be independent for each individual shard. On the contrary, if a sharded cluster makes use of deprecated `num_shards` attribute (with values > 1), instance size auto-scaling will be performed uniformily across all shards in the cluster. +* `compute_enabled` - (Optional) Flag that indicates whether instance size auto-scaling is enabled. This parameter defaults to false. If a sharded cluster is making use of the [New Sharding Configuration](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/advanced-cluster-new-sharding-schema), auto-scaling of the instance size will be independent for each individual shard. Please reference the [Use Auto-Scaling Per Shard](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/advanced-cluster-new-sharding-schema#use-auto-scaling-per-shard) section for more details. On the contrary, if a sharded cluster makes use of deprecated `num_shards` attribute (with values > 1), instance size auto-scaling will be performed uniformly across all shards in the cluster. ~> **IMPORTANT:** If `disk_gb_enabled` or `compute_enabled` is true, Atlas automatically scales the cluster up or down. This will cause the value of `replication_specs.#.region_config.#.(electable_specs|read_only_specs).disk_size_gb` or `replication_specs.#.region_config.#.(electable_specs|read_only_specs).instance_size` returned to potentially be different than what is specified in the Terraform config. If you then apply a plan, not noting this, Terraform will scale the cluster back to the original values in the config. @@ -620,7 +620,7 @@ lifecycle { ### analytics_auto_scaling * `disk_gb_enabled` - (Optional) Flag that indicates whether this cluster enables disk auto-scaling. This parameter defaults to false. -* `compute_enabled` - (Optional) Flag that indicates whether analytics instance size auto-scaling is enabled. This parameter defaults to false. If a sharded cluster is making use of the [New Sharding Configuration](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/advanced-cluster-new-sharding-schema), auto-scaling of analytics instance size will be independent for each individual shard. On the contrary, if a sharded cluster makes use of deprecated `num_shards` attribute (with values > 1), analytics instance size auto-scaling will be performed uniformily across all shards in the cluster. +* `compute_enabled` - (Optional) Flag that indicates whether analytics instance size auto-scaling is enabled. This parameter defaults to false. If a sharded cluster is making use of the [New Sharding Configuration](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/advanced-cluster-new-sharding-schema), auto-scaling of analytics instance size will be independent for each individual shard. Please reference the [Use Auto-Scaling Per Shard](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/advanced-cluster-new-sharding-schema#use-auto-scaling-per-shard) section for more details. On the contrary, if a sharded cluster makes use of deprecated `num_shards` attribute (with values > 1), analytics instance size auto-scaling will be performed uniformily across all shards in the cluster. ~> **IMPORTANT:** If `disk_gb_enabled` or `compute_enabled` is true, Atlas automatically scales the cluster up or down. This will cause the value of `replication_specs.#.region_config.#.analytics_specs.0.disk_size_gb` or `replication_specs.#.region_config.#.analytics_specs.0.instance_size` returned to potentially be different than what is specified in the Terraform config. If you then apply a plan, not noting this, Terraform will scale the cluster back to the original values in the config. diff --git a/examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/README.md b/examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/README.md new file mode 100644 index 0000000000..8ea9c7bbe8 --- /dev/null +++ b/examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/README.md @@ -0,0 +1,63 @@ +# MongoDB Atlas Provider -- Sharded Cluster with Independent Shard Auto-scaling + +This example creates a Sharded Cluster with 2 shards defining electable and analytics nodes. Compute auto-scaling is enabled for both `electable_specs` and `analytics_specs`, while also leveraging the [New Sharding Configuration](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/advanced-cluster-new-sharding-schema) by defining each shard with its individual `replication_specs`. This enables scaling of each shard to be independent. Please reference the [Use Auto-Scaling Per Shard](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/advanced-cluster-new-sharding-schema#use-auto-scaling-per-shard) section for more details. + + +## Dependencies + +* Terraform MongoDB Atlas Provider v1.23.0 +* A MongoDB Atlas account + +``` +Terraform >= 0.13 ++ provider registry.terraform.io/terraform-providers/mongodbatlas v1.23.0 +``` + + +## Usage +**1\. If you haven't already, set up your MongoDB Atlas credentials.** + +This can be done using environment variables: + +```bash +export MONGODB_ATLAS_PUBLIC_KEY="xxxx" +export MONGODB_ATLAS_PRIVATE_KEY="xxxx" +``` + +... or follow as in the `variables.tf` file and create **terraform.tfvars** file with all the variable values, ex: +``` +public_key = "" +private_key = "" +atlas_org_id = "" +``` + +Alternatively, you can use [AWS Secrets Manager](https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/website/docs/index.html.markdown#aws-secrets-manager). + +**2\. Review the Terraform plan.** + +Execute the below command and ensure you are happy with the plan. + +``` bash +$ terraform plan +``` +This project currently supports the below deployments: + +- An Atlas Project +- A Sharded Cluster with independent shards with varying cluster tiers + +**3\. Apply your changes.** + +Now execute the plan to provision the Atlas Project and Cluster resources. + +``` bash +$ terraform apply +``` + +**4\. Destroy the resources.** + +Once you are finished your testing, ensure you destroy the resources to avoid unnecessary Atlas charges. + +``` bash +$ terraform destroy +``` + diff --git a/examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/main.tf b/examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/main.tf new file mode 100644 index 0000000000..a628d19e4c --- /dev/null +++ b/examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/main.tf @@ -0,0 +1,71 @@ +provider "mongodbatlas" { + public_key = var.public_key + private_key = var.private_key +} + +resource "mongodbatlas_advanced_cluster" "test" { + project_id = mongodbatlas_project.project.id + name = "AutoScalingCluster" + cluster_type = "SHARDED" + replication_specs { # first shard + region_configs { + auto_scaling { + compute_enabled = true + compute_max_instance_size = "M60" + } + analytics_auto_scaling { + compute_enabled = true + compute_max_instance_size = "M60" + } + electable_specs { + instance_size = "M40" + node_count = 3 + } + analytics_specs { + instance_size = "M40" + node_count = 1 + } + provider_name = "AWS" + priority = 7 + region_name = "EU_WEST_1" + } + zone_name = "Zone 1" + } + replication_specs { # second shard + region_configs { + auto_scaling { + compute_enabled = true + compute_max_instance_size = "M60" + } + analytics_auto_scaling { + compute_enabled = true + compute_max_instance_size = "M60" + } + electable_specs { + instance_size = "M40" + node_count = 3 + } + analytics_specs { + instance_size = "M40" + node_count = 1 + } + provider_name = "AWS" + priority = 7 + region_name = "EU_WEST_1" + } + zone_name = "Zone 1" + } + lifecycle { # avoids non-empty plans as instance size start to scale from initial values + ignore_changes = [ + replication_specs[0].region_configs[0].electable_specs[0].instance_size, + replication_specs[0].region_configs[0].analytics_specs[0].instance_size, + replication_specs[1].region_configs[0].electable_specs[0].instance_size, + replication_specs[1].region_configs[0].analytics_specs[0].instance_size + ] + } +} + +resource "mongodbatlas_project" "project" { + name = "AutoScalingPerShardCluster" + org_id = var.atlas_org_id +} diff --git a/examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/variables.tf b/examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/variables.tf new file mode 100644 index 0000000000..d34c0ba2be --- /dev/null +++ b/examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/variables.tf @@ -0,0 +1,12 @@ +variable "atlas_org_id" { + description = "Atlas organization id" + type = string +} +variable "public_key" { + description = "Public API key to authenticate to Atlas" + type = string +} +variable "private_key" { + description = "Private API key to authenticate to Atlas" + type = string +} diff --git a/examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/versions.tf b/examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/versions.tf new file mode 100644 index 0000000000..f4f37e1912 --- /dev/null +++ b/examples/mongodbatlas_advanced_cluster/auto-scaling-per-shard/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_providers { + mongodbatlas = { + source = "mongodb/mongodbatlas" + version = "~> 1.22" + } + } + required_version = ">= 1.0" +} From 0f5defe5c8766aa7f874ca3be592bb57e2bba8aa Mon Sep 17 00:00:00 2001 From: Agustin Bettati Date: Fri, 13 Dec 2024 14:45:52 +0100 Subject: [PATCH 09/12] chore: Merge latest changes in master into auto-scaling per shard dev branch (#2886) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: Updates Atlas Go SDK (#2805) * build(deps): bump go.mongodb.org/atlas-sdk * fix breaking changes --------- Co-authored-by: wtrocki <981838+wtrocki@users.noreply.github.com> Co-authored-by: Oriol Arbusi * chore: Continues with data source schema auto-generation (#2815) * schema_generation * resource policy * plural datasource for resource_policy * encryption_at_rest_private_endpoint * extract project resource schema to resource_schema.go * project * rename to resource_project_schema.go * Update docs/data-sources/stream_processor.md Co-authored-by: carriecwk <107137496+carriecwk@users.noreply.github.com> * Update docs/data-sources/stream_processors.md Co-authored-by: carriecwk <107137496+carriecwk@users.noreply.github.com> * Update docs/data-sources/stream_processors.md Co-authored-by: carriecwk <107137496+carriecwk@users.noreply.github.com> * Update internal/service/streamprocessor/data_source_schema.go Co-authored-by: carriecwk <107137496+carriecwk@users.noreply.github.com> * Update internal/service/streamprocessor/data_source_schema.go Co-authored-by: carriecwk <107137496+carriecwk@users.noreply.github.com> * fix schema admin reference * apply feedback * stream_instance * fix project * remove checks * project_ip_access timeout as attribute * project_ip_access_list * stream_connection * update templates * remove checks * changelog * apply feedback --------- Co-authored-by: carriecwk <107137496+carriecwk@users.noreply.github.com> * chore: Updates CHANGELOG.md for #2815 * chore: Bump github.com/hashicorp/terraform-plugin-testing (#2809) Bumps [github.com/hashicorp/terraform-plugin-testing](https://github.com/hashicorp/terraform-plugin-testing) from 1.9.0 to 1.11.0. - [Release notes](https://github.com/hashicorp/terraform-plugin-testing/releases) - [Changelog](https://github.com/hashicorp/terraform-plugin-testing/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/terraform-plugin-testing/compare/v1.9.0...v1.11.0) --- updated-dependencies: - dependency-name: github.com/hashicorp/terraform-plugin-testing dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Reverts changes to project data source (#2818) * remove changelog * revert files * chore: Updates CHANGELOG.md for #2818 * feat: Adds `mongodbatlas_flex_cluster` resource and data sources (#2816) * use SDK dev-preview * chore: Generate Flex Cluster file structure and resource schema (#2702) * generate resource and schema * pr comments * correct Map * feat: Implements `mongodbatlas_flex_cluster` resource (#2716) * create implementation * read implementation * update and delete implementation * Implement model * schema refactor * format * wip: model tests * initial model test * test for NewTFModel * Test NewAtlasCreateReq * test NewAtlasUpdateReq * fix tests * refactor for tags * fixes * implement import * simplify update * basic acceptance test * wip: acc tests * fix model test * final changes on tests * changelog entry * add resource to fallback template * Update .changelog/2716.txt Co-authored-by: Agustin Bettati * set resource to preview --------- Co-authored-by: Melanija Cvetic Co-authored-by: Agustin Bettati * chore: Enable mongodbatlas_flex_cluster test in CI (#2720) * create implementation * read implementation * update and delete implementation * initial model test * Test NewAtlasCreateReq * fixes * changelong and fix to acceptance-tests-runner.yml * fix to changelog * removed changelog * resolve rebase issue * fix to implementation * change test to use existing project id * Adjusting predeployed project id name and added preview enable * fix the naming convension of env var --------- Co-authored-by: Oriol Arbusi * chore: Generate Flex Cluster data source file and schemas (#2725) * generate data source file and schema for singular Flex Cluster * Generate plural data source schema * Changing type of tags in schema * Fix to data source schema * chore: Adds state transition logic to mongodbatlas_flex_cluster resource (#2721) * implements state transition * use state transition in create, update and delete * PR comments * chore: Update operation improvements for `mongodbatlas_flex_cluster` resource (#2729) * schema refactors * revert rename * implement isUpdateAllowed * failed update test case * refactor equal checks * make more exhaustive the failed update test * remove UseStateForUnknown in state_name * wip: use plan modifier for non updatable fields * wip: use plan modifiers on all non updatable attributes * use plan modifiers to fail on update of certain attributes * rename planmodifier * simplify planmodifier * PR comments * remove attribute parameter * markdowndescription over description * test: Enable mongodbatlas_flex_cluster tests in QA environment (#2741) * feat: Implements and tests `mongodbatlas_flex_cluster` data source (#2738) * Implementing read funciton in data source * Acc test for data source * Added changelog * implementing review suggestions * fix to rebase * Adjusting default timeout of `flex_cluster` to 3 hours (#2757) * chore: Rebase dev_branch onto master_branch (#2764) * feat: Adds `is_slow_operation_thresholding_enabled` attribute to `mongodbatlas_project` (#2698) * feat: Initial support for is_slow_operation_thresholding_enabled * test: fix test cases * chore: add changelog entry * test: Add extra check for plural data source * refactor: only set SetSlowOperationThresholding once during update * chore: fix lint error * fix: need to set SetSlowOperationThresholding before reading project props from API * chore: address PR comment * doc: Add documentation for `is_slow_operation_thresholding_enabled` to project (#2700) * chore: Updates CHANGELOG.md for #2698 * chore: Use `qa` for TestSuite on Sundays (#2701) * build(deps): bump go.mongodb.org/atlas-sdk (#2705) Co-authored-by: lantoli <430982+lantoli@users.noreply.github.com> * wait in second test (#2707) * chore: Supports running Test Suite in QA on sundays (#2711) * Revert "chore: Use `qa` for TestSuite on Sundays (#2701)" This reverts commit 942e0977c2d299ccdd3d0d10179ef240e3351871. * chore: Supports running qa only on Sundays * address PR comments * refactor: move job to steps of variables * chore: Add top level description * chore: Adds SDK Preview (#2713) * add client * SDK update GHA * simulate Preview update * example of use for Admin Preview * Revert "example of use for Admin Preview" This reverts commit c5edef52847034af8cdb5daf7310743ed630f801. * rename adminPreview to adminpreview in client * example of use of SDK Preview * reverse example * go mod tidy * build(deps): bump go.mongodb.org/atlas-sdk (#2715) Co-authored-by: lantoli <430982+lantoli@users.noreply.github.com> * ci: fix env-vars for azure QA (#2709) * doc: Advanced Cluster Differences and TF Core Upgrades (#2633) * adv cluster differences doc updates * Update docs/index.md * Update index.md * Update advanced_cluster.md * Update advanced_cluster.md * Update advanced_cluster.md * Update cluster.md * Update docs/index.md Co-authored-by: maastha <122359335+maastha@users.noreply.github.com> * Update docs/resources/cluster.md Co-authored-by: maastha <122359335+maastha@users.noreply.github.com> * Update docs/resources/cluster.md Co-authored-by: Melissa Plunkett * Update advanced_cluster.md * Update cluster-to-advanced-cluster-migration-guide.md --------- Co-authored-by: maastha <122359335+maastha@users.noreply.github.com> Co-authored-by: Melissa Plunkett * revert SDK preview changes (#2719) * fix: Fixes inconsistent result when using a multi-region cluster by always using a single spec (#2685) * fix: Initial workaround for multiple specs issuing a warning of spec missmatch * fix: can only use multiple specs in data source (schema limitation) * test: Add a test to confirm multi-region cluster can be used with search deployment * chore: changelog file * chore: fix test enum value * chore: revert timeout changes * Update .changelog/2685.txt Co-authored-by: kanchana-mongodb <54281287+kanchana-mongodb@users.noreply.github.com> --------- Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com> Co-authored-by: kanchana-mongodb <54281287+kanchana-mongodb@users.noreply.github.com> * chore: Updates CHANGELOG.md for #2685 * chore: Updates examples link in index.md for v1.21.2 release * chore: Updates CHANGELOG.md header for v1.21.2 release * fix TestAccBackupSnapshotExportJob_basic (#2723) * chore: Bump github.com/hashicorp/terraform-plugin-framework-validators (#2727) Bumps [github.com/hashicorp/terraform-plugin-framework-validators](https://github.com/hashicorp/terraform-plugin-framework-validators) from 0.13.0 to 0.14.0. - [Release notes](https://github.com/hashicorp/terraform-plugin-framework-validators/releases) - [Changelog](https://github.com/hashicorp/terraform-plugin-framework-validators/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/terraform-plugin-framework-validators/compare/v0.13.0...v0.14.0) --- updated-dependencies: - dependency-name: github.com/hashicorp/terraform-plugin-framework-validators dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix: Fixes `mongodbatlas_project` when user doesn't have project owner permission (#2731) * update doc * add deprecated message * changelog * deprecate params * initial TestAccProject_slowOperationNotOwner * update version to 1.24.0 * changeRoles * Revert "changeRoles" This reverts commit c8ba3c84c2e419d468be1135b5bf408961f8f92a. * Revert "initial TestAccProject_slowOperationNotOwner" This reverts commit d1473711e888887ab5e3991f3cd7314ec52a23e2. * don't update the value if it's in Create so value is unknown * pass warnings * Update internal/service/project/resource_project.go Co-authored-by: Marco Suma * apply feedback in doc * clarify docs --------- Co-authored-by: Marco Suma * chore: Updates CHANGELOG.md for #2731 * chore: Merging schema generation internal tool PoC into master branch (#2735) * feat: Adds initial schema and config models for PoC - Model generation (#2638) * update computability type (#2668) * chore: PoC - Model generation - support primitive types at root level (#2673) * chore: PoC - Schema code generation - Initial support of primitive types (#2682) * initial commit with schema generation function and test fixture * small changes wip * include specific type generators * handling element types and imports * remove unrelated file * extract template logic to separate file * small revert change * extract import to const * follow up adjustments from PR comments and sync with Aastha * chore: PoC - Schema code generation - Supporting nested attributes (#2689) * support nested attribute types * rebasing changes related to unit testing adjustment * chore: PoC - Model generation - Supporting nested schema (List, ListNested, Set & SetNested) (#2693) * chore: PoC - Model generation - Supporting nested schema (objects - Map, MapNested, SingleNested Attributes) (#2704) * chore: PoC - Schema code generation - Supporting generation of typed model (#2703) * support typed model generation inlcuding root and nested attributes * minor fix for type of types map * add clarifying comment * improve name of generated object types, refactor function naming for readability * fix list map and set nested attribute generation (#2708) * chore: PoC - Model generation - support config aliases, ignores, and description overrides (#2712) * chore: PoC - Define make command to call code generation logic (#2706) * wip * iterating over all resources * add config for search deployment * update golden file test with fix in package name * use xstring implementation for pascal case * simplify write file logic * merge fixes * chore: PoC - Support configuration of timeout in schema (#2717) * wip * rebase fixes * fix logic avoiding adding timeout in nested schemas * fix generation * fix enum processing * fix golden file in timeout test * comment out unsupported config properties * simplify interfaces for attribute generation leaving common code in a separate function * chore: PoC - handle merging computability in nested attributes (#2722) * adjusting contributing guide (#2732) --------- Co-authored-by: maastha <122359335+maastha@users.noreply.github.com> Co-authored-by: Aastha Mahendru * doc: Adds documentation for `replication_specs.*.external_id` computed attribute for `mongodbatlas_advanced_cluster` (#2734) * adds M0 (#2730) * docs: Remove legacy project_id attribute in docs as it has been removed (#2733) * chore: Updates examples link in index.md for v1.21.3 release * chore: Updates CHANGELOG.md header for v1.21.3 release * chore: Unify file name for plural data source schema (#2739) * change name * fix name * rename to plural_data_source.go * check cluster creation times (#2728) * fix: Adds new attribute `results` and deprecates `resource_policies` for `mongodbatlas_resource_policies` data source (#2740) * new attribute results and deprecate resource_policies * changelog entry * change test to check new attribute * fix changelog * changelog fix * fix docs * Update .changelog/2740.txt Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com> * migration test * skip mig test until next version * fix comment --------- Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com> * chore: Updates CHANGELOG.md for #2740 * build(deps): bump go.mongodb.org/atlas-sdk (#2745) Co-authored-by: wtrocki <981838+wtrocki@users.noreply.github.com> * fix: Fixes change assigments in `mongodbatlas_project_api_key` (#2737) * fix changed assigments * fix TestAccProjectAPIKey_updateRole * changelog * join configMultiple to configBasic * don't allow duplicate projectIDs * fix TestAccProjectAPIKey_dataSources * refactor Create * refactor getAPIProjectAssignments and flattenProjectAssignments * refactor Read * refactor Delete * fix TestAccProjectAPIKey_recreateWhenDeletedExternally * refactor Import * remove flattenProjectAssignments, flattenProjectAPIKeyRoles and getAPIProjectAssignments * fix plural ds * fix basicTestCase * refactor Update description * refactor Update * refactor expandProjectAssignments * update changelog * initial checkAggr * checkExists * delete redundant TestAccProjectAPIKey_dataSources * refactor configDuplicatedProject * refactor configChangingProject * model file * more detailed changelog * revert import * doc * refactor checks * chore: Updates CHANGELOG.md for #2737 * chore: Updates examples link in index.md for v1.21.4 release * chore: Updates CHANGELOG.md header for v1.21.4 release * chore: Support computability override in schema generation config (#2743) * test without parsing config options * add support for override of computability in config * refactor tests removing redudant code * extract common api spec path, handle computed only case * chore: Bump crazy-max/ghaction-import-gpg from 6.1.0 to 6.2.0 (#2754) Bumps [crazy-max/ghaction-import-gpg](https://github.com/crazy-max/ghaction-import-gpg) from 6.1.0 to 6.2.0. - [Release notes](https://github.com/crazy-max/ghaction-import-gpg/releases) - [Commits](https://github.com/crazy-max/ghaction-import-gpg/compare/01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4...cb9bde2e2525e640591a934b1fd28eef1dcaf5e5) --- updated-dependencies: - dependency-name: crazy-max/ghaction-import-gpg dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump actions/setup-go from 5.0.2 to 5.1.0 (#2753) Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.2 to 5.1.0. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32...41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump github.com/pb33f/libopenapi from 0.18.1 to 0.18.6 (#2750) Bumps [github.com/pb33f/libopenapi](https://github.com/pb33f/libopenapi) from 0.18.1 to 0.18.6. - [Release notes](https://github.com/pb33f/libopenapi/releases) - [Commits](https://github.com/pb33f/libopenapi/compare/v0.18.1...v0.18.6) --- updated-dependencies: - dependency-name: github.com/pb33f/libopenapi dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump tj-actions/verify-changed-files (#2751) Bumps [tj-actions/verify-changed-files](https://github.com/tj-actions/verify-changed-files) from 54483a2138ca67989bc40785aa22faee8b085894 to 530d86d0a237225c87beaa000750988f8965ee31. - [Release notes](https://github.com/tj-actions/verify-changed-files/releases) - [Changelog](https://github.com/tj-actions/verify-changed-files/blob/main/HISTORY.md) - [Commits](https://github.com/tj-actions/verify-changed-files/compare/54483a2138ca67989bc40785aa22faee8b085894...530d86d0a237225c87beaa000750988f8965ee31) --- updated-dependencies: - dependency-name: tj-actions/verify-changed-files dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump actions/checkout from 4.2.1 to 4.2.2 (#2752) * chore: Bump actions/checkout from 4.2.1 to 4.2.2 Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.1 to 4.2.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871...11bd71901bbe5b1630ceea73d27597364c9af683) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Trigger Build --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com> * chore: Automatically updates Terraform version used in repository and test-suite (#2755) * rename workflow (#2761) * chore: Updates Atlas Go SDK (#2748) * build(deps): bump go.mongodb.org/atlas-sdk * Pin cluster POST and PATCH operations to 2024-08-05 avoiding any unintentional shard level autoscaling * unifying version clarification in comments * use sdk utility function for checking error code value * adjust conditional of error checking preserving behaviour --------- Co-authored-by: AgustinBettati <20469408+AgustinBettati@users.noreply.github.com> Co-authored-by: Agustin Bettati * chore: Generate Flex Cluster file structure and resource schema (#2702) * generate resource and schema * pr comments * correct Map * feat: Implements `mongodbatlas_flex_cluster` resource (#2716) * create implementation * read implementation * update and delete implementation * Implement model * schema refactor * format * wip: model tests * initial model test * test for NewTFModel * Test NewAtlasCreateReq * test NewAtlasUpdateReq * fix tests * refactor for tags * fixes * implement import * simplify update * basic acceptance test * wip: acc tests * fix model test * final changes on tests * changelog entry * add resource to fallback template * Update .changelog/2716.txt Co-authored-by: Agustin Bettati * set resource to preview --------- Co-authored-by: Melanija Cvetic Co-authored-by: Agustin Bettati * chore: Enable mongodbatlas_flex_cluster test in CI (#2720) * create implementation * read implementation * update and delete implementation * initial model test * Test NewAtlasCreateReq * fixes * changelong and fix to acceptance-tests-runner.yml * fix to changelog * removed changelog * resolve rebase issue * fix to implementation * change test to use existing project id * Adjusting predeployed project id name and added preview enable * fix the naming convension of env var --------- Co-authored-by: Oriol Arbusi * chore: Generate Flex Cluster data source file and schemas (#2725) * generate data source file and schema for singular Flex Cluster * Generate plural data source schema * Changing type of tags in schema * Fix to data source schema * chore: Adds state transition logic to mongodbatlas_flex_cluster resource (#2721) * implements state transition * use state transition in create, update and delete * PR comments * chore: Update operation improvements for `mongodbatlas_flex_cluster` resource (#2729) * schema refactors * revert rename * implement isUpdateAllowed * failed update test case * refactor equal checks * make more exhaustive the failed update test * remove UseStateForUnknown in state_name * wip: use plan modifier for non updatable fields * wip: use plan modifiers on all non updatable attributes * use plan modifiers to fail on update of certain attributes * rename planmodifier * simplify planmodifier * PR comments * remove attribute parameter * markdowndescription over description * test: Enable mongodbatlas_flex_cluster tests in QA environment (#2741) * feat: Implements and tests `mongodbatlas_flex_cluster` data source (#2738) * Implementing read funciton in data source * Acc test for data source * Added changelog * implementing review suggestions * fix to rebase * Adjusting default timeout of `flex_cluster` to 3 hours (#2757) * fixing imports * Adopting latest preview SDK version * fix flex varibale names after bump * fix atlasuser - set to continue using older SDK version * Fix to variable type names in flex unit test * fix duplicate * fix to api call in atlasUser tests --------- Signed-off-by: dependabot[bot] Co-authored-by: Espen Albert Co-authored-by: svc-apix-bot Co-authored-by: svc-apix-Bot <142542575+svc-apix-Bot@users.noreply.github.com> Co-authored-by: lantoli <430982+lantoli@users.noreply.github.com> Co-authored-by: Zuhair Ahmed Co-authored-by: maastha <122359335+maastha@users.noreply.github.com> Co-authored-by: Melissa Plunkett Co-authored-by: kanchana-mongodb <54281287+kanchana-mongodb@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Marco Suma Co-authored-by: Agustin Bettati Co-authored-by: Aastha Mahendru Co-authored-by: Oriol Co-authored-by: wtrocki <981838+wtrocki@users.noreply.github.com> Co-authored-by: AgustinBettati <20469408+AgustinBettati@users.noreply.github.com> * feat: Implements `mongodbatlas_flex_cluster` plural data source (#2767) * Fix naming convensions in plural DS schema * Implementing plural DS read function * testing and plural ds model * fixes after rebase * additional unit testing for model * changelog * lint fix * removing parellel testing * implemented review feedback * lint fix * chore: Improvements to SDK version update (#2770) * comment use of older API version in atlasUser * add connv220240805 to factory.go * doc: Adds documentation and example for mongodbatlas_flex_cluster resource and data source (#2744) * wip: docs and example (missing data source * change version to make the CI check successful * fmt * regenerate * data source examples * readme created - to adjust preview feature note on release of flex to prod * data source templates * fix typo * generate data source documentation * fix to flex_cluster example * fix to flex_cluster example * fix to generated docs * Added flex to dedicated migration guide * fix typo * Implementing feedback and improving flex-dedicated migratoin guide * adjust flex example README.md * fix to example --------- Co-authored-by: Melanija Cvetic * deprecate: Deprecates Serverless functionality (#2742) * deprecates serverless functionality * documentation * deprecate attributes in data sources * set link to migration guide with supported migration paths * doc: Adds migration guides to transition out of Serverless and Shared-tier clusters (#2746) * wip: migration guides * add details on 1.22 guide * remove guide, will be in resource docs * wip: correct details on 1.22 guide * added migration guide for serverless to flex and serverless to dedicated * added migration guide for shared-tier to flex * added migration guide for serverless to free * implementing review feedback * implementing feedback to guide * changes to migration guide * Adjustments to migration guides * put URL instead of placeholder * move post before pre autoconversion guides, clarify serverless to dedicated * pr comment * pr comments * Update docs/guides/1.22.0-upgrade-guide.md Co-authored-by: lmkerbey-mdb <105309825+lmkerbey-mdb@users.noreply.github.com> * Update docs/guides/serverless-shared-migration-guide.md Co-authored-by: lmkerbey-mdb <105309825+lmkerbey-mdb@users.noreply.github.com> * Update docs/guides/1.22.0-upgrade-guide.md Co-authored-by: lmkerbey-mdb <105309825+lmkerbey-mdb@users.noreply.github.com> * Update docs/guides/serverless-shared-migration-guide.md Co-authored-by: lmkerbey-mdb <105309825+lmkerbey-mdb@users.noreply.github.com> * Update docs/guides/serverless-shared-migration-guide.md Co-authored-by: lmkerbey-mdb <105309825+lmkerbey-mdb@users.noreply.github.com> * Update docs/guides/serverless-shared-migration-guide.md Co-authored-by: lmkerbey-mdb <105309825+lmkerbey-mdb@users.noreply.github.com> * Update docs/guides/serverless-shared-migration-guide.md Co-authored-by: cveticm <119604954+cveticm@users.noreply.github.com> * Update docs/guides/serverless-shared-migration-guide.md Co-authored-by: cveticm <119604954+cveticm@users.noreply.github.com> --------- Co-authored-by: Melanija Cvetic Co-authored-by: lmkerbey-mdb <105309825+lmkerbey-mdb@users.noreply.github.com> Co-authored-by: cveticm <119604954+cveticm@users.noreply.github.com> * chore: Removes mentions and examples of Serverless and Shared-tier instances (#2811) * wip remove mentions of serverless and shared tier * remove examples from template for serverless privatelink * change from M5 to M0 for tenant examples of adv cluster * add note on M0 * chore: Refactor tags attribute schema and conversion logic (#2788) * Implements tag as common function * Refactor project and flex cluster to use new common tag functions * fix to testing and lint * fix changelog entry * january or later for shared tier autoconversion * auto-generate singular data source, temporarily with checks * remove singular data source check * update Description in plural data source --------- Signed-off-by: dependabot[bot] Co-authored-by: Melanija Cvetic Co-authored-by: Agustin Bettati Co-authored-by: cveticm <119604954+cveticm@users.noreply.github.com> Co-authored-by: Espen Albert Co-authored-by: svc-apix-bot Co-authored-by: svc-apix-Bot <142542575+svc-apix-Bot@users.noreply.github.com> Co-authored-by: lantoli <430982+lantoli@users.noreply.github.com> Co-authored-by: Zuhair Ahmed Co-authored-by: maastha <122359335+maastha@users.noreply.github.com> Co-authored-by: Melissa Plunkett Co-authored-by: kanchana-mongodb <54281287+kanchana-mongodb@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Marco Suma Co-authored-by: Aastha Mahendru Co-authored-by: wtrocki <981838+wtrocki@users.noreply.github.com> Co-authored-by: AgustinBettati <20469408+AgustinBettati@users.noreply.github.com> Co-authored-by: lmkerbey-mdb <105309825+lmkerbey-mdb@users.noreply.github.com> * chore: Updates CHANGELOG.md for #2816 * fix: Adds changelog for decreased delay in `mongobatlas_privatelink_endpoint_service` (#2819) * Adds changelog * Fix to changelog * Fix to changelog * chore: Updates CHANGELOG.md for #2819 * chore: Adds initial TPF implementation for advanced_cluster (#2813) * initial create operation * initial resource implementation * support returning nil when advanced config fields are null * test: Add support for overriding http round tripper to allow mocking http request/responses * minor error renaming * remove mocked responses * test: initial TestAdvancedCluster_configSharded requests * chore: use same admin version as existing cluster * mock: allow re-reading GETs * test: support raising error when mock variables are not set * fix: don't dump GroupID in cluster payloads * test: update test case to match existing * refactor: use full request.id() to keep aligned with generator format (differentiate requests with the distinct payloads) * fix: add `computed` to adv_cluster attributes to avoid provider errors * test: minor mock fixes * feat: support state transitions and pause logic * chore: test data updates * test: Support overriding diff files by using `_manual` suffix * style: fmt * test: delete old mock files * test: rename basic to replicast * fix: Deleted should support IDLE --> DELETED * fix: cluster name update requires replace * test: Add tenant test case * chore: include provider changes * fix(move_state): Use ValueString() and do a proper conversion * test: Support mocking test case * refactor: use new `unit.MockTestCase` to simplify resource_test.go * test: Introduce "live" acceptance test for tpf * refactor: re-use existing retry strategy states * refactor: introduce constant.error_codes * refactor: minor cleanups * test: Refactor MockTestCase to also run and support setting TF_ACC dynamically * chore: increase unit test timeout to enable tpf unit tests * minor improvements * unit test timeout increase. Used 75s locally * ci: support running mocked acceptance tests as part of advanced_cluster_tpf job * ci: as of now, advancedclustertpf unit tests cannot run as part of normal unit test since the resource is not added in provider * test: Skip broken move_state_tests * minor fix * chore: fix imports to latest SDK * estetic change to workflow file * refactor: Use provider_mock instead of customizing existing provider (revert all changes to client.go and provider.go * address PR comments * use `diags` instead of returning summary, detail * only removeResource in read * address immediate PR comments * refactor: Use a higher abstraction level in update * refactor: Return TFModel to make purpose more explicit * refactor: Replace awaitChanges method with AwaitChanges function for improved clarity and consistency * apply suggestion * chore: Add step count assertion * refactor: move out all the unit tests and mocked unit test logic * remove: accidental provider changes * remove last changes for unit tests * build(deps): bump go.mongodb.org/atlas-sdk (#2823) Co-authored-by: wtrocki <981838+wtrocki@users.noreply.github.com> * fix: Fixes tags in `mongodbatlas_flex_cluster` (#2829) * fix tags * add tests * fix * chore: Updates examples link in index.md for v1.22.0 release * chore: Updates CHANGELOG.md header for v1.22.0 release * doc: Add preview notice in `mongodbatlas_flex_cluster` docs (#2830) * preview notice * small fix * chore: Bump github.com/wI2L/jsondiff from 0.6.0 to 0.6.1 (#2835) Bumps [github.com/wI2L/jsondiff](https://github.com/wI2L/jsondiff) from 0.6.0 to 0.6.1. - [Release notes](https://github.com/wI2L/jsondiff/releases) - [Changelog](https://github.com/wI2L/jsondiff/blob/master/.goreleaser.yml) - [Commits](https://github.com/wI2L/jsondiff/compare/v0.6.0...v0.6.1) --- updated-dependencies: - dependency-name: github.com/wI2L/jsondiff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump actions/checkout from 4.2.1 to 4.2.2 (#2833) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.1 to 4.2.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4.2.1...11bd71901bbe5b1630ceea73d27597364c9af683) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Update tj-actions/verify-changed-files requirement to 530d86d0a237225c87beaa000750988f8965ee31 (#2832) Updates the requirements on [tj-actions/verify-changed-files](https://github.com/tj-actions/verify-changed-files) to permit the latest version. - [Release notes](https://github.com/tj-actions/verify-changed-files/releases) - [Changelog](https://github.com/tj-actions/verify-changed-files/blob/main/HISTORY.md) - [Commits](https://github.com/tj-actions/verify-changed-files/commits/530d86d0a237225c87beaa000750988f8965ee31) --- updated-dependencies: - dependency-name: tj-actions/verify-changed-files dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump srvaroa/labeler from 1.11.1 to 1.12.0 (#2831) Bumps [srvaroa/labeler](https://github.com/srvaroa/labeler) from 1.11.1 to 1.12.0. - [Release notes](https://github.com/srvaroa/labeler/releases) - [Commits](https://github.com/srvaroa/labeler/compare/29471ee1118fa4e10b011964e6e8fe2fd243e700...fe4b1c73bb8abf2f14a44a6912a8b4fee835d631) --- updated-dependencies: - dependency-name: srvaroa/labeler dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump github.com/stretchr/testify from 1.9.0 to 1.10.0 (#2834) Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.9.0 to 1.10.0. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.9.0...v1.10.0) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump slackapi/slack-github-action from 1.27.0 to 2.0.0 (#2810) * chore: Bump slackapi/slack-github-action from 1.27.0 to 2.0.0 Bumps [slackapi/slack-github-action](https://github.com/slackapi/slack-github-action) from 1.27.0 to 2.0.0. - [Release notes](https://github.com/slackapi/slack-github-action/releases) - [Commits](https://github.com/slackapi/slack-github-action/compare/37ebaef184d7626c5f204ab8d3baff4262dd30f0...485a9d42d3a73031f12ec201c457e2162c45d02d) --- updated-dependencies: - dependency-name: slackapi/slack-github-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * chore: Adjusting how webhook-type is provided in new slack-github-action 2.0 version --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Agustin Bettati * chore: Updates repository to use supported Terraform versions (#2838) Co-authored-by: maastha <122359335+maastha@users.noreply.github.com> * chore: Test converter for TPF (#2822) * initial create operation * initial resource implementation * support returning nil when advanced config fields are null * test: Add support for overriding http round tripper to allow mocking http request/responses * minor error renaming * remove mocked responses * test: initial TestAdvancedCluster_configSharded requests * chore: use same admin version as existing cluster * mock: allow re-reading GETs * test: support raising error when mock variables are not set * fix: don't dump GroupID in cluster payloads * test: update test case to match existing * refactor: use full request.id() to keep aligned with generator format (differentiate requests with the distinct payloads) * fix: add `computed` to adv_cluster attributes to avoid provider errors * test: minor mock fixes * feat: support state transitions and pause logic * chore: test data updates * test: Support overriding diff files by using `_manual` suffix * style: fmt * test: delete old mock files * test: rename basic to replicast * fix: Deleted should support IDLE --> DELETED * fix: cluster name update requires replace * test: Add tenant test case * chore: include provider changes * fix(move_state): Use ValueString() and do a proper conversion * test: Support mocking test case * refactor: use new `unit.MockTestCase` to simplify resource_test.go * test: Introduce "live" acceptance test for tpf * refactor: re-use existing retry strategy states * refactor: introduce constant.error_codes * refactor: minor cleanups * test: Refactor MockTestCase to also run and support setting TF_ACC dynamically * chore: increase unit test timeout to enable tpf unit tests * minor improvements * unit test timeout increase. Used 75s locally * ci: support running mocked acceptance tests as part of advanced_cluster_tpf job * ci: as of now, advancedclustertpf unit tests cannot run as part of normal unit test since the resource is not added in provider * test: Skip broken move_state_tests * minor fix * chore: fix imports to latest SDK * estetic change to workflow file * refactor: Use provider_mock instead of customizing existing provider (revert all changes to client.go and provider.go * address PR comments * use `diags` instead of returning summary, detail * only removeResource in read * address immediate PR comments * refactor: Use a higher abstraction level in update * refactor: Return TFModel to make purpose more explicit * refactor: Replace awaitChanges method with AwaitChanges function for improved clarity and consistency * apply suggestion * chore: Add step count assertion * refactor: move out all the unit tests and mocked unit test logic * remove: accidental provider changes * remove last changes for unit tests * enable TestAccClusterAdvancedCluster_basicTenant in TPF * initial unit test * AssertEqualHCL * AssertEqualHCL tests * call ConvertAdvancedClusterToTPF from tests * update go-cty * use more complex test * passing TestConvertAdvancedClusterToTPF * refactor * revert go.mod & go.sum * revertgithub.com/hashicorp/terraform-plugin-testing to v1.11.0 * go mod tidy * getBlockBody * enable env var * test without env * CheckDestroyCluster for TPF * don't check exists or data sources yet * import tests in TPF --------- Co-authored-by: Espen Albert * test: Adds support for mocked-acceptance-tests (#2820) * initial create operation * initial resource implementation * support returning nil when advanced config fields are null * test: Add support for overriding http round tripper to allow mocking http request/responses * minor error renaming * remove mocked responses * test: initial TestAdvancedCluster_configSharded requests * chore: use same admin version as existing cluster * mock: allow re-reading GETs * test: support raising error when mock variables are not set * fix: don't dump GroupID in cluster payloads * test: update test case to match existing * refactor: use full request.id() to keep aligned with generator format (differentiate requests with the distinct payloads) * fix: add `computed` to adv_cluster attributes to avoid provider errors * test: minor mock fixes * feat: support state transitions and pause logic * chore: test data updates * test: Support overriding diff files by using `_manual` suffix * style: fmt * test: delete old mock files * test: rename basic to replicast * fix: Deleted should support IDLE --> DELETED * fix: cluster name update requires replace * test: Add tenant test case * chore: include provider changes * fix(move_state): Use ValueString() and do a proper conversion * test: Support mocking test case * refactor: use new `unit.MockTestCase` to simplify resource_test.go * test: Introduce "live" acceptance test for tpf * refactor: re-use existing retry strategy states * refactor: introduce constant.error_codes * refactor: minor cleanups * test: Refactor MockTestCase to also run and support setting TF_ACC dynamically * chore: increase unit test timeout to enable tpf unit tests * minor improvements * unit test timeout increase. Used 75s locally * ci: support running mocked acceptance tests as part of advanced_cluster_tpf job * ci: as of now, advancedclustertpf unit tests cannot run as part of normal unit test since the resource is not added in provider * test: Skip broken move_state_tests * minor fix * chore: fix imports to latest SDK * estetic change to workflow file * refactor: Use provider_mock instead of customizing existing provider (revert all changes to client.go and provider.go * address PR comments * use `diags` instead of returning summary, detail * only removeResource in read * address immediate PR comments * refactor: Use a higher abstraction level in update * refactor: Return TFModel to make purpose more explicit * refactor: Replace awaitChanges method with AwaitChanges function for improved clarity and consistency * apply suggestion * chore: Add step count assertion * refactor: move out all the unit tests and mocked unit test logic * remove: accidental provider changes * remove last changes for unit tests * test: Add support for mocked acceptance tests * test: Support maintaining response order with responseIndex * test: update test data for adv cluster unit tests * test: mocker use colored diffs and support empty payloads in diffs * update mocker test data * test: Add check for AllowReReading * test: Add labels and tags to mock cluster JSON test data * update old guides (#2842) * chore: Includes the rest of blocks in TPF test converter (#2841) * don't remove double lines * enable TestAccClusterAdvancedCluster_withTags * tests for labels and tests * label and tags converter * common generateAllAttributeSpecs * change getVal return type * simplify generateAllAttrSpecs call * don't run data source checks for TPF yet * test for advanced_configuration * converter for advanced_configuration * bi_connector_config transform * test for bi_connector_config * fix tests * make explicit dependency from ds * Fix error message typo (#2843) When there's an error setting the `private_key`, it should output an error message mentioning `private_key` instead of `public_key` * chore: Plural data sources in TPF leveraging on resource data source (#2844) * PluralDataSourceSchemaFromResource * flexcluster * flexcluster doc * overridenFields and overridenRootFields in PluralDataSourceSchemaFromResource * advancedclustertpf * encryptionatrestprivateendpoint * resourcepolicy * streamconnection * streaminstance * fix TestPaginatedDSSchema * streamprocessor * remove checks and unneeded code * doc feedback * use struct for params * chore: Environment variable to enable dual schema (#2847) * LatestAdvancedClusterEnabled * TEMPORARY check allowLatestAdvancedClusterEnabled is caught * Revert "TEMPORARY check allowLatestAdvancedClusterEnabled is caught" This reverts commit 1694766b9884cfc3d501e1c210b2bd6154eccd50. * configure resource * make goal * CI config * use config.LatestAdvancedClusterEnabled * TEMPORARY check converter is caught * Revert "TEMPORARY check converter is caught" This reverts commit 98c34f37be7beab76f3be7aeb4a1862177497151. * chore: Adds support for multiple API versions for adv_cluster TPF (#2840) * feat: Support update.IsEmpty * initial start of `num_shards` support * feat: differentiate API Versions used * chore: formatting * feat: intial usage of latest admin api * feat: implement support for num_shards and add legacy compatibility functions for CREATE * chore: use ordinary diffs instead of colors * refactor: remove commented-out code * test: pass static orgID for unit testing * chore: initial working legacy schema * minor cleanup before review * test: Add acceptance test SymmetricShardedOldSchemaDiskSizeGBAtElectableLevel * feat: enhance disk size handling and normalization in advanced cluster resource * chore: PatchPayload, support IgnoreInState * address some PR comments * chore: Avoid update options (handled in normalize instead) * test: refresh golden file * feat: Initial update support using 20240530 * refactor: Always set root disk size * chore: update to use correct test data * refactor: always set rootDiskSize * refactor: update legacy model to include disk size and adjust replication specs handling * feat: add tests and mock data for symmetric sharded old schema configuration+Handle MongoDBMajor version formatting * test: fix mock file and remove manual change * chore: fix broken sharded test * refactor: minor refactorings * fix: Address PR comments * test: Change log message to fatal error for missing steps in request tracker * address PR comments 2 * wait in each cluster creation (#2848) * build(deps): bump go.mongodb.org/atlas-sdk (#2849) Co-authored-by: wtrocki <981838+wtrocki@users.noreply.github.com> * chore: Implements Move State (#2850) * move state impl * fix TestAccAdvancedCluster_move_invalid * TestAccAdvancedCluster_move_not_supported_sdkv2 * apply feedback * rename env var to MONGODB_ATLAS_ADVANCED_CLUSTER_V2_SCHEMA and associated elements * rename SkipIfTPFAdvancedCluster to SkipIfAdvancedClusterV2Schema * parallel tests for move * add last step so no dangling resources * chore: Bump tj-actions/verify-changed-files (#2853) Bumps [tj-actions/verify-changed-files](https://github.com/tj-actions/verify-changed-files) from 530d86d0a237225c87beaa000750988f8965ee31 to dc57d4518c9e75995e0fff59265333d19a684163. - [Release notes](https://github.com/tj-actions/verify-changed-files/releases) - [Changelog](https://github.com/tj-actions/verify-changed-files/blob/main/HISTORY.md) - [Commits](https://github.com/tj-actions/verify-changed-files/compare/530d86d0a237225c87beaa000750988f8965ee31...dc57d4518c9e75995e0fff59265333d19a684163) --- updated-dependencies: - dependency-name: tj-actions/verify-changed-files dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump github.com/zclconf/go-cty from 1.15.0 to 1.15.1 (#2854) Bumps [github.com/zclconf/go-cty](https://github.com/zclconf/go-cty) from 1.15.0 to 1.15.1. - [Release notes](https://github.com/zclconf/go-cty/releases) - [Changelog](https://github.com/zclconf/go-cty/blob/main/CHANGELOG.md) - [Commits](https://github.com/zclconf/go-cty/compare/v1.15.0...v1.15.1) --- updated-dependencies: - dependency-name: github.com/zclconf/go-cty dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Implements extra API Calls for AdvancedCluster TPF (#2852) * chore: Add support for ExtraAPIInfo in TFModel to find replication_specs.*.container_id * feat: Initial /tenantUpgrade logic * refactor: Fix zoneName default for legacy schema * address PR comments part 1 * use explicit code instead of comments Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com> * chore: remove comments and fix suggested change commit * chore: remove comment * address PR comments 2 * test: hard code extra container response --------- Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com> * build(deps): bump go.mongodb.org/atlas-sdk (#2856) Co-authored-by: lantoli <430982+lantoli@users.noreply.github.com> * update Go and linter (#2857) * chore: Ensures that MoveState works in all supported TF versions (#2858) * rename adv schema files * run MoveState matrix in GH * run MoveState tests only if TF version is at least 1.8.0 * revert change * clarify doc * only if above 1.8 * extract acc.CheckExistsCluster and use it in both cluster and adv_cluster (#2860) * chore: Updates repository to use supported Terraform versions (#2861) Co-authored-by: maastha <122359335+maastha@users.noreply.github.com> * chore: Enables all tests for TPF (#2862) * ConvertToTPFAttrsMap * use ConvertToTPFAttrsMap * move TPF test help funcs to the same file * acc.ConvertToTPFAttrsMap returns the attrs instead of mutating the input * ConvertToTPFAttrsSet * delete all SkipIfAdvancedClusterV2Schema except the ones already tried * adjust datasource checks * use ConvertAdvancedClusterToTPF( * refactor attrNameToSchemaV2 * skip some tests * skip more tests * add use_replication_spec_per_shard to data source schema * more tests skipped * don't use dynamic blocks so it can work in TPF as well * missing quotes * fix dynamic block extract * enable mig tests * skip specific mig tests * fix mig tests * skip TestMigAdvancedCluster_asymmetricShardedNewSchema * chore: Adds equivalent CRUD logic for Advanced Cluster TPF (#2855) * chore: remove immediate TODOs from schema * feat: Support retainBackups usage * refactor: Update API info handling and remove legacy schema references * feat: Enhance legacy ID handling in replication specs and update related functions * feat: Add validation for oplog_size_mb attribute in AdvancedConfigurationSchema * remove more todos * test: deleted unused diff files * feat: Support only updating advanced_configuration in update * feat: Add validation for MongoDB version compatibility in advanced configuration * chore: fix comment location * feat: support partial updates and fix advanced_config updates * perf: Support re-using /containers response based on cloud provider * refactor: Remove all UseStateForUnknown * refactor: Always read advanced_configuration, even when there are no changes. Even though plan has no changes with state, we cannot be sure that something has changed externally, better to ensure state always have the latest values * refactor: improve schema validation and plan modifiers * fix: address PR comments * fix: pause set on create * fix: set default value for changeStreamOptionsPreAndPostImagesExpireAfterSeconds to -1 when unset by user and handle `null` reponse from API * Revert "refactor: Always read advanced_configuration, even when there are no changes. Even though plan has no changes with state, we cannot be sure that something has changed externally, better to ensure state always have the latest values" This reverts commit c73d938542126586ea124431346ad4777c875f1c. * feat: Adds new `advanced_configuration.0.default_max_time_ms` attribute to `mongodbatlas_advanced_cluster` resource and data sources (#2825) * chore: Updates CHANGELOG.md for #2825 * chore: Updates Atlas Go SDK (#2870) * build(deps): bump go.mongodb.org/atlas-sdk * fix breaking changes --------- Co-authored-by: lantoli <430982+lantoli@users.noreply.github.com> * chore: Enables paused on create test (#2867) * feat: Support `pinned_fcv` attribute in advanced_cluster resource and data sources (#2789) * wip * support pinning with and without expiration date * add support for unpinning on update * commented code for handling validation * make expiration date required * add waiting before continueing with other updates * handle fcv during creation * add support for singular data source * add in plural data source * add changelog entry * add in cluster tpf schema * include docs for fcv * adding warning to provide reduce possibility of re-applying fcv * adding acceptance test * adjust changelog entry file * specify date format in docs * add step to verify incorrect format * add skipping in advanced_cluster tpf * add tpf limited implementation * adjust test and fix in plural data source to capture upgrade and downgrade * handle warning when expiration date has passed * add knowledge hub article reference * adding example * fix example formatting * add changelog for mongo_db_major_version fix * applying doc review changes * adding link to new docs page * applying doc review changes * pr review comments * extract checks into unified function * minor refactors * chore: Updates CHANGELOG.md for #2789 * chore: Supports setting `retain_backups_enabled` in adv_cluster TPF (#2866) * chore: Refactor advanced cluster tests and enhance compatibility handling for RetainBackupsEnabled * chore: Skip Migration tests and adjust checks to be compatible * chore: Update disk IOPS attribute handling for TPF compatibility and expose AttrNameToSchemaV2 * Update internal/testutil/acc/advanced_cluster_schema_v2.go Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com> * chore: Fix formatting in AttrNameToSchemaV2 function for consistency * chore: Rename function to better reflect its purpose in handling attribute state --------- Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com> * doc: Updates Terraform Compatibility Matrix documentation (#2837) Co-authored-by: maastha <122359335+maastha@users.noreply.github.com> * feat: Support `pinned_fcv` in attribute in cluster resource and data sources (#2817) * add resource and data source implementations * apply docs changes * reuse checks from advanced cluster test for fcv pinning * simplify if * chore: Updates CHANGELOG.md for #2817 * chore: Bump golang.org/x/crypto from 0.29.0 to 0.31.0 (#2881) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.29.0 to 0.31.0. - [Commits](https://github.com/golang/crypto/compare/v0.29.0...v0.31.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Updates repository to use supported Terraform versions (#2883) Co-authored-by: maastha <122359335+maastha@users.noreply.github.com> * chore: Makes test checks valid for SDKv2 and TPF (#2882) * enable data source tests removing calls to AdvancedClusterV2Schema * schemav2 helper check funcs * skip data sources checks in tpf * rename funcs to use schemav2 naming * implement check funcs for schema v2 * testCheckFuncAlwaysPass * move ConvertAdvancedClusterToSchemaV2 to config funcs * avoid relying on resource id and instead on attribute directly --------- Signed-off-by: dependabot[bot] Co-authored-by: svc-apix-Bot <142542575+svc-apix-Bot@users.noreply.github.com> Co-authored-by: wtrocki <981838+wtrocki@users.noreply.github.com> Co-authored-by: Oriol Arbusi Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com> Co-authored-by: carriecwk <107137496+carriecwk@users.noreply.github.com> Co-authored-by: svc-apix-bot Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Melanija Cvetic Co-authored-by: cveticm <119604954+cveticm@users.noreply.github.com> Co-authored-by: Espen Albert Co-authored-by: Zuhair Ahmed Co-authored-by: maastha <122359335+maastha@users.noreply.github.com> Co-authored-by: Melissa Plunkett Co-authored-by: kanchana-mongodb <54281287+kanchana-mongodb@users.noreply.github.com> Co-authored-by: Marco Suma Co-authored-by: Aastha Mahendru Co-authored-by: AgustinBettati <20469408+AgustinBettati@users.noreply.github.com> Co-authored-by: lmkerbey-mdb <105309825+lmkerbey-mdb@users.noreply.github.com> Co-authored-by: Espen Albert Co-authored-by: Sérgio Silva --- .changelog/2716.txt | 3 + .changelog/2738.txt | 3 + .changelog/2742.txt | 39 + .changelog/2767.txt | 3 + .changelog/2789.txt | 23 + .changelog/2817.txt | 23 + .changelog/2819.txt | 3 + .changelog/2825.txt | 11 + .github/workflows/acceptance-tests-runner.yml | 74 +- .github/workflows/acceptance-tests.yml | 1 + .github/workflows/code-health.yml | 2 +- .github/workflows/generate-changelog.yml | 7 +- .github/workflows/notify-docs-team.yml | 7 +- .github/workflows/pull-request-lint.yml | 2 +- .../terraform-compatibility-matrix.yml | 7 +- .github/workflows/test-suite.yml | 11 +- .github/workflows/update-sdk.yml | 2 +- .github/workflows/update-tf-versions.yml | 4 +- .tool-versions | 2 +- CHANGELOG.md | 43 + GNUmakefile | 14 +- docs/data-sources/advanced_cluster.md | 11 +- docs/data-sources/advanced_clusters.md | 11 +- docs/data-sources/cluster.md | 6 + docs/data-sources/clusters.md | 5 + .../encryption_at_rest_private_endpoint.md | 2 +- .../encryption_at_rest_private_endpoints.md | 6 +- docs/data-sources/flex_cluster.md | 86 ++ docs/data-sources/flex_clusters.md | 94 ++ ...privatelink_endpoint_service_serverless.md | 6 + ...rivatelink_endpoints_service_serverless.md | 6 + docs/data-sources/resource_policies.md | 2 +- docs/data-sources/serverless_instance.md | 4 +- docs/data-sources/serverless_instances.md | 4 +- docs/data-sources/stream_processor.md | 8 +- docs/data-sources/stream_processors.md | 8 +- docs/guides/1.12.0-upgrade-guide.md | 1 + docs/guides/1.13.0-upgrade-guide.md | 1 + docs/guides/1.22.0-upgrade-guide.md | 30 + ...ter-to-dedicated-cluster-migraton-guide.md | 65 + .../serverless-shared-migration-guide.md | 267 ++++ docs/index.md | 3 +- docs/resources/advanced_cluster.md | 13 +- docs/resources/cluster.md | 19 +- docs/resources/flex_cluster.md | 99 ++ .../privatelink_endpoint_serverless.md | 6 + ...privatelink_endpoint_service_serverless.md | 6 + docs/resources/serverless_instance.md | 4 +- docs/resources/stream_processor.md | 4 +- .../version-upgrade-with-pinned-fcv/README.md | 57 + .../version-upgrade-with-pinned-fcv/main.tf | 33 + .../variables.tf | 17 + .../versions.tf | 6 +- examples/mongodbatlas_flex_cluster/README.md | 8 + examples/mongodbatlas_flex_cluster/main.tf | 26 + .../mongodbatlas_flex_cluster/provider.tf | 4 + .../mongodbatlas_flex_cluster/variables.tf | 17 + .../versions.tf | 6 +- .../aws/serverless-instance/README.md | 116 -- .../serverless-instance/atlas-privatelink.tf | 14 - .../atlas-serverless-instance.tf | 13 - .../aws/serverless-instance/aws-vpc.tf | 57 - .../aws/serverless-instance/output.tf | 14 - .../aws/serverless-instance/provider.tf | 9 - .../aws/serverless-instance/variables.tf | 25 - .../aws/README.md | 97 -- .../aws/atlas-cluster.tf | 26 - .../aws/aws-vpc.tf | 59 - .../aws/main.tf | 23 - .../aws/provider.tf | 9 - .../aws/variables.tf | 25 - .../azure/Readme.md | 84 -- .../azure/main.tf | 71 - .../azure/variables.tf | 30 - .../azure/versions.tf | 13 - go.mod | 27 +- go.sum | 56 +- internal/common/constant/cloud_provider.go | 7 +- internal/common/constant/deprecation.go | 17 +- internal/common/conversion/flatten_expand.go | 2 +- .../common/conversion/schema_generation.go | 173 ++- .../conversion/schema_generation_test.go | 281 +++- internal/common/conversion/tags.go | 37 + internal/common/conversion/tags_test.go | 53 + .../customplanmodifier/non_updatable.go | 36 + internal/common/dsschema/pagination_schema.go | 34 - .../common/dsschema/pagination_schema_test.go | 63 - internal/common/retrystrategy/retry_state.go | 26 +- internal/common/update/patch_payload.go | 48 +- internal/common/update/patch_payload_test.go | 58 +- internal/config/advanced_cluster_v2_schema.go | 14 + .../config/advanced_cluster_v2_schema_test.go | 13 + internal/config/client.go | 2 +- internal/provider/provider.go | 11 + internal/provider/provider_sdk2.go | 10 +- .../data_source_accesslist_api_keys.go | 2 +- .../resource_access_list_api_key.go | 2 +- .../data_source_advanced_cluster.go | 16 + .../data_source_advanced_clusters.go | 19 +- .../advancedcluster/model_advanced_cluster.go | 47 +- .../model_advanced_cluster_test.go | 4 +- .../model_sdk_version_conversion.go | 2 +- .../model_sdk_version_conversion_test.go | 2 +- .../advancedcluster/move_state_test.go | 84 ++ .../resource_advanced_cluster.go | 120 +- ...esource_advanced_cluster_migration_test.go | 85 +- ...ce_advanced_cluster_state_upgrader_test.go | 8 +- .../resource_advanced_cluster_test.go | 1190 +++++++++++------ .../advancedcluster/resource_update_logic.go | 2 +- .../resource_update_logic_test.go | 2 +- internal/service/advancedclustertpf/README.md | 4 +- .../service/advancedclustertpf/data_source.go | 20 +- .../advancedclustertpf/data_source_schema.go | 11 - .../model_ClusterDescription20240805.go | 107 +- ...l_ClusterDescriptionProcessArgs20240805.go | 13 +- .../model_to_AdvancedClusterDescription.go | 60 + .../model_to_ClusterDescription20240805.go | 25 +- ...el_to_ClusterDescription20240805_legacy.go | 160 +++ ...o_ClusterDescriptionProcessArgs20240805.go | 2 +- .../service/advancedclustertpf/move_state.go | 221 +-- .../advancedclustertpf/move_state_test.go | 107 +- .../advancedclustertpf/plural_data_source.go | 23 +- .../plural_data_source_schema.go | 57 - .../service/advancedclustertpf/resource.go | 410 +++++- .../resource_compatibility_reuse.go | 179 +++ .../resource_compatiblity.go | 246 ++++ .../advancedclustertpf/resource_schema.go | 159 ++- .../resource_schema_test.go | 88 +- .../advancedclustertpf/resource_test.go | 301 +---- .../advancedclustertpf/resource_unit_test.go | 270 ++++ .../advancedclustertpf/resource_upgrade.go | 27 + .../service/advancedclustertpf/responses.go | 256 ---- .../advancedclustertpf/state_transition.go | 111 ++ ...TestMockAdvancedCluster_configSharded.yaml | 216 +++ ..._groups_{groupId}_clusters_2024-10-23.json | 40 + ...Id}_clusters_{clusterName}_2024-08-05.json | 70 + ...sters_{clusterName}_2024-08-05_manual.json | 72 + ...Id}_clusters_{clusterName}_2023-02-01.json | 0 .../TestMockAdvancedCluster_replicaset.yaml | 431 ++++++ ..._groups_{groupId}_clusters_2024-10-23.json | 32 + ...Id}_clusters_{clusterName}_2024-10-23.json | 24 + ...Id}_clusters_{clusterName}_2024-10-23.json | 3 + ...Id}_clusters_{clusterName}_2024-10-23.json | 3 + ..._{clusterName}_processArgs_2024-08-05.json | 4 + ...Id}_clusters_{clusterName}_2023-02-01.json | 0 ...usterConfig_symmetricShardedOldSchema.yaml | 371 +++++ ..._groups_{groupId}_clusters_2024-10-23.json | 64 + ...Id}_clusters_{clusterName}_2023-02-01.json | 36 + ...sters_{clusterName}_2023-02-01_manual.json | 56 + ...Id}_clusters_{clusterName}_2024-10-23.json | 3 + ...Id}_clusters_{clusterName}_2023-02-01.json | 0 ...edOldSchemaDiskSizeGBAtElectableLevel.yaml | 318 +++++ ..._groups_{groupId}_clusters_2024-10-23.json | 49 + ..._{groupId}_clusters_2024-10-23_manual.json | 50 + ..._groups_{groupId}_settings_2023-01-01.json | 8 + ..._groups_{groupId}_clusters_2024-08-05.json | 47 + ...Id}_clusters_{clusterName}_2023-02-01.json | 27 + ...sters_{clusterName}_2023-02-01_manual.json | 36 + ...Id}_clusters_{clusterName}_2023-02-01.json | 0 ...ockClusterAdvancedCluster_basicTenant.yaml | 286 ++++ ..._groups_{groupId}_clusters_2024-10-23.json | 23 + ..._{groupId}_clusters_2024-10-23_manual.json | 22 + ...Id}_clusters_{clusterName}_2023-02-01.json | 0 ..._groups_{groupId}_clusters_2024-10-23.json | 23 + ..._{groupId}_clusters_2024-10-23_manual.json | 22 + ...d}_clusters_{clusterName2}_2023-02-01.json | 0 ...kClusterAdvancedCluster_tenantUpgrade.yaml | 186 +++ ..._groups_{groupId}_clusters_2024-10-23.json | 23 + ..._{groupId}_clusters_2024-10-23_manual.json | 22 + ...Id}_clusters_tenantUpgrade_2023-01-01.json | 8 + ...Id}_clusters_{clusterName}_2023-02-01.json | 0 .../testdata/process_args_1.json | 15 - .../testdata/process_args_1_legacy.json | 17 - .../testdata/process_args_2.json | 15 - .../testdata/process_args_2_legacy.json | 17 - .../testdata/process_args_2_request.json | 12 - .../process_args_2_request_legacy.json | 4 - .../testdata/replicaset_create.json | 24 - .../testdata/replicaset_create_resp1.json | 85 -- .../replicaset_create_resp1_final.json | 86 -- .../testdata/replicaset_update1.json | 3 - .../testdata/replicaset_update1_resp.json | 86 -- .../testdata/replicaset_update2.json | 27 - .../testdata/replicaset_update2_resp.json | 100 -- .../replicaset_update2_resp_final.json | 100 -- .../testdata/sharded_create.json | 41 - .../testdata/sharded_create_resp1.json | 132 -- .../testdata/sharded_create_resp1_final.json | 90 -- .../testdata/sharded_update1.json | 88 -- .../testdata/sharded_update_resp1.json | 134 -- .../testdata/sharded_update_resp1_final.json | 90 -- .../advancedclustertpf/validate_schema.go | 84 ++ .../data_source_alert_configuration.go | 2 +- .../data_source_alert_configurations.go | 2 +- .../model_alert_configuration.go | 2 +- .../model_alert_configuration_test.go | 2 +- .../resource_alert_configuration.go | 2 +- .../service/apikey/data_source_api_keys.go | 2 +- internal/service/apikey/resource_api_key.go | 4 +- .../atlasuser/data_source_atlas_user.go | 4 +- .../atlasuser/data_source_atlas_user_test.go | 3 +- .../atlasuser/data_source_atlas_users.go | 4 +- .../atlasuser/data_source_atlas_users_test.go | 3 +- .../service/auditing/resource_auditing.go | 2 +- .../resource_backup_compliance_policy.go | 2 +- .../data_source_cloud_backup_schedule.go | 2 +- .../model_cloud_backup_schedule.go | 2 +- .../model_cloud_backup_schedule_test.go | 2 +- .../model_sdk_version_conversion.go | 2 +- .../resource_cloud_backup_schedule.go | 2 +- .../data_source_cloud_backup_snapshots.go | 2 +- .../model_cloud_backup_snapshot.go | 2 +- .../model_cloud_backup_snapshot_test.go | 2 +- .../resource_cloud_backup_snapshot.go | 2 +- .../resource_cloud_backup_snapshot_test.go | 2 +- ...ce_cloud_backup_snapshot_export_buckets.go | 2 +- ...rce_cloud_backup_snapshot_export_bucket.go | 2 +- ...ource_cloud_backup_snapshot_export_jobs.go | 2 +- ...source_cloud_backup_snapshot_export_job.go | 2 +- ...urce_cloud_backup_snapshot_restore_jobs.go | 2 +- ...ource_cloud_backup_snapshot_restore_job.go | 2 +- ...rce_cloud_provider_access_authorization.go | 2 +- .../resource_cloud_provider_access_setup.go | 2 +- .../service/cluster/data_source_cluster.go | 33 +- .../service/cluster/data_source_clusters.go | 28 +- internal/service/cluster/new_atlas.go | 14 +- internal/service/cluster/resource_cluster.go | 58 +- .../service/cluster/resource_cluster_test.go | 209 ++- .../resource_cluster_outage_simulation.go | 2 +- .../controlplaneipaddresses/data_source.go | 2 +- .../service/controlplaneipaddresses/model.go | 2 +- .../controlplaneipaddresses/model_test.go | 2 +- .../data_source_custom_db_roles.go | 2 +- .../customdbrole/resource_custom_db_role.go | 2 +- .../resource_custom_db_role_test.go | 2 +- ...ce_custom_dns_configuration_cluster_aws.go | 2 +- ...ce_custom_dns_configuration_cluster_aws.go | 10 +- ...stom_dns_configuration_cluster_aws_test.go | 4 +- .../databaseuser/model_database_user.go | 2 +- .../databaseuser/model_database_user_test.go | 2 +- .../resource_database_user_migration_test.go | 2 +- .../resource_database_user_test.go | 2 +- .../data_source_data_lake_pipeline_run.go | 2 +- .../data_source_data_lake_pipeline_runs.go | 2 +- .../data_source_data_lake_pipelines.go | 2 +- .../resource_data_lake_pipeline.go | 2 +- .../encryptionatrest/data_source_schema.go | 2 +- internal/service/encryptionatrest/model.go | 2 +- .../service/encryptionatrest/model_test.go | 2 +- internal/service/encryptionatrest/resource.go | 2 +- .../resource_migration_test.go | 2 +- .../service/encryptionatrest/resource_test.go | 4 +- .../data_source.go | 5 +- .../data_source_schema.go | 17 +- .../encryptionatrestprivateendpoint/model.go | 2 +- .../model_test.go | 2 +- .../plural_data_source.go | 7 +- .../plural_data_source_schema.go | 36 - .../resource.go | 2 +- .../resource_test.go | 2 +- .../state_transition.go | 2 +- .../state_transition_test.go | 4 +- .../eventtrigger/resource_event_trigger.go | 12 +- ...source_federated_database_instance_test.go | 2 +- ...ata_source_federated_database_instances.go | 2 +- .../resource_federated_database_instance.go | 2 +- .../data_source_federated_query_limits.go | 2 +- .../resource_federated_query_limit.go | 2 +- ...e_federated_settings_identity_providers.go | 2 +- ...el_federated_settings_identity_provider.go | 2 +- ...derated_settings_identity_provider_test.go | 2 +- .../data_source_federated_settings.go | 2 +- ...ource_federated_settings_connected_orgs.go | 2 +- ...model_federated_settings_connected_orgs.go | 2 +- ...ce_federated_settings_org_role_mappings.go | 2 +- ...del_federated_settings_org_role_mapping.go | 2 +- ...rce_federated_settings_org_role_mapping.go | 2 +- internal/service/flexcluster/data_source.go | 52 + internal/service/flexcluster/main_test.go | 15 + internal/service/flexcluster/model.go | 133 ++ internal/service/flexcluster/model_test.go | 385 ++++++ .../service/flexcluster/plural_data_source.go | 66 + internal/service/flexcluster/resource.go | 215 +++ .../service/flexcluster/resource_schema.go | 203 +++ internal/service/flexcluster/resource_test.go | 202 +++ .../service/flexcluster/state_transition.go | 60 + .../flexcluster/state_transition_test.go | 163 +++ .../tfplugingen/generator_config.yml | 21 + .../resource_global_cluster_config.go | 2 +- .../data_source_ldap_configuration.go | 2 +- .../resource_ldap_configuration.go | 10 +- .../resource_ldap_configuration_test.go | 2 +- .../ldapverify/data_source_ldap_verify.go | 2 +- .../ldapverify/resource_ldap_verify.go | 10 +- .../ldapverify/resource_ldap_verify_test.go | 2 +- .../resource_maintenance_window.go | 2 +- .../mongodbemployeeaccessgrant/data_source.go | 4 +- .../mongodbemployeeaccessgrant/model.go | 2 +- .../mongodbemployeeaccessgrant/model_test.go | 2 +- .../mongodbemployeeaccessgrant/resource.go | 4 +- .../data_source_network_containers.go | 2 +- .../resource_network_container.go | 2 +- .../data_source_network_peering.go | 2 +- .../data_source_network_peerings.go | 2 +- .../resource_network_peering.go | 2 +- .../onlinearchive/resource_online_archive.go | 2 +- .../organization/data_source_organizations.go | 2 +- .../organization/resource_organization.go | 4 +- .../resource_organization_test.go | 2 +- .../orginvitation/resource_org_invitation.go | 2 +- ...resource_private_endpoint_regional_mode.go | 2 +- .../resource_privatelink_endpoint.go | 2 +- ...esource_privatelink_endpoint_serverless.go | 4 +- .../resource_privatelink_endpoint_service.go | 2 +- ...service_data_federation_online_archives.go | 2 +- ..._service_data_federation_online_archive.go | 2 +- ...privatelink_endpoint_service_serverless.go | 4 +- ...rivatelink_endpoints_service_serverless.go | 7 +- ...privatelink_endpoint_service_serverless.go | 4 +- .../service/project/data_source_project.go | 4 +- .../service/project/data_source_projects.go | 3 +- internal/service/project/model_project.go | 31 +- .../service/project/model_project_test.go | 55 +- internal/service/project/resource_project.go | 276 +--- .../resource_project_migration_test.go | 2 +- .../project/resource_project_schema.go | 273 ++++ .../service/project/resource_project_test.go | 8 +- .../data_source_project_api_keys.go | 2 +- .../projectapikey/model_project_api_key.go | 2 +- .../projectapikey/resource_project_api_key.go | 2 +- .../resource_project_invitation.go | 2 +- .../data_source_project_ip_access_list.go | 17 +- .../model_project_ip_access_list.go | 2 +- .../model_project_ip_access_list_test.go | 2 +- .../resource_project_ip_access_list.go | 88 +- .../projectipaccesslist/resource_schema.go | 93 ++ .../service/projectipaddresses/data_source.go | 2 +- internal/service/projectipaddresses/model.go | 2 +- .../service/projectipaddresses/model_test.go | 2 +- .../service/pushbasedlogexport/data_source.go | 4 +- internal/service/pushbasedlogexport/model.go | 2 +- .../service/pushbasedlogexport/model_test.go | 2 +- .../service/pushbasedlogexport/resource.go | 2 +- .../pushbasedlogexport/state_transition.go | 2 +- .../state_transition_test.go | 4 +- .../service/resourcepolicy/data_source.go | 5 +- .../resourcepolicy/data_source_schema.go | 102 -- internal/service/resourcepolicy/model.go | 2 +- internal/service/resourcepolicy/model_test.go | 2 +- .../resourcepolicy/plural_data_source.go | 15 +- .../plural_data_source_schema.go | 43 - internal/service/resourcepolicy/resource.go | 3 +- .../service/resourcepolicy/resource_schema.go | 21 +- .../data_source_search_deployment.go | 4 +- .../model_search_deployment.go | 2 +- .../model_search_deployment_test.go | 2 +- .../state_transition_search_deployment.go | 2 +- ...state_transition_search_deployment_test.go | 4 +- .../searchindex/data_source_search_indexes.go | 2 +- .../service/searchindex/model_search_index.go | 2 +- .../searchindex/resource_search_index.go | 2 +- .../data_source_serverless_instance.go | 16 +- .../data_source_serverless_instances.go | 2 +- .../resource_serverless_instance.go | 17 +- .../resource_serverless_instance_test.go | 2 +- ...a_source_cloud_shared_tier_restore_jobs.go | 2 +- .../data_source_shared_tier_snapshots.go | 2 +- .../data_source_stream_connection.go | 85 +- .../data_source_stream_connections.go | 38 +- .../data_source_stream_connections_test.go | 2 +- .../model_stream_connection.go | 2 +- .../model_stream_connection_test.go | 2 +- .../streamconnection/resource_schema.go | 100 ++ .../resource_stream_connection.go | 93 +- .../data_source_stream_instance.go | 50 +- .../data_source_stream_instances.go | 33 +- .../data_source_stream_instances_test.go | 2 +- .../streaminstance/model_stream_instance.go | 2 +- .../model_stream_instance_test.go | 2 +- .../service/streaminstance/resource_schema.go | 85 ++ .../resource_stream_instance.go | 79 +- .../service/streamprocessor/data_source.go | 6 +- .../streamprocessor/data_source_schema.go | 63 - internal/service/streamprocessor/model.go | 2 +- .../service/streamprocessor/model_test.go | 2 +- .../streamprocessor/plural_data_source.go | 27 +- .../plural_data_source_schema.go | 56 - internal/service/streamprocessor/resource.go | 2 +- .../streamprocessor/resource_schema.go | 78 +- .../streamprocessor/state_transition.go | 2 +- .../streamprocessor/state_transition_test.go | 4 +- internal/service/team/data_source_team.go | 2 +- internal/service/team/resource_team.go | 4 +- internal/service/team/update_user.go | 4 +- internal/service/team/update_user_test.go | 14 +- .../data_source_third_party_integrations.go | 2 +- ...ource_x509_authentication_database_user.go | 2 +- ...ource_x509_authentication_database_user.go | 6 +- ..._x509_authentication_database_user_test.go | 2 +- internal/testutil/acc/advanced_cluster.go | 76 +- .../acc/advanced_cluster_schema_v2.go | 218 +++ .../acc/advanced_cluster_schema_v2_test.go | 261 ++++ internal/testutil/acc/atlas.go | 2 +- internal/testutil/acc/cluster.go | 2 +- internal/testutil/acc/config_cluster.go | 4 +- internal/testutil/acc/config_formatter.go | 10 +- internal/testutil/acc/database_user.go | 2 +- internal/testutil/acc/encryption_at_rest.go | 2 +- internal/testutil/acc/factory.go | 2 +- internal/testutil/acc/pre_check.go | 7 +- internal/testutil/acc/project.go | 2 +- internal/testutil/acc/serverless.go | 2 +- internal/testutil/acc/shared_resource.go | 9 +- internal/testutil/acc/sort.go | 12 + internal/testutil/mig/test_case.go | 4 +- internal/testutil/tc/advanced_cluster.go | 322 +++++ internal/testutil/unit/http_mocker.go | 354 +++++ internal/testutil/unit/http_mocker_test.go | 161 +++ internal/testutil/unit/provider_mock.go | 91 ++ .../unit/testdata/TestMockRoundTripper.yaml | 169 +++ ...s_{orgId}_resourcePolicies_2024-08-05.json | 8 + ...olicies_{resourcePolicyId}_2024-08-05.json | 8 + ...olicies_{resourcePolicyId}_2024-08-05.json | 0 ..._{resourcePolicyId}_2024-08-05_manual.json | 1 + .../TestMockRoundTripperAllowReRead.yaml | 37 + ...s_{orgId}_resourcePolicies_2024-08-05.json | 8 + scripts/generate-doc.sh | 2 +- scripts/generate-docs-all.sh | 2 +- templates/data-source.md.tmpl | 2 - templates/data-sources/flex_cluster.md.tmpl | 12 + templates/data-sources/flex_clusters.md.tmpl | 12 + templates/resources.md.tmpl | 3 - templates/resources/flex_cluster.md.tmpl | 19 + tools/codegen/config.yml | 3 - tools/scaffold/template/datasource.tmpl | 1 + tools/scaffold/template/pluraldatasource.tmpl | 1 + tools/scaffold/template/resource.tmpl | 1 + 437 files changed, 12001 insertions(+), 5178 deletions(-) create mode 100644 .changelog/2716.txt create mode 100644 .changelog/2738.txt create mode 100644 .changelog/2742.txt create mode 100644 .changelog/2767.txt create mode 100644 .changelog/2789.txt create mode 100644 .changelog/2817.txt create mode 100644 .changelog/2819.txt create mode 100644 .changelog/2825.txt create mode 100644 docs/data-sources/flex_cluster.md create mode 100644 docs/data-sources/flex_clusters.md create mode 100644 docs/guides/1.22.0-upgrade-guide.md create mode 100644 docs/guides/flex-cluster-to-dedicated-cluster-migraton-guide.md create mode 100644 docs/guides/serverless-shared-migration-guide.md create mode 100644 docs/resources/flex_cluster.md create mode 100644 examples/mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv/README.md create mode 100644 examples/mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv/main.tf create mode 100644 examples/mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv/variables.tf rename examples/{mongodbatlas_privatelink_endpoint/aws/serverless-instance => mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv}/versions.tf (57%) create mode 100644 examples/mongodbatlas_flex_cluster/README.md create mode 100644 examples/mongodbatlas_flex_cluster/main.tf create mode 100644 examples/mongodbatlas_flex_cluster/provider.tf create mode 100644 examples/mongodbatlas_flex_cluster/variables.tf rename examples/{mongodbatlas_privatelink_endpoint_service_serverless/aws => mongodbatlas_flex_cluster}/versions.tf (57%) delete mode 100644 examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/README.md delete mode 100644 examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-privatelink.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-serverless-instance.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/aws-vpc.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/output.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/provider.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/variables.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/README.md delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/atlas-cluster.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/aws-vpc.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/main.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/provider.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/variables.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/Readme.md delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/main.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/variables.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/versions.tf create mode 100644 internal/common/conversion/tags.go create mode 100644 internal/common/conversion/tags_test.go create mode 100644 internal/common/customplanmodifier/non_updatable.go delete mode 100644 internal/common/dsschema/pagination_schema.go delete mode 100644 internal/common/dsschema/pagination_schema_test.go create mode 100644 internal/config/advanced_cluster_v2_schema.go create mode 100644 internal/config/advanced_cluster_v2_schema_test.go create mode 100644 internal/service/advancedcluster/move_state_test.go delete mode 100644 internal/service/advancedclustertpf/data_source_schema.go create mode 100644 internal/service/advancedclustertpf/model_to_AdvancedClusterDescription.go create mode 100644 internal/service/advancedclustertpf/model_to_ClusterDescription20240805_legacy.go delete mode 100644 internal/service/advancedclustertpf/plural_data_source_schema.go create mode 100644 internal/service/advancedclustertpf/resource_compatibility_reuse.go create mode 100644 internal/service/advancedclustertpf/resource_compatiblity.go create mode 100644 internal/service/advancedclustertpf/resource_unit_test.go create mode 100644 internal/service/advancedclustertpf/resource_upgrade.go delete mode 100644 internal/service/advancedclustertpf/responses.go create mode 100644 internal/service/advancedclustertpf/state_transition.go create mode 100644 internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded.yaml create mode 100644 internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-08-05.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-08-05_manual.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded/03_01_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset.yaml create mode 100644 internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/03_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/03_02_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/04_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/05_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_processArgs_2024-08-05.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/06_01_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema.yaml create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01_manual.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/02_02_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/02_03_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel.yaml create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_02_PATCH__api_atlas_v2_groups_{groupId}_settings_2023-01-01.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_03_POST__api_atlas_v2_groups_{groupId}_clusters_2024-08-05.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01_manual.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/02_02_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant.yaml create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/02_01_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/02_02_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/02_02_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/03_01_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName2}_2023-02-01.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade.yaml create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/02_01_POST__api_atlas_v2_groups_{groupId}_clusters_tenantUpgrade_2023-01-01.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/02_02_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json delete mode 100644 internal/service/advancedclustertpf/testdata/process_args_1.json delete mode 100644 internal/service/advancedclustertpf/testdata/process_args_1_legacy.json delete mode 100644 internal/service/advancedclustertpf/testdata/process_args_2.json delete mode 100644 internal/service/advancedclustertpf/testdata/process_args_2_legacy.json delete mode 100644 internal/service/advancedclustertpf/testdata/process_args_2_request.json delete mode 100644 internal/service/advancedclustertpf/testdata/process_args_2_request_legacy.json delete mode 100644 internal/service/advancedclustertpf/testdata/replicaset_create.json delete mode 100644 internal/service/advancedclustertpf/testdata/replicaset_create_resp1.json delete mode 100644 internal/service/advancedclustertpf/testdata/replicaset_create_resp1_final.json delete mode 100644 internal/service/advancedclustertpf/testdata/replicaset_update1.json delete mode 100644 internal/service/advancedclustertpf/testdata/replicaset_update1_resp.json delete mode 100644 internal/service/advancedclustertpf/testdata/replicaset_update2.json delete mode 100644 internal/service/advancedclustertpf/testdata/replicaset_update2_resp.json delete mode 100644 internal/service/advancedclustertpf/testdata/replicaset_update2_resp_final.json delete mode 100644 internal/service/advancedclustertpf/testdata/sharded_create.json delete mode 100644 internal/service/advancedclustertpf/testdata/sharded_create_resp1.json delete mode 100644 internal/service/advancedclustertpf/testdata/sharded_create_resp1_final.json delete mode 100644 internal/service/advancedclustertpf/testdata/sharded_update1.json delete mode 100644 internal/service/advancedclustertpf/testdata/sharded_update_resp1.json delete mode 100644 internal/service/advancedclustertpf/testdata/sharded_update_resp1_final.json create mode 100644 internal/service/advancedclustertpf/validate_schema.go delete mode 100644 internal/service/encryptionatrestprivateendpoint/plural_data_source_schema.go create mode 100644 internal/service/flexcluster/data_source.go create mode 100644 internal/service/flexcluster/main_test.go create mode 100644 internal/service/flexcluster/model.go create mode 100644 internal/service/flexcluster/model_test.go create mode 100644 internal/service/flexcluster/plural_data_source.go create mode 100644 internal/service/flexcluster/resource.go create mode 100644 internal/service/flexcluster/resource_schema.go create mode 100644 internal/service/flexcluster/resource_test.go create mode 100644 internal/service/flexcluster/state_transition.go create mode 100644 internal/service/flexcluster/state_transition_test.go create mode 100644 internal/service/flexcluster/tfplugingen/generator_config.yml create mode 100644 internal/service/project/resource_project_schema.go create mode 100644 internal/service/projectipaccesslist/resource_schema.go delete mode 100644 internal/service/resourcepolicy/data_source_schema.go delete mode 100644 internal/service/resourcepolicy/plural_data_source_schema.go create mode 100644 internal/service/streamconnection/resource_schema.go create mode 100644 internal/service/streaminstance/resource_schema.go delete mode 100644 internal/service/streamprocessor/data_source_schema.go delete mode 100644 internal/service/streamprocessor/plural_data_source_schema.go create mode 100644 internal/testutil/acc/advanced_cluster_schema_v2.go create mode 100644 internal/testutil/acc/advanced_cluster_schema_v2_test.go create mode 100644 internal/testutil/acc/sort.go create mode 100644 internal/testutil/tc/advanced_cluster.go create mode 100644 internal/testutil/unit/http_mocker.go create mode 100644 internal/testutil/unit/http_mocker_test.go create mode 100644 internal/testutil/unit/provider_mock.go create mode 100644 internal/testutil/unit/testdata/TestMockRoundTripper.yaml create mode 100644 internal/testutil/unit/testdata/TestMockRoundTripper/01_01_POST__api_atlas_v2_orgs_{orgId}_resourcePolicies_2024-08-05.json create mode 100644 internal/testutil/unit/testdata/TestMockRoundTripper/02_01_PATCH__api_atlas_v2_orgs_{orgId}_resourcePolicies_{resourcePolicyId}_2024-08-05.json create mode 100644 internal/testutil/unit/testdata/TestMockRoundTripper/03_01_DELETE__api_atlas_v2_orgs_{orgId}_resourcePolicies_{resourcePolicyId}_2024-08-05.json create mode 100644 internal/testutil/unit/testdata/TestMockRoundTripper/03_01_DELETE__api_atlas_v2_orgs_{orgId}_resourcePolicies_{resourcePolicyId}_2024-08-05_manual.json create mode 100644 internal/testutil/unit/testdata/TestMockRoundTripperAllowReRead.yaml create mode 100644 internal/testutil/unit/testdata/TestMockRoundTripperAllowReRead/01_01_POST__api_atlas_v2_orgs_{orgId}_resourcePolicies_2024-08-05.json create mode 100644 templates/data-sources/flex_cluster.md.tmpl create mode 100644 templates/data-sources/flex_clusters.md.tmpl create mode 100644 templates/resources/flex_cluster.md.tmpl diff --git a/.changelog/2716.txt b/.changelog/2716.txt new file mode 100644 index 0000000000..f89d6c2f27 --- /dev/null +++ b/.changelog/2716.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +mongodbatlas_flex_cluster +``` diff --git a/.changelog/2738.txt b/.changelog/2738.txt new file mode 100644 index 0000000000..d163afad6c --- /dev/null +++ b/.changelog/2738.txt @@ -0,0 +1,3 @@ +```release-note:new-datasource +mongodbatlas_flex_cluster +``` diff --git a/.changelog/2742.txt b/.changelog/2742.txt new file mode 100644 index 0000000000..eb7fed6d0c --- /dev/null +++ b/.changelog/2742.txt @@ -0,0 +1,39 @@ +```release-note:note +resource/mongodbatlas_serverless_instance: Deprecates `continuous_backup_enabled` attribute +``` + +```release-note:note +resource/mongodbatlas_serverless_instance: Deprecates `auto_indexing` attribute +``` + +```release-note:note +data-source/mongodbatlas_serverless_instance: Deprecates `continuous_backup_enabled` attribute +``` + +```release-note:note +data-source/mongodbatlas_serverless_instance: Deprecates `auto_indexing` attribute +``` + +```release-note:note +data-source/mongodbatlas_serverless_instances: Deprecates `continuous_backup_enabled` attribute +``` + +```release-note:note +data-source/mongodbatlas_serverless_instances: Deprecates `auto_indexing` attribute +``` + +```release-note:note +resource/mongodbatlas_privatelink_endpoint_serverless: Deprecates resource +``` + +```release-note:note +resource/mongodbatlas_privatelink_endpoint_service_serverless: Deprecates resource +``` + +```release-note:note +data-source/mongodbatlas_privatelink_endpoint_service_serverless: Deprecates data source +``` + +```release-note:note +data-source/mongodbatlas_privatelink_endpoints_service_serverless: Deprecates data source +``` diff --git a/.changelog/2767.txt b/.changelog/2767.txt new file mode 100644 index 0000000000..63ae120d36 --- /dev/null +++ b/.changelog/2767.txt @@ -0,0 +1,3 @@ +```release-note:new-datasource +mongodbatlas_flex_clusters +``` diff --git a/.changelog/2789.txt b/.changelog/2789.txt new file mode 100644 index 0000000000..e435d6bcb0 --- /dev/null +++ b/.changelog/2789.txt @@ -0,0 +1,23 @@ +```release-note:enhancement +resource/mongodbatlas_advanced_cluster: Adds `pinned_fcv` attribute +``` + +```release-note:enhancement +data-source/mongodbatlas_advanced_cluster: Adds `pinned_fcv` attribute +``` + +```release-note:enhancement +data-source/mongodbatlas_advanced_clusters: Adds `pinned_fcv` attribute +``` + +```release-note:bug +resource/mongodbatlas_advanced_cluster: `mongo_db_major_version` attribute is populated with binary version when FCV pin is active +``` + +```release-note:bug +data-source/mongodbatlas_advanced_cluster: `mongo_db_major_version` attribute is populated with binary version when FCV pin is active +``` + +```release-note:bug +data-source/mongodbatlas_advanced_clusters: `mongo_db_major_version` attribute is populated with binary version when FCV pin is active +``` diff --git a/.changelog/2817.txt b/.changelog/2817.txt new file mode 100644 index 0000000000..945c9b00bc --- /dev/null +++ b/.changelog/2817.txt @@ -0,0 +1,23 @@ +```release-note:enhancement +resource/mongodbatlas_cluster: Adds `pinned_fcv` attribute +``` + +```release-note:enhancement +data-source/mongodbatlas_cluster: Adds `pinned_fcv` attribute +``` + +```release-note:enhancement +data-source/mongodbatlas_clusters: Adds `pinned_fcv` attribute +``` + +```release-note:bug +resource/mongodbatlas_cluster: `mongo_db_major_version` attribute is populated with binary version when FCV pin is active +``` + +```release-note:bug +data-source/mongodbatlas_cluster: `mongo_db_major_version` attribute is populated with binary version when FCV pin is active +``` + +```release-note:bug +data-source/mongodbatlas_clusters: `mongo_db_major_version` attribute is populated with binary version when FCV pin is active +``` diff --git a/.changelog/2819.txt b/.changelog/2819.txt new file mode 100644 index 0000000000..77ff5d1c22 --- /dev/null +++ b/.changelog/2819.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/mongodbatlas_privatelink_endpoint_service: Decreases delay time when creating or deleting a resource +``` diff --git a/.changelog/2825.txt b/.changelog/2825.txt new file mode 100644 index 0000000000..42e2f3cdcd --- /dev/null +++ b/.changelog/2825.txt @@ -0,0 +1,11 @@ +```release-note:note +resource/mongodbatlas_advanced_cluster: Adds new `advanced_configuration.0.default_max_time_ms` attribute +``` + +```release-note:note +data-source/mongodbatlas_advanced_cluster: Adds new `advanced_configuration.0.default_max_time_ms` attribute +``` + +```release-note:note +data-source/mongodbatlas_advanced_clusters: Adds new `advanced_configuration.0.default_max_time_ms` attribute +``` diff --git a/.github/workflows/acceptance-tests-runner.yml b/.github/workflows/acceptance-tests-runner.yml index 81418aa803..c1d7c199d3 100644 --- a/.github/workflows/acceptance-tests-runner.yml +++ b/.github/workflows/acceptance-tests-runner.yml @@ -6,7 +6,7 @@ on: workflow_call: inputs: terraform_version: - description: 'Terraform version to use, e.g. 1.6.x, empty for latest' + description: 'Terraform version to use, e.g. 1.6.x' type: string required: true provider_version: @@ -95,6 +95,9 @@ on: azure_private_endpoint_region: type: string required: true + mongodb_atlas_flex_project_id: + type: string + required: true secrets: # all secrets are passed explicitly in this workflow mongodb_atlas_public_key: required: true @@ -213,6 +216,7 @@ jobs: encryption: ${{ steps.filter.outputs.encryption == 'true' || env.mustTrigger == 'true' }} event_trigger: ${{ steps.filter.outputs.event_trigger == 'true' || env.mustTrigger == 'true' }} federated: ${{ steps.filter.outputs.federated == 'true' || env.mustTrigger == 'true' }} + flex_cluster: ${{ steps.filter.outputs.flex_cluster == 'true' || env.mustTrigger == 'true' }} generic: ${{ steps.filter.outputs.generic == 'true' || env.mustTrigger == 'true' }} global_cluster_config: ${{ steps.filter.outputs.global_cluster_config == 'true' || env.mustTrigger == 'true' }} ldap: ${{ steps.filter.outputs.ldap == 'true' || env.mustTrigger == 'true' }} @@ -278,6 +282,8 @@ jobs: - 'internal/service/federatedsettingsidentityprovider/*.go' - 'internal/service/federatedsettingsorgconfig/*.go' - 'internal/service/federatedsettingsorgrolemapping/*.go' + flex_cluster: + - 'internal/service/flexcluster/*.go' generic: - 'internal/service/auditing/*.go' - 'internal/service/backupcompliancepolicy/*.go' @@ -344,6 +350,8 @@ jobs: advanced_cluster_tpf: needs: [ change-detection, get-provider-version ] if: ${{ needs.change-detection.outputs.advanced_cluster_tpf == 'true' || inputs.test_group == 'advanced_cluster_tpf' }} + env: + MONGODB_ATLAS_ADVANCED_CLUSTER_V2_SCHEMA: 'true' runs-on: ubuntu-latest permissions: {} steps: @@ -359,15 +367,53 @@ jobs: terraform_wrapper: false - name: Prepare new advanced_cluster run: make tools enable-advancedclustertpf + - name: Unit tests # delete after allowAdvancedClusterV2Schema is removed + run: go test -v ./internal/testutil/acc/advanced_cluster_schema_v2_test.go + - name: Mocked Acceptance Tests + env: + ACCTEST_REGEX_RUN: '^TestMock' + ACCTEST_PACKAGES: ./internal/service/advancedclustertpf + run: make testacc - name: Acceptance Tests env: MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }} - MONGODB_ATLAS_TPF_ADV_CLUSTER_TESTS: "true" ACCTEST_PACKAGES: | ./internal/service/advancedcluster ./internal/service/advancedclustertpf run: make testacc + advanced_cluster_tpf_move: + needs: [ change-detection, get-provider-version ] + if: ${{ (needs.change-detection.outputs.advanced_cluster_tpf == 'true' || inputs.test_group == 'advanced_cluster_tpf') && inputs.terraform_version == '1.10.x' }} + env: + MONGODB_ATLAS_ADVANCED_CLUSTER_V2_SCHEMA: 'true' + strategy: + max-parallel: 2 + fail-fast: false + matrix: + terraform_version: ['1.8.x', '1.9.x'] # TF supported versions for MoveState apart from latest one, 1.10.x + name: advanced_cluster_tpf_move-${{ matrix.terraform_version }} + runs-on: ubuntu-latest + permissions: {} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + ref: ${{ inputs.ref || github.ref }} + - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed + with: + go-version-file: 'go.mod' + - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd + with: + terraform_version: ${{ matrix.terraform_version }} + terraform_wrapper: false + - name: Prepare new advanced_cluster + run: make tools enable-advancedclustertpf + - name: Acceptance Tests + env: + ACCTEST_REGEX_RUN: '^TestAccAdvancedCluster_move' + ACCTEST_PACKAGES: ./internal/service/advancedclustertpf + run: make testacc + assume_role: needs: [ change-detection, get-provider-version ] if: ${{ needs.change-detection.outputs.assume_role == 'true' || inputs.test_group == 'assume_role' }} @@ -654,6 +700,30 @@ jobs: ./internal/service/federatedsettingsorgrolemapping run: make testacc + flex_cluster: + needs: [ change-detection, get-provider-version ] + if: ${{ needs.change-detection.outputs.flex_cluster == 'true' || inputs.test_group == 'flex_cluster' }} + runs-on: ubuntu-latest + permissions: {} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + ref: ${{ inputs.ref || github.ref }} + - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed + with: + go-version-file: 'go.mod' + - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd + with: + terraform_version: ${{ inputs.terraform_version }} + terraform_wrapper: false + - name: Acceptance Tests + env: + MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }} + MONGODB_ATLAS_FLEX_PROJECT_ID: ${{ inputs.mongodb_atlas_flex_project_id }} + MONGODB_ATLAS_ENABLE_PREVIEW: "true" + ACCTEST_PACKAGES: ./internal/service/flexcluster + run: make testacc + generic: needs: [ change-detection, get-provider-version ] if: ${{ needs.change-detection.outputs.generic == 'true' || inputs.test_group == 'generic' }} diff --git a/.github/workflows/acceptance-tests.yml b/.github/workflows/acceptance-tests.yml index cf8fb734e2..22b164959d 100644 --- a/.github/workflows/acceptance-tests.yml +++ b/.github/workflows/acceptance-tests.yml @@ -115,3 +115,4 @@ jobs: mongodb_atlas_enable_preview: ${{ vars.MONGODB_ATLAS_ENABLE_PREVIEW }} azure_private_endpoint_region: ${{ vars.AZURE_PRIVATE_ENDPOINT_REGION }} mongodb_atlas_rp_org_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_RP_ORG_ID_QA || vars.MONGODB_ATLAS_RP_ORG_ID_DEV }} + mongodb_atlas_flex_project_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_FLEX_PROJECT_ID_QA || vars.MONGODB_ATLAS_FLEX_PROJECT_ID }} diff --git a/.github/workflows/code-health.yml b/.github/workflows/code-health.yml index 0a0c8b7c18..a0717564e9 100644 --- a/.github/workflows/code-health.yml +++ b/.github/workflows/code-health.yml @@ -49,7 +49,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 with: - version: v1.61.0 # Also update GOLANGCI_VERSION variable in GNUmakefile when updating this version + version: v1.62.2 # Also update GOLANGCI_VERSION variable in GNUmakefile when updating this version - name: actionlint run: | make tools diff --git a/.github/workflows/generate-changelog.yml b/.github/workflows/generate-changelog.yml index 37c6ce991c..84ae7623f4 100644 --- a/.github/workflows/generate-changelog.yml +++ b/.github/workflows/generate-changelog.yml @@ -28,8 +28,10 @@ jobs: steps: - name: Send Slack message id: slack - uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 + uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d with: + webhook: ${{ secrets.SLACK_WEBHOOK_URL }} + webhook-type: incoming-webhook payload: | { "text": "Automatic Changelog update failed", @@ -43,6 +45,3 @@ jobs: } ] } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK \ No newline at end of file diff --git a/.github/workflows/notify-docs-team.yml b/.github/workflows/notify-docs-team.yml index 52c474a581..4a23f6e789 100644 --- a/.github/workflows/notify-docs-team.yml +++ b/.github/workflows/notify-docs-team.yml @@ -29,11 +29,10 @@ jobs: permissions: pull-requests: write # Needed by sticky-pull-request-comment steps: - - uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_DOCS }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + - uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d with: + webhook: ${{ secrets.SLACK_WEBHOOK_URL_DOCS }} + webhook-type: incoming-webhook payload: | { "blocks": [ diff --git a/.github/workflows/pull-request-lint.yml b/.github/workflows/pull-request-lint.yml index 862a78b46e..1d7291fd54 100644 --- a/.github/workflows/pull-request-lint.yml +++ b/.github/workflows/pull-request-lint.yml @@ -75,7 +75,7 @@ jobs: contents: read pull-requests: write # Needed by labeler steps: - - uses: srvaroa/labeler@29471ee1118fa4e10b011964e6e8fe2fd243e700 + - uses: srvaroa/labeler@fe4b1c73bb8abf2f14a44a6912a8b4fee835d631 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/.github/workflows/terraform-compatibility-matrix.yml b/.github/workflows/terraform-compatibility-matrix.yml index 5eb6c2d7cc..b4067f7bbc 100644 --- a/.github/workflows/terraform-compatibility-matrix.yml +++ b/.github/workflows/terraform-compatibility-matrix.yml @@ -64,11 +64,10 @@ jobs: echo "slack_payload=${slack_message}" >> "${GITHUB_OUTPUT}" - name: Send Slack message id: slack - uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 + uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d with: + webhook: ${{ secrets.SLACK_WEBHOOK_URL }} + webhook-type: incoming-webhook payload: ${{ steps.slack-payload.outputs.slack_payload }} - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 64e775da02..ff66248df6 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -8,7 +8,7 @@ on: inputs: terraform_matrix: description: 'Terraform version matrix (JSON array)' - default: '["1.9.x","1.8.x","1.7.x","1.6.x","1.5.x","1.4.x"]' + default: '["1.10.x","1.9.x","1.8.x","1.7.x","1.6.x","1.5.x","1.4.x"]' provider_matrix: description: 'Previous MongoDB Atlas Provider version matrix for migration tests (JSON array)' default: '[""]' # "" for latest version @@ -43,7 +43,7 @@ concurrency: jobs: variables: env: - schedule_terraform_matrix: '["1.9.x"]' + schedule_terraform_matrix: '["1.10.x"]' schedule_provider_matrix: '[""]' # "" for latest version runs-on: ubuntu-latest outputs: @@ -91,8 +91,10 @@ jobs: steps: - name: Send Slack message id: slack - uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 + uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d with: + webhook: ${{ secrets.SLACK_WEBHOOK_URL }} + webhook-type: incoming-webhook payload: | { "text": ":red_circle: Test Suite failed (reminder to log failures)", @@ -119,6 +121,3 @@ jobs: } ] } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/.github/workflows/update-sdk.yml b/.github/workflows/update-sdk.yml index 1cddac5c79..33c5e88a62 100644 --- a/.github/workflows/update-sdk.yml +++ b/.github/workflows/update-sdk.yml @@ -20,7 +20,7 @@ jobs: - name: Update files run: make tools update-atlas-sdk - name: Verify Changed files - uses: tj-actions/verify-changed-files@530d86d0a237225c87beaa000750988f8965ee31 + uses: tj-actions/verify-changed-files@dc57d4518c9e75995e0fff59265333d19a684163 id: verify-changed-files - name: Create PR uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f diff --git a/.github/workflows/update-tf-versions.yml b/.github/workflows/update-tf-versions.yml index 00437410d4..1153a19f61 100644 --- a/.github/workflows/update-tf-versions.yml +++ b/.github/workflows/update-tf-versions.yml @@ -19,7 +19,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: make update-tf-compatibility-matrix - name: Verify Changed files - uses: tj-actions/verify-changed-files@530d86d0a237225c87beaa000750988f8965ee31 + uses: tj-actions/verify-changed-files@dc57d4518c9e75995e0fff59265333d19a684163 id: verify-changed-files - name: Create PR uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f @@ -44,7 +44,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: make update-tf-version-in-repository - name: Verify Changed files - uses: tj-actions/verify-changed-files@530d86d0a237225c87beaa000750988f8965ee31 + uses: tj-actions/verify-changed-files@dc57d4518c9e75995e0fff59265333d19a684163 id: verify-changed-files - name: Create PR uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f diff --git a/.tool-versions b/.tool-versions index 2c087aba58..6650ebad8f 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1 @@ -terraform 1.9.8 +terraform 1.10.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index e97a77dc35..80ee7e62bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,51 @@ NOTES: +* data-source/mongodbatlas_advanced_cluster: Adds new `advanced_configuration.0.default_max_time_ms` attribute ([#2825](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2825)) +* data-source/mongodbatlas_advanced_clusters: Adds new `advanced_configuration.0.default_max_time_ms` attribute ([#2825](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2825)) +* resource/mongodbatlas_advanced_cluster: Adds new `advanced_configuration.0.default_max_time_ms` attribute ([#2825](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2825)) + +ENHANCEMENTS: + +* data-source/mongodbatlas_advanced_cluster: Adds `pinned_fcv` attribute ([#2789](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2789)) +* data-source/mongodbatlas_advanced_clusters: Adds `pinned_fcv` attribute ([#2789](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2789)) +* data-source/mongodbatlas_cluster: Adds `pinned_fcv` attribute ([#2817](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2817)) +* data-source/mongodbatlas_clusters: Adds `pinned_fcv` attribute ([#2817](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2817)) +* resource/mongodbatlas_advanced_cluster: Adds `pinned_fcv` attribute ([#2789](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2789)) +* resource/mongodbatlas_cluster: Adds `pinned_fcv` attribute ([#2817](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2817)) + +BUG FIXES: + +* data-source/mongodbatlas_advanced_cluster: `mongo_db_major_version` attribute is populated with binary version when FCV pin is active ([#2789](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2789)) +* data-source/mongodbatlas_advanced_clusters: `mongo_db_major_version` attribute is populated with binary version when FCV pin is active ([#2789](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2789)) +* data-source/mongodbatlas_cluster: `mongo_db_major_version` attribute is populated with binary version when FCV pin is active ([#2817](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2817)) +* data-source/mongodbatlas_clusters: `mongo_db_major_version` attribute is populated with binary version when FCV pin is active ([#2817](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2817)) +* resource/mongodbatlas_advanced_cluster: `mongo_db_major_version` attribute is populated with binary version when FCV pin is active ([#2789](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2789)) +* resource/mongodbatlas_cluster: `mongo_db_major_version` attribute is populated with binary version when FCV pin is active ([#2817](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2817)) + +## 1.22.0 (November 26, 2024) + +NOTES: + * data-source/mongodbatlas_organization: Adds new `gen_ai_features_enabled` attribute ([#2724](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2724)) * data-source/mongodbatlas_organizations: Adds new `gen_ai_features_enabled` attribute ([#2724](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2724)) +* data-source/mongodbatlas_privatelink_endpoint_service_serverless: Deprecates data source ([#2742](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2742)) +* data-source/mongodbatlas_privatelink_endpoints_service_serverless: Deprecates data source ([#2742](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2742)) +* data-source/mongodbatlas_serverless_instance: Deprecates `auto_indexing` attribute ([#2742](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2742)) +* data-source/mongodbatlas_serverless_instance: Deprecates `continuous_backup_enabled` attribute ([#2742](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2742)) +* data-source/mongodbatlas_serverless_instances: Deprecates `auto_indexing` attribute ([#2742](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2742)) +* data-source/mongodbatlas_serverless_instances: Deprecates `continuous_backup_enabled` attribute ([#2742](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2742)) * resource/mongodbatlas_organization: Adds new `gen_ai_features_enabled` attribute ([#2724](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2724)) +* resource/mongodbatlas_privatelink_endpoint_serverless: Deprecates resource ([#2742](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2742)) +* resource/mongodbatlas_privatelink_endpoint_service_serverless: Deprecates resource ([#2742](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2742)) +* resource/mongodbatlas_serverless_instance: Deprecates `auto_indexing` attribute ([#2742](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2742)) +* resource/mongodbatlas_serverless_instance: Deprecates `continuous_backup_enabled` attribute ([#2742](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2742)) + +FEATURES: + +* **New Data Source:** `mongodbatlas_flex_cluster` ([#2738](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2738)) +* **New Data Source:** `mongodbatlas_flex_clusters` ([#2767](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2767)) +* **New Resource:** `mongodbatlas_flex_cluster` ([#2716](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2716)) ENHANCEMENTS: @@ -13,6 +55,7 @@ ENHANCEMENTS: * resource/mongodbatlas_cloud_backup_snapshot_restore_job: Adds `failed` attribute ([#2781](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2781)) * resource/mongodbatlas_network_peering: Improve error message when networking peering reaches a failed status ([#2766](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2766)) * resource/mongodbatlas_privatelink_endpoint: Improves error message when privatelink endpoint returns error after POST ([#2803](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2803)) +* resource/mongodbatlas_privatelink_endpoint_service: Decreases delay time when creating or deleting a resource ([#2819](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2819)) * resource/mongodbatlas_privatelink_endpoint_service: Improves error message when privatelink endpoint service returns error after POST ([#2803](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2803)) ## 1.21.4 (October 29, 2024) diff --git a/GNUmakefile b/GNUmakefile index e60e77780d..e01efbd902 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -18,7 +18,7 @@ GITTAG=$(shell git describe --always --tags) VERSION=$(GITTAG:v%=%) LINKER_FLAGS=-s -w -X 'github.com/mongodb/terraform-provider-mongodbatlas/version.ProviderVersion=${VERSION}' -GOLANGCI_VERSION=v1.61.0 # Also update golangci-lint GH action in code-health.yml when updating this version +GOLANGCI_VERSION=v1.62.2 # Also update golangci-lint GH action in code-health.yml when updating this version export PATH := $(shell go env GOPATH)/bin:$(PATH) export SHELL := env PATH=$(PATH) /bin/bash @@ -167,10 +167,7 @@ jira-release-version: .PHONY: enable-advancedclustertpf enable-advancedclustertpf: - make delete-lines filename="./internal/provider/provider_sdk2.go" delete="mongodbatlas_advanced_cluster" - make add-lines filename=./internal/provider/provider.go find="project.Resource," add="advancedclustertpf.Resource," - make add-lines filename=./internal/provider/provider.go find="project.DataSource," add="advancedclustertpf.DataSource," - make add-lines filename=./internal/provider/provider.go find="project.PluralDataSource," add="advancedclustertpf.PluralDataSource," + make change-lines filename=./internal/config/advanced_cluster_v2_schema.go find="allowAdvancedClusterV2Schema = false" new="allowAdvancedClusterV2Schema = true" .PHONY: delete-lines ${filename} ${delete} delete-lines: @@ -185,3 +182,10 @@ add-lines: sed 's/${find}/${find}${add}/' "${filename}" > "file.tmp" mv file.tmp ${filename} goimports -w ${filename} + +.PHONY: change-lines ${filename} ${find} ${new} +change-lines: + rm -f file.tmp + sed 's/${find}/${new}/' "${filename}" > "file.tmp" + mv file.tmp ${filename} + goimports -w ${filename} diff --git a/docs/data-sources/advanced_cluster.md b/docs/data-sources/advanced_cluster.md index fb1619f01c..bfce0ff9c2 100644 --- a/docs/data-sources/advanced_cluster.md +++ b/docs/data-sources/advanced_cluster.md @@ -19,7 +19,7 @@ resource "mongodbatlas_advanced_cluster" "example" { replication_specs { region_configs { electable_specs { - instance_size = "M5" + instance_size = "M0" } provider_name = "TENANT" backing_provider_name = "AWS" @@ -35,6 +35,8 @@ data "mongodbatlas_advanced_cluster" "example" { } ``` +**NOTE:** There can only be one M0 cluster per project. + ## Example using latest sharding configurations with independent shard scaling in the cluster ```terraform @@ -96,6 +98,7 @@ In addition to all arguments above, the following attributes are exported: * `tags` - Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#tags). * `labels` - Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#labels). **(DEPRECATED.)** Use `tags` instead. * `mongo_db_major_version` - Version of the cluster to deploy. +* `pinned_fcv` - The pinned Feature Compatibility Version (FCV) with its associated expiration date. See [below](#pinned_fcv). * `pit_enabled` - Flag that indicates if the cluster uses Continuous Cloud Backup. * `replication_specs` - List of settings that configure your cluster regions. If `use_replication_spec_per_shard = true`, this array has one object per shard representing node configurations in each shard. For replica sets there is only one object representing node configurations. See [below](#replication_specs). * `root_cert_type` - Certificate Authority that MongoDB Atlas clusters use. @@ -200,8 +203,14 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le * `sample_size_bi_connector` - Number of documents per database to sample when gathering schema information. Defaults to 100. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `sample_refresh_interval_bi_connector` - Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `transaction_lifetime_limit_seconds` - Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. +* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. This parameter is supported only for MongoDB version 8.0 and above. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds This parameter is only supported for MongoDB version 6.0 and above. Defaults to `-1`(off). +### pinned_fcv + +* `expiration_date` - Expiration date of the fixed FCV. This value is in the ISO 8601 timestamp format (e.g. "2024-12-04T16:25:00Z"). +* `version` - Feature compatibility version of the cluster. + ## Attributes Reference In addition to all arguments above, the following attributes are exported: diff --git a/docs/data-sources/advanced_clusters.md b/docs/data-sources/advanced_clusters.md index 5fe861a771..2759de71a8 100644 --- a/docs/data-sources/advanced_clusters.md +++ b/docs/data-sources/advanced_clusters.md @@ -19,7 +19,7 @@ resource "mongodbatlas_advanced_cluster" "example" { replication_specs { region_configs { electable_specs { - instance_size = "M5" + instance_size = "M0" } provider_name = "TENANT" backing_provider_name = "AWS" @@ -34,6 +34,8 @@ data "mongodbatlas_advanced_clusters" "example" { } ``` +**NOTE:** There can only be one M0 cluster per project. + ## Example using latest sharding configurations with independent shard scaling in the cluster ```terraform @@ -98,6 +100,7 @@ In addition to all arguments above, the following attributes are exported: * `tags` - Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#tags). * `labels` - Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#labels). * `mongo_db_major_version` - Version of the cluster to deploy. +* `pinned_fcv` - The pinned Feature Compatibility Version (FCV) with its associated expiration date. See [below](#pinned_fcv). * `pit_enabled` - Flag that indicates if the cluster uses Continuous Cloud Backup. * `replication_specs` - List of settings that configure your cluster regions. If `use_replication_spec_per_shard = true`, this array has one object per shard representing node configurations in each shard. For replica sets there is only one object representing node configurations. See [below](#replication_specs) * `root_cert_type` - Certificate Authority that MongoDB Atlas clusters use. @@ -202,9 +205,15 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le * `oplog_min_retention_hours` - Minimum retention window for cluster's oplog expressed in hours. A value of null indicates that the cluster uses the default minimum oplog window that MongoDB Cloud calculates. * `sample_size_bi_connector` - Number of documents per database to sample when gathering schema information. Defaults to 100. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `sample_refresh_interval_bi_connector` - Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. +* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. This parameter is supported only for MongoDB version 8.0 and above. * `transaction_lifetime_limit_seconds` - (Optional) Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds. This parameter is only supported for MongoDB version 6.0 and above. Defaults to `-1`(off). +### pinned_fcv + +* `expiration_date` - Expiration date of the fixed FCV. This value is in the ISO 8601 timestamp format (e.g. "2024-12-04T16:25:00Z"). +* `version` - Feature compatibility version of the cluster. + ## Attributes Reference diff --git a/docs/data-sources/cluster.md b/docs/data-sources/cluster.md index e8f96a3e9d..0541f0df68 100644 --- a/docs/data-sources/cluster.md +++ b/docs/data-sources/cluster.md @@ -104,6 +104,7 @@ In addition to all arguments above, the following attributes are exported: * `tags` - Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#tags). * `labels` - Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#labels). **DEPRECATED** Use `tags` instead. * `mongo_db_major_version` - Indicates the version of the cluster to deploy. +* `pinned_fcv` - The pinned Feature Compatibility Version (FCV) with its associated expiration date. See [below](#pinned-fcv). * `num_shards` - Indicates whether the cluster is a replica set or a sharded cluster. * `cloud_backup` - Flag indicating if the cluster uses Cloud Backup Snapshots for backups. * `termination_protection_enabled` - Flag that indicates whether termination protection is enabled on the cluster. If set to true, MongoDB Cloud won't delete the cluster. If set to false, MongoDB Cloud will delete the cluster. @@ -233,4 +234,9 @@ Contains a key-value pair that tags that the cluster was created by a Terraform * `transaction_lifetime_limit_seconds` - Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds. This parameter is only supported for MongoDB version 6.0 and above. Defaults to `-1`(off). +### Pinned FCV + +* `expiration_date` - Expiration date of the fixed FCV. This value is in the ISO 8601 timestamp format (e.g. "2024-12-04T16:25:00Z"). +* `version` - Feature compatibility version of the cluster. + See detailed information for arguments and attributes: [MongoDB API Clusters](https://docs.atlas.mongodb.com/reference/api/clusters-create-one/) diff --git a/docs/data-sources/clusters.md b/docs/data-sources/clusters.md index 4cef071990..73d2485726 100644 --- a/docs/data-sources/clusters.md +++ b/docs/data-sources/clusters.md @@ -94,6 +94,7 @@ In addition to all arguments above, the following attributes are exported: * `tags` - Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#tags). * `labels` - Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#labels). **DEPRECATED** Use `tags` instead. * `mongo_db_major_version` - Indicates the version of the cluster to deploy. +* `pinned_fcv` - The pinned Feature Compatibility Version (FCV) with its associated expiration date. See [below](#pinned-fcv). * `num_shards` - Indicates whether the cluster is a replica set or a sharded cluster. * `provider_backup_enabled` - Flag indicating if the cluster uses Cloud Backup Snapshots for backups. **DEPRECATED** Use `cloud_backup` instead. * `cloud_backup` - Flag indicating if the cluster uses Cloud Backup Snapshots for backups. @@ -220,5 +221,9 @@ Contains a key-value pair that tags that the cluster was created by a Terraform * `sample_refresh_interval_bi_connector` - Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds. This parameter is only supported for MongoDB version 6.0 and above. Defaults to `-1`(off). +### Pinned FCV + +* `expiration_date` - Expiration date of the fixed FCV. This value is in the ISO 8601 timestamp format (e.g. "2024-12-04T16:25:00Z"). +* `version` - Feature compatibility version of the cluster. See detailed information for arguments and attributes: [MongoDB API Clusters](https://docs.atlas.mongodb.com/reference/api/clusters-create-one/) diff --git a/docs/data-sources/encryption_at_rest_private_endpoint.md b/docs/data-sources/encryption_at_rest_private_endpoint.md index 2bf3c9a263..72e1ec198a 100644 --- a/docs/data-sources/encryption_at_rest_private_endpoint.md +++ b/docs/data-sources/encryption_at_rest_private_endpoint.md @@ -26,7 +26,7 @@ output "endpoint_connection_name" { ### Required -- `cloud_provider` (String) Label that identifies the cloud provider of the private endpoint. +- `cloud_provider` (String) Label that identifies the cloud provider for the Encryption At Rest private endpoint. - `id` (String) Unique 24-hexadecimal digit string that identifies the Private Endpoint Service. - `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. diff --git a/docs/data-sources/encryption_at_rest_private_endpoints.md b/docs/data-sources/encryption_at_rest_private_endpoints.md index 91a47d78af..1338c7109c 100644 --- a/docs/data-sources/encryption_at_rest_private_endpoints.md +++ b/docs/data-sources/encryption_at_rest_private_endpoints.md @@ -25,19 +25,19 @@ output "number_of_endpoints" { ### Required -- `cloud_provider` (String) Label that identifies the cloud provider of the private endpoint. +- `cloud_provider` (String) Label that identifies the cloud provider for the Encryption At Rest private endpoint. - `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. ### Read-Only -- `results` (Attributes List) List of returned documents that MongoDB Cloud providers when completing this request. (see [below for nested schema](#nestedatt--results)) +- `results` (Attributes List) List of documents that MongoDB Cloud returns for this request. (see [below for nested schema](#nestedatt--results)) ### Nested Schema for `results` Read-Only: -- `cloud_provider` (String) Label that identifies the cloud provider of the private endpoint. +- `cloud_provider` (String) Label that identifies the cloud provider for the Encryption At Rest private endpoint. - `error_message` (String) Error message for failures associated with the Encryption At Rest private endpoint. - `id` (String) Unique 24-hexadecimal digit string that identifies the Private Endpoint Service. - `private_endpoint_connection_name` (String) Connection name of the Azure Private Endpoint. diff --git a/docs/data-sources/flex_cluster.md b/docs/data-sources/flex_cluster.md new file mode 100644 index 0000000000..6d4a9c0a28 --- /dev/null +++ b/docs/data-sources/flex_cluster.md @@ -0,0 +1,86 @@ +# Data Source: mongodbatlas_flex_cluster + +`mongodbatlas_flex_cluster` describes a flex cluster. + +**NOTE:** Flex Cluster is in Public Preview. In order to use the resource and data sources you need to set the environment variable MONGODB_ATLAS_ENABLE_PREVIEW to true. + +## Example Usages +```terraform +resource "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = var.cluster_name + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true +} + +data "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.example-cluster.name +} + +data "mongodbatlas_flex_clusters" "example-clusters" { + project_id = var.project_id +} + +output "mongodbatlas_flex_cluster" { + value = data.mongodbatlas_flex_cluster.example-cluster.name +} + +output "mongodbatlas_flex_clusters_names" { + value = [for cluster in data.mongodbatlas_flex_clusters.example-clusters.results : cluster.name] +} +``` + + +## Schema + +### Required + +- `name` (String) Human-readable label that identifies the instance. +- `project_id` (String) Unique 24-hexadecimal character string that identifies the project. + +### Read-Only + +- `backup_settings` (Attributes) Flex backup configuration (see [below for nested schema](#nestedatt--backup_settings)) +- `cluster_type` (String) Flex cluster topology. +- `connection_strings` (Attributes) Collection of Uniform Resource Locators that point to the MongoDB database. (see [below for nested schema](#nestedatt--connection_strings)) +- `create_date` (String) Date and time when MongoDB Cloud created this instance. This parameter expresses its value in ISO 8601 format in UTC. +- `id` (String) Unique 24-hexadecimal digit string that identifies the instance. +- `mongo_db_version` (String) Version of MongoDB that the instance runs. +- `provider_settings` (Attributes) Group of cloud provider settings that configure the provisioned MongoDB flex cluster. (see [below for nested schema](#nestedatt--provider_settings)) +- `state_name` (String) Human-readable label that indicates the current operating condition of this instance. +- `tags` (Map of String) Map that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the instance. +- `termination_protection_enabled` (Boolean) Flag that indicates whether termination protection is enabled on the cluster. If set to `true`, MongoDB Cloud won't delete the cluster. If set to `false`, MongoDB Cloud will delete the cluster. +- `version_release_system` (String) Method by which the cluster maintains the MongoDB versions. + + +### Nested Schema for `backup_settings` + +Read-Only: + +- `enabled` (Boolean) Flag that indicates whether backups are performed for this flex cluster. Backup uses [TODO](TODO) for flex clusters. + + + +### Nested Schema for `connection_strings` + +Read-Only: + +- `standard` (String) Public connection string that you can use to connect to this cluster. This connection string uses the mongodb:// protocol. +- `standard_srv` (String) Public connection string that you can use to connect to this flex cluster. This connection string uses the `mongodb+srv://` protocol. + + + +### Nested Schema for `provider_settings` + +Read-Only: + +- `backing_provider_name` (String) Cloud service provider on which MongoDB Cloud provisioned the flex cluster. +- `disk_size_gb` (Number) Storage capacity available to the flex cluster expressed in gigabytes. +- `provider_name` (String) Human-readable label that identifies the cloud service provider. +- `region_name` (String) Human-readable label that identifies the geographic location of your MongoDB flex cluster. The region you choose can affect network latency for clients accessing your databases. For a complete list of region names, see [AWS](https://docs.atlas.mongodb.com/reference/amazon-aws/#std-label-amazon-aws), [GCP](https://docs.atlas.mongodb.com/reference/google-gcp/), and [Azure](https://docs.atlas.mongodb.com/reference/microsoft-azure/). + +For more information see: [MongoDB Atlas API - Flex Cluster](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Flex-Clusters/operation/getFlexCluster) Documentation. diff --git a/docs/data-sources/flex_clusters.md b/docs/data-sources/flex_clusters.md new file mode 100644 index 0000000000..5f49408236 --- /dev/null +++ b/docs/data-sources/flex_clusters.md @@ -0,0 +1,94 @@ +# Data Source: mongodbatlas_flex_clusters + +`mongodbatlas_flex_clusters` returns all flex clusters in a project. + +**NOTE:** Flex Cluster is in Public Preview. In order to use the resource and data sources you need to set the environment variable MONGODB_ATLAS_ENABLE_PREVIEW to true. + +## Example Usages +```terraform +resource "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = var.cluster_name + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true +} + +data "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.example-cluster.name +} + +data "mongodbatlas_flex_clusters" "example-clusters" { + project_id = var.project_id +} + +output "mongodbatlas_flex_cluster" { + value = data.mongodbatlas_flex_cluster.example-cluster.name +} + +output "mongodbatlas_flex_clusters_names" { + value = [for cluster in data.mongodbatlas_flex_clusters.example-clusters.results : cluster.name] +} +``` + + +## Schema + +### Required + +- `project_id` (String) Unique 24-hexadecimal character string that identifies the project. + +### Read-Only + +- `results` (Attributes List) List of documents that MongoDB Cloud returns for this request. (see [below for nested schema](#nestedatt--results)) + + +### Nested Schema for `results` + +Read-Only: + +- `backup_settings` (Attributes) Flex backup configuration (see [below for nested schema](#nestedatt--results--backup_settings)) +- `cluster_type` (String) Flex cluster topology. +- `connection_strings` (Attributes) Collection of Uniform Resource Locators that point to the MongoDB database. (see [below for nested schema](#nestedatt--results--connection_strings)) +- `create_date` (String) Date and time when MongoDB Cloud created this instance. This parameter expresses its value in ISO 8601 format in UTC. +- `id` (String) Unique 24-hexadecimal digit string that identifies the instance. +- `mongo_db_version` (String) Version of MongoDB that the instance runs. +- `name` (String) Human-readable label that identifies the instance. +- `project_id` (String) Unique 24-hexadecimal character string that identifies the project. +- `provider_settings` (Attributes) Group of cloud provider settings that configure the provisioned MongoDB flex cluster. (see [below for nested schema](#nestedatt--results--provider_settings)) +- `state_name` (String) Human-readable label that indicates the current operating condition of this instance. +- `tags` (Map of String) Map that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the instance. +- `termination_protection_enabled` (Boolean) Flag that indicates whether termination protection is enabled on the cluster. If set to `true`, MongoDB Cloud won't delete the cluster. If set to `false`, MongoDB Cloud will delete the cluster. +- `version_release_system` (String) Method by which the cluster maintains the MongoDB versions. + + +### Nested Schema for `results.backup_settings` + +Read-Only: + +- `enabled` (Boolean) Flag that indicates whether backups are performed for this flex cluster. Backup uses [TODO](TODO) for flex clusters. + + + +### Nested Schema for `results.connection_strings` + +Read-Only: + +- `standard` (String) Public connection string that you can use to connect to this cluster. This connection string uses the mongodb:// protocol. +- `standard_srv` (String) Public connection string that you can use to connect to this flex cluster. This connection string uses the `mongodb+srv://` protocol. + + + +### Nested Schema for `results.provider_settings` + +Read-Only: + +- `backing_provider_name` (String) Cloud service provider on which MongoDB Cloud provisioned the flex cluster. +- `disk_size_gb` (Number) Storage capacity available to the flex cluster expressed in gigabytes. +- `provider_name` (String) Human-readable label that identifies the cloud service provider. +- `region_name` (String) Human-readable label that identifies the geographic location of your MongoDB flex cluster. The region you choose can affect network latency for clients accessing your databases. For a complete list of region names, see [AWS](https://docs.atlas.mongodb.com/reference/amazon-aws/#std-label-amazon-aws), [GCP](https://docs.atlas.mongodb.com/reference/google-gcp/), and [Azure](https://docs.atlas.mongodb.com/reference/microsoft-azure/). + +For more information see: [MongoDB Atlas API - Flex Clusters](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Streams/operation/listFlexClusters) Documentation. diff --git a/docs/data-sources/privatelink_endpoint_service_serverless.md b/docs/data-sources/privatelink_endpoint_service_serverless.md index 224a17c1e0..bc054fa0fc 100644 --- a/docs/data-sources/privatelink_endpoint_service_serverless.md +++ b/docs/data-sources/privatelink_endpoint_service_serverless.md @@ -1,3 +1,9 @@ +--- +subcategory: "Deprecated" +--- + +**WARNING:** This data source is deprecated and will be removed in March 2025. For more datails see [Migration Guide: Transition out of Serverless Instances and Shared-tier clusters](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide) + # Data Source: privatelink_endpoint_service_serverless `privatelink_endpoint_service_serverless` provides a Serverless PrivateLink Endpoint Service resource. diff --git a/docs/data-sources/privatelink_endpoints_service_serverless.md b/docs/data-sources/privatelink_endpoints_service_serverless.md index 6740e49d52..997b84a29f 100644 --- a/docs/data-sources/privatelink_endpoints_service_serverless.md +++ b/docs/data-sources/privatelink_endpoints_service_serverless.md @@ -1,3 +1,9 @@ +--- +subcategory: "Deprecated" +--- + +**WARNING:** This data source is deprecated and will be removed in March 2025. For more datails see [Migration Guide: Transition out of Serverless Instances and Shared-tier clusters](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide) + # Data Source: privatelink_endpoints_service_serverless `privatelink_endpoints_service_serverless` describes the list of all Serverless PrivateLink Endpoint Service resource. diff --git a/docs/data-sources/resource_policies.md b/docs/data-sources/resource_policies.md index 792fb4a5f9..b1af9e290c 100644 --- a/docs/data-sources/resource_policies.md +++ b/docs/data-sources/resource_policies.md @@ -98,7 +98,7 @@ output "policy_ids" { ### Read-Only - `resource_policies` (Attributes List, Deprecated) (see [below for nested schema](#nestedatt--resource_policies)) -- `results` (Attributes List) (see [below for nested schema](#nestedatt--results)) +- `results` (Attributes List) List of documents that MongoDB Cloud returns for this request. (see [below for nested schema](#nestedatt--results)) ### Nested Schema for `resource_policies` diff --git a/docs/data-sources/serverless_instance.md b/docs/data-sources/serverless_instance.md index 48a0be84d7..6776c53b2f 100644 --- a/docs/data-sources/serverless_instance.md +++ b/docs/data-sources/serverless_instance.md @@ -43,9 +43,9 @@ Follow this example to [setup private connection to a serverless instance using * `provider_settings_provider_name` - Cloud service provider that applies to the provisioned the serverless instance. * `provider_settings_region_name` - Human-readable label that identifies the physical location of your MongoDB serverless instance. The region you choose can affect network latency for clients accessing your databases. * `state_name` - Stage of deployment of this serverless instance when the resource made its request. -* `continuous_backup_enabled` - Flag that indicates whether the serverless instance uses Serverless Continuous Backup. +* `continuous_backup_enabled` - (Deprecated) Flag that indicates whether the serverless instance uses Serverless Continuous Backup. * `termination_protection_enabled` - Flag that indicates whether termination protection is enabled on the cluster. If set to true, MongoDB Cloud won't delete the cluster. If set to false, MongoDB Cloud will delete the cluster. -* `auto_indexing` - Flag that indicates whether the serverless instance uses [Serverless Auto Indexing](https://www.mongodb.com/docs/atlas/performance-advisor/auto-index-serverless/). +* `auto_indexing` - (Deprecated) Flag that indicates whether the serverless instance uses [Serverless Auto Indexing](https://www.mongodb.com/docs/atlas/performance-advisor/auto-index-serverless/). * `tags` - Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#tags). ### Tags diff --git a/docs/data-sources/serverless_instances.md b/docs/data-sources/serverless_instances.md index 5dfb38816f..1c7a976d53 100644 --- a/docs/data-sources/serverless_instances.md +++ b/docs/data-sources/serverless_instances.md @@ -34,9 +34,9 @@ data "mongodbatlas_serverless_instances" "data_serverless" { * `provider_settings_provider_name` - Cloud service provider that applies to the provisioned the serverless instance. * `provider_settings_region_name` - Human-readable label that identifies the physical location of your MongoDB serverless instance. The region you choose can affect network latency for clients accessing your databases. * `state_name` - Stage of deployment of this serverless instance when the resource made its request. -* `continuous_backup_enabled` - Flag that indicates whether the serverless instance uses Serverless Continuous Backup. +* `continuous_backup_enabled` - (Deprecated) Flag that indicates whether the serverless instance uses Serverless Continuous Backup. * `termination_protection_enabled` - Flag that indicates whether termination protection is enabled on the cluster. If set to true, MongoDB Cloud won't delete the cluster. If set to false, MongoDB Cloud will delete the cluster. -* `auto_indexing` - Flag that indicates whether the serverless instance uses [Serverless Auto Indexing](https://www.mongodb.com/docs/atlas/performance-advisor/auto-index-serverless/). +* `auto_indexing` - (Deprecated) Flag that indicates whether the serverless instance uses [Serverless Auto Indexing](https://www.mongodb.com/docs/atlas/performance-advisor/auto-index-serverless/). * `tags` - Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#tags). ### Tags diff --git a/docs/data-sources/stream_processor.md b/docs/data-sources/stream_processor.md index ae220bafa0..aff1c3bc37 100644 --- a/docs/data-sources/stream_processor.md +++ b/docs/data-sources/stream_processor.md @@ -127,9 +127,11 @@ output "stream_processors_results" { - `id` (String) Unique 24-hexadecimal character string that identifies the stream processor. - `options` (Attributes) Optional configuration for the stream processor. (see [below for nested schema](#nestedatt--options)) -- `pipeline` (String) Stream aggregation pipeline you want to apply to your streaming data. -- `state` (String) The state of the stream processor. -- `stats` (String) The stats associated with the stream processor. +- `pipeline` (String) Stream aggregation pipeline you want to apply to your streaming data. [MongoDB Atlas Docs](https://www.mongodb.com/docs/atlas/atlas-stream-processing/stream-aggregation/#std-label-stream-aggregation) contain more information. Using [jsonencode](https://developer.hashicorp.com/terraform/language/functions/jsonencode) is recommended when setting this attribute. For more details see the [Aggregation Pipelines Documentation](https://www.mongodb.com/docs/atlas/atlas-stream-processing/stream-aggregation/) +- `state` (String) The state of the stream processor. Commonly occurring states are 'CREATED', 'STARTED', 'STOPPED' and 'FAILED'. Used to start or stop the Stream Processor. Valid values are `CREATED`, `STARTED` or `STOPPED`. When a Stream Processor is created without specifying the state, it will default to `CREATED` state. + +**NOTE** When creating a stream processor, setting the state to STARTED can automatically start the stream processor. +- `stats` (String) The stats associated with the stream processor. Refer to the [MongoDB Atlas Docs](https://www.mongodb.com/docs/atlas/atlas-stream-processing/manage-stream-processor/#view-statistics-of-a-stream-processor) for more information. ### Nested Schema for `options` diff --git a/docs/data-sources/stream_processors.md b/docs/data-sources/stream_processors.md index b34ecbbe85..9535b9d472 100644 --- a/docs/data-sources/stream_processors.md +++ b/docs/data-sources/stream_processors.md @@ -138,13 +138,15 @@ Read-Only: - `id` (String) Unique 24-hexadecimal character string that identifies the stream processor. - `instance_name` (String) Human-readable label that identifies the stream instance. - `options` (Attributes) Optional configuration for the stream processor. (see [below for nested schema](#nestedatt--results--options)) -- `pipeline` (String) Stream aggregation pipeline you want to apply to your streaming data. +- `pipeline` (String) Stream aggregation pipeline you want to apply to your streaming data. [MongoDB Atlas Docs](https://www.mongodb.com/docs/atlas/atlas-stream-processing/stream-aggregation/#std-label-stream-aggregation) contain more information. Using [jsonencode](https://developer.hashicorp.com/terraform/language/functions/jsonencode) is recommended when setting this attribute. For more details see the [Aggregation Pipelines Documentation](https://www.mongodb.com/docs/atlas/atlas-stream-processing/stream-aggregation/) - `processor_name` (String) Human-readable label that identifies the stream processor. - `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access. **NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups. -- `state` (String) The state of the stream processor. -- `stats` (String) The stats associated with the stream processor. +- `state` (String) The state of the stream processor. Commonly occurring states are 'CREATED', 'STARTED', 'STOPPED' and 'FAILED'. Used to start or stop the Stream Processor. Valid values are `CREATED`, `STARTED` or `STOPPED`. When a Stream Processor is created without specifying the state, it will default to `CREATED` state. + +**NOTE** When creating a stream processor, setting the state to STARTED can automatically start the stream processor. +- `stats` (String) The stats associated with the stream processor. Refer to the [MongoDB Atlas Docs](https://www.mongodb.com/docs/atlas/atlas-stream-processing/manage-stream-processor/#view-statistics-of-a-stream-processor) for more information. ### Nested Schema for `results.options` diff --git a/docs/guides/1.12.0-upgrade-guide.md b/docs/guides/1.12.0-upgrade-guide.md index 98f63a3aea..3bb80e8ffe 100644 --- a/docs/guides/1.12.0-upgrade-guide.md +++ b/docs/guides/1.12.0-upgrade-guide.md @@ -1,5 +1,6 @@ --- page_title: "Upgrade Guide 1.12.0" +subcategory: "Older Guides" --- # MongoDB Atlas Provider 1.12.0: Upgrade and Information Guide diff --git a/docs/guides/1.13.0-upgrade-guide.md b/docs/guides/1.13.0-upgrade-guide.md index fcd697d4f1..14d39295f7 100644 --- a/docs/guides/1.13.0-upgrade-guide.md +++ b/docs/guides/1.13.0-upgrade-guide.md @@ -1,5 +1,6 @@ --- page_title: "Upgrade Guide 1.13.0" +subcategory: "Older Guides" --- # MongoDB Atlas Provider 1.13.0: Upgrade and Information Guide diff --git a/docs/guides/1.22.0-upgrade-guide.md b/docs/guides/1.22.0-upgrade-guide.md new file mode 100644 index 0000000000..7f0f96cb1d --- /dev/null +++ b/docs/guides/1.22.0-upgrade-guide.md @@ -0,0 +1,30 @@ +--- +page_title: "Upgrade Guide 1.22.0" +--- + +# MongoDB Atlas Provider 1.22.0: Upgrade and Information Guide + +The Terraform MongoDB Atlas Provider version 1.22.0 has a number of new and exciting features. + +## New Resources, Data Sources, and Features + +- You can now manage Flex Clusters with the new `mongodbatlas_flex_cluster` resource and corresponding data sources. The feature is available as a preview feature. To learn more, please review `mongodbatlas_flex_cluster` [resource documentation](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/flex_cluster). + +## Deprecations and removals + +- `continuous_backup_enabled` attribute is deprecated in `mongodbatlas_serverless_instance` resource and data sources. If your workload requires this feature, we recommend switching to Atlas Dedicated clusters. To learn more, see the [Migration Guide: Transition out of Serverless Instances and Shared-tier clusters](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide). +- `auto_indexing` attribute is deprecated in `mongodbatlas_serverless_instance` resource and data sources. If your workload requires this feature, we recommend switching to Atlas Dedicated clusters. To learn more, please see the [Migration Guide: Transition out of Serverless Instances and Shared-tier clusters](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide). +- `mongodbatlas_privatelink_endpoint_serverless` resource is deprecated. If your workload requires this feature, we recommend switching to Atlas Dedicated clusters. To learn more, please see the [Migration Guide: Transition out of Serverless Instances and Shared-tier clusters](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide). +- `mongodbatlas_privatelink_endpoint_service_serverless` resource, `mongodbatlas_privatelink_endpoint_service_serverless` and `mongodbatlas_privatelink_endpoints_service_serverless` data sources are deprecated. If your workload requires this feature, we recommend switching to Atlas Dedicated clusters. To learn more, please see the [Migration Guide: Transition out of Serverless Instances and Shared-tier clusters](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide). + +## Terraform MongoDB Atlas modules + +You can now leverage our [Terraform Modules](https://registry.terraform.io/namespaces/terraform-mongodbatlas-modules) to easily get started with MongoDB Atlas and critical features like [Push-based log export](https://registry.terraform.io/modules/terraform-mongodbatlas-modules/push-based-log-export/mongodbatlas/latest), [Private Endpoints](https://registry.terraform.io/modules/terraform-mongodbatlas-modules/private-endpoint/mongodbatlas/latest), etc. + +## Helpful Links + +* [Report bugs](https://github.com/mongodb/terraform-provider-mongodbatlas/issues) + +* [Request Features](https://feedback.mongodb.com/forums/924145-atlas?category_id=370723) + +* [Contact Support](https://docs.atlas.mongodb.com/support/) covered by MongoDB Atlas support plans, Developer and above. diff --git a/docs/guides/flex-cluster-to-dedicated-cluster-migraton-guide.md b/docs/guides/flex-cluster-to-dedicated-cluster-migraton-guide.md new file mode 100644 index 0000000000..466eb03107 --- /dev/null +++ b/docs/guides/flex-cluster-to-dedicated-cluster-migraton-guide.md @@ -0,0 +1,65 @@ +--- +page_title: "Migration Guide: Flex Cluster to Dedicated Cluster" +--- + +# Migration Guide: Flex Cluster to Dedicated Cluster + +**Objective**: This guide explains how to replace the `mongodbatlas_flex_cluster` resource with the `mongodbatlas_advanced_cluster` resource. + +Currently, the only method to migrate your Flex cluster to a Dedicated cluster is via the Atlas UI. + + + +## Best Practices Before Migrating +Before doing any migration, create a backup of your [Terraform state file](https://developer.hashicorp.com/terraform/cli/commands/state). + +### Procedure + + +See [Modify a Cluster](https://www.mongodb.com/docs/atlas/scale-cluster/) for how to migrate via the Atlas UI. + +Complete the following procedure to resolves the configuration drift in Terraform. This does not affect the underlying cluster infrastructure. + +1. Find the import IDs of the new Dedicated cluster your Flex cluster has migrated to: `{PROJECT_ID}-{CLUSTER_NAME}`, such as `664619d870c247237f4b86a6-clusterName` +2. Add an import block to one of your `.tf` files: + ```terraform + import { + to = mongodbatlas_advanced_cluster.this + id = "664619d870c247237f4b86a6-clusterName" # from step 1 + } + ``` + 3. Run `terraform plan -generate-config-out=adv_cluster.tf`. This should generate a `adv_cluster.tf` file. + 4. Run `terraform apply`. You should see the resource imported: `Apply complete! Resources: 1 imported, 0 added, 0 changed, 0 destroyed.` + 5. Remove the "default" fields. Many fields of this resource are optional. Look for fields with a `null` or `0` value or blocks you didn't specify before. Required fields have been outlined in the below example resource block: + ``` terraform + resource "mongodbatlas_advanced_cluster" "this" { + cluster_type = "REPLICASET" + name = "clusterName" + project_id = "664619d870c247237f4b86a6" + replication_specs { + zone_name = "Zone 1" + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "EU_WEST_1" + analytics_specs { + instance_size = "M10" + node_count = 0 + } + electable_specs { + instance_size = "M10" + node_count = 3 + } + } + } + } + ``` + 6. Re-use existing [Terraform expressions](https://developer.hashicorp.com/terraform/language/expressions). All fields in the generated configuration have static values. Look in your previous configuration for: + - variables, for example: `var.project_id` + - Terraform keywords, for example: `for_each`, `count`, and `depends_on` + 7. Re-run `terraform apply` to ensure you have no planned changes: `No changes. Your infrastructure matches the configuration.` + 8. Update the references from your previous cluster resource: `mongodbatlas_flex_cluster.this.X` to the new `mongodbatlas_advanced_cluster.this.X`. + 9. Update any data source blocks to refer to `mongodbatlas_advanced_cluster`. + 10. Replace your existing clusters with the ones from `adv_cluster.tf` and run `terraform state rm mongodbatlas_flex_cluster.this`. Without this step, Terraform creates a plan to delete your existing cluster. + 11. Remove the import block created in step 2. + 12. Re-run `terraform apply` to ensure you have no planned changes: `No changes. Your infrastructure matches the configuration.` diff --git a/docs/guides/serverless-shared-migration-guide.md b/docs/guides/serverless-shared-migration-guide.md new file mode 100644 index 0000000000..04c0c7a859 --- /dev/null +++ b/docs/guides/serverless-shared-migration-guide.md @@ -0,0 +1,267 @@ +--- +page_title: "Migration Guide: Transition out of Serverless Instances and Shared-tier clusters" +--- + +# Migration Guide: Transition out of Serverless Instances and Shared-tier clusters + +The goal of this guide is to help users transition from Serverless Instances and Shared-tier clusters (M2/M5) to Free, Flex or Dedicated Clusters. + +Starting in January 2025 or later, all Shared-tier clusters (in both `mongodbatlas_cluster` and `mongodbatlas_advanced_cluster`) will automatically convert to Flex clusters. Similarly, in March 2025 all Serverless instances (`mongodb_serverless_instance`) will be converted into Free/Flex/Dedicated clusters, [depending on your existing configuration](https://www.mongodb.com/docs/atlas/flex-migration/). +If a Serverless instance has $0 MRR, it automatically converts into a Free cluster. Else, if it does not fit the constraints of a Flex cluster, it will convert into a Dedicated cluster, resulting in downtime and workload disruption. Otherwise, it will convert to a Flex cluster. +Some of these conversions will result in configuration drift in Terraform. + + +You can migrate from Serverless instances and Shared-tier clusters manually before autoconversion. + +**--> NOTE:** We recommend waiting until March 2025 or later for Serverless instances and Shared-tier clusters to autoconvert. + +For Shared-tier clusters, we are working on enhancing the User Experience such that Terraform Atlas Providers users can make even fewer required changes to their scripts from what is shown below. More updates to come over the next few months. For more details reach out to: zuhair.ahmed@mongodb.com + +### Jump to: +- [Shared-tier to Flex](#from-shared-tier-clusters-to-flex) +- [Serverless to Free](#from-serverless-to-free) +- [Serverless to Flex](#from-serverless-to-flex) +- [Serverless to Dedicated](#from-serverless-to-dedicated) + +## From Shared-tier clusters to Flex + +### Post-Autoconversion Migration Procedure + +Shared-tier clusters will automatically convert in January 2025 or later to Flex clusters in Atlas, retaining all data. We recommend to migrate to `mongodbatlas_flex_cluster` resource once the autoconversion is done. + +The following steps explain how to move your exising Shared-tier cluster resource to the new `mongodbatlas_flex_cluster` resource and does not affect the underlying cluster infrastructure: + +1. Find the import IDs of the Flex clusters: `{PROJECT_ID}-{CLUSTER_NAME}`, such as `664619d870c247237f4b86a6-flexClusterName` +2. Add an import block per cluster to one of your `.tf` files: + ```terraform + import { + to = mongodbatlas_flex_cluster.this + id = "664619d870c247237f4b86a6-flexClusterName" # from step 1 + } + ``` +3. Run `terraform plan -generate-config-out=flex_cluster.tf`. This should generate a `flex_cluster.tf` file with your Flex cluster in it. +4. Run `terraform apply`. You should see the resource(s) imported: `Apply complete! Resources: 1 imported, 0 added, 0 changed, 0 destroyed.` +5. Remove the "default" fields. Many fields of this resource are optional. Look for fields with a `null` or `0` value. +6. Re-use existing [Terraform expressions](https://developer.hashicorp.com/terraform/language/expressions). All fields in the generated configuration have static values. Look in your previous configuration for: + - variables, for example: `var.project_id` + - Terraform keywords, for example: `for_each`, `count`, and `depends_on` +7. Update the references from your previous cluster resource: `mongodbatlas_advanced_cluster.this.X` or `mongodbatlas_cluster.this.X` to the new `mongodbatlas_flex_cluster.this.X`. +8. Update any shared-tier data source blocks to refer to `mongodbatlas_flex_cluster`. +9. Replace your existing clusters with the ones from `flex_cluster.tf` and run + + `terraform state rm mongodbatlas_advanced_cluster.this` + + or `terraform state rm mongodbatlas_cluster.this`. + + Without this step, Terraform creates a plan to delete your existing cluster. + +10. Remove the import block created in step 2. +11. Re-run `terraform plan` to ensure you have no planned changes: `No changes. Your infrastructure matches the configuration.` + +### Pre-Autoconversion Migration Procedure + +**NOTE:** We recommend waiting until January 2025 or later for Shared-tier clusters to autoconvert. Manually doing the migration can cause downtime and workload disruption. + +1. Create a new Flex Cluster directly from your `.tf` file, e.g.: + + ```terraform + resource "mongodbatlas_flex_cluster" "this" { + project_id = var.project_id + name = "flexClusterName" + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true + } + ``` +2. Run `terraform apply` to create the new resource. +3. Migrate data from your Shared-tier cluster to the Flex cluster using `mongodump` and `mongostore`. + + Please see the following guide on how to retrieve data from one cluster and store it in another cluster: [Convert a Serverless Instance to a Dedicated Cluster](https://www.mongodb.com/docs/atlas/tutorial/convert-serverless-to-dedicated/) + + Verify that your data is present within the Flex cluster before proceeding. +4. Delete the Shared-tier cluster by running a destroy command against it. + + For *mongodbatlas_advanced_cluster*: + + `terraform destroy -target=mongodbatlas_advanced_cluster.this` + + For *mongodbatlas_cluster*: + + `terraform destroy -target=mongodbatlas_cluster.this` + + 5. Remove the resource block for the Shared-tier cluster from your `.tf` file. + +## From Serverless to Free + +**Please ensure your Serverless instance meets the following requirements to migrate to Free:** +- $0 MRR + +### Post-Autoconversion Migration Procedure + +Given your Serverless Instance has $0 MRR, it will automatically convert in March 2025 into a Free cluster in Atlas, retaining all data. + +The following steps resolve the configuration drift in Terraform without affecting the underlying cluster infrastructure: + +1. Find the import IDs of the Free clusters: `{PROJECT_ID}-{CLUSTER_NAME}`, such as `664619d870c247237f4b86a6-freeClusterName` +2. Add an import block per cluster to one of your `.tf` files: + ```terraform + import { + to = mongodbatlas_advanced_cluster.this + id = "664619d870c247237f4b86a6-freeClusterName" # from step 1 + } + ``` +3. Run `terraform plan -generate-config-out=free_cluster.tf`. This should generate a `free_cluster.tf` file with your Free cluster in it. +4. Run `terraform apply`. You should see the resource(s) imported: `Apply complete! Resources: 1 imported, 0 added, 0 changed, 0 destroyed.` +5. Remove the "default" fields. Many fields of this resource are optional. Look for fields with a `null` or `0` value. +6. Re-use existing [Terraform expressions](https://developer.hashicorp.com/terraform/language/expressions). All fields in the generated configuration have static values. Look in your previous configuration for: + - variables, for example: `var.project_id` + - Terraform keywords, for example: `for_each`, `count`, and `depends_on` +7. Update the references from your previous cluster resource: `mongodbatlas_serverless_instance.this.X` to the new `mongodbatlas_advanced_cluster.this.X`. +8. Update any shared-tier data source blocks to refer to `mongodbatlas_advanced_cluster`. +9. Replace your existing clusters with the ones from `free_cluster.tf` and run `terraform state rm mongodbatlas_serverless_instance.this`. Without this step, Terraform creates a plan to delete your existing cluster. +10. Remove the import block created in step 2. +11. Re-run `terraform plan` to ensure you have no planned changes: `No changes. Your infrastructure matches the configuration.` + +### Pre-Autoconversion Migration Procedure + +**NOTE:** We recommend waiting until March 2025 or later for Serverless instances to autoconvert. Manually doing the migration can cause downtime and workload disruption. + +1. Create a new Free Cluster directly from your `.tf` file, e.g.: + + ```terraform + resource "mongodbatlas_advanced_cluster" "this" { + project_id = var.atlas_project_id + name = "freeClusterName" + cluster_type = "REPLICASET" + + replication_specs { + region_configs { + electable_specs { + instance_size = "M0" + } + provider_name = "TENANT" + backing_provider_name = "AWS" + region_name = "US_EAST_1" + priority = 7 + } + } + } + ``` +2. Run `terraform apply` to create the new resource. +3. Migrate data from your Serverless Instance to the Free cluster using `mongodump` and `mongostore`. + + Please see the following guide on how to retrieve data from one cluster and store it in another cluster: [Convert a Serverless Instance to a Dedicated Cluster](https://www.mongodb.com/docs/atlas/tutorial/convert-serverless-to-dedicated/) + + Verify that your data is present within the Free cluster before proceeding. +4. Delete the Serverless Instance by running a destroy command against the Serverless Instance: + + `terraform destroy -target=mongodbatlas_serverless_instance.this` + + 5. Remove the resource block for the Serverless Instance from your `.tf` file. + +## From Serverless to Flex + +**Please ensure your Serverless instance meets the following requirements to migrate to Flex:** +- <= 5GB of data +- no privatelink or continuous backup +- < 500 ops/sec consistently. + +### Post-Autoconversion Migration Procedure + +Given your Serverless Instance fits the constraints of a Flex cluster, it will automatically convert in March 2025 into a Flex cluster in Atlas, retaining all data. We recommend to migrate to `mongodbatlas_flex_cluster` resource once the autoconversion is done. + +The following steps explain how to move your exising Serverless instance resource to the new `mongodbatlas_flex_cluster` resource and does not affect the underlying cluster infrastructure: + +1. Find the import IDs of the Flex clusters: `{PROJECT_ID}-{CLUSTER_NAME}`, such as `664619d870c247237f4b86a6-flexClusterName` +2. Add an import block per cluster to one of your `.tf` files: + ```terraform + import { + to = mongodbatlas_flex_cluster.this + id = "664619d870c247237f4b86a6-flexClusterName" # from step 1 + } + ``` +3. Run `terraform plan -generate-config-out=flex_cluster.tf`. This should generate a `flex_cluster.tf` file with your Flex cluster in it. +4. Run `terraform apply`. You should see the resource(s) imported: `Apply complete! Resources: 1 imported, 0 added, 0 changed, 0 destroyed.` +5. Remove the "default" fields. Many fields of this resource are optional. Look for fields with a `null` or `0` value. +6. Re-use existing [Terraform expressions](https://developer.hashicorp.com/terraform/language/expressions). All fields in the generated configuration have static values. Look in your previous configuration for: + - variables, for example: `var.project_id` + - Terraform keywords, for example: `for_each`, `count`, and `depends_on` +7. Update the references from your previous cluster resource: `mongodbatlas_serverless_instance.this.X` to the new `mongodbatlas_flex_cluster.this.X`. +8. Update any shared-tier data source blocks to refer to `mongodbatlas_flex_cluster`. +9. Replace your existing clusters with the ones from `flex_cluster.tf` and run `terraform state rm mongodbatlas_serverless_instance.this`. Without this step, Terraform creates a plan to delete your existing cluster. +10. Remove the import block created in step 2. +11. Re-run `terraform plan` to ensure you have no planned changes: `No changes. Your infrastructure matches the configuration.` + +### Pre-Autoconversion Migration Procedure + +**NOTE:** We recommend waiting until March 2025 or later for Serverless instances to autoconvert. Manual migration can cause downtime and workload disruption. + +1. Create a new Flex Cluster directly from your `.tf` file, e.g.: + + ```terraform + resource "mongodbatlas_flex_cluster" "this" { + project_id = var.project_id + name = "flexClusterName" + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true + } + ``` +2. Run `terraform apply` to create the new resource. +3. Migrate data from your Serverless Instance to the Flex cluster using `mongodump` and `mongostore`. + + Please see the following guide on how to retrieve data from one cluster and store it in another cluster: [Convert a Serverless Instance to a Dedicated Cluster](https://www.mongodb.com/docs/atlas/tutorial/convert-serverless-to-dedicated/) + + Verify that your data is present within the Flex cluster before proceeding. +4. Delete the Serverless Instance by running a destroy command against it: + + `terraform destroy -target=mongodbatlas_serverless_instance.this` + + 5. You may now safely remove the resource block for the Serverless Instance from your `.tf` file. + +## From Serverless to Dedicated + +**Please note your Serverless instance will need to migrate to Decidated if it meets the following requirements:** +- \>= 5GB of data +- needs privatelink or continuous backup +- \> 500 ops/sec consistently. + +You cannot migrate from Serverless to Dedicated using the Terraform provider. + +### Pre-Autoconversion Migration Procedure + +**NOTE:** In early 2025, we will release a UI-based tool for migrating your workloads from Serverless instances to Dedicated clusters. This tool will ensure correct migration with little downtime. You won't need to change connection strings. + +To migrate from Serverless to Dedicated prior to early 2025, please see the following guide: [Convert a Serverless Instance to a Dedicated Cluster](https://www.mongodb.com/docs/atlas/tutorial/convert-serverless-to-dedicated/). **NOTE:** Manual migration can cause downtime and workload disruption. + +### Post-Autoconversion Migration Procedure + +**NOTE:** Auto-conversion from Serverless to Dedicated will cause downtime and workload disruption. This guide is only valid after the auto-conversion is done. + +Given your Serverless Instance doesn't fit the constraints of a Flex cluster, it will automatically convert in March 2025 into a Dedicated cluster in Atlas, retaining all data. + +The following steps resolve the configuration drift in Terraform and does not affect the underlying cluster infrastructure: + +1. Find the import IDs of the Dedicated clusters: `{PROJECT_ID}-{CLUSTER_NAME}`, such as `664619d870c247237f4b86a6-advancedClusterName` +2. Add an import block per cluster to one of your `.tf` files: + ```terraform + import { + to = mongodbatlas_advanced_cluster.this + id = "664619d870c247237f4b86a6-advancedClusterName" # from step 1 + } + ``` +3. Run `terraform plan -generate-config-out=dedicated_cluster.tf`. This should generate a `dedicated_cluster.tf` file with your Dedicated cluster in it. +4. Run `terraform apply`. You should see the resource(s) imported: `Apply complete! Resources: 1 imported, 0 added, 0 changed, 0 destroyed.` +5. Remove the "default" fields. Many fields of this resource are optional. Look for fields with a `null` or `0` value. +6. Re-use existing [Terraform expressions](https://developer.hashicorp.com/terraform/language/expressions). All fields in the generated configuration have static values. Look in your previous configuration for: + - variables, for example: `var.project_id` + - Terraform keywords, for example: `for_each`, `count`, and `depends_on` +7. Update the references from your previous cluster resource: `mongodbatlas_serverless_instance.this.X` to the new `mongodbatlas_advanced_cluster.this.X`. +8. Update any shared-tier data source blocks to refer to `mongodbatlas_advanced_cluster`. +9. Replace your existing clusters with the ones from `dedicated_cluster.tf` and run `terraform state rm mongodbatlas_serverless_instance.this`. Without this step, Terraform creates a plan to delete your existing cluster. +10. Remove the import block created in step 2. +11. Re-run `terraform plan` to ensure you have no planned changes: `No changes. Your infrastructure matches the configuration.` diff --git a/docs/index.md b/docs/index.md index b294bf3c00..156b21dfd9 100644 --- a/docs/index.md +++ b/docs/index.md @@ -179,6 +179,7 @@ For more information on configuring and managing programmatic API Keys see the [ | HashiCorp Terraform Release | HashiCorp Terraform Release Date | HashiCorp Terraform Full Support End Date | MongoDB Atlas Support End Date | |:-------:|:------------:|:------------:|:------------:| +| 1.10.x | 2024-11-27 | 2026-11-30 | 2026-11-30 | | 1.9.x | 2024-06-26 | 2026-06-30 | 2026-06-30 | | 1.8.x | 2024-04-10 | 2026-04-30 | 2026-04-30 | | 1.7.x | 2024-01-17 | 2026-01-31 | 2026-01-31 | @@ -220,7 +221,7 @@ We ship binaries but do not prioritize fixes for the following operating system ## Examples from MongoDB and the Community -We have [example configurations](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/v1.21.4/examples) +We have [example configurations](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/v1.22.0/examples) in our GitHub repo that will help both beginner and more advanced users. Have a good example you've created and want to share? diff --git a/docs/resources/advanced_cluster.md b/docs/resources/advanced_cluster.md index b153901cc2..03cbee9022 100644 --- a/docs/resources/advanced_cluster.md +++ b/docs/resources/advanced_cluster.md @@ -56,7 +56,7 @@ resource "mongodbatlas_advanced_cluster" "test" { replication_specs { region_configs { electable_specs { - instance_size = "M5" + instance_size = "M0" } provider_name = "TENANT" backing_provider_name = "AWS" @@ -67,6 +67,8 @@ resource "mongodbatlas_advanced_cluster" "test" { } ``` +**NOTE:** There can only be one M0 cluster per project. + **NOTE**: Upgrading the shared tier is supported. Any change from a shared tier cluster (a tenant) to a different instance size will be considered a tenant upgrade. When upgrading from the shared tier, change the `provider_name` from "TENANT" to your preferred provider (AWS, GCP or Azure) and remove the variable `backing_provider_name`. See the [Example Tenant Cluster Upgrade](#Example-Tenant-Cluster-Upgrade) below. You can upgrade a shared tier cluster only to a single provider on an M10-tier cluster or greater. When upgrading from the shared tier, *only* the upgrade changes will be applied. This helps avoid a corrupt state file in the event that the upgrade succeeds but subsequent updates fail within the same `terraform apply`. To apply additional cluster changes, run a secondary `terraform apply` after the upgrade succeeds. @@ -383,7 +385,8 @@ This parameter defaults to false. * `tags` - (Optional) Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#tags). * `labels` - (Optional) Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#labels). **DEPRECATED** Use `tags` instead. * `mongo_db_major_version` - (Optional) Version of the cluster to deploy. Atlas supports all the MongoDB versions that have **not** reached [End of Live](https://www.mongodb.com/legal/support-policy/lifecycles) for M10+ clusters. If omitted, Atlas deploys the cluster with the default version. For more details, see [documentation](https://www.mongodb.com/docs/atlas/reference/faq/database/#which-versions-of-mongodb-do-service-clusters-use-). Atlas always deploys the cluster with the latest stable release of the specified version. If you set a value to this parameter and set `version_release_system` `CONTINUOUS`, the resource returns an error. Either clear this parameter or set `version_release_system`: `LTS`. -* `pit_enabled` - (Optional) - Flag that indicates if the cluster uses Continuous Cloud Backup. +* `pinned_fcv` - (Optional) Pins the Feature Compatibility Version (FCV) to the current MongoDB version with a provided expiration date. To unpin the FCV the `pinned_fcv` attribute must be removed. This operation can take several minutes as the request processes through the MongoDB data plane. Once FCV is unpinned it will not be possible to downgrade the `mongo_db_major_version`. It is advised that updates to `pinned_fcv` are done isolated from other cluster changes. If a plan contains multiple changes, the FCV change will be applied first. If FCV is unpinned past the expiration date the `pinned_fcv` attribute must be removed. The following [knowledge hub article](https://kb.corp.mongodb.com/article/000021785/) and [FCV documentation](https://www.mongodb.com/docs/atlas/tutorial/major-version-change/#manage-feature-compatibility--fcv--during-upgrades) can be referenced for more details. See [below](#pinned_fcv). +* `pit_enabled` - (Optional) Flag that indicates if the cluster uses Continuous Cloud Backup. * `replication_specs` - List of settings that configure your cluster regions. This attribute has one object per shard representing node configurations in each shard. For replica sets there is only one object representing node configurations. If for each replication_spec `num_shards` is configured with a value greater than 1 (using deprecated sharding configurations), then each object represents a zone with one or more shards. See [below](#replication_specs) * `root_cert_type` - (Optional) - Certificate Authority that MongoDB Atlas clusters use. You can specify ISRGROOTX1 (for ISRG Root X1). * `termination_protection_enabled` - Flag that indicates whether termination protection is enabled on the cluster. If set to true, MongoDB Cloud won't delete the cluster. If set to false, MongoDB Cloud will delete the cluster. @@ -460,6 +463,7 @@ Include **desired options** within advanced_configuration: * `sample_refresh_interval_bi_connector` - (Optional) Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `transaction_lifetime_limit_seconds` - (Optional) Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds. This option corresponds to the `changeStreamOptions.preAndPostImages.expireAfterSeconds` cluster parameter. Defaults to `-1`(off). This setting controls the retention policy of change stream pre- and post-images. Pre- and post-images are the versions of a document before and after document modification, respectively. `expireAfterSeconds` controls how long MongoDB retains pre- and post-images. When set to -1 (off), MongoDB uses the default retention policy: pre- and post-images are retained until the corresponding change stream events are removed from the oplog. To set the minimum pre- and post-image retention time, specify an integer value greater than zero. Setting this too low could increase the risk of interrupting Realm sync or triggers processing. This parameter is only supported for MongoDB version 6.0 and above. +* `default_max_time_ms` - (Optional) Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. This parameter is supported only for MongoDB version 8.0 and above. ### Tags @@ -640,6 +644,11 @@ lifecycle { * `compute_min_instance_size` - (Optional) Minimum instance size to which your cluster can automatically scale (such as M10). Atlas requires this parameter if `replication_specs.#.region_configs.#.analytics_auto_scaling.0.compute_scale_down_enabled` is true. * `compute_max_instance_size` - (Optional) Maximum instance size to which your cluster can automatically scale (such as M40). Atlas requires this parameter if `replication_specs.#.region_configs.#.analytics_auto_scaling.0.compute_enabled` is true. +### pinned_fcv + +* `expiration_date` - (Required) Expiration date of the fixed FCV. This value is in the ISO 8601 timestamp format (e.g. "2024-12-04T16:25:00Z"). Note that this field cannot exceed 4 weeks from the pinned date. +* `version` - Feature compatibility version of the cluster. + ## Attributes Reference In addition to all arguments above, the following attributes are exported: diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index 25b7bd76e6..801792475d 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -187,19 +187,6 @@ resource "mongodbatlas_cluster" "cluster-test" { } } ``` -### Example AWS Shared Tier (M2/M5) cluster -```terraform -resource "mongodbatlas_cluster" "cluster-test" { - project_id = "" - name = "cluster-test-global" - - # Provider Settings "block" - provider_name = "TENANT" - backing_provider_name = "AWS" - provider_region_name = "US_EAST_1" - provider_instance_size_name = "M2" -} -``` ### Example AWS Free Tier cluster ```terraform resource "mongodbatlas_cluster" "cluster-test" { @@ -340,6 +327,7 @@ But in order to explicitly change `provider_instance_size_name` comment the `lif * `tags` - (Optional) Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#tags). * `labels` - (Optional) Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#labels). **DEPRECATED** Use `tags` instead. * `mongo_db_major_version` - (Optional) Version of the cluster to deploy. Atlas supports all the MongoDB versions that have **not** reached [End of Live](https://www.mongodb.com/legal/support-policy/lifecycles) for M10+ clusters. If omitted, Atlas deploys the cluster with the default version. For more details, see [documentation](https://www.mongodb.com/docs/atlas/reference/faq/database/#which-versions-of-mongodb-do-service-clusters-use-). Atlas always deploys the cluster with the latest stable release of the specified version. See [Release Notes](https://www.mongodb.com/docs/upcoming/release-notes/) for latest Current Stable Release. +* `pinned_fcv` - (Optional) Pins the Feature Compatibility Version (FCV) to the current MongoDB version with a provided expiration date. To unpin the FCV the `pinned_fcv` attribute must be removed. This operation can take several minutes as the request processes through the MongoDB data plane. Once FCV is unpinned it will not be possible to downgrade the `mongo_db_major_version`. It is advised that updates to `pinned_fcv` are done isolated from other cluster changes. If a plan contains multiple changes, the FCV change will be applied first. If FCV is unpinned past the expiration date the `pinned_fcv` attribute must be removed. The following [knowledge hub article](https://kb.corp.mongodb.com/article/000021785/) and [FCV documentation](https://www.mongodb.com/docs/atlas/tutorial/major-version-change/#manage-feature-compatibility--fcv--during-upgrades) can be referenced for more details. See [below](#pinned-fcv). * `num_shards` - (Optional) Selects whether the cluster is a replica set or a sharded cluster. If you use the replicationSpecs parameter, you must set num_shards. * `pit_enabled` - (Optional) - Flag that indicates if the cluster uses Continuous Cloud Backup. If set to true, cloud_backup must also be set to true. * `cloud_backup` - (Optional) Flag indicating if the cluster uses Cloud Backup for backups. @@ -539,6 +527,11 @@ To learn more, see [Resource Tags](https://dochub.mongodb.org/core/add-cluster-t -> **NOTE:** MongoDB Atlas doesn't display your labels. +### Pinned FCV + +* `expiration_date` - (Required) Expiration date of the fixed FCV. This value is in the ISO 8601 timestamp format (e.g. "2024-12-04T16:25:00Z"). Note that this field cannot exceed 4 weeks from the pinned date. +* `version` - Feature compatibility version of the cluster. + ## Attributes Reference In addition to all arguments above, the following attributes are exported: diff --git a/docs/resources/flex_cluster.md b/docs/resources/flex_cluster.md new file mode 100644 index 0000000000..a73359d3ee --- /dev/null +++ b/docs/resources/flex_cluster.md @@ -0,0 +1,99 @@ +# Resource: mongodbatlas_flex_cluster + +`mongodbatlas_flex_cluster` provides a Flex Cluster resource. The resource lets you create, update, delete and import a flex cluster. + +**NOTE:** Flex Cluster is in Public Preview. In order to use the resource and data sources you need to set the environment variable MONGODB_ATLAS_ENABLE_PREVIEW to true. + +## Example Usages + +```terraform +resource "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = var.cluster_name + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true +} + +data "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.example-cluster.name +} + +data "mongodbatlas_flex_clusters" "example-clusters" { + project_id = var.project_id +} + +output "mongodbatlas_flex_cluster" { + value = data.mongodbatlas_flex_cluster.example-cluster.name +} + +output "mongodbatlas_flex_clusters_names" { + value = [for cluster in data.mongodbatlas_flex_clusters.example-clusters.results : cluster.name] +} +``` + + +## Schema + +### Required + +- `name` (String) Human-readable label that identifies the instance. +- `project_id` (String) Unique 24-hexadecimal character string that identifies the project. +- `provider_settings` (Attributes) Group of cloud provider settings that configure the provisioned MongoDB flex cluster. (see [below for nested schema](#nestedatt--provider_settings)) + +### Optional + +- `tags` (Map of String) Map that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the instance. +- `termination_protection_enabled` (Boolean) Flag that indicates whether termination protection is enabled on the cluster. If set to `true`, MongoDB Cloud won't delete the cluster. If set to `false`, MongoDB Cloud will delete the cluster. + +### Read-Only + +- `backup_settings` (Attributes) Flex backup configuration (see [below for nested schema](#nestedatt--backup_settings)) +- `cluster_type` (String) Flex cluster topology. +- `connection_strings` (Attributes) Collection of Uniform Resource Locators that point to the MongoDB database. (see [below for nested schema](#nestedatt--connection_strings)) +- `create_date` (String) Date and time when MongoDB Cloud created this instance. This parameter expresses its value in ISO 8601 format in UTC. +- `id` (String) Unique 24-hexadecimal digit string that identifies the instance. +- `mongo_db_version` (String) Version of MongoDB that the instance runs. +- `state_name` (String) Human-readable label that indicates the current operating condition of this instance. +- `version_release_system` (String) Method by which the cluster maintains the MongoDB versions. + + +### Nested Schema for `provider_settings` + +Required: + +- `backing_provider_name` (String) Cloud service provider on which MongoDB Cloud provisioned the flex cluster. +- `region_name` (String) Human-readable label that identifies the geographic location of your MongoDB flex cluster. The region you choose can affect network latency for clients accessing your databases. For a complete list of region names, see [AWS](https://docs.atlas.mongodb.com/reference/amazon-aws/#std-label-amazon-aws), [GCP](https://docs.atlas.mongodb.com/reference/google-gcp/), and [Azure](https://docs.atlas.mongodb.com/reference/microsoft-azure/). + +Read-Only: + +- `disk_size_gb` (Number) Storage capacity available to the flex cluster expressed in gigabytes. +- `provider_name` (String) Human-readable label that identifies the cloud service provider. + + + +### Nested Schema for `backup_settings` + +Read-Only: + +- `enabled` (Boolean) Flag that indicates whether backups are performed for this flex cluster. Backup uses [TODO](TODO) for flex clusters. + + + +### Nested Schema for `connection_strings` + +Read-Only: + +- `standard` (String) Public connection string that you can use to connect to this cluster. This connection string uses the mongodb:// protocol. +- `standard_srv` (String) Public connection string that you can use to connect to this flex cluster. This connection string uses the `mongodb+srv://` protocol. + +# Import +You can import the Flex Cluster resource by using the Project ID and Flex Cluster name, in the format `PROJECT_ID-FLEX_CLUSTER_NAME`. For example: +``` +$ terraform import mongodbatlas_flex_cluster.test 6117ac2fe2a3d04ed27a987v-yourFlexClusterName +``` + +For more information see: [MongoDB Atlas API - Flex Cluster](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Flex-Clusters/operation/createFlexcluster) Documentation. diff --git a/docs/resources/privatelink_endpoint_serverless.md b/docs/resources/privatelink_endpoint_serverless.md index d5edd9dc3e..bcd41d0238 100644 --- a/docs/resources/privatelink_endpoint_serverless.md +++ b/docs/resources/privatelink_endpoint_serverless.md @@ -1,3 +1,9 @@ +--- +subcategory: "Deprecated" +--- + +**WARNING:** This resource is deprecated and will be removed in March 2025. For more datails see [Migration Guide: Transition out of Serverless Instances and Shared-tier clusters](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide) + # Resource: privatelink_endpoint_serverless `privatelink_endpoint_serverless` Provides a Serverless PrivateLink Endpoint resource. diff --git a/docs/resources/privatelink_endpoint_service_serverless.md b/docs/resources/privatelink_endpoint_service_serverless.md index c541969aa0..8cf2ec9211 100644 --- a/docs/resources/privatelink_endpoint_service_serverless.md +++ b/docs/resources/privatelink_endpoint_service_serverless.md @@ -1,3 +1,9 @@ +--- +subcategory: "Deprecated" +--- + +**WARNING:** This resource is deprecated and will be removed in March 2025. For more datails see [Migration Guide: Transition out of Serverless Instances and Shared-tier clusters](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide) + # Resource: privatelink_endpoint_service_serverless `privatelink_endpoint_service_serverless` Provides a Serverless PrivateLink Endpoint Service resource. diff --git a/docs/resources/serverless_instance.md b/docs/resources/serverless_instance.md index 03b283632f..df3daf7c34 100644 --- a/docs/resources/serverless_instance.md +++ b/docs/resources/serverless_instance.md @@ -36,9 +36,9 @@ Follow this example to [setup private connection to a serverless instance using * `provider_settings_provider_name` - (Required) Cloud service provider that applies to the provisioned the serverless instance. * `provider_settings_region_name` - (Required) Human-readable label that identifies the physical location of your MongoDB serverless instance. The region you choose can affect network latency for clients accessing your databases. -* `continuous_backup_enabled` - (Optional) Flag that indicates whether the serverless instance uses [Serverless Continuous Backup](https://www.mongodb.com/docs/atlas/configure-serverless-backup). If this parameter is false or not used, the serverless instance uses [Basic Backup](https://www.mongodb.com/docs/atlas/configure-serverless-backup). +* `continuous_backup_enabled` - (Deprecated, Optional) Flag that indicates whether the serverless instance uses [Serverless Continuous Backup](https://www.mongodb.com/docs/atlas/configure-serverless-backup). If this parameter is false or not used, the serverless instance uses [Basic Backup](https://www.mongodb.com/docs/atlas/configure-serverless-backup). * `termination_protection_enabled` - Flag that indicates whether termination protection is enabled on the cluster. If set to true, MongoDB Cloud won't delete the cluster. If set to false, MongoDB Cloud will delete the cluster. -* `auto_indexing` - (Optional) Flag that indicates whether the serverless instance uses [Serverless Auto Indexing](https://www.mongodb.com/docs/atlas/performance-advisor/auto-index-serverless/). This parameter defaults to true. +* `auto_indexing` - (Deprecated, Optional) Flag that indicates whether the serverless instance uses [Serverless Auto Indexing](https://www.mongodb.com/docs/atlas/performance-advisor/auto-index-serverless/). This parameter defaults to true. * `tags` - (Optional) Set that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the cluster. See [below](#tags). ### Tags diff --git a/docs/resources/stream_processor.md b/docs/resources/stream_processor.md index e731d540cd..ef3cc40b32 100644 --- a/docs/resources/stream_processor.md +++ b/docs/resources/stream_processor.md @@ -132,7 +132,7 @@ output "stream_processors_results" { ### Required - `instance_name` (String) Human-readable label that identifies the stream instance. -- `pipeline` (String) Stream aggregation pipeline you want to apply to your streaming data. [MongoDB Atlas Docs](https://www.mongodb.com/docs/atlas/atlas-stream-processing/stream-aggregation/#std-label-stream-aggregation) contain more information. Using [jsonencode](https://developer.hashicorp.com/terraform/language/functions/jsonencode) is recommended when settig this attribute. For more details see [Aggregation Pipelines Documentation](https://www.mongodb.com/docs/atlas/atlas-stream-processing/stream-aggregation/) +- `pipeline` (String) Stream aggregation pipeline you want to apply to your streaming data. [MongoDB Atlas Docs](https://www.mongodb.com/docs/atlas/atlas-stream-processing/stream-aggregation/#std-label-stream-aggregation) contain more information. Using [jsonencode](https://developer.hashicorp.com/terraform/language/functions/jsonencode) is recommended when setting this attribute. For more details see the [Aggregation Pipelines Documentation](https://www.mongodb.com/docs/atlas/atlas-stream-processing/stream-aggregation/) - `processor_name` (String) Human-readable label that identifies the stream processor. - `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access. @@ -143,7 +143,7 @@ output "stream_processors_results" { - `options` (Attributes) Optional configuration for the stream processor. (see [below for nested schema](#nestedatt--options)) - `state` (String) The state of the stream processor. Commonly occurring states are 'CREATED', 'STARTED', 'STOPPED' and 'FAILED'. Used to start or stop the Stream Processor. Valid values are `CREATED`, `STARTED` or `STOPPED`. When a Stream Processor is created without specifying the state, it will default to `CREATED` state. -**NOTE** When a stream processor is created, the only valid states are CREATED or STARTED. A stream processor can be automatically started when creating it if the state is set to STARTED. +**NOTE** When creating a stream processor, setting the state to STARTED can automatically start the stream processor. ### Read-Only diff --git a/examples/mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv/README.md b/examples/mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv/README.md new file mode 100644 index 0000000000..4acb9d2ec1 --- /dev/null +++ b/examples/mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv/README.md @@ -0,0 +1,57 @@ +# MongoDB Atlas Provider -- Cluster with pinned FCV + +Example shows how to pin the FCV of a cluster making use of `pinned_fcv` block. This enables direct control to pin cluster’s FCV before performing an upgrade on the `mongo_db_major_version`. Users can then downgrade to the previous MongoDB version with minimal risk if desired, as the FCV is maintained. + +The unpin operation can be performed by removing the `pinned_fcv` block. **Note**: Once FCV is unpinned it will not be possible to downgrade the `mongo_db_major_version`. If FCV is unpinned past the expiration date the `pinned_fcv` attribute must be removed. + +The following [knowledge hub article](https://kb.corp.mongodb.com/article/000021785/) and [FCV documentation](https://www.mongodb.com/docs/atlas/tutorial/major-version-change/#manage-feature-compatibility--fcv--during-upgrades) can be referenced for more details. + +## Dependencies + +* Terraform MongoDB Atlas Provider v1.23.0 +* A MongoDB Atlas account + +``` +Terraform >= 0.13 ++ provider registry.terraform.io/terraform-providers/mongodbatlas v1.23.0 +``` + + +## Usage +**1\. Ensure your MongoDB Atlas credentials are set up.** + +Following `variables.tf` file create **terraform.tfvars** file with all the variable values, as demonstrated below: +``` +public_key = "" +private_key = "" +atlas_project_id = "" +fcv_expiration_date = "" +``` + +**2\. Review the Terraform plan.** + +Execute the following command. + +``` bash +$ terraform plan +``` +This project currently supports the following deployments: + +- A Cluster with pinned FCV configured. + +**3\. Execute the Terraform apply.** + +Execute the following plan to provision the Atlas Project and Cluster resources. + +``` bash +$ terraform apply +``` + +**4\. Destroy the resources.** + +Once you finished your testing, ensure you destroy the resources to avoid unnecessary Atlas charges. + +``` bash +$ terraform destroy +``` + diff --git a/examples/mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv/main.tf b/examples/mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv/main.tf new file mode 100644 index 0000000000..e9a66f972a --- /dev/null +++ b/examples/mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv/main.tf @@ -0,0 +1,33 @@ +provider "mongodbatlas" { + public_key = var.public_key + private_key = var.private_key +} + +resource "mongodbatlas_advanced_cluster" "cluster" { + project_id = var.project_id + name = "cluster" + cluster_type = "REPLICASET" + + mongo_db_major_version = "7.0" + + pinned_fcv { + expiration_date = var.fcv_expiration_date # e.g. format: "2024-11-22T10:50:00Z". Hashicorp time provider https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/offset can be used to compute this string value. + } + + replication_specs { + region_configs { + electable_specs { + instance_size = "M10" + node_count = 3 + } + provider_name = "AWS" + priority = 7 + region_name = "EU_WEST_1" + } + } +} + +output "feature_compatibility_version" { + value = mongodbatlas_advanced_cluster.cluster.pinned_fcv[0].version +} + diff --git a/examples/mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv/variables.tf b/examples/mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv/variables.tf new file mode 100644 index 0000000000..590efc9578 --- /dev/null +++ b/examples/mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv/variables.tf @@ -0,0 +1,17 @@ +variable "project_id" { + description = "Atlas project id" + type = string +} +variable "public_key" { + description = "Public API key to authenticate to Atlas" + type = string +} +variable "private_key" { + description = "Private API key to authenticate to Atlas" + type = string +} + +variable "fcv_expiration_date" { + description = "Expiration date of the pinned FCV" + type = string +} diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/versions.tf b/examples/mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv/versions.tf similarity index 57% rename from examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/versions.tf rename to examples/mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv/versions.tf index 6b9f728948..f4f37e1912 100644 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/versions.tf +++ b/examples/mongodbatlas_advanced_cluster/version-upgrade-with-pinned-fcv/versions.tf @@ -1,12 +1,8 @@ terraform { required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 5.0" - } mongodbatlas = { source = "mongodb/mongodbatlas" - version = "~> 1.0" + version = "~> 1.22" } } required_version = ">= 1.0" diff --git a/examples/mongodbatlas_flex_cluster/README.md b/examples/mongodbatlas_flex_cluster/README.md new file mode 100644 index 0000000000..bdf65398b8 --- /dev/null +++ b/examples/mongodbatlas_flex_cluster/README.md @@ -0,0 +1,8 @@ +# MongoDB Atlas Provider -- Atlas Flex Cluster +This example creates one flex cluster in a project. + +Variables Required to be set: +- `public_key`: Atlas public key +- `private_key`: Atlas private key +- `project_id`: Project ID where flex cluster will be created +- `cluster_name`: Name of flex cluster that will be created \ No newline at end of file diff --git a/examples/mongodbatlas_flex_cluster/main.tf b/examples/mongodbatlas_flex_cluster/main.tf new file mode 100644 index 0000000000..a08df1eaf3 --- /dev/null +++ b/examples/mongodbatlas_flex_cluster/main.tf @@ -0,0 +1,26 @@ +resource "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = var.cluster_name + provider_settings = { + backing_provider_name = "AWS" + region_name = "US_EAST_1" + } + termination_protection_enabled = true +} + +data "mongodbatlas_flex_cluster" "example-cluster" { + project_id = var.project_id + name = mongodbatlas_flex_cluster.example-cluster.name +} + +data "mongodbatlas_flex_clusters" "example-clusters" { + project_id = var.project_id +} + +output "mongodbatlas_flex_cluster" { + value = data.mongodbatlas_flex_cluster.example-cluster.name +} + +output "mongodbatlas_flex_clusters_names" { + value = [for cluster in data.mongodbatlas_flex_clusters.example-clusters.results : cluster.name] +} diff --git a/examples/mongodbatlas_flex_cluster/provider.tf b/examples/mongodbatlas_flex_cluster/provider.tf new file mode 100644 index 0000000000..e5aeda8033 --- /dev/null +++ b/examples/mongodbatlas_flex_cluster/provider.tf @@ -0,0 +1,4 @@ +provider "mongodbatlas" { + public_key = var.public_key + private_key = var.private_key +} \ No newline at end of file diff --git a/examples/mongodbatlas_flex_cluster/variables.tf b/examples/mongodbatlas_flex_cluster/variables.tf new file mode 100644 index 0000000000..5dbb16a6af --- /dev/null +++ b/examples/mongodbatlas_flex_cluster/variables.tf @@ -0,0 +1,17 @@ +variable "public_key" { + description = "Public API key to authenticate to Atlas" + type = string +} +variable "private_key" { + description = "Private API key to authenticate to Atlas" + type = string +} +variable "project_id" { + description = "Atlas Project ID" + type = string +} +variable "cluster_name" { + description = "Atlas cluster name" + type = string + default = "string" +} \ No newline at end of file diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/versions.tf b/examples/mongodbatlas_flex_cluster/versions.tf similarity index 57% rename from examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/versions.tf rename to examples/mongodbatlas_flex_cluster/versions.tf index 6b9f728948..3faf38df1a 100644 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/versions.tf +++ b/examples/mongodbatlas_flex_cluster/versions.tf @@ -1,12 +1,8 @@ terraform { required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 5.0" - } mongodbatlas = { source = "mongodb/mongodbatlas" - version = "~> 1.0" + version = "~> 1.21.3" } } required_version = ">= 1.0" diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/README.md b/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/README.md deleted file mode 100644 index 3235900b62..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/README.md +++ /dev/null @@ -1,116 +0,0 @@ -# Example - AWS and Atlas PrivateLink with Terraform - -Setup private connection to a [MongoDB Atlas Serverless Instance](https://www.mongodb.com/use-cases/serverless) utilizing [Amazon Virtual Private Cloud (aws vpc)](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html). - -## Dependencies - -* Terraform v0.13 -* An AWS account - provider.aws: version = "~> 4" -* A MongoDB Atlas account - provider.mongodbatlas: version = "~> 1.8" - -## Usage - -**1\. Ensure your AWS and MongoDB Atlas credentials are set up.** - -This can be done using environment variables: - -```bash -export MONGODB_ATLAS_PUBLIC_KEY="xxxx" -export MONGODB_ATLAS_PRIVATE_KEY="xxxx" -``` - -``` bash -$ export AWS_SECRET_ACCESS_KEY='your secret key' -$ export AWS_ACCESS_KEY_ID='your key id' -``` - -... or the `~/.aws/credentials` file. - -``` -$ cat ~/.aws/credentials -[default] -aws_access_key_id = your key id -aws_secret_access_key = your secret key - -``` -... or follow as in the `variables.tf` file and create **terraform.tfvars** file with all the variable values, ex: -``` -access_key = "" -secret_key = "" -public_key = "" -private_key = "" -project_id = "" -cluster_name = "aws-private-connection" -``` - -**2\. Review the Terraform plan.** - -Execute the below command and ensure you are happy with the plan. - -``` bash -$ terraform plan -``` -This project currently does the below deployments: - -- MongoDB cluster - M10 -- AWS Custom VPC, Internet Gateway, Route Tables, Subnets with Public and Private access -- PrivateLink Connection at MongoDB Atlas -- Create VPC Endpoint in AWS - -**3\. Configure the security group as required.** - -The security group in this configuration allows All Traffic access in Inbound and Outbound Rules. - -**4\. Execute the Terraform apply.** - -Now execute the plan to provision the AWS and Atlas resources. - -``` bash -$ terraform apply -``` - -**5\. Destroy the resources.** - -Once you are finished your testing, ensure you destroy the resources to avoid unnecessary charges. - -``` bash -$ terraform destroy -``` - -**What's the resource dependency chain?** -1. `mongodbatlas_project` must exist for any of the following -2. `mongodbatlas_serverless_instance` is dependent on the `mongodbatlas_project` -3. `mongodbatlas_privatelink_endpoint_serverless` is dependent on the `mongodbatlas_serverless_instance` -4. `aws_vpc_endpoint` is dependent on `mongodbatlas_privatelink_endpoint_serverless` -5. `mongodbatlas_privatelink_endpoint_service_serverless` is dependent on `aws_vpc_endpoint` -6. `mongodbatlas_serverless_instance` is dependent on `mongodbatlas_privatelink_endpoint_service_serverless` for its `connection_strings_private_endpoint_srv` - -**Important Point on dependency chain** -- `mongodbatlas_serverless_instance` must exist in-order to create a `mongodbatlas_privatelink_endpoint_service_serverless` for that instance. -- `mongodbatlas_privatelink_endpoint_service_serverless` must exist before `mongodbatlas_serverless_instance` can have its `connection_strings_private_endpoint_srv`. - -It is impossible to create both resources and have `connection_strings_private_endpoint_srv` populated in a single `terraform apply`.\ -To circumvent this issue, this example utilitizes the following data source - -``` -data "mongodbatlas_serverless_instance" "aws_private_connection" { - project_id = mongodbatlas_serverless_instance.aws_private_connection.project_id - name = mongodbatlas_serverless_instance.aws_private_connection.name - - depends_on = [mongodbatlas_privatelink_endpoint_service_serverless.pe_east_service] -} -``` - - -Serverless instance `connection_strings_private_endpoint_srv` is a list of strings.\ -To output the private connection strings, follow the [example output.tf](output.tf): - -``` -locals { - private_endpoints = coalesce(data.mongodbatlas_serverless_instance.aws_private_connection.connection_strings_private_endpoint_srv, []) -} - -output "connection_strings" { - value = local.private_endpoints -} -``` \ No newline at end of file diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-privatelink.tf b/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-privatelink.tf deleted file mode 100644 index 36f3c90fed..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-privatelink.tf +++ /dev/null @@ -1,14 +0,0 @@ -resource "mongodbatlas_privatelink_endpoint_serverless" "pe_east" { - project_id = mongodbatlas_serverless_instance.aws_private_connection.project_id - instance_name = mongodbatlas_serverless_instance.aws_private_connection.name - provider_name = "AWS" -} - -resource "mongodbatlas_privatelink_endpoint_service_serverless" "pe_east_service" { - project_id = mongodbatlas_privatelink_endpoint_serverless.pe_east.project_id - instance_name = mongodbatlas_privatelink_endpoint_serverless.pe_east.instance_name - endpoint_id = mongodbatlas_privatelink_endpoint_serverless.pe_east.endpoint_id - provider_name = mongodbatlas_privatelink_endpoint_serverless.pe_east.provider_name - cloud_provider_endpoint_id = aws_vpc_endpoint.vpce_east.id - comment = "New serverless endpoint" -} \ No newline at end of file diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-serverless-instance.tf b/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-serverless-instance.tf deleted file mode 100644 index 5039308d40..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-serverless-instance.tf +++ /dev/null @@ -1,13 +0,0 @@ -resource "mongodbatlas_serverless_instance" "aws_private_connection" { - project_id = var.project_id - name = var.instance_name - provider_settings_backing_provider_name = "AWS" - provider_settings_provider_name = "SERVERLESS" - provider_settings_region_name = "US_EAST_1" - continuous_backup_enabled = true - - tags { - key = "environment" - value = "dev" - } -} \ No newline at end of file diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/aws-vpc.tf b/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/aws-vpc.tf deleted file mode 100644 index a3d3d581d2..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/aws-vpc.tf +++ /dev/null @@ -1,57 +0,0 @@ -resource "aws_vpc_endpoint" "vpce_east" { - vpc_id = aws_vpc.vpc_east.id - service_name = mongodbatlas_privatelink_endpoint_serverless.pe_east.endpoint_service_name - vpc_endpoint_type = "Interface" - subnet_ids = [aws_subnet.subnet_east_a.id, aws_subnet.subnet_east_b.id] - security_group_ids = [aws_security_group.sg_east.id] -} - -resource "aws_vpc" "vpc_east" { - cidr_block = "10.0.0.0/16" - enable_dns_hostnames = true - enable_dns_support = true -} - -resource "aws_internet_gateway" "ig_east" { - vpc_id = aws_vpc.vpc_east.id -} - -resource "aws_route" "route_east" { - route_table_id = aws_vpc.vpc_east.main_route_table_id - destination_cidr_block = "0.0.0.0/0" - gateway_id = aws_internet_gateway.ig_east.id -} - -resource "aws_subnet" "subnet_east_a" { - vpc_id = aws_vpc.vpc_east.id - cidr_block = "10.0.1.0/24" - map_public_ip_on_launch = true - availability_zone = "us-east-1a" -} - -resource "aws_subnet" "subnet_east_b" { - vpc_id = aws_vpc.vpc_east.id - cidr_block = "10.0.2.0/24" - map_public_ip_on_launch = false - availability_zone = "us-east-1b" -} - -resource "aws_security_group" "sg_east" { - name_prefix = "default-" - description = "Default security group for all instances in vpc" - vpc_id = aws_vpc.vpc_east.id - ingress { - from_port = 0 - to_port = 0 - protocol = "tcp" - cidr_blocks = [ - "0.0.0.0/0", - ] - } - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } -} diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/output.tf b/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/output.tf deleted file mode 100644 index 6ced909ebf..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/output.tf +++ /dev/null @@ -1,14 +0,0 @@ -data "mongodbatlas_serverless_instance" "aws_private_connection" { - project_id = mongodbatlas_serverless_instance.aws_private_connection.project_id - name = mongodbatlas_serverless_instance.aws_private_connection.name - - depends_on = [mongodbatlas_privatelink_endpoint_service_serverless.pe_east_service] -} - -locals { - private_endpoints = coalesce(data.mongodbatlas_serverless_instance.aws_private_connection.connection_strings_private_endpoint_srv, []) -} - -output "connection_strings" { - value = local.private_endpoints -} \ No newline at end of file diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/provider.tf b/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/provider.tf deleted file mode 100644 index 61ef7cb227..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/provider.tf +++ /dev/null @@ -1,9 +0,0 @@ -provider "aws" { - access_key = var.access_key - secret_key = var.secret_key - region = "us-east-1" -} -provider "mongodbatlas" { - public_key = var.public_key - private_key = var.private_key -} diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/variables.tf b/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/variables.tf deleted file mode 100644 index 17cc8b1259..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/variables.tf +++ /dev/null @@ -1,25 +0,0 @@ -variable "public_key" { - description = "The public API key for MongoDB Atlas" - type = string -} -variable "private_key" { - description = "The private API key for MongoDB Atlas" - type = string -} -variable "access_key" { - description = "The access key for AWS Account" - type = string -} -variable "secret_key" { - description = "The secret key for AWS Account" - type = string -} -variable "project_id" { - description = "Atlas project ID" - type = string -} -variable "instance_name" { - description = "Atlas serverless instance name" - default = "aws-private-connection" - type = string -} diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/README.md b/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/README.md deleted file mode 100644 index 88c764b227..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/README.md +++ /dev/null @@ -1,97 +0,0 @@ -# Example - AWS and Atlas PrivateLink with Terraform - -This project aims to provide a very straight-forward example of setting up PrivateLink connection between AWS and MongoDB Atlas Serverless. - - -## Dependencies - -* Terraform v0.13 -* An AWS account - provider.aws: version = "~> 3.3" -* A MongoDB Atlas account - provider.mongodbatlas: version = "~> 0.6" - -## Usage - -**1\. Ensure your AWS and MongoDB Atlas credentials are set up.** - -This can be done using environment variables: - -``` bash -$ export AWS_SECRET_ACCESS_KEY='your secret key' -$ export AWS_ACCESS_KEY_ID='your key id' -``` - -```bash -export MONGODB_ATLAS_PUBLIC_KEY="xxxx" -export MONGODB_ATLAS_PRIVATE_KEY="xxxx" -``` - -... or the `~/.aws/credentials` file. - -``` -$ cat ~/.aws/credentials -[default] -aws_access_key_id = your key id -aws_secret_access_key = your secret key - -``` -... or follow as in the `variables.tf` file and create **terraform.tfvars** file with all the variable values and make sure **not to commit it**. - -**2\. Review the Terraform plan.** - -Execute the below command and ensure you are happy with the plan. - -``` bash -$ terraform plan -``` -This project currently does the below deployments: - -- MongoDB cluster - M10 -- AWS Custom VPC, Internet Gateway, Route Tables, Subnets with Public and Private access -- PrivateLink Connection at MongoDB Atlas -- Create VPC Endpoint in AWS - -**3\. Configure the security group as required.** - -The security group in this configuration allows All Traffic access in Inbound and Outbound Rules. - -**4\. Execute the Terraform apply.** - -Now execute the plan to provision the AWS and Atlas resources. - -``` bash -$ terraform apply -``` - -**5\. Destroy the resources.** - -Once you are finished your testing, ensure you destroy the resources to avoid unnecessary charges. - -``` bash -$ terraform destroy -``` - -**Important Point** - -To fetch the connection string follow the below steps: -``` -output "atlasclusterstring" { - value = data.mongodbatlas_serverless_instance.cluster_atlas.connection_strings_standard_srv -} -``` -**Outputs:** -``` -atlasclusterstring = "mongodb+srv://cluster-atlas.za3fb.mongodb.net" - -``` - -To fetch a private connection string, use the output of terraform as below after second apply: - -``` -output "plstring" { - value = mongodbatlas_serverless_instance.cluster_atlas.connection_strings_private_endpoint_srv[0] -} -``` -**Output:** -``` -plstring = mongodb+srv://cluster-atlas-pe-0.za3fb.mongodb.net -``` diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/atlas-cluster.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/atlas-cluster.tf deleted file mode 100644 index dc4ba8a1b6..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/atlas-cluster.tf +++ /dev/null @@ -1,26 +0,0 @@ -resource "mongodbatlas_serverless_instance" "cluster_atlas" { - project_id = var.atlasprojectid - name = "ClusterAtlas" - provider_settings_backing_provider_name = "AWS" - provider_settings_provider_name = "SERVERLESS" - provider_settings_region_name = "US_EAST_1" - continuous_backup_enabled = true -} - -data "mongodbatlas_serverless_instance" "cluster_atlas" { - project_id = var.atlasprojectid - name = mongodbatlas_serverless_instance.cluster_atlas.name - depends_on = [mongodbatlas_privatelink_endpoint_service_serverless.atlaseplink] -} - - -output "atlasclusterstring" { - value = data.mongodbatlas_serverless_instance.cluster_atlas.connection_strings_standard_srv -} - -/* Note Value not available until second apply*/ -/* -output "plstring" { - value = mongodbatlas_serverless_instance.cluster_atlas.connection_strings_private_endpoint_srv[0] -} -*/ diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/aws-vpc.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/aws-vpc.tf deleted file mode 100644 index e6bd39e188..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/aws-vpc.tf +++ /dev/null @@ -1,59 +0,0 @@ -# Create Primary VPC -resource "aws_vpc" "primary" { - cidr_block = "10.0.0.0/16" - enable_dns_hostnames = true - enable_dns_support = true -} - -# Create IGW -resource "aws_internet_gateway" "primary" { - vpc_id = aws_vpc.primary.id -} - -# Route Table -resource "aws_route" "primary-internet_access" { - route_table_id = aws_vpc.primary.main_route_table_id - destination_cidr_block = "0.0.0.0/0" - gateway_id = aws_internet_gateway.primary.id -} - -# Subnet-A -resource "aws_subnet" "primary-az1" { - vpc_id = aws_vpc.primary.id - cidr_block = "10.0.1.0/24" - map_public_ip_on_launch = true - availability_zone = "${var.aws_region}a" -} - -# Subnet-B -resource "aws_subnet" "primary-az2" { - vpc_id = aws_vpc.primary.id - cidr_block = "10.0.2.0/24" - map_public_ip_on_launch = false - availability_zone = "${var.aws_region}b" -} - -/*Security-Group -Ingress - Port 80 -- limited to instance - Port 22 -- Open to ssh without limitations -Egress - Open to All*/ - -resource "aws_security_group" "primary_default" { - name_prefix = "default-" - description = "Default security group for all instances in ${aws_vpc.primary.id}" - vpc_id = aws_vpc.primary.id - ingress { - from_port = 0 - to_port = 0 - protocol = "tcp" - cidr_blocks = [ - "0.0.0.0/0", - ] - } - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } -} diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/main.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/main.tf deleted file mode 100644 index cff417bd28..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/main.tf +++ /dev/null @@ -1,23 +0,0 @@ -resource "mongodbatlas_privatelink_endpoint_serverless" "atlaspl" { - project_id = var.atlasprojectid - provider_name = "AWS" - instance_name = mongodbatlas_serverless_instance.cluster_atlas.name -} - -resource "aws_vpc_endpoint" "ptfe_service" { - vpc_id = aws_vpc.primary.id - service_name = mongodbatlas_privatelink_endpoint_serverless.atlaspl.endpoint_service_name - vpc_endpoint_type = "Interface" - subnet_ids = [aws_subnet.primary-az1.id, aws_subnet.primary-az2.id] - security_group_ids = [aws_security_group.primary_default.id] -} - -resource "mongodbatlas_privatelink_endpoint_service_serverless" "atlaseplink" { - project_id = mongodbatlas_privatelink_endpoint_serverless.atlaspl.project_id - instance_name = mongodbatlas_serverless_instance.cluster_atlas.name - endpoint_id = mongodbatlas_privatelink_endpoint_serverless.atlaspl.endpoint_id - cloud_provider_endpoint_id = aws_vpc_endpoint.ptfe_service.id - provider_name = "AWS" - comment = "test" - -} diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/provider.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/provider.tf deleted file mode 100644 index e075e34d7e..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/provider.tf +++ /dev/null @@ -1,9 +0,0 @@ -provider "mongodbatlas" { - public_key = var.public_key - private_key = var.private_key -} -provider "aws" { - access_key = var.access_key - secret_key = var.secret_key - region = var.aws_region -} diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/variables.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/variables.tf deleted file mode 100644 index 86977d1bde..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/variables.tf +++ /dev/null @@ -1,25 +0,0 @@ -variable "public_key" { - description = "The public API key for MongoDB Atlas" - type = string -} -variable "private_key" { - description = "The private API key for MongoDB Atlas" - type = string -} -variable "atlasprojectid" { - description = "Atlas project ID" - type = string -} -variable "access_key" { - description = "The access key for AWS Account" - type = string -} -variable "secret_key" { - description = "The secret key for AWS Account" - type = string -} -variable "aws_region" { - default = "us-east-1" - description = "AWS Region" - type = string -} diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/Readme.md b/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/Readme.md deleted file mode 100644 index 012e789f2c..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/Readme.md +++ /dev/null @@ -1,84 +0,0 @@ -# Example - Microsoft Azure and MongoDB Atlas Private Endpoint Serverless - -This project aims to provide an example of using Azure and MongoDB Atlas together. - - -## Dependencies - -* Terraform v0.13 -* Microsoft Azure account -* MongoDB Atlas account - -``` -Terraform v0.13.0 -+ provider registry.terraform.io/hashicorp/azuread v1.0.0 -+ provider registry.terraform.io/hashicorp/azurerm v2.31.1 -+ provider registry.terraform.io/terraform-providers/mongodbatlas v0.6.5 -``` - -## Usage - -**1\. Ensure your Azure credentials are set up.** - -1. Install the Azure CLI by following the steps from the [official Azure documentation](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli). -2. Run the command `az login` and this will take you to the default browser and perform the authentication. -3. Once authenticated, it will print the user details as below: - -``` -⇒ az login -You have logged in. Now let us find all the subscriptions to which you have access... -The following tenants don't contain accessible subscriptions. Use 'az login --allow-no-subscriptions' to have tenant level access. -XXXXX -[ - { - "cloudName": "AzureCloud", - "homeTenantId": "XXXXX", - "id": "XXXXX", - "isDefault": true, - "managedByTenants": [], - "name": "Pay-As-You-Go", - "state": "Enabled", - "tenantId": "XXXXX", - "user": { - "name": "person@domain.com", - "type": "user" - } - } -] -``` - -**2\. TFVARS** - -Now create **terraform.tfvars** file with all the variable values and make sure **not to commit it**. - -An serverless cluster in the project will be linked via the `cluster_name` variable. -If included, the azure connection string to the cluster will be output. - -**3\. Review the Terraform plan.** - -Execute the below command and ensure you are happy with the plan. - -``` bash -$ terraform plan -``` -This project currently does the below deployments: - -- MongoDB Atlas Azure Private Endpoint -- Azure Resource Group, VNET, Subnet, Private Endpoint -- Azure-MongoDB Private Link - -**4\. Execute the Terraform apply.** - -Now execute the plan to provision the Azure resources. - -``` bash -$ terraform apply -``` - -**5\. Destroy the resources.** - -Once you are finished your testing, ensure you destroy the resources to avoid unnecessary Azure and Atlas charges. - -``` bash -$ terraform destroy -``` diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/main.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/main.tf deleted file mode 100644 index d40e580bc5..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/main.tf +++ /dev/null @@ -1,71 +0,0 @@ -provider "azurerm" { - subscription_id = var.subscription_id - client_id = var.client_id - client_secret = var.client_secret - tenant_id = var.tenant_id - features { - } -} - -data "azurerm_resource_group" "test" { - name = var.resource_group_name -} - -resource "azurerm_virtual_network" "test" { - name = "acceptanceTestVirtualNetwork1" - address_space = ["10.0.0.0/16"] - location = data.azurerm_resource_group.test.location - resource_group_name = var.resource_group_name -} - -resource "azurerm_subnet" "test" { - name = "testsubnet" - resource_group_name = var.resource_group_name - virtual_network_name = azurerm_virtual_network.test.name - address_prefixes = ["10.0.1.0/24"] - private_link_service_network_policies_enabled = true - private_endpoint_network_policies_enabled = true -} - -resource "mongodbatlas_privatelink_endpoint_serverless" "test" { - project_id = var.project_id - instance_name = mongodbatlas_serverless_instance.test.name - provider_name = "AZURE" -} - -resource "azurerm_private_endpoint" "test" { - name = "endpoint-test" - location = data.azurerm_resource_group.test.location - resource_group_name = var.resource_group_name - subnet_id = azurerm_subnet.test.id - private_service_connection { - name = mongodbatlas_privatelink_endpoint_serverless.test.endpoint_service_name - private_connection_resource_id = mongodbatlas_privatelink_endpoint_serverless.test.private_link_service_resource_id - is_manual_connection = true - request_message = "Azure Private Link test" - } - -} - -resource "mongodbatlas_privatelink_endpoint_service_serverless" "test" { - project_id = mongodbatlas_privatelink_endpoint_serverless.test.project_id - instance_name = mongodbatlas_serverless_instance.test.name - endpoint_id = mongodbatlas_privatelink_endpoint_serverless.test.endpoint_id - cloud_provider_endpoint_id = azurerm_private_endpoint.test.id - private_endpoint_ip_address = azurerm_private_endpoint.test.private_service_connection[0].private_ip_address - provider_name = "AZURE" - comment = "test" -} - -resource "mongodbatlas_serverless_instance" "test" { - project_id = var.project_id - name = var.cluster_name - provider_settings_backing_provider_name = "AZURE" - provider_settings_provider_name = "SERVERLESS" - provider_settings_region_name = "US_EAST_2" - continuous_backup_enabled = true -} - -output "private_endpoints" { - value = mongodbatlas_serverless_instance.test.connection_strings_private_endpoint_srv[0] -} \ No newline at end of file diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/variables.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/variables.tf deleted file mode 100644 index 65b1347a9f..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/variables.tf +++ /dev/null @@ -1,30 +0,0 @@ - -variable "project_id" { - default = "PROJECT-ID" - type = string -} -variable "subscription_id" { - default = "AZURE SUBSCRIPTION ID" - type = string -} -variable "client_id" { - default = "AZURE CLIENT ID" - type = string -} -variable "client_secret" { - default = "AZURE CLIENT SECRET" - type = string -} -variable "tenant_id" { - default = "AZURE TENANT ID" - type = string -} -variable "resource_group_name" { - default = "AZURE RESOURCE GROUP NAME" - type = string -} -variable "cluster_name" { - description = "Cluster whose connection string to output" - default = "cluster-serverless" - type = string -} diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/versions.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/versions.tf deleted file mode 100644 index 7d50229e5c..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/versions.tf +++ /dev/null @@ -1,13 +0,0 @@ -terraform { - required_providers { - azurerm = { - source = "hashicorp/azurerm" - version = "~> 3.0" - } - mongodbatlas = { - source = "mongodb/mongodbatlas" - version = "~> 1.0" - } - } - required_version = ">= 1.0" -} diff --git a/go.mod b/go.mod index 444fcd41fa..30946abf26 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/mongodb/terraform-provider-mongodbatlas -go 1.23.2 +go 1.23.4 require ( github.com/andygrunwald/go-jira/v2 v2.0.0-20240116150243-50d59fe116d6 @@ -18,20 +18,21 @@ require ( github.com/hashicorp/terraform-plugin-mux v0.17.0 github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0 - github.com/hashicorp/terraform-plugin-testing v1.9.0 + github.com/hashicorp/terraform-plugin-testing v1.11.0 github.com/huandu/xstrings v1.5.0 + github.com/jarcoal/httpmock v1.3.1 github.com/mongodb-forks/digest v1.1.0 - github.com/mongodb/atlas-sdk-go v1.0.1-0.20241111083735-3754d2e9204b + github.com/mongodb/atlas-sdk-go v1.0.1-0.20241209122044-6b70e4ddd10f github.com/pb33f/libopenapi v0.18.7 github.com/sebdah/goldie/v2 v2.5.5 github.com/spf13/cast v1.6.0 - github.com/stretchr/testify v1.9.0 - github.com/wI2L/jsondiff v0.6.0 - github.com/zclconf/go-cty v1.15.0 + github.com/stretchr/testify v1.10.0 + github.com/wI2L/jsondiff v0.6.1 + github.com/zclconf/go-cty v1.15.1 go.mongodb.org/atlas v0.37.0 go.mongodb.org/atlas-sdk/v20240530005 v20240530005.0.0 go.mongodb.org/atlas-sdk/v20240805005 v20240805005.0.0 - go.mongodb.org/atlas-sdk/v20241023002 v20241023002.1.0 + go.mongodb.org/atlas-sdk/v20241113003 v20241113003.0.0 go.mongodb.org/realm v0.1.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -121,7 +122,7 @@ require ( github.com/skeema/knownhosts v1.2.2 // indirect github.com/spf13/afero v1.9.2 // indirect github.com/stretchr/objx v0.5.2 // indirect - github.com/tidwall/gjson v1.17.1 // indirect + github.com/tidwall/gjson v1.18.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/sjson v1.2.5 // indirect @@ -140,13 +141,13 @@ require ( go.opentelemetry.io/otel v1.22.0 // indirect go.opentelemetry.io/otel/metric v1.22.0 // indirect go.opentelemetry.io/otel/trace v1.22.0 // indirect - golang.org/x/crypto v0.28.0 // indirect + golang.org/x/crypto v0.31.0 // indirect golang.org/x/mod v0.21.0 // indirect golang.org/x/net v0.28.0 // indirect - golang.org/x/oauth2 v0.22.0 // indirect - golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/text v0.19.0 // indirect + golang.org/x/oauth2 v0.24.0 // indirect + golang.org/x/sync v0.10.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/api v0.162.0 // indirect diff --git a/go.sum b/go.sum index 1270b1e15a..44f106e1f4 100644 --- a/go.sum +++ b/go.sum @@ -545,8 +545,8 @@ github.com/hashicorp/terraform-plugin-sdk v1.17.2/go.mod h1:wkvldbraEMkz23NxkkAs github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0 h1:wyKCCtn6pBBL46c1uIIBNUOWlNfYXfXpVo16iDyLp8Y= github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0/go.mod h1:B0Al8NyYVr8Mp/KLwssKXG1RqnTk7FySqSn4fRuLNgw= github.com/hashicorp/terraform-plugin-test/v2 v2.2.1/go.mod h1:eZ9JL3O69Cb71Skn6OhHyj17sLmHRb+H6VrDcJjKrYU= -github.com/hashicorp/terraform-plugin-testing v1.9.0 h1:xOsQRqqlHKXpFq6etTxih3ubdK3HVDtfE1IY7Rpd37o= -github.com/hashicorp/terraform-plugin-testing v1.9.0/go.mod h1:fhhVx/8+XNJZTD5o3b4stfZ6+q7z9+lIWigIYdT6/44= +github.com/hashicorp/terraform-plugin-testing v1.11.0 h1:MeDT5W3YHbONJt2aPQyaBsgQeAIckwPX41EUHXEn29A= +github.com/hashicorp/terraform-plugin-testing v1.11.0/go.mod h1:WNAHQ3DcgV/0J+B15WTE6hDvxcUdkPPpnB1FR3M910U= github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= @@ -568,6 +568,8 @@ github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= +github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww= +github.com/jarcoal/httpmock v1.3.1/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= @@ -622,6 +624,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/maxatome/go-testdeep v1.12.0 h1:Ql7Go8Tg0C1D/uMMX59LAoYK7LffeJQ6X2T04nTH68g= +github.com/maxatome/go-testdeep v1.12.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM= github.com/mitchellh/cli v1.1.2/go.mod h1:6iaV0fGdElS6dPBx0EApTxHrcWvmJphyh2n8YBLPPZ4= github.com/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng= github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= @@ -651,8 +655,8 @@ github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx github.com/mmcloughlin/avo v0.5.0/go.mod h1:ChHFdoV7ql95Wi7vuq2YT1bwCJqiWdZrQ1im3VujLYM= github.com/mongodb-forks/digest v1.1.0 h1:7eUdsR1BtqLv0mdNm4OXs6ddWvR4X2/OsLwdKksrOoc= github.com/mongodb-forks/digest v1.1.0/go.mod h1:rb+EX8zotClD5Dj4NdgxnJXG9nwrlx3NWKJ8xttz1Dg= -github.com/mongodb/atlas-sdk-go v1.0.1-0.20241111083735-3754d2e9204b h1:VEG2jvvpQgFXF07XAveez6SxEIjeWyO15p1bxOKXGZk= -github.com/mongodb/atlas-sdk-go v1.0.1-0.20241111083735-3754d2e9204b/go.mod h1:CE0qO1AJFrP9ajK/KnRUwKzoPKVoqAmZVFnsofvTwRE= +github.com/mongodb/atlas-sdk-go v1.0.1-0.20241209122044-6b70e4ddd10f h1:hgZvdTynTl1ep9xWH+1K697K1wsjp6jgqYgMoz3ynxc= +github.com/mongodb/atlas-sdk-go v1.0.1-0.20241209122044-6b70e4ddd10f/go.mod h1:WzU2E+/RcJGnhjdnBzXpbGBqq/XbDhFDEaru0UNmbxc= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= @@ -764,11 +768,11 @@ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1F github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= -github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= @@ -792,8 +796,8 @@ github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAh github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/vmware-labs/yaml-jsonpath v0.3.2 h1:/5QKeCBGdsInyDCyVNLbXyilb61MXGi9NP674f9Hobk= github.com/vmware-labs/yaml-jsonpath v0.3.2/go.mod h1:U6whw1z03QyqgWdgXxvVnQ90zN1BWz5V+51Ewf8k+rQ= -github.com/wI2L/jsondiff v0.6.0 h1:zrsH3FbfVa3JO9llxrcDy/XLkYPLgoMX6Mz3T2PP2AI= -github.com/wI2L/jsondiff v0.6.0/go.mod h1:D6aQ5gKgPF9g17j+E9N7aasmU1O+XvfmWm1y8UMmNpw= +github.com/wI2L/jsondiff v0.6.1 h1:ISZb9oNWbP64LHnu4AUhsMF5W0FIj5Ok3Krip9Shqpw= +github.com/wI2L/jsondiff v0.6.1/go.mod h1:KAEIojdQq66oJiHhDyQez2x+sRit0vIzC9KeK0yizxM= github.com/wk8/go-ordered-map/v2 v2.1.9-0.20240815153524-6ea36470d1bd h1:dLuIF2kX9c+KknGJUdJi1Il1SDiTSK158/BB9kdgAew= github.com/wk8/go-ordered-map/v2 v2.1.9-0.20240815153524-6ea36470d1bd/go.mod h1:DbzwytT4g/odXquuOCqroKvtxxldI4nb3nuesHF/Exo= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= @@ -811,8 +815,8 @@ github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLE github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.8.2/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ= -github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.15.1 h1:RgQYm4j2EvoBRXOPxhUvxPzRrGDo1eCOhHXuGfrj5S0= +github.com/zclconf/go-cty v1.15.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= @@ -825,8 +829,8 @@ go.mongodb.org/atlas-sdk/v20240530005 v20240530005.0.0 h1:d/gbYJ+obR0EM/3DZf7+ZM go.mongodb.org/atlas-sdk/v20240530005 v20240530005.0.0/go.mod h1:O47ZrMMfcWb31wznNIq2PQkkdoFoK0ea2GlmRqGJC2s= go.mongodb.org/atlas-sdk/v20240805005 v20240805005.0.0 h1:EGTT54tKbDbkhhK+jH5AqINFQbHdvaOSpI0oeI5Tl1s= go.mongodb.org/atlas-sdk/v20240805005 v20240805005.0.0/go.mod h1:UTNpAyiKm/7utu+Nl0FafgjgvS+ONNGEoxBT5g/40WM= -go.mongodb.org/atlas-sdk/v20241023002 v20241023002.1.0 h1:np4VLZ3RU+gafyYaU91odUySDhxqvH2ioqVQqHmD2eQ= -go.mongodb.org/atlas-sdk/v20241023002 v20241023002.1.0/go.mod h1:Giw92LBGnr495/nZfEoCtOiW7rkyFdc8ljqIZp+nA48= +go.mongodb.org/atlas-sdk/v20241113003 v20241113003.0.0 h1:aH1LZIgSLxKhCuPm99OIwwzhVKVYpzHuJ9RjCOYlh0s= +go.mongodb.org/atlas-sdk/v20241113003 v20241113003.0.0/go.mod h1:bdVaUm4xI5Ns3+ie3VPPVravSfiGlnMfaAlVAiscA0U= go.mongodb.org/realm v0.1.0 h1:zJiXyLaZrznQ+Pz947ziSrDKUep39DO4SfA0Fzx8M4M= go.mongodb.org/realm v0.1.0/go.mod h1:4Vj6iy+Puo1TDERcoh4XZ+pjtwbOzPpzqy3Cwe8ZmDM= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -874,8 +878,8 @@ golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1016,8 +1020,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= -golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= +golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1035,8 +1039,8 @@ golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1134,8 +1138,8 @@ golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1149,8 +1153,8 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1170,8 +1174,8 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/internal/common/constant/cloud_provider.go b/internal/common/constant/cloud_provider.go index f77b0ff731..edc8a01fff 100644 --- a/internal/common/constant/cloud_provider.go +++ b/internal/common/constant/cloud_provider.go @@ -1,7 +1,8 @@ package constant const ( - AWS = "AWS" - AZURE = "AZURE" - GCP = "GCP" + AWS = "AWS" + AZURE = "AZURE" + GCP = "GCP" + TENANT = "TENANT" ) diff --git a/internal/common/constant/deprecation.go b/internal/common/constant/deprecation.go index b0fc609f2e..458eaaab70 100644 --- a/internal/common/constant/deprecation.go +++ b/internal/common/constant/deprecation.go @@ -1,11 +1,14 @@ package constant const ( - DeprecationParam = "This parameter is deprecated." - DeprecationParamWithReplacement = "This parameter is deprecated. Please transition to %s." - DeprecationParamByVersion = "This parameter is deprecated and will be removed in version %s." - DeprecationParamByVersionWithReplacement = "This parameter is deprecated and will be removed in version %s. Please transition to %s." - DeprecationParamFutureWithReplacement = "This parameter is deprecated and will be removed in the future. Please transition to %s" - DeprecationResourceByDateWithReplacement = "This resource is deprecated and will be removed in %s. Please transition to %s." - DeprecationDataSourceByDateWithReplacement = "This data source is deprecated and will be removed in %s. Please transition to %s." + DeprecationParam = "This parameter is deprecated." + DeprecationParamWithReplacement = "This parameter is deprecated. Please transition to %s." + DeprecationParamByVersion = "This parameter is deprecated and will be removed in version %s." + DeprecationParamByVersionWithReplacement = "This parameter is deprecated and will be removed in version %s. Please transition to %s." + DeprecationParamFutureWithReplacement = "This parameter is deprecated and will be removed in the future. Please transition to %s" + DeprecationResourceByDateWithReplacement = "This resource is deprecated and will be removed in %s. Please transition to %s." + DeprecationDataSourceByDateWithReplacement = "This data source is deprecated and will be removed in %s. Please transition to %s." + DeprecationResourceByDateWithExternalLink = "This resource is deprecated and will be removed in %s. For more details see %s." + DeprecationDataSourceByDateWithExternalLink = "This data source is deprecated and will be removed in %s. For more details see %s." + DeprecatioParamByDateWithExternalLink = "This parameter is deprecated and will be removed in %s. For more details see %s." ) diff --git a/internal/common/conversion/flatten_expand.go b/internal/common/conversion/flatten_expand.go index a28e5ec6fa..2f407a8c97 100644 --- a/internal/common/conversion/flatten_expand.go +++ b/internal/common/conversion/flatten_expand.go @@ -3,7 +3,7 @@ package conversion import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func FlattenLinks(links []admin.Link) []map[string]string { diff --git a/internal/common/conversion/schema_generation.go b/internal/common/conversion/schema_generation.go index 306205da70..b9ece6fe51 100644 --- a/internal/common/conversion/schema_generation.go +++ b/internal/common/conversion/schema_generation.go @@ -8,14 +8,60 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema" ) -func DataSourceSchemaFromResource(rs schema.Schema, requiredFields ...string) dsschema.Schema { - ignoreFields := []string{"timeouts"} - if len(rs.Blocks) > 0 { - panic("blocks not supported yet") +type DataSourceSchemaRequest struct { + OverridenFields map[string]dsschema.Attribute + RequiredFields []string +} + +type PluralDataSourceSchemaRequest struct { + OverridenFields map[string]dsschema.Attribute + OverridenRootFields map[string]dsschema.Attribute + OverrideResultsDoc string + RequiredFields []string + HasLegacyFields bool +} + +func DataSourceSchemaFromResource(rs schema.Schema, req *DataSourceSchemaRequest) dsschema.Schema { + blocks := convertBlocks(rs.Blocks, req.RequiredFields) + attrs := convertAttrs(rs.Attributes, req.RequiredFields) + overrideFields(attrs, req.OverridenFields) + ds := dsschema.Schema{Attributes: attrs, Blocks: blocks} + UpdateSchemaDescription(&ds) + return ds +} + +func PluralDataSourceSchemaFromResource(rs schema.Schema, req *PluralDataSourceSchemaRequest) dsschema.Schema { + blocks := convertBlocks(rs.Blocks, nil) + if len(blocks) > 0 { + panic("blocks not supported yet in auto-generated plural data source schema as they can't go in ListNestedAttribute") + } + attrs := convertAttrs(rs.Attributes, nil) + overrideFields(attrs, req.OverridenFields) + rootAttrs := convertAttrs(rs.Attributes, req.RequiredFields) + for name := range rootAttrs { + if !slices.Contains(req.RequiredFields, name) { + delete(rootAttrs, name) + } } - ds := dsschema.Schema{ - Attributes: convertAttrs(rs.Attributes, requiredFields, ignoreFields), + overrideFields(rootAttrs, req.OverridenRootFields) + resultsDoc := "List of documents that MongoDB Cloud returns for this request." + if req.OverrideResultsDoc != "" { + resultsDoc = req.OverrideResultsDoc } + rootAttrs["results"] = dsschema.ListNestedAttribute{ + Computed: true, + NestedObject: dsschema.NestedAttributeObject{ + Attributes: attrs, + }, + MarkdownDescription: resultsDoc, + } + if req.HasLegacyFields { + rootAttrs["id"] = dsschema.StringAttribute{Computed: true} + rootAttrs["total_count"] = dsschema.Int64Attribute{Computed: true} + rootAttrs["page_num"] = dsschema.Int64Attribute{Optional: true} + rootAttrs["items_per_page"] = dsschema.Int64Attribute{Optional: true} + } + ds := dsschema.Schema{Attributes: rootAttrs} UpdateSchemaDescription(&ds) return ds } @@ -33,50 +79,95 @@ var convertMappings = map[string]reflect.Type{ "SingleNestedAttribute": reflect.TypeOf(dsschema.SingleNestedAttribute{}), "ListNestedAttribute": reflect.TypeOf(dsschema.ListNestedAttribute{}), "SetNestedAttribute": reflect.TypeOf(dsschema.SetNestedAttribute{}), + "ListAttribute": reflect.TypeOf(dsschema.ListAttribute{}), + "SetNestedBlock": reflect.TypeOf(dsschema.SetNestedBlock{}), + "SetAttribute": reflect.TypeOf(dsschema.SetAttribute{}), } -func convertAttrs(rsAttrs map[string]schema.Attribute, requiredFields, ignoreFields []string) map[string]dsschema.Attribute { +var convertNestedMappings = map[string]reflect.Type{ + "NestedAttributeObject": reflect.TypeOf(dsschema.NestedAttributeObject{}), + "NestedBlockObject": reflect.TypeOf(dsschema.NestedBlockObject{}), +} + +func convertAttrs(rsAttrs map[string]schema.Attribute, requiredFields []string) map[string]dsschema.Attribute { + const ignoreField = "timeouts" + if rsAttrs == nil { + return nil + } dsAttrs := make(map[string]dsschema.Attribute, len(rsAttrs)) for name, attr := range rsAttrs { - if slices.Contains(ignoreFields, name) { + if name == ignoreField { continue } - computed := true - required := false - if slices.Contains(requiredFields, name) { - computed = false - required = true - } - vSrc := reflect.ValueOf(attr) - tSrc := reflect.TypeOf(attr) - tDst := convertMappings[tSrc.Name()] - if tDst == nil { - panic("attribute type not support yet, add it to convertMappings: " + tSrc.Name()) - } - vDest := reflect.New(tDst).Elem() - vDest.FieldByName("MarkdownDescription").Set(vSrc.FieldByName("MarkdownDescription")) - vDest.FieldByName("Computed").SetBool(computed) - vDest.FieldByName("Required").SetBool(required) - // ElementType is in schema.MapAttribute - if fElementType := vDest.FieldByName("ElementType"); fElementType.IsValid() && fElementType.CanSet() { - fElementType.Set(vSrc.FieldByName("ElementType")) - } - // Attributes is in schema.SingleNestedAttribute - if fAttributes := vDest.FieldByName("Attributes"); fAttributes.IsValid() && fAttributes.CanSet() { - attrsSrc := vSrc.FieldByName("Attributes").Interface().(map[string]schema.Attribute) - fAttributes.Set(reflect.ValueOf(convertAttrs(attrsSrc, nil, nil))) + dsAttrs[name] = convertElement(name, attr, requiredFields).(dsschema.Attribute) + } + return dsAttrs +} + +func convertBlocks(rsBlocks map[string]schema.Block, requiredFields []string) map[string]dsschema.Block { + if rsBlocks == nil { + return nil + } + dsBlocks := make(map[string]dsschema.Block, len(rsBlocks)) + for name, block := range rsBlocks { + dsBlocks[name] = convertElement(name, block, requiredFields).(dsschema.Block) + } + return dsBlocks +} + +func convertElement(name string, element any, requiredFields []string) any { + computed := true + required := false + if slices.Contains(requiredFields, name) { + computed = false + required = true + } + vSrc := reflect.ValueOf(element) + tSrc := reflect.TypeOf(element) + tDest := convertMappings[tSrc.Name()] + if tDest == nil { + panic("attribute type not support yet, add it to convertMappings: " + tSrc.Name()) + } + vDest := reflect.New(tDest).Elem() + vDest.FieldByName("MarkdownDescription").Set(vSrc.FieldByName("MarkdownDescription")) + vDest.FieldByName("DeprecationMessage").Set(vSrc.FieldByName("DeprecationMessage")) + if fSensitive := vDest.FieldByName("Sensitive"); fSensitive.CanSet() { + fSensitive.Set(vSrc.FieldByName("Sensitive")) + } + if fComputed := vDest.FieldByName("Computed"); fComputed.CanSet() { + fComputed.SetBool(computed) + } + if fRequired := vDest.FieldByName("Required"); fRequired.CanSet() { + fRequired.SetBool(required) + } + if fElementType := vDest.FieldByName("ElementType"); fElementType.CanSet() { + fElementType.Set(vSrc.FieldByName("ElementType")) + } + if fAttributes := vDest.FieldByName("Attributes"); fAttributes.CanSet() { + attrsSrc := vSrc.FieldByName("Attributes").Interface().(map[string]schema.Attribute) + fAttributes.Set(reflect.ValueOf(convertAttrs(attrsSrc, nil))) + } + if fNested := vDest.FieldByName("NestedObject"); fNested.CanSet() { + tNested := convertNestedMappings[fNested.Type().Name()] + if tNested == nil { + panic("nested type not support yet, add it to convertNestedMappings: " + fNested.Type().Name()) } - // NestedObject is in schema.ListNestedAttribute and schema.SetNestedAttribute - if fNestedObject := vDest.FieldByName("NestedObject"); fNestedObject.IsValid() && fNestedObject.CanSet() { - attrsSrc := vSrc.FieldByName("NestedObject").FieldByName("Attributes").Interface().(map[string]schema.Attribute) - nested := dsschema.NestedAttributeObject{ - Attributes: convertAttrs(attrsSrc, nil, nil), - } - fNestedObject.Set(reflect.ValueOf(nested)) + attrsSrc := vSrc.FieldByName("NestedObject").FieldByName("Attributes").Interface().(map[string]schema.Attribute) + vNested := reflect.New(tNested).Elem() + vNested.FieldByName("Attributes").Set(reflect.ValueOf(convertAttrs(attrsSrc, nil))) + fNested.Set(vNested) + } + return vDest.Interface() +} + +func overrideFields(attrs, overridenFields map[string]dsschema.Attribute) { + for name, attr := range overridenFields { + if attr == nil { + delete(attrs, name) + } else { + attrs[name] = attr } - dsAttrs[name] = vDest.Interface().(dsschema.Attribute) } - return dsAttrs } // UpdateAttr is exported for testing purposes only and should not be used directly. diff --git a/internal/common/conversion/schema_generation_test.go b/internal/common/conversion/schema_generation_test.go index d32d21ae75..5fd9c043e2 100644 --- a/internal/common/conversion/schema_generation_test.go +++ b/internal/common/conversion/schema_generation_test.go @@ -5,8 +5,11 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" dsschema "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/stretchr/testify/assert" @@ -39,11 +42,30 @@ func TestDataSourceSchemaFromResource(t *testing.T) { Computed: true, MarkdownDescription: "desc attrBool", }, + "attrDelete": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "desc attrDelete", + }, + "attrSensitive": schema.StringAttribute{ + Computed: true, + Sensitive: true, + MarkdownDescription: "desc attrSensitive", + }, "mapAttr": schema.MapAttribute{ Computed: true, ElementType: types.StringType, MarkdownDescription: "desc mapAttr", }, + "listAttr": schema.ListAttribute{ + Computed: true, + ElementType: types.StringType, + MarkdownDescription: "desc listAttr", + }, + "setAttr": schema.SetAttribute{ + Computed: true, + ElementType: types.StringType, + MarkdownDescription: "desc setAttr", + }, "nestSingle": schema.SingleNestedAttribute{ Computed: true, MarkdownDescription: "desc nestSingle", @@ -88,6 +110,18 @@ func TestDataSourceSchemaFromResource(t *testing.T) { Delete: true, }), }, + Blocks: map[string]schema.Block{ + "nestBlock": schema.SetNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "nestBlockAttr": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "desc nestBlockAttr", + }, + }, + }, + }, + }, } expected := dsschema.Schema{ @@ -122,12 +156,30 @@ func TestDataSourceSchemaFromResource(t *testing.T) { MarkdownDescription: "desc attrBool", Description: "desc attrBool", }, + "attrSensitive": dsschema.StringAttribute{ + Computed: true, + Sensitive: true, + MarkdownDescription: "desc attrSensitive", + Description: "desc attrSensitive", + }, "mapAttr": dsschema.MapAttribute{ Computed: true, ElementType: types.StringType, MarkdownDescription: "desc mapAttr", Description: "desc mapAttr", }, + "listAttr": dsschema.ListAttribute{ + Computed: true, + ElementType: types.StringType, + MarkdownDescription: "desc listAttr", + Description: "desc listAttr", + }, + "setAttr": dsschema.SetAttribute{ + Computed: true, + ElementType: types.StringType, + MarkdownDescription: "desc setAttr", + Description: "desc setAttr", + }, "nestSingle": dsschema.SingleNestedAttribute{ Computed: true, MarkdownDescription: "desc nestSingle", @@ -173,9 +225,236 @@ func TestDataSourceSchemaFromResource(t *testing.T) { }, }, }, + "overridenString": dsschema.StringAttribute{ + Computed: true, + Description: "desc overridenString", + MarkdownDescription: "desc overridenString", + Validators: []validator.String{ + stringvalidator.ConflictsWith(path.MatchRoot("otherAttr")), + }, + }, + }, + Blocks: map[string]dsschema.Block{ + "nestBlock": dsschema.SetNestedBlock{ + NestedObject: dsschema.NestedBlockObject{ + Attributes: map[string]dsschema.Attribute{ + "nestBlockAttr": dsschema.StringAttribute{ + Computed: true, + MarkdownDescription: "desc nestBlockAttr", + Description: "desc nestBlockAttr", + }, + }, + }, + }, + }, + } + + ds := conversion.DataSourceSchemaFromResource(s, &conversion.DataSourceSchemaRequest{ + RequiredFields: []string{"requiredAttrString", "requiredAttrInt64"}, + OverridenFields: map[string]dsschema.Attribute{ + "overridenString": dsschema.StringAttribute{ + Computed: true, + MarkdownDescription: "desc overridenString", + Validators: []validator.String{ + stringvalidator.ConflictsWith(path.MatchRoot("otherAttr")), + }, + }, + "attrDelete": nil, + }, + }) + assert.Equal(t, expected, ds) +} + +func TestPluralDataSourceSchemaFromResource(t *testing.T) { + s := schema.Schema{ + Attributes: map[string]schema.Attribute{ + "requiredAttrString": schema.StringAttribute{ + Required: true, + MarkdownDescription: "desc requiredAttrString", + }, + "attrString": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "desc attrString", + }, + "attrDelete": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "desc attrDelete", + }, + "overridenString": dsschema.StringAttribute{ + Computed: true, + Description: "desc overridenString", + MarkdownDescription: "desc overridenString", + }, + }, + } + + expected := dsschema.Schema{ + Attributes: map[string]dsschema.Attribute{ + "requiredAttrString": dsschema.StringAttribute{ + Required: true, + MarkdownDescription: "desc requiredAttrString", + Description: "desc requiredAttrString", + }, + "overridenRootStringOptional": dsschema.StringAttribute{ + Optional: true, + MarkdownDescription: "desc overridenRootStringOptional", + Description: "desc overridenRootStringOptional", + }, + "overridenRootStringRequired": dsschema.StringAttribute{ + Required: true, + MarkdownDescription: "desc overridenRootStringRequired", + Description: "desc overridenRootStringRequired", + }, + "results": dsschema.ListNestedAttribute{ + Computed: true, + NestedObject: dsschema.NestedAttributeObject{ + Attributes: map[string]dsschema.Attribute{ + "requiredAttrString": dsschema.StringAttribute{ + Computed: true, + MarkdownDescription: "desc requiredAttrString", + Description: "desc requiredAttrString", + }, + "attrString": dsschema.StringAttribute{ + Computed: true, + MarkdownDescription: "desc attrString", + Description: "desc attrString", + }, + "overridenString": dsschema.StringAttribute{ + Computed: true, + Description: "desc overridenString", + MarkdownDescription: "desc overridenString", + Validators: []validator.String{ + stringvalidator.ConflictsWith(path.MatchRoot("otherAttr")), + }, + }, + }, + }, + Description: "List of documents that MongoDB Cloud returns for this request.", + MarkdownDescription: "List of documents that MongoDB Cloud returns for this request.", + }, + }, + } + + ds := conversion.PluralDataSourceSchemaFromResource(s, &conversion.PluralDataSourceSchemaRequest{ + RequiredFields: []string{"requiredAttrString"}, + OverridenFields: map[string]dsschema.Attribute{ + "overridenString": dsschema.StringAttribute{ + Computed: true, + MarkdownDescription: "desc overridenString", + Validators: []validator.String{ + stringvalidator.ConflictsWith(path.MatchRoot("otherAttr")), + }, + }, + "attrDelete": nil, + }, + OverridenRootFields: map[string]dsschema.Attribute{ + "overridenRootStringOptional": dsschema.StringAttribute{ + Optional: true, + MarkdownDescription: "desc overridenRootStringOptional", + }, + "overridenRootStringRequired": dsschema.StringAttribute{ + Required: true, + MarkdownDescription: "desc overridenRootStringRequired", + }, + }, + }) + assert.Equal(t, expected, ds) +} + +func TestPluralDataSourceSchemaFromResource_legacyFields(t *testing.T) { + s := schema.Schema{ + Attributes: map[string]schema.Attribute{ + "requiredAttrString": schema.StringAttribute{ + Required: true, + MarkdownDescription: "desc requiredAttrString", + }, + "attrString": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "desc attrString", + }, + }, + } + + expected := dsschema.Schema{ + Attributes: map[string]dsschema.Attribute{ + "requiredAttrString": dsschema.StringAttribute{ + Required: true, + MarkdownDescription: "desc requiredAttrString", + Description: "desc requiredAttrString", + }, + "id": dsschema.StringAttribute{ + Computed: true, + }, + "page_num": dsschema.Int64Attribute{ + Optional: true, + }, + "items_per_page": dsschema.Int64Attribute{ + Optional: true, + }, + "total_count": dsschema.Int64Attribute{ + Computed: true, + }, + "results": dsschema.ListNestedAttribute{ + Computed: true, + NestedObject: dsschema.NestedAttributeObject{ + Attributes: map[string]dsschema.Attribute{ + "requiredAttrString": dsschema.StringAttribute{ + Computed: true, + MarkdownDescription: "desc requiredAttrString", + Description: "desc requiredAttrString", + }, + "attrString": dsschema.StringAttribute{ + Computed: true, + MarkdownDescription: "desc attrString", + Description: "desc attrString", + }, + }, + }, + Description: "List of documents that MongoDB Cloud returns for this request.", + MarkdownDescription: "List of documents that MongoDB Cloud returns for this request.", + }, + }, + } + ds := conversion.PluralDataSourceSchemaFromResource(s, &conversion.PluralDataSourceSchemaRequest{ + RequiredFields: []string{"requiredAttrString"}, + HasLegacyFields: true, + }) + assert.Equal(t, expected, ds) +} + +func TestPluralDataSourceSchemaFromResource_overrideResultsDoc(t *testing.T) { + doc := "results doc" + + s := schema.Schema{ + Attributes: map[string]schema.Attribute{ + "attrString": dsschema.StringAttribute{ + Optional: true, + MarkdownDescription: "desc attrString", + }, + }, + } + + expected := dsschema.Schema{ + Attributes: map[string]dsschema.Attribute{ + "results": dsschema.ListNestedAttribute{ + Computed: true, + MarkdownDescription: doc, + Description: doc, + NestedObject: dsschema.NestedAttributeObject{ + Attributes: map[string]dsschema.Attribute{ + "attrString": dsschema.StringAttribute{ + Computed: true, + MarkdownDescription: "desc attrString", + Description: "desc attrString", + }, + }, + }, + }, }, } - ds := conversion.DataSourceSchemaFromResource(s, "requiredAttrString", "requiredAttrInt64") + ds := conversion.PluralDataSourceSchemaFromResource(s, &conversion.PluralDataSourceSchemaRequest{ + OverrideResultsDoc: doc, + }) assert.Equal(t, expected, ds) } diff --git a/internal/common/conversion/tags.go b/internal/common/conversion/tags.go new file mode 100644 index 0000000000..f4269c32b5 --- /dev/null +++ b/internal/common/conversion/tags.go @@ -0,0 +1,37 @@ +package conversion + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/types" + "go.mongodb.org/atlas-sdk/v20241113003/admin" +) + +func NewResourceTags(ctx context.Context, tags types.Map) *[]admin.ResourceTag { + if tags.IsNull() || len(tags.Elements()) == 0 { + return &[]admin.ResourceTag{} + } + elements := make(map[string]types.String, len(tags.Elements())) + _ = tags.ElementsAs(ctx, &elements, false) + var tagsAdmin []admin.ResourceTag + for key, tagValue := range elements { + tagsAdmin = append(tagsAdmin, admin.ResourceTag{ + Key: key, + Value: tagValue.ValueString(), + }) + } + return &tagsAdmin +} + +func NewTFTags(tags []admin.ResourceTag) types.Map { + typesTags := make(map[string]attr.Value, len(tags)) + for _, tag := range tags { + typesTags[tag.Key] = types.StringValue(tag.Value) + } + return types.MapValueMust(types.StringType, typesTags) +} + +func UseNilForEmpty(planTag, newTag types.Map) bool { + return planTag.IsNull() && len(newTag.Elements()) == 0 +} diff --git a/internal/common/conversion/tags_test.go b/internal/common/conversion/tags_test.go new file mode 100644 index 0000000000..19e6fd25f2 --- /dev/null +++ b/internal/common/conversion/tags_test.go @@ -0,0 +1,53 @@ +package conversion_test + +import ( + "context" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" + "github.com/stretchr/testify/assert" + "go.mongodb.org/atlas-sdk/v20241113003/admin" +) + +func TestNewResourceTags(t *testing.T) { + testCases := map[string]struct { + expected *[]admin.ResourceTag + plan types.Map + }{ + "tags null": {&[]admin.ResourceTag{}, types.MapNull(types.StringType)}, + "tags unknown": {&[]admin.ResourceTag{}, types.MapUnknown(types.StringType)}, + "tags convert normally": {&[]admin.ResourceTag{ + *admin.NewResourceTag("key1", "value1"), + }, types.MapValueMust(types.StringType, map[string]attr.Value{ + "key1": types.StringValue("value1"), + })}, + } + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + assert.Equal(t, tc.expected, conversion.NewResourceTags(context.Background(), tc.plan)) + }) + } +} + +func TestNewTFTags(t *testing.T) { + var ( + tfMapEmpty = types.MapValueMust(types.StringType, map[string]attr.Value{}) + apiListEmpty = []admin.ResourceTag{} + apiSingleTag = []admin.ResourceTag{*admin.NewResourceTag("key1", "value1")} + tfMapSingleTag = types.MapValueMust(types.StringType, map[string]attr.Value{"key1": types.StringValue("value1")}) + ) + testCases := map[string]struct { + expected types.Map + adminTags []admin.ResourceTag + }{ + "api empty list tf null should give map null": {tfMapEmpty, apiListEmpty}, + "tags single value tf null should give map single": {tfMapSingleTag, apiSingleTag}, + } + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + assert.Equal(t, tc.expected, conversion.NewTFTags(tc.adminTags)) + }) + } +} diff --git a/internal/common/customplanmodifier/non_updatable.go b/internal/common/customplanmodifier/non_updatable.go new file mode 100644 index 0000000000..7f47282bb1 --- /dev/null +++ b/internal/common/customplanmodifier/non_updatable.go @@ -0,0 +1,36 @@ +package customplanmodifier + +import ( + "context" + "fmt" + + planmodifier "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" +) + +func NonUpdatableStringAttributePlanModifier() planmodifier.String { + return &nonUpdatableStringAttributePlanModifier{} +} + +type nonUpdatableStringAttributePlanModifier struct { +} + +func (d *nonUpdatableStringAttributePlanModifier) Description(ctx context.Context) string { + return d.MarkdownDescription(ctx) +} + +func (d *nonUpdatableStringAttributePlanModifier) MarkdownDescription(ctx context.Context) string { + return "Ensures that update operations fails when updating an attribute." +} + +func (d *nonUpdatableStringAttributePlanModifier) PlanModifyString(ctx context.Context, req planmodifier.StringRequest, resp *planmodifier.StringResponse) { + planAttributeValue := req.PlanValue + stateAttributeValue := req.StateValue + + if !stateAttributeValue.IsNull() && stateAttributeValue.ValueString() != planAttributeValue.ValueString() { + resp.Diagnostics.AddError( + fmt.Sprintf("%s cannot be updated", req.Path), + fmt.Sprintf("%s cannot be updated", req.Path), + ) + return + } +} diff --git a/internal/common/dsschema/pagination_schema.go b/internal/common/dsschema/pagination_schema.go deleted file mode 100644 index 1ed5e6fe93..0000000000 --- a/internal/common/dsschema/pagination_schema.go +++ /dev/null @@ -1,34 +0,0 @@ -package dsschema - -import ( - "maps" - - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" -) - -func PaginatedDSSchema(arguments, resultAttributes map[string]schema.Attribute) schema.Schema { - result := schema.Schema{ - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "page_num": schema.Int64Attribute{ - Optional: true, - }, - "items_per_page": schema.Int64Attribute{ - Optional: true, - }, - "total_count": schema.Int64Attribute{ - Computed: true, - }, - "results": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: resultAttributes, - }, - }, - }, - } - maps.Copy(result.Attributes, arguments) - return result -} diff --git a/internal/common/dsschema/pagination_schema_test.go b/internal/common/dsschema/pagination_schema_test.go deleted file mode 100644 index 2d61bed750..0000000000 --- a/internal/common/dsschema/pagination_schema_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package dsschema_test - -import ( - "reflect" - "testing" - - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/dsschema" -) - -func TestPaginatedDSSchema(t *testing.T) { - expectedSchema := schema.Schema{ - Attributes: map[string]schema.Attribute{ - "project_id": schema.StringAttribute{ - Required: true, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "page_num": schema.Int64Attribute{ - Optional: true, - }, - "items_per_page": schema.Int64Attribute{ - Optional: true, - }, - "total_count": schema.Int64Attribute{ - Computed: true, - }, - "results": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "instance_name": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - }, - } - - resultSchema := dsschema.PaginatedDSSchema( - map[string]schema.Attribute{ - "project_id": schema.StringAttribute{ - Required: true, - }, - }, - map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "instance_name": schema.StringAttribute{ - Computed: true, - }, - }) - - if !reflect.DeepEqual(resultSchema, expectedSchema) { - t.Errorf("created schema does not matched expected") - } -} diff --git a/internal/common/retrystrategy/retry_state.go b/internal/common/retrystrategy/retry_state.go index 00d5f6670e..b0ea4500e3 100644 --- a/internal/common/retrystrategy/retry_state.go +++ b/internal/common/retrystrategy/retry_state.go @@ -1,18 +1,20 @@ package retrystrategy const ( - RetryStrategyPendingState = "PENDING" - RetryStrategyCompletedState = "COMPLETED" - RetryStrategyErrorState = "ERROR" - RetryStrategyPausedState = "PAUSED" - RetryStrategyUpdatingState = "UPDATING" - RetryStrategyDeletingState = "DELETING" - RetryStrategyInitiatingState = "INITIATING" - RetryStrategyIdleState = "IDLE" - RetryStrategyFailedState = "FAILED" - RetryStrategyActiveState = "ACTIVE" - RetryStrategyDeletedState = "DELETED" - + RetryStrategyActiveState = "ACTIVE" + RetryStrategyCompletedState = "COMPLETED" + RetryStrategyCreatingState = "CREATING" + RetryStrategyDeletedState = "DELETED" + RetryStrategyDeletingState = "DELETING" + RetryStrategyErrorState = "ERROR" + RetryStrategyFailedState = "FAILED" + RetryStrategyIdleState = "IDLE" + RetryStrategyInitiatingState = "INITIATING" + RetryStrategyPausedState = "PAUSED" RetryStrategyPendingAcceptanceState = "PENDING_ACCEPTANCE" RetryStrategyPendingRecreationState = "PENDING_RECREATION" + RetryStrategyPendingState = "PENDING" + RetryStrategyRepairingState = "REPAIRING" + RetryStrategyRepeatingState = "REPEATING" + RetryStrategyUpdatingState = "UPDATING" ) diff --git a/internal/common/update/patch_payload.go b/internal/common/update/patch_payload.go index 5e7c6bfefe..a5ac0cfe40 100644 --- a/internal/common/update/patch_payload.go +++ b/internal/common/update/patch_payload.go @@ -2,6 +2,7 @@ package update import ( "encoding/json" + "reflect" "regexp" "slices" "strings" @@ -11,12 +12,28 @@ import ( ) type attrPatchOperations struct { - data map[string][]jsondiff.Operation + data map[string][]jsondiff.Operation + ignoreInState []string } -func newAttrPatchOperations(patch jsondiff.Patch) *attrPatchOperations { +func (m *attrPatchOperations) ignoreInStatePath(path string) bool { + for _, ignore := range m.ignoreInState { + suffix := "/" + ignore + if strings.HasSuffix(path, suffix) { + return true + } + } + return false +} + +func newAttrPatchOperations(patch jsondiff.Patch, options []PatchOptions) *attrPatchOperations { + ignoreInState := []string{} + for _, option := range options { + ignoreInState = append(ignoreInState, option.IgnoreInState...) + } self := &attrPatchOperations{ - data: map[string][]jsondiff.Operation{}, + data: map[string][]jsondiff.Operation{}, + ignoreInState: ignoreInState, } for _, op := range patch { if op.Path == "" { @@ -79,10 +96,14 @@ func (m *attrPatchOperations) StatePatch(attr string) jsondiff.Patch { lastValue = op.Value } if op.Type == jsondiff.OperationRemove && !indexRemoval(op.Path) { + path := op.Path + if m.ignoreInStatePath(path) { + continue + } patch = append(patch, jsondiff.Operation{ Type: jsondiff.OperationAdd, Value: lastValue, - Path: op.Path, + Path: path, }) } } @@ -113,6 +134,11 @@ func convertJSONDiffToJSONPatch(patch jsondiff.Patch) (jsonpatch.Patch, error) { return decodedPatch, nil } +// Current limitation if the field is set as part of a nested attribute in a map +type PatchOptions struct { + IgnoreInState []string +} + // PatchPayload uses the state and plan to changes to find the patch request, including changes only when: // - The plan has replaced, added, or removed list values from the state // Note that we intentionally do NOT include removed state values: @@ -129,7 +155,7 @@ func convertJSONDiffToJSONPatch(patch jsondiff.Patch) (jsonpatch.Patch, error) { // 4. Adds nested "removed" values from the state to the request // 5. Use `jsonpatch` to apply each attribute plan & state patch to an empty JSON object // 6. Create a `patchReq` pointer with the final JSON object marshaled to `T` or return nil if there are no changes (`{}`) -func PatchPayload[T any](state, plan *T) (*T, error) { +func PatchPayload[T any, U any](state *T, plan *U, options ...PatchOptions) (*U, error) { if plan == nil { return nil, nil } @@ -137,7 +163,7 @@ func PatchPayload[T any](state, plan *T) (*T, error) { if err != nil { return nil, err } - attrOperations := newAttrPatchOperations(statePlanPatch) + attrOperations := newAttrPatchOperations(statePlanPatch, options) reqJSON := []byte(`{}`) addPatchToRequest := func(patchDiff jsondiff.Patch) error { @@ -155,7 +181,7 @@ func PatchPayload[T any](state, plan *T) (*T, error) { return nil } - patchReq := new(T) + patchReq := new(U) patchFromPlanDiff, err := jsondiff.Compare(patchReq, plan) if err != nil { return nil, err @@ -177,3 +203,11 @@ func PatchPayload[T any](state, plan *T) (*T, error) { } return patchReq, json.Unmarshal(reqJSON, patchReq) } + +func IsZeroValues[T any](last *T) bool { + if last == nil { + return true + } + empty := new(T) + return reflect.DeepEqual(last, empty) +} diff --git a/internal/common/update/patch_payload_test.go b/internal/common/update/patch_payload_test.go index c0397e0ed4..fa6b142a8c 100644 --- a/internal/common/update/patch_payload_test.go +++ b/internal/common/update/patch_payload_test.go @@ -7,7 +7,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/update" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func TestPatchReplicationSpecs(t *testing.T) { @@ -66,6 +66,7 @@ func TestPatchReplicationSpecs(t *testing.T) { state *admin.ClusterDescription20240805 plan *admin.ClusterDescription20240805 patchExpected *admin.ClusterDescription20240805 + options []update.PatchOptions }{ "ComputedValues from the state are added to plan and unchanged attributes are not included": { state: &state, @@ -187,14 +188,30 @@ func TestPatchReplicationSpecs(t *testing.T) { plan: &planNoChanges, patchExpected: nil, }, + "Empty array should return no changes": { + state: &admin.ClusterDescription20240805{ + Labels: &[]admin.ComponentLabel{}, + }, + plan: &admin.ClusterDescription20240805{ + Labels: &[]admin.ComponentLabel{}, + }, + patchExpected: nil, + }, + "diskSizeGb ignored in state": { + state: clusterDescriptionDiskSizeNodeCount(50.0, 3, conversion.Pointer(50.0), 0), + plan: clusterDescriptionDiskSizeNodeCount(55.0, 3, nil, 0), + patchExpected: clusterDescriptionDiskSizeNodeCount(55.0, 3, nil, 0), + options: []update.PatchOptions{ + { + IgnoreInState: []string{"diskSizeGB"}, + }, + }, + }, } ) for name, tc := range testCases { t.Run(name, func(t *testing.T) { - if name == "Removed list entry should be included" { - t.Log("This test case is expected to fail due to the current implementation") - } - patchReq, err := update.PatchPayload(tc.state, tc.plan) + patchReq, err := update.PatchPayload(tc.state, tc.plan, tc.options...) require.NoError(t, err) assert.Equal(t, tc.patchExpected, patchReq) }) @@ -210,6 +227,7 @@ func TestPatchAdvancedConfig(t *testing.T) { state *admin.ClusterDescriptionProcessArgs20240805 plan *admin.ClusterDescriptionProcessArgs20240805 patchExpected *admin.ClusterDescriptionProcessArgs20240805 + options []update.PatchOptions }{ "JavascriptEnabled is set to false": { state: &state, @@ -248,9 +266,37 @@ func TestPatchAdvancedConfig(t *testing.T) { ) for name, tc := range testCases { t.Run(name, func(t *testing.T) { - patchReq, err := update.PatchPayload(tc.state, tc.plan) + patchReq, err := update.PatchPayload(tc.state, tc.plan, tc.options...) require.NoError(t, err) assert.Equal(t, tc.patchExpected, patchReq) }) } } + +func TestIsEmpty(t *testing.T) { + assert.True(t, update.IsZeroValues(&admin.ClusterDescription20240805{})) + var myVar admin.ClusterDescription20240805 + assert.True(t, update.IsZeroValues(&myVar)) + assert.False(t, update.IsZeroValues(&admin.ClusterDescription20240805{Name: conversion.Pointer("my-cluster")})) +} + +func clusterDescriptionDiskSizeNodeCount(diskSizeGBElectable float64, nodeCountElectable int, diskSizeGBReadOnly *float64, nodeCountReadOnly int) *admin.ClusterDescription20240805 { + return &admin.ClusterDescription20240805{ + ReplicationSpecs: &[]admin.ReplicationSpec20240805{ + { + RegionConfigs: &[]admin.CloudRegionConfig20240805{ + { + ElectableSpecs: &admin.HardwareSpec20240805{ + NodeCount: &nodeCountElectable, + DiskSizeGB: &diskSizeGBElectable, + }, + ReadOnlySpecs: &admin.DedicatedHardwareSpec20240805{ + NodeCount: &nodeCountReadOnly, + DiskSizeGB: diskSizeGBReadOnly, + }, + }, + }, + }, + }, + } +} diff --git a/internal/config/advanced_cluster_v2_schema.go b/internal/config/advanced_cluster_v2_schema.go new file mode 100644 index 0000000000..76e65bfb26 --- /dev/null +++ b/internal/config/advanced_cluster_v2_schema.go @@ -0,0 +1,14 @@ +package config + +import ( + "os" + "strconv" +) + +const AdvancedClusterV2SchemaEnvVar = "MONGODB_ATLAS_ADVANCED_CLUSTER_V2_SCHEMA" +const allowAdvancedClusterV2Schema = false // Don't allow in master branch yet, not in const block to allow automatic change + +func AdvancedClusterV2Schema() bool { + env, _ := strconv.ParseBool(os.Getenv(AdvancedClusterV2SchemaEnvVar)) + return allowAdvancedClusterV2Schema && env +} diff --git a/internal/config/advanced_cluster_v2_schema_test.go b/internal/config/advanced_cluster_v2_schema_test.go new file mode 100644 index 0000000000..6bd8e8836a --- /dev/null +++ b/internal/config/advanced_cluster_v2_schema_test.go @@ -0,0 +1,13 @@ +package config_test + +import ( + "testing" + + "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" + "github.com/stretchr/testify/assert" +) + +func TestAdvancedClusterV2Schema_notEnabled(t *testing.T) { + t.Setenv(config.AdvancedClusterV2SchemaEnvVar, "true") + assert.False(t, config.AdvancedClusterV2Schema(), "AdvancedClusterV2Schema can't be enabled yet") +} diff --git a/internal/config/client.go b/internal/config/client.go index fe0546684d..87521b3fe4 100644 --- a/internal/config/client.go +++ b/internal/config/client.go @@ -12,7 +12,7 @@ import ( adminpreview "github.com/mongodb/atlas-sdk-go/admin" admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" matlasClient "go.mongodb.org/atlas/mongodbatlas" realmAuth "go.mongodb.org/realm/auth" "go.mongodb.org/realm/realm" diff --git a/internal/provider/provider.go b/internal/provider/provider.go index e432f4737d..5a6fd9b186 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -26,12 +26,14 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/validate" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedclustertpf" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/alertconfiguration" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/atlasuser" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/controlplaneipaddresses" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/databaseuser" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/encryptionatrest" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/encryptionatrestprivateendpoint" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/flexcluster" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/mongodbemployeeaccessgrant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/project" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/projectipaccesslist" @@ -446,9 +448,14 @@ func (p *MongodbtlasProvider) DataSources(context.Context) []func() datasource.D encryptionatrestprivateendpoint.PluralDataSource, mongodbemployeeaccessgrant.DataSource, } + if config.AdvancedClusterV2Schema() { + dataSources = append(dataSources, advancedclustertpf.DataSource, advancedclustertpf.PluralDataSource) + } previewDataSources := []func() datasource.DataSource{ resourcepolicy.DataSource, resourcepolicy.PluralDataSource, + flexcluster.DataSource, + flexcluster.PluralDataSource, } // Data sources not yet in GA if providerEnablePreview { dataSources = append(dataSources, previewDataSources...) @@ -471,8 +478,12 @@ func (p *MongodbtlasProvider) Resources(context.Context) []func() resource.Resou encryptionatrestprivateendpoint.Resource, mongodbemployeeaccessgrant.Resource, } + if config.AdvancedClusterV2Schema() { + resources = append(resources, advancedclustertpf.Resource) + } previewResources := []func() resource.Resource{ resourcepolicy.Resource, + flexcluster.Resource, } // Resources not yet in GA if providerEnablePreview { resources = append(resources, previewResources...) diff --git a/internal/provider/provider_sdk2.go b/internal/provider/provider_sdk2.go index da783f94fd..89bec33375 100644 --- a/internal/provider/provider_sdk2.go +++ b/internal/provider/provider_sdk2.go @@ -136,8 +136,6 @@ func NewSdkV2Provider(proxyPort *int) *schema.Provider { func getDataSourcesMap() map[string]*schema.Resource { dataSourcesMap := map[string]*schema.Resource{ - "mongodbatlas_advanced_cluster": advancedcluster.DataSource(), - "mongodbatlas_advanced_clusters": advancedcluster.PluralDataSource(), "mongodbatlas_custom_db_role": customdbrole.DataSource(), "mongodbatlas_custom_db_roles": customdbrole.PluralDataSource(), "mongodbatlas_api_key": apikey.DataSource(), @@ -215,12 +213,15 @@ func getDataSourcesMap() map[string]*schema.Resource { "mongodbatlas_shared_tier_snapshot": sharedtier.DataSourceSnapshot(), "mongodbatlas_shared_tier_snapshots": sharedtier.PluralDataSourceSnapshot(), } + if !config.AdvancedClusterV2Schema() { + dataSourcesMap["mongodbatlas_advanced_cluster"] = advancedcluster.DataSource() + dataSourcesMap["mongodbatlas_advanced_clusters"] = advancedcluster.PluralDataSource() + } return dataSourcesMap } func getResourcesMap() map[string]*schema.Resource { resourcesMap := map[string]*schema.Resource{ - "mongodbatlas_advanced_cluster": advancedcluster.Resource(), "mongodbatlas_api_key": apikey.Resource(), "mongodbatlas_access_list_api_key": accesslistapikey.Resource(), "mongodbatlas_project_api_key": projectapikey.Resource(), @@ -267,6 +268,9 @@ func getResourcesMap() map[string]*schema.Resource { "mongodbatlas_serverless_instance": serverlessinstance.Resource(), "mongodbatlas_cluster_outage_simulation": clusteroutagesimulation.Resource(), } + if !config.AdvancedClusterV2Schema() { + resourcesMap["mongodbatlas_advanced_cluster"] = advancedcluster.Resource() + } return resourcesMap } diff --git a/internal/service/accesslistapikey/data_source_accesslist_api_keys.go b/internal/service/accesslistapikey/data_source_accesslist_api_keys.go index bfc9cb7962..fd02838252 100644 --- a/internal/service/accesslistapikey/data_source_accesslist_api_keys.go +++ b/internal/service/accesslistapikey/data_source_accesslist_api_keys.go @@ -10,7 +10,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { diff --git a/internal/service/accesslistapikey/resource_access_list_api_key.go b/internal/service/accesslistapikey/resource_access_list_api_key.go index 6a3db8b0af..e768586aea 100644 --- a/internal/service/accesslistapikey/resource_access_list_api_key.go +++ b/internal/service/accesslistapikey/resource_access_list_api_key.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func Resource() *schema.Resource { diff --git a/internal/service/advancedcluster/data_source_advanced_cluster.go b/internal/service/advancedcluster/data_source_advanced_cluster.go index 69c6623586..5299c62603 100644 --- a/internal/service/advancedcluster/data_source_advanced_cluster.go +++ b/internal/service/advancedcluster/data_source_advanced_cluster.go @@ -259,6 +259,22 @@ func DataSource() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "pinned_fcv": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "version": { + Type: schema.TypeString, + Computed: true, + }, + "expiration_date": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, }, } } diff --git a/internal/service/advancedcluster/data_source_advanced_clusters.go b/internal/service/advancedcluster/data_source_advanced_clusters.go index 9e456350f1..90cc4ab867 100644 --- a/internal/service/advancedcluster/data_source_advanced_clusters.go +++ b/internal/service/advancedcluster/data_source_advanced_clusters.go @@ -7,7 +7,7 @@ import ( "net/http" admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" @@ -273,6 +273,22 @@ func PluralDataSource() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "pinned_fcv": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "version": { + Type: schema.TypeString, + Computed: true, + }, + "expiration_date": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, }, }, }, @@ -374,6 +390,7 @@ func flattenAdvancedClusters(ctx context.Context, connV220240530 *admin20240530. "redact_client_log_data": cluster.GetRedactClientLogData(), "config_server_management_mode": cluster.GetConfigServerManagementMode(), "config_server_type": cluster.GetConfigServerType(), + "pinned_fcv": FlattenPinnedFCV(cluster), } results = append(results, result) } diff --git a/internal/service/advancedcluster/model_advanced_cluster.go b/internal/service/advancedcluster/model_advanced_cluster.go index 744c889be0..3e9d9a35eb 100644 --- a/internal/service/advancedcluster/model_advanced_cluster.go +++ b/internal/service/advancedcluster/model_advanced_cluster.go @@ -12,7 +12,7 @@ import ( "strings" admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" @@ -24,6 +24,7 @@ import ( ) const minVersionForChangeStreamOptions = 6.0 +const minVersionForDefaultMaxTimeMS = 8.0 type OldShardConfigMeta struct { ID string @@ -121,6 +122,10 @@ func SchemaAdvancedConfigDS() *schema.Schema { Type: schema.TypeInt, Computed: true, }, + "default_max_time_ms": { + Type: schema.TypeInt, + Computed: true, + }, }, }, } @@ -266,6 +271,10 @@ func SchemaAdvancedConfig() *schema.Schema { Optional: true, Default: -1, }, + "default_max_time_ms": { + Type: schema.TypeInt, + Optional: true, + }, }, }, } @@ -430,6 +439,16 @@ func CheckRegionConfigsPriorityOrderOld(regionConfigs []admin20240530.Replicatio return nil } +func FlattenPinnedFCV(cluster *admin.ClusterDescription20240805) []map[string]string { + if cluster.FeatureCompatibilityVersionExpirationDate == nil { // pinned_fcv is defined in state only if featureCompatibilityVersionExpirationDate is present in cluster response + return nil + } + nestedObj := map[string]string{} + nestedObj["version"] = cluster.GetFeatureCompatibilityVersion() + nestedObj["expiration_date"] = conversion.TimeToString(cluster.GetFeatureCompatibilityVersionExpirationDate()) + return []map[string]string{nestedObj} +} + func flattenConnectionStrings(str admin.ClusterConnectionStrings) []map[string]any { return []map[string]any{ { @@ -515,7 +534,12 @@ func flattenProcessArgs(p20240530 *admin20240530.ClusterDescriptionProcessArgs, } else { flattenedProcessArgs[0]["change_stream_options_pre_and_post_images_expire_after_seconds"] = p.GetChangeStreamOptionsPreAndPostImagesExpireAfterSeconds() } + + if v := p.DefaultMaxTimeMS; v != nil { + flattenedProcessArgs[0]["default_max_time_ms"] = p.GetDefaultMaxTimeMS() + } } + return flattenedProcessArgs } @@ -879,10 +903,19 @@ func expandProcessArgs(d *schema.ResourceData, p map[string]any, mongodbMajorVer res.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds = conversion.IntPtr(tmpInt) } + + if _, ok := d.GetOkExists("advanced_configuration.0.default_max_time_ms"); ok { + if IsDefaultMaxTimeMinRequiredMajorVersion(mongodbMajorVersion) { + res.DefaultMaxTimeMS = conversion.Pointer(cast.ToInt(p["default_max_time_ms"])) + } else { + log.Print(ErrorDefaultMaxTimeMinVersion) + } + } + return res20240530, res } -func IsChangeStreamOptionsMinRequiredMajorVersion(input *string) bool { +func isMinRequiredMajorVersion(input *string, minVersion float64) bool { if input == nil || *input == "" { return true } @@ -896,7 +929,15 @@ func IsChangeStreamOptionsMinRequiredMajorVersion(input *string) bool { return false } - return value >= minVersionForChangeStreamOptions + return value >= minVersion +} + +func IsChangeStreamOptionsMinRequiredMajorVersion(input *string) bool { + return isMinRequiredMajorVersion(input, minVersionForChangeStreamOptions) +} + +func IsDefaultMaxTimeMinRequiredMajorVersion(input *string) bool { + return isMinRequiredMajorVersion(input, minVersionForDefaultMaxTimeMS) } func expandLabelSliceFromSetSchema(d *schema.ResourceData) ([]admin.ComponentLabel, diag.Diagnostics) { diff --git a/internal/service/advancedcluster/model_advanced_cluster_test.go b/internal/service/advancedcluster/model_advanced_cluster_test.go index 92835f6df9..88d3f19441 100644 --- a/internal/service/advancedcluster/model_advanced_cluster_test.go +++ b/internal/service/advancedcluster/model_advanced_cluster_test.go @@ -8,8 +8,8 @@ import ( "testing" admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" - "go.mongodb.org/atlas-sdk/v20241023002/admin" - "go.mongodb.org/atlas-sdk/v20241023002/mockadmin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" + "go.mongodb.org/atlas-sdk/v20241113003/mockadmin" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/stretchr/testify/assert" diff --git a/internal/service/advancedcluster/model_sdk_version_conversion.go b/internal/service/advancedcluster/model_sdk_version_conversion.go index 7628a71bad..33bcb463ee 100644 --- a/internal/service/advancedcluster/model_sdk_version_conversion.go +++ b/internal/service/advancedcluster/model_sdk_version_conversion.go @@ -3,7 +3,7 @@ package advancedcluster import ( admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" ) diff --git a/internal/service/advancedcluster/model_sdk_version_conversion_test.go b/internal/service/advancedcluster/model_sdk_version_conversion_test.go index b496ccbba6..d90b3ac499 100644 --- a/internal/service/advancedcluster/model_sdk_version_conversion_test.go +++ b/internal/service/advancedcluster/model_sdk_version_conversion_test.go @@ -7,7 +7,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster" "github.com/stretchr/testify/assert" admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func TestConvertClusterDescription20241023to20240805(t *testing.T) { diff --git a/internal/service/advancedcluster/move_state_test.go b/internal/service/advancedcluster/move_state_test.go new file mode 100644 index 0000000000..179e566a09 --- /dev/null +++ b/internal/service/advancedcluster/move_state_test.go @@ -0,0 +1,84 @@ +package advancedcluster_test + +import ( + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/tfversion" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" +) + +func TestAccAdvancedCluster_moveNotSupportedLegacySchema(t *testing.T) { + acc.SkipIfAdvancedClusterV2Schema(t) // This test is specific to the legacy schema + var ( + projectID = acc.ProjectIDExecution(t) + clusterName = acc.RandomClusterName() + ) + resource.ParallelTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configMoveFirst(projectID, clusterName), + }, + { + Config: configMoveSecond(projectID, clusterName), + ExpectError: regexp.MustCompile("Move Resource State Not Supported"), + }, + { + Config: configMoveFirst(projectID, clusterName), + }, + }, + }) +} + +func configMoveFirst(projectID, clusterName string) string { + return fmt.Sprintf(` + resource "mongodbatlas_cluster" "old" { + project_id = %[1]q + name = %[2]q + cluster_type = "REPLICASET" + provider_name = "AWS" + provider_instance_size_name = "M10" + replication_specs { + num_shards = 1 + regions_config { + region_name = "US_WEST_2" + electable_nodes = 3 + priority = 7 + } + } + } + `, projectID, clusterName) +} + +func configMoveSecond(projectID, clusterName string) string { + return fmt.Sprintf(` + moved { + from = mongodbatlas_cluster.old + to = mongodbatlas_advanced_cluster.test + } + + resource "mongodbatlas_advanced_cluster" "test" { + project_id = %[1]q + name = %[2]q + cluster_type = "REPLICASET" + replication_specs { + region_configs { + electable_specs { + instance_size = "M10" + node_count = 3 + } + provider_name = "AWS" + priority = 7 + region_name = "US_WEST_2" + } + } + } + `, projectID, clusterName) +} diff --git a/internal/service/advancedcluster/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index 720bd9cd3b..1222628afc 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -14,7 +14,7 @@ import ( admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" @@ -40,6 +40,7 @@ const ( ErrorClusterAdvancedSetting = "error setting `%s` for MongoDB ClusterAdvanced (%s): %s" ErrorAdvancedClusterListStatus = "error awaiting MongoDB ClusterAdvanced List IDLE: %s" ErrorOperationNotPermitted = "error operation not permitted" + ErrorDefaultMaxTimeMinVersion = "default_max_time_ms can not be set for mongo_db_major_version lower than 8.0" ignoreLabel = "Infrastructure Tool" DeprecationOldSchemaAction = "Please refer to our examples, documentation, and 1.18.0 migration guide for more details at https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/1.18.0-upgrade-guide.html.markdown" ) @@ -355,6 +356,23 @@ func Resource() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "pinned_fcv": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "version": { + Type: schema.TypeString, + Computed: true, + }, + "expiration_date": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, }, Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(3 * time.Hour), @@ -472,12 +490,17 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. params.ConfigServerManagementMode = conversion.StringPtr(v.(string)) } - // Validate oplog_size_mb to show the error before the cluster is created. + // Validate advanced configuration params to show the error before the cluster is created. if oplogSizeMB, ok := d.GetOkExists("advanced_configuration.0.oplog_size_mb"); ok { if cast.ToInt64(oplogSizeMB) < 0 { return diag.FromErr(fmt.Errorf("`advanced_configuration.oplog_size_mb` cannot be < 0")) } } + if _, ok := d.GetOkExists("advanced_configuration.0.default_max_time_ms"); ok { + if !IsDefaultMaxTimeMinRequiredMajorVersion(params.MongoDBMajorVersion) { + return diag.FromErr(errors.New(ErrorDefaultMaxTimeMinVersion)) + } + } if err := CheckRegionConfigsPriorityOrder(params.GetReplicationSpecs()); err != nil { return diag.FromErr(err) @@ -525,6 +548,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. } } + var waitForChanges bool if v := d.Get("paused").(bool); v { request := &admin20240805.ClusterDescription20240805{ Paused: conversion.Pointer(v), @@ -533,6 +557,17 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. if _, _, err := connV220240805.ClustersApi.UpdateCluster(ctx, projectID, d.Get("name").(string), request).Execute(); err != nil { return diag.FromErr(fmt.Errorf(errorUpdate, d.Get("name").(string), err)) } + waitForChanges = true + } + + if pinnedFCVBlock, _ := d.Get("pinned_fcv").([]any); len(pinnedFCVBlock) > 0 { + if diags := PinFCV(ctx, connV2, projectID, clusterName, pinnedFCVBlock[0]); diags.HasError() { + return diags + } + waitForChanges = true + } + + if waitForChanges { if err = waitForUpdateToFinish(ctx, connV2, projectID, d.Get("name").(string), timeout); err != nil { return diag.FromErr(fmt.Errorf(errorUpdate, d.Get("name").(string), err)) } @@ -595,6 +630,8 @@ func resourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Di return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "replication_specs", clusterName, err)) } } + + warning := WarningIfFCVExpiredOrUnpinnedExternally(d, cluster) // has to be called before pinned_fcv value is updated in ResourceData to know prior state value diags := setRootFields(d, cluster, true) if diags.HasError() { return diags @@ -617,7 +654,7 @@ func resourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Di return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "advanced_configuration", clusterName, err)) } - return nil + return warning } // GetReplicationSpecAttributesFromOldAPI returns the id and num shard values of replication specs coming from old API. This is used to populate replication_specs.*.id and replication_specs.*.num_shard attributes for old sharding confirgurations. @@ -739,6 +776,39 @@ func setRootFields(d *schema.ResourceData, cluster *admin.ClusterDescription2024 if err := d.Set("config_server_management_mode", cluster.GetConfigServerManagementMode()); err != nil { return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "config_server_management_mode", clusterName, err)) } + + if err := d.Set("pinned_fcv", FlattenPinnedFCV(cluster)); err != nil { + return diag.FromErr(fmt.Errorf(ErrorClusterAdvancedSetting, "pinned_fcv", clusterName, err)) + } + + return nil +} + +func WarningIfFCVExpiredOrUnpinnedExternally(d *schema.ResourceData, cluster *admin.ClusterDescription20240805) diag.Diagnostics { + pinnedFCVBlock, _ := d.Get("pinned_fcv").([]any) + presentInState := len(pinnedFCVBlock) > 0 + pinIsActive := cluster.FeatureCompatibilityVersionExpirationDate != nil + if presentInState && !pinIsActive { // pin is not active but present in state (and potentially in config file) + return diag.Diagnostics{ + diag.Diagnostic{ + Severity: diag.Warning, + Summary: "FCV pin is no longer active", + Detail: "Please remove `pinned_fcv` from the configuration and apply changes to avoid re-pinning the FCV. Warning can be ignored if `pinned_fcv` block has been removed from the configuration.", + }, + } + } + if presentInState && pinIsActive { + expirationDate := cluster.GetFeatureCompatibilityVersionExpirationDate() + if time.Now().After(expirationDate) { // pin is active, present in state, but its expiration date has passed + return diag.Diagnostics{ + diag.Diagnostic{ + Severity: diag.Warning, + Summary: "FCV pin expiration date has expired", + Detail: "During the next maintenance window FCV will be unpinned. FCV expiration date can be extended, or `pinned_fcv` block can be removed to trigger the unpin immediately.", + }, + } + } + } return nil } @@ -799,6 +869,11 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. timeout := d.Timeout(schema.TimeoutUpdate) + // FCV update is intentionally handled before other cluster updates, and will wait for cluster to reach IDLE state before continuing + if diags := HandlePinnedFCVUpdate(ctx, connV2, projectID, clusterName, d, timeout); diags != nil { + return diags + } + if isUsingOldShardingConfiguration(d) { req, diags := updateRequestOldAPI(d, clusterName) if diags != nil { @@ -895,6 +970,45 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. return resourceRead(ctx, d, meta) } +func HandlePinnedFCVUpdate(ctx context.Context, connV2 *admin.APIClient, projectID, clusterName string, d *schema.ResourceData, timeout time.Duration) diag.Diagnostics { + if d.HasChange("pinned_fcv") { + pinnedFCVBlock, _ := d.Get("pinned_fcv").([]any) + isFCVPresentInConfig := len(pinnedFCVBlock) > 0 + if isFCVPresentInConfig { + // pinned_fcv has been defined or updated expiration date + if diags := PinFCV(ctx, connV2, projectID, clusterName, pinnedFCVBlock[0]); diags.HasError() { + return diags + } + } else { + // pinned_fcv has been removed from the config so unpin method is called + if _, _, err := connV2.ClustersApi.UnpinFeatureCompatibilityVersion(ctx, projectID, clusterName).Execute(); err != nil { + return diag.FromErr(fmt.Errorf(errorUpdate, clusterName, err)) + } + } + // ensures cluster is in IDLE state before continuing with other changes + if err := waitForUpdateToFinish(ctx, connV2, projectID, clusterName, timeout); err != nil { + return diag.FromErr(fmt.Errorf(errorUpdate, clusterName, err)) + } + } + return nil +} + +func PinFCV(ctx context.Context, connV2 *admin.APIClient, projectID, clusterName string, fcvBlock any) diag.Diagnostics { + req := admin.PinFCV{} + if nestedObj, ok := fcvBlock.(map[string]any); ok { + expDateStrPtr := conversion.StringPtr(cast.ToString(nestedObj["expiration_date"])) + expirationTime, ok := conversion.StringPtrToTimePtr(expDateStrPtr) + if !ok { + return diag.FromErr(fmt.Errorf("expiration_date format is incorrect: %s", *expDateStrPtr)) + } + req.ExpirationDate = expirationTime + } + if _, _, err := connV2.ClustersApi.PinFeatureCompatibilityVersion(ctx, projectID, clusterName, &req).Execute(); err != nil { + return diag.FromErr(fmt.Errorf(errorUpdate, clusterName, err)) + } + return nil +} + func updateRequest(ctx context.Context, d *schema.ResourceData, projectID, clusterName string, connV2 *admin.APIClient) (*admin.ClusterDescription20240805, diag.Diagnostics) { cluster := new(admin.ClusterDescription20240805) diff --git a/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go b/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go index 82933fbef7..5d34349677 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go @@ -15,38 +15,45 @@ import ( const versionBeforeISSRelease = "1.17.6" func TestMigAdvancedCluster_replicaSetAWSProvider(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) - testCase := replicaSetAWSProviderTestCase(t) + acc.SkipIfAdvancedClusterV2Schema(t) // AttributeName("advanced_configuration"): invalid JSON, expected "{", got "[" + testCase := replicaSetAWSProviderTestCase(t, false) mig.CreateAndRunTest(t, &testCase) } func TestMigAdvancedCluster_replicaSetMultiCloud(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) - testCase := replicaSetMultiCloudTestCase(t) + acc.SkipIfAdvancedClusterV2Schema(t) // AttributeName("advanced_configuration"): invalid JSON, expected "{", got "[" + testCase := replicaSetMultiCloudTestCase(t, false) mig.CreateAndRunTest(t, &testCase) } func TestMigAdvancedCluster_singleShardedMultiCloud(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) - testCase := singleShardedMultiCloudTestCase(t) + testCase := singleShardedMultiCloudTestCase(t, false) mig.CreateAndRunTest(t, &testCase) } func TestMigAdvancedCluster_symmetricGeoShardedOldSchema(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) - testCase := symmetricGeoShardedOldSchemaTestCase(t) + testCase := symmetricGeoShardedOldSchemaTestCase(t, false) mig.CreateAndRunTest(t, &testCase) } func TestMigAdvancedCluster_asymmetricShardedNewSchema(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + // TODO: Already prepared for TPF but getting this error, note that TestAccClusterAdvancedClusterConfig_asymmetricShardedNewSchema is passing though: + // resource_advanced_cluster_migration_test.go:39: Step 1/2 error: Check failed: Check 2/15 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.0.region_configs.0.electable_specs.disk_iops' not found + // Check 5/15 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.0.region_configs.0.electable_specs.instance_size' not found + // Check 6/15 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.1.region_configs.0.electable_specs.instance_size' not found + // Check 7/15 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.1.region_configs.0.electable_specs.disk_size_gb' not found + // Check 8/15 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.0.region_configs.0.analytics_specs.disk_size_gb' not found + // Check 9/15 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.1.region_configs.0.analytics_specs.disk_size_gb' not found + // Check 10/15 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.0.region_configs.0.electable_specs.disk_size_gb' not found + // Check 11/15 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.1.region_configs.0.electable_specs.disk_iops' not found + acc.SkipIfAdvancedClusterV2Schema(t) mig.SkipIfVersionBelow(t, "1.23.0") // version where sharded cluster tier auto-scaling was introduced - testCase := asymmetricShardedNewSchemaTestCase(t) + testCase := asymmetricShardedNewSchemaTestCase(t, false) mig.CreateAndRunTest(t, &testCase) } func TestMigAdvancedCluster_replicaSetAWSProviderUpdate(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + acc.SkipIfAdvancedClusterV2Schema(t) // This test is specific to the legacy schema var ( projectID = acc.ProjectIDExecution(t) clusterName = acc.RandomClusterName() @@ -58,20 +65,20 @@ func TestMigAdvancedCluster_replicaSetAWSProviderUpdate(t *testing.T) { Steps: []resource.TestStep{ { ExternalProviders: acc.ExternalProviders(versionBeforeISSRelease), - Config: configReplicaSetAWSProvider(projectID, clusterName, 60, 3), - Check: checkReplicaSetAWSProvider(projectID, clusterName, 60, 3, false, false), + Config: configReplicaSetAWSProvider(t, false, projectID, clusterName, 60, 3), + Check: checkReplicaSetAWSProvider(false, projectID, clusterName, 60, 3, false, false), }, { ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Config: configReplicaSetAWSProvider(projectID, clusterName, 60, 5), - Check: checkReplicaSetAWSProvider(projectID, clusterName, 60, 5, true, true), + Config: configReplicaSetAWSProvider(t, false, projectID, clusterName, 60, 5), + Check: checkReplicaSetAWSProvider(false, projectID, clusterName, 60, 5, true, true), }, }, }) } func TestMigAdvancedCluster_geoShardedOldSchemaUpdate(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + acc.SkipIfAdvancedClusterV2Schema(t) // This test is specific to the legacy schema var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region @@ -84,20 +91,20 @@ func TestMigAdvancedCluster_geoShardedOldSchemaUpdate(t *testing.T) { Steps: []resource.TestStep{ { ExternalProviders: acc.ExternalProviders(versionBeforeISSRelease), - Config: configGeoShardedOldSchema(orgID, projectName, clusterName, 2, 2, false), - Check: checkGeoShardedOldSchema(clusterName, 2, 2, false, false), + Config: configGeoShardedOldSchema(t, false, orgID, projectName, clusterName, 2, 2, false), + Check: checkGeoShardedOldSchema(false, clusterName, 2, 2, false, false), }, { ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Config: configGeoShardedOldSchema(orgID, projectName, clusterName, 2, 1, false), - Check: checkGeoShardedOldSchema(clusterName, 2, 1, true, false), + Config: configGeoShardedOldSchema(t, false, orgID, projectName, clusterName, 2, 1, false), + Check: checkGeoShardedOldSchema(false, clusterName, 2, 1, true, false), }, }, }) } func TestMigAdvancedCluster_shardedMigrationFromOldToNewSchema(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + acc.SkipIfAdvancedClusterV2Schema(t) // This test is specific to the legacy schema var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() @@ -110,20 +117,20 @@ func TestMigAdvancedCluster_shardedMigrationFromOldToNewSchema(t *testing.T) { Steps: []resource.TestStep{ { ExternalProviders: acc.ExternalProviders(versionBeforeISSRelease), - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, false, false), - Check: checkShardedTransitionOldToNewSchema(false), + Config: configShardedTransitionOldToNewSchema(t, false, orgID, projectName, clusterName, false, false), + Check: checkShardedTransitionOldToNewSchema(false, false), }, { ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, false), - Check: checkShardedTransitionOldToNewSchema(true), + Config: configShardedTransitionOldToNewSchema(t, false, orgID, projectName, clusterName, true, false), + Check: checkShardedTransitionOldToNewSchema(false, true), }, }, }) } func TestMigAdvancedCluster_geoShardedMigrationFromOldToNewSchema(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + acc.SkipIfAdvancedClusterV2Schema(t) // This test is specific to the legacy schema var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() @@ -136,21 +143,21 @@ func TestMigAdvancedCluster_geoShardedMigrationFromOldToNewSchema(t *testing.T) Steps: []resource.TestStep{ { ExternalProviders: acc.ExternalProviders(versionBeforeISSRelease), - Config: configGeoShardedTransitionOldToNewSchema(orgID, projectName, clusterName, false), - Check: checkGeoShardedTransitionOldToNewSchema(false), + Config: configGeoShardedTransitionOldToNewSchema(t, false, orgID, projectName, clusterName, false), + Check: checkGeoShardedTransitionOldToNewSchema(false, false), }, { ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Config: configGeoShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true), - Check: checkGeoShardedTransitionOldToNewSchema(true), + Config: configGeoShardedTransitionOldToNewSchema(t, false, orgID, projectName, clusterName, true), + Check: checkGeoShardedTransitionOldToNewSchema(false, true), }, }, }) } func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) - mig.SkipIfVersionBelow(t, "1.19.0") // version where change_stream_options_pre_and_post_images_expire_after_seconds was introduced + acc.SkipIfAdvancedClusterV2Schema(t) // This test is specific to the legacy schema + mig.SkipIfVersionBelow(t, "1.22.1") // version where default_max_time_ms was introduced var ( projectID = acc.ProjectIDExecution(t) clusterName = acc.RandomClusterName() @@ -180,7 +187,8 @@ func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) { no_table_scan = false default_read_concern = "available" sample_size_bi_connector = 110 - sample_refresh_interval_bi_connector = 310 + sample_refresh_interval_bi_connector = 310 + default_max_time_ms = 65 } bi_connector_config { @@ -199,7 +207,7 @@ func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) { ExternalProviders: mig.ExternalProviders(), Config: config, Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.fail_index_key_too_long", "false"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.javascript_enabled", "true"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.minimum_enabled_tls_protocol", "TLS1_1"), @@ -213,13 +221,14 @@ func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) { ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, Config: configUpdated, Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.fail_index_key_too_long", "false"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.javascript_enabled", "true"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.minimum_enabled_tls_protocol", "TLS1_1"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.no_table_scan", "false"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.sample_refresh_interval_bi_connector", "310"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.sample_size_bi_connector", "110"), + resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.default_max_time_ms", "65"), resource.TestCheckResourceAttr(resourceName, "bi_connector_config.0.enabled", "false"), resource.TestCheckResourceAttr(resourceName, "bi_connector_config.0.read_preference", "secondary"), ), @@ -230,7 +239,7 @@ func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) { } func TestMigAdvancedCluster_newSchemaFromAutoscalingDisabledToEnabled(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + acc.SkipIfAdvancedClusterV2Schema(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() @@ -243,12 +252,12 @@ func TestMigAdvancedCluster_newSchemaFromAutoscalingDisabledToEnabled(t *testing Steps: []resource.TestStep{ { ExternalProviders: acc.ExternalProviders("1.22.0"), // last version before cluster tier auto-scaling per shard was introduced - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, false), + Config: configShardedTransitionOldToNewSchema(t, false, orgID, projectName, clusterName, true, false), Check: checkIndependentShardScalingMode(clusterName, "CLUSTER"), }, { ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, true), + Config: configShardedTransitionOldToNewSchema(t, false, orgID, projectName, clusterName, true, true), Check: checkIndependentShardScalingMode(clusterName, "SHARD"), }, }, diff --git a/internal/service/advancedcluster/resource_advanced_cluster_state_upgrader_test.go b/internal/service/advancedcluster/resource_advanced_cluster_state_upgrader_test.go index 3ab1a30369..8bc208c61a 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_state_upgrader_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_state_upgrader_test.go @@ -10,8 +10,8 @@ import ( ) func TestMigAdvancedCluster_empty_advancedConfig(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) - acc.SkipInUnitTest(t) // needed because TF test infra is not used + acc.SkipIfAdvancedClusterV2Schema(t) // This test is specific to the legacy schema + acc.SkipInUnitTest(t) // needed because TF test infra is not used v0State := map[string]any{ "project_id": "test-id", "name": "test-cluster", @@ -64,8 +64,8 @@ func TestMigAdvancedCluster_empty_advancedConfig(t *testing.T) { } func TestMigAdvancedCluster_v0StateUpgrade_ReplicationSpecs(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) - acc.SkipInUnitTest(t) // needed because TF test infra is not used + acc.SkipIfAdvancedClusterV2Schema(t) // This test is specific to the legacy schema + acc.SkipInUnitTest(t) // needed because TF test infra is not used v0State := map[string]any{ "project_id": "test-id", "name": "test-cluster", diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index 244dab7f2b..c7827648c1 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -8,10 +8,11 @@ import ( "regexp" "strconv" "testing" + "time" admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" mockadmin20240530 "go.mongodb.org/atlas-sdk/v20240530005/mockadmin" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -90,7 +91,6 @@ func TestGetReplicationSpecAttributesFromOldAPI(t *testing.T) { } func TestAccClusterAdvancedCluster_basicTenant(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) var ( projectID = acc.ProjectIDExecution(t) clusterName = acc.RandomClusterName() @@ -102,28 +102,23 @@ func TestAccClusterAdvancedCluster_basicTenant(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configTenant(projectID, clusterName), - Check: checkTenant(projectID, clusterName), + Config: configTenant(t, true, projectID, clusterName), + Check: checkTenant(true, projectID, clusterName), }, { - Config: configTenant(projectID, clusterNameUpdated), - Check: checkTenant(projectID, clusterNameUpdated), - }, - { - ResourceName: resourceName, - ImportStateIdFunc: acc.ImportStateClusterIDFunc(resourceName), - ImportState: true, - ImportStateVerify: true, + Config: configTenant(t, true, projectID, clusterNameUpdated), + Check: checkTenant(true, projectID, clusterNameUpdated), }, + acc.TestStepImportCluster(resourceName), }, }) } func TestAccClusterAdvancedCluster_replicaSetAWSProvider(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) - resource.ParallelTest(t, replicaSetAWSProviderTestCase(t)) + resource.ParallelTest(t, replicaSetAWSProviderTestCase(t, true)) } -func replicaSetAWSProviderTestCase(t *testing.T) resource.TestCase { + +func replicaSetAWSProviderTestCase(t *testing.T, isAcc bool) resource.TestCase { t.Helper() var ( projectID = acc.ProjectIDExecution(t) @@ -136,29 +131,23 @@ func replicaSetAWSProviderTestCase(t *testing.T) resource.TestCase { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configReplicaSetAWSProvider(projectID, clusterName, 60, 3), - Check: checkReplicaSetAWSProvider(projectID, clusterName, 60, 3, true, true), - }, - { - Config: configReplicaSetAWSProvider(projectID, clusterName, 50, 5), - Check: checkReplicaSetAWSProvider(projectID, clusterName, 50, 5, true, true), + Config: configReplicaSetAWSProvider(t, isAcc, projectID, clusterName, 60, 3), + Check: checkReplicaSetAWSProvider(isAcc, projectID, clusterName, 60, 3, true, true), }, { - ResourceName: resourceName, - ImportStateIdFunc: acc.ImportStateClusterIDFunc(resourceName), - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"replication_specs", "retain_backups_enabled"}, + Config: configReplicaSetAWSProvider(t, isAcc, projectID, clusterName, 50, 5), + Check: checkReplicaSetAWSProvider(isAcc, projectID, clusterName, 50, 5, true, true), }, + acc.TestStepImportCluster(resourceName, "replication_specs", "retain_backups_enabled"), }, } } func TestAccClusterAdvancedCluster_replicaSetMultiCloud(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) - resource.ParallelTest(t, replicaSetMultiCloudTestCase(t)) + resource.ParallelTest(t, replicaSetMultiCloudTestCase(t, true)) } -func replicaSetMultiCloudTestCase(t *testing.T) resource.TestCase { + +func replicaSetMultiCloudTestCase(t *testing.T, isAcc bool) resource.TestCase { t.Helper() var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") @@ -173,31 +162,29 @@ func replicaSetMultiCloudTestCase(t *testing.T) resource.TestCase { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configReplicaSetMultiCloud(orgID, projectName, clusterName), - Check: checkReplicaSetMultiCloud(clusterName, 3), - }, - { - Config: configReplicaSetMultiCloud(orgID, projectName, clusterNameUpdated), - Check: checkReplicaSetMultiCloud(clusterNameUpdated, 3), + Config: configReplicaSetMultiCloud(t, isAcc, orgID, projectName, clusterName), + Check: checkReplicaSetMultiCloud(isAcc, clusterName, 3), }, { - ResourceName: resourceName, - ImportStateIdFunc: acc.ImportStateClusterIDFunc(resourceName), - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"replication_specs", "retain_backups_enabled"}, + Config: configReplicaSetMultiCloud(t, isAcc, orgID, projectName, clusterNameUpdated), + Check: checkReplicaSetMultiCloud(isAcc, clusterNameUpdated, 3), }, + acc.TestStepImportCluster(resourceName, "replication_specs", "retain_backups_enabled"), }, } } func TestAccClusterAdvancedCluster_singleShardedMultiCloud(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) - resource.ParallelTest(t, singleShardedMultiCloudTestCase(t)) + resource.ParallelTest(t, singleShardedMultiCloudTestCase(t, true)) } -func singleShardedMultiCloudTestCase(t *testing.T) resource.TestCase { +func singleShardedMultiCloudTestCase(t *testing.T, isAcc bool) resource.TestCase { t.Helper() + // TODO: Already prepared for TPF but getting this error: + // resource_advanced_cluster_test.go:119: Step 1/3 error: Check failed: Check 9/12 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.0.region_configs.0.electable_specs.0.disk_iops' expected to be set + // Check 10/12 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.0.region_configs.0.analytics_specs.0.disk_iops' expected to be set + // Check 11/12 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.0.region_configs.1.electable_specs.0.disk_iops' expected to be set + acc.SkipIfAdvancedClusterV2Schema(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region @@ -211,26 +198,19 @@ func singleShardedMultiCloudTestCase(t *testing.T) resource.TestCase { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configShardedOldSchemaMultiCloud(orgID, projectName, clusterName, 1, "M10", nil), - Check: checkShardedOldSchemaMultiCloud(clusterName, 1, "M10", true, nil), - }, - { - Config: configShardedOldSchemaMultiCloud(orgID, projectName, clusterNameUpdated, 1, "M10", nil), - Check: checkShardedOldSchemaMultiCloud(clusterNameUpdated, 1, "M10", true, nil), + Config: configShardedOldSchemaMultiCloud(t, isAcc, orgID, projectName, clusterName, 1, "M10", nil), + Check: checkShardedOldSchemaMultiCloud(isAcc, clusterName, 1, "M10", true, nil), }, { - ResourceName: resourceName, - ImportStateIdFunc: acc.ImportStateClusterIDFunc(resourceName), - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"replication_specs"}, + Config: configShardedOldSchemaMultiCloud(t, isAcc, orgID, projectName, clusterNameUpdated, 1, "M10", nil), + Check: checkShardedOldSchemaMultiCloud(isAcc, clusterNameUpdated, 1, "M10", true, nil), }, + acc.TestStepImportCluster(resourceName, "replication_specs"), }, } } func TestAccClusterAdvancedCluster_unpausedToPaused(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) var ( projectID = acc.ProjectIDExecution(t) clusterName = acc.RandomClusterName() @@ -244,30 +224,23 @@ func TestAccClusterAdvancedCluster_unpausedToPaused(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configSingleProviderPaused(projectID, clusterName, false, instanceSize), - Check: checkSingleProviderPaused(clusterName, false), + Config: configSingleProviderPaused(t, true, projectID, clusterName, false, instanceSize), + Check: checkSingleProviderPaused(true, clusterName, false), }, { - Config: configSingleProviderPaused(projectID, clusterName, true, instanceSize), - Check: checkSingleProviderPaused(clusterName, true), + Config: configSingleProviderPaused(t, true, projectID, clusterName, true, instanceSize), + Check: checkSingleProviderPaused(true, clusterName, true), }, { - Config: configSingleProviderPaused(projectID, clusterName, true, anotherInstanceSize), + Config: configSingleProviderPaused(t, true, projectID, clusterName, true, anotherInstanceSize), ExpectError: regexp.MustCompile("CANNOT_UPDATE_PAUSED_CLUSTER"), }, - { - ResourceName: resourceName, - ImportStateIdFunc: acc.ImportStateClusterIDFunc(resourceName), - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"replication_specs"}, - }, + acc.TestStepImportCluster(resourceName, "replication_specs"), }, }) } func TestAccClusterAdvancedCluster_pausedToUnpaused(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) var ( projectID = acc.ProjectIDExecution(t) clusterName = acc.RandomClusterName() @@ -280,38 +253,75 @@ func TestAccClusterAdvancedCluster_pausedToUnpaused(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configSingleProviderPaused(projectID, clusterName, true, instanceSize), - Check: checkSingleProviderPaused(clusterName, true), + Config: configSingleProviderPaused(t, true, projectID, clusterName, true, instanceSize), + Check: checkSingleProviderPaused(true, clusterName, true), }, { - Config: configSingleProviderPaused(projectID, clusterName, false, instanceSize), - Check: checkSingleProviderPaused(clusterName, false), + Config: configSingleProviderPaused(t, true, projectID, clusterName, false, instanceSize), + Check: checkSingleProviderPaused(true, clusterName, false), }, { - Config: configSingleProviderPaused(projectID, clusterName, true, instanceSize), + Config: configSingleProviderPaused(t, true, projectID, clusterName, true, instanceSize), ExpectError: regexp.MustCompile("CANNOT_PAUSE_RECENTLY_RESUMED_CLUSTER"), }, { - Config: configSingleProviderPaused(projectID, clusterName, false, instanceSize), + Config: configSingleProviderPaused(t, true, projectID, clusterName, false, instanceSize), + }, + acc.TestStepImportCluster(resourceName, "replication_specs"), + }, + }) +} + +func TestAccClusterAdvancedCluster_advancedConfig_oldMongoDBVersion(t *testing.T) { + // TODO: Already prepared for TPF but getting this error: + // unexpected new value: .advanced_configuration.fail_index_key_too_long: was cty.False, but now null + acc.SkipIfAdvancedClusterV2Schema(t) + var ( + projectID = acc.ProjectIDExecution(t) + clusterName = acc.RandomClusterName() + + processArgs20240530 = &admin20240530.ClusterDescriptionProcessArgs{ + DefaultReadConcern: conversion.StringPtr("available"), + DefaultWriteConcern: conversion.StringPtr("1"), + FailIndexKeyTooLong: conversion.Pointer(false), + JavascriptEnabled: conversion.Pointer(true), + MinimumEnabledTlsProtocol: conversion.StringPtr("TLS1_1"), + NoTableScan: conversion.Pointer(false), + OplogSizeMB: conversion.Pointer(1000), + SampleRefreshIntervalBIConnector: conversion.Pointer(310), + SampleSizeBIConnector: conversion.Pointer(110), + TransactionLifetimeLimitSeconds: conversion.Pointer[int64](300), + } + processArgs = &admin.ClusterDescriptionProcessArgs20240805{ + ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: conversion.IntPtr(-1), // this will not be set in the TF configuration + DefaultMaxTimeMS: conversion.IntPtr(65), + } + ) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName), + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configAdvanced(t, true, projectID, clusterName, "6.0", processArgs20240530, processArgs), + ExpectError: regexp.MustCompile(advancedcluster.ErrorDefaultMaxTimeMinVersion), }, { - ResourceName: resourceName, - ImportStateIdFunc: acc.ImportStateClusterIDFunc(resourceName), - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"replication_specs"}, + Config: configAdvanced(t, true, projectID, clusterName, "6.0", processArgs20240530, &admin.ClusterDescriptionProcessArgs20240805{}), + Check: checkAdvanced(true, clusterName, "TLS1_1", &admin.ClusterDescriptionProcessArgs20240805{}), }, }, }) } func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + acc.SkipIfAdvancedClusterV2Schema(t) var ( - projectID = acc.ProjectIDExecution(t) - clusterName = acc.RandomClusterName() - clusterNameUpdated = acc.RandomClusterName() - processArgs = &admin20240530.ClusterDescriptionProcessArgs{ + projectID = acc.ProjectIDExecution(t) + clusterName = acc.RandomClusterName() + clusterNameUpdated = acc.RandomClusterName() + processArgs20240530 = &admin20240530.ClusterDescriptionProcessArgs{ DefaultReadConcern: conversion.StringPtr("available"), DefaultWriteConcern: conversion.StringPtr("1"), FailIndexKeyTooLong: conversion.Pointer(false), @@ -323,7 +333,11 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { SampleSizeBIConnector: conversion.Pointer(110), TransactionLifetimeLimitSeconds: conversion.Pointer[int64](300), } - processArgsUpdated = &admin20240530.ClusterDescriptionProcessArgs{ + processArgs = &admin.ClusterDescriptionProcessArgs20240805{ + ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: conversion.IntPtr(-1), // this will not be set in the TF configuration + } + + processArgs20240530Updated = &admin20240530.ClusterDescriptionProcessArgs{ DefaultReadConcern: conversion.StringPtr("available"), DefaultWriteConcern: conversion.StringPtr("0"), FailIndexKeyTooLong: conversion.Pointer(false), @@ -335,6 +349,10 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { SampleSizeBIConnector: conversion.Pointer(110), TransactionLifetimeLimitSeconds: conversion.Pointer[int64](300), } + processArgsUpdated = &admin.ClusterDescriptionProcessArgs20240805{ + DefaultMaxTimeMS: conversion.IntPtr(65), + ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: conversion.IntPtr(100), + } ) resource.ParallelTest(t, resource.TestCase{ @@ -343,19 +361,21 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configAdvanced(projectID, clusterName, processArgs, nil), - Check: checkAdvanced(clusterName, "TLS1_1", "-1"), + Config: configAdvanced(t, true, projectID, clusterName, "", processArgs20240530, processArgs), + Check: checkAdvanced(true, clusterName, "TLS1_1", processArgs), }, { - Config: configAdvanced(projectID, clusterNameUpdated, processArgsUpdated, conversion.IntPtr(100)), - Check: checkAdvanced(clusterNameUpdated, "TLS1_2", "100"), + Config: configAdvanced(t, true, projectID, clusterNameUpdated, "", processArgs20240530Updated, processArgsUpdated), + Check: checkAdvanced(true, clusterNameUpdated, "TLS1_2", processArgsUpdated), }, }, }) } func TestAccClusterAdvancedCluster_defaultWrite(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + // TODO: Already prepared for TPF but getting this error: + // Check failed: Check 8/14 error: mongodbatlas_advanced_cluster.test: Attribute 'advanced_configuration.fail_index_key_too_long' not found + acc.SkipIfAdvancedClusterV2Schema(t) var ( projectID = acc.ProjectIDExecution(t) clusterName = acc.RandomClusterName() @@ -389,19 +409,21 @@ func TestAccClusterAdvancedCluster_defaultWrite(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configAdvancedDefaultWrite(projectID, clusterName, processArgs), - Check: checkAdvancedDefaultWrite(clusterName, "1", "TLS1_1"), + Config: configAdvancedDefaultWrite(t, true, projectID, clusterName, processArgs), + Check: checkAdvancedDefaultWrite(true, clusterName, "1", "TLS1_1"), }, { - Config: configAdvancedDefaultWrite(projectID, clusterNameUpdated, processArgsUpdated), - Check: checkAdvancedDefaultWrite(clusterNameUpdated, "majority", "TLS1_2"), + Config: configAdvancedDefaultWrite(t, true, projectID, clusterNameUpdated, processArgsUpdated), + Check: checkAdvancedDefaultWrite(true, clusterNameUpdated, "majority", "TLS1_2"), }, }, }) } func TestAccClusterAdvancedClusterConfig_replicationSpecsAutoScaling(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + // TODO: Already prepared for TPF but getting this error: + // POST: HTTP 400 Bad Request (Error code: "INVALID_ENUM_VALUE") Detail: An invalid enumeration value was specified. Reason: Bad Request. Params: [], + acc.SkipIfAdvancedClusterV2Schema(t) var ( projectID = acc.ProjectIDExecution(t) clusterName = acc.RandomClusterName() @@ -422,22 +444,22 @@ func TestAccClusterAdvancedClusterConfig_replicationSpecsAutoScaling(t *testing. CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configReplicationSpecsAutoScaling(projectID, clusterName, autoScaling), + Config: configReplicationSpecsAutoScaling(t, true, projectID, clusterName, autoScaling), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), - resource.TestCheckResourceAttr(resourceName, "name", clusterName), - resource.TestCheckResourceAttrSet(resourceName, "replication_specs.0.region_configs.#"), - resource.TestCheckResourceAttr(resourceName, "replication_specs.0.region_configs.0.auto_scaling.0.compute_enabled", "false"), - resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.oplog_min_retention_hours", "5.5"), + acc.CheckExistsCluster(resourceName), + acc.TestCheckResourceAttrSchemaV2(true, resourceName, "name", clusterName), + acc.TestCheckResourceAttrSetSchemaV2(true, resourceName, "replication_specs.0.region_configs.#"), + acc.TestCheckResourceAttrSchemaV2(true, resourceName, "replication_specs.0.region_configs.0.auto_scaling.0.compute_enabled", "false"), + acc.TestCheckResourceAttrSchemaV2(true, resourceName, "advanced_configuration.0.oplog_min_retention_hours", "5.5"), ), }, { - Config: configReplicationSpecsAutoScaling(projectID, clusterNameUpdated, autoScalingUpdated), + Config: configReplicationSpecsAutoScaling(t, true, projectID, clusterNameUpdated, autoScalingUpdated), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), - resource.TestCheckResourceAttr(resourceName, "name", clusterNameUpdated), - resource.TestCheckResourceAttrSet(resourceName, "replication_specs.0.region_configs.#"), - resource.TestCheckResourceAttr(resourceName, "replication_specs.0.region_configs.0.auto_scaling.0.compute_enabled", "true"), + acc.CheckExistsCluster(resourceName), + acc.TestCheckResourceAttrSchemaV2(true, resourceName, "name", clusterNameUpdated), + acc.TestCheckResourceAttrSetSchemaV2(true, resourceName, "replication_specs.0.region_configs.#"), + acc.TestCheckResourceAttrSchemaV2(true, resourceName, "replication_specs.0.region_configs.0.auto_scaling.0.compute_enabled", "true"), ), }, }, @@ -445,7 +467,9 @@ func TestAccClusterAdvancedClusterConfig_replicationSpecsAutoScaling(t *testing. } func TestAccClusterAdvancedClusterConfig_replicationSpecsAnalyticsAutoScaling(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + // TODO: Already prepared for TPF but getting this error: + // POST: HTTP 400 Bad Request (Error code: "INVALID_ENUM_VALUE") Detail: An invalid enumeration value was specified. Reason: Bad Request. Params: [], + acc.SkipIfAdvancedClusterV2Schema(t) var ( projectID = acc.ProjectIDExecution(t) clusterName = acc.RandomClusterName() @@ -466,21 +490,21 @@ func TestAccClusterAdvancedClusterConfig_replicationSpecsAnalyticsAutoScaling(t CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configReplicationSpecsAnalyticsAutoScaling(projectID, clusterName, autoScaling), + Config: configReplicationSpecsAnalyticsAutoScaling(t, true, projectID, clusterName, autoScaling), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), - resource.TestCheckResourceAttr(resourceName, "name", clusterName), - resource.TestCheckResourceAttrSet(resourceName, "replication_specs.0.region_configs.#"), - resource.TestCheckResourceAttr(resourceName, "replication_specs.0.region_configs.0.analytics_auto_scaling.0.compute_enabled", "false"), + acc.CheckExistsCluster(resourceName), + acc.TestCheckResourceAttrSchemaV2(true, resourceName, "name", clusterName), + acc.TestCheckResourceAttrSetSchemaV2(true, resourceName, "replication_specs.0.region_configs.#"), + acc.TestCheckResourceAttrSchemaV2(true, resourceName, "replication_specs.0.region_configs.0.analytics_auto_scaling.0.compute_enabled", "false"), ), }, { - Config: configReplicationSpecsAnalyticsAutoScaling(projectID, clusterNameUpdated, autoScalingUpdated), + Config: configReplicationSpecsAnalyticsAutoScaling(t, true, projectID, clusterNameUpdated, autoScalingUpdated), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), - resource.TestCheckResourceAttr(resourceName, "name", clusterNameUpdated), - resource.TestCheckResourceAttrSet(resourceName, "replication_specs.0.region_configs.#"), - resource.TestCheckResourceAttr(resourceName, "replication_specs.0.region_configs.0.analytics_auto_scaling.0.compute_enabled", "true"), + acc.CheckExistsCluster(resourceName), + acc.TestCheckResourceAttrSchemaV2(true, resourceName, "name", clusterNameUpdated), + acc.TestCheckResourceAttrSetSchemaV2(true, resourceName, "replication_specs.0.region_configs.#"), + acc.TestCheckResourceAttrSchemaV2(true, resourceName, "replication_specs.0.region_configs.0.analytics_auto_scaling.0.compute_enabled", "true"), ), }, }, @@ -488,7 +512,9 @@ func TestAccClusterAdvancedClusterConfig_replicationSpecsAnalyticsAutoScaling(t } func TestAccClusterAdvancedClusterConfig_singleShardedTransitionToOldSchemaExpectsError(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + // TODO: Already prepared for TPF but getting this error: + // POST: HTTP 400 Bad Request (Error code: "ASYMMETRIC_REGION_TOPOLOGY_IN_ZONE"). Detail: All shards in the same zone must have the same region topology. + acc.SkipIfAdvancedClusterV2Schema(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region @@ -501,11 +527,11 @@ func TestAccClusterAdvancedClusterConfig_singleShardedTransitionToOldSchemaExpec CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configGeoShardedOldSchema(orgID, projectName, clusterName, 1, 1, false), - Check: checkGeoShardedOldSchema(clusterName, 1, 1, true, true), + Config: configGeoShardedOldSchema(t, true, orgID, projectName, clusterName, 1, 1, false), + Check: checkGeoShardedOldSchema(true, clusterName, 1, 1, true, true), }, { - Config: configGeoShardedOldSchema(orgID, projectName, clusterName, 1, 2, false), + Config: configGeoShardedOldSchema(t, true, orgID, projectName, clusterName, 1, 2, false), ExpectError: regexp.MustCompile(advancedcluster.ErrorOperationNotPermitted), }, }, @@ -513,7 +539,6 @@ func TestAccClusterAdvancedClusterConfig_singleShardedTransitionToOldSchemaExpec } func TestAccClusterAdvancedCluster_withTags(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() // No ProjectIDExecution to check correctly plural data source in the different test steps @@ -526,27 +551,62 @@ func TestAccClusterAdvancedCluster_withTags(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configWithTags(orgID, projectName, clusterName), - Check: checkTags(clusterName), + Config: configWithKeyValueBlocks(t, true, orgID, projectName, clusterName, "tags"), + Check: checkKeyValueBlocks(true, clusterName, "tags"), }, { - Config: configWithTags(orgID, projectName, clusterName, acc.ClusterTagsMap1, acc.ClusterTagsMap2), - Check: checkTags(clusterName, acc.ClusterTagsMap1, acc.ClusterTagsMap2), + Config: configWithKeyValueBlocks(t, true, orgID, projectName, clusterName, "tags", acc.ClusterTagsMap1, acc.ClusterTagsMap2), + Check: checkKeyValueBlocks(true, clusterName, "tags", acc.ClusterTagsMap1, acc.ClusterTagsMap2), }, { - Config: configWithTags(orgID, projectName, clusterName, acc.ClusterTagsMap3), - Check: checkTags(clusterName, acc.ClusterTagsMap3), + Config: configWithKeyValueBlocks(t, true, orgID, projectName, clusterName, "tags", acc.ClusterTagsMap3), + Check: checkKeyValueBlocks(true, clusterName, "tags", acc.ClusterTagsMap3), + }, + }, + }) +} + +func TestAccClusterAdvancedCluster_withLabels(t *testing.T) { + var ( + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acc.RandomProjectName() // No ProjectIDExecution to check correctly plural data source in the different test steps + clusterName = acc.RandomClusterName() + ) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acc.PreCheckBasic(t) }, + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configWithKeyValueBlocks(t, true, orgID, projectName, clusterName, "labels"), + Check: checkKeyValueBlocks(true, clusterName, "labels"), + }, + { + Config: configWithKeyValueBlocks(t, true, orgID, projectName, clusterName, "labels", acc.ClusterLabelsMap1, acc.ClusterLabelsMap2), + Check: checkKeyValueBlocks(true, clusterName, "labels", acc.ClusterLabelsMap1, acc.ClusterLabelsMap2), + }, + { + Config: configWithKeyValueBlocks(t, true, orgID, projectName, clusterName, "labels", acc.ClusterLabelsMap3), + Check: checkKeyValueBlocks(true, clusterName, "labels", acc.ClusterLabelsMap3), }, }, }) } func TestAccClusterAdvancedClusterConfig_selfManagedSharding(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + // TODO: Already prepared for TPF but getting this error: + // POST: HTTP 400 Bad Request (Error code: "ASYMMETRIC_REGION_TOPOLOGY_IN_ZONE"). Detail: All shards in the same zone must have the same region topology. + acc.SkipIfAdvancedClusterV2Schema(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region clusterName = acc.RandomClusterName() + checks = []resource.TestCheckFunc{ + acc.CheckExistsCluster(resourceName), + acc.TestCheckResourceAttrSchemaV2(true, resourceName, "global_cluster_self_managed_sharding", "true"), + acc.TestCheckResourceAttrSchemaV2(true, dataSourceName, "global_cluster_self_managed_sharding", "true"), + } ) resource.ParallelTest(t, resource.TestCase{ @@ -555,15 +615,12 @@ func TestAccClusterAdvancedClusterConfig_selfManagedSharding(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configGeoShardedOldSchema(orgID, projectName, clusterName, 1, 1, true), - Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), - resource.TestCheckResourceAttr(resourceName, "global_cluster_self_managed_sharding", "true"), - resource.TestCheckResourceAttr(dataSourceName, "global_cluster_self_managed_sharding", "true"), + Config: configGeoShardedOldSchema(t, true, orgID, projectName, clusterName, 1, 1, true), + Check: resource.ComposeAggregateTestCheckFunc(checks..., ), }, { - Config: configGeoShardedOldSchema(orgID, projectName, clusterName, 1, 1, false), + Config: configGeoShardedOldSchema(t, true, orgID, projectName, clusterName, 1, 1, false), ExpectError: regexp.MustCompile("CANNOT_MODIFY_GLOBAL_CLUSTER_MANAGEMENT_SETTING"), }, }, @@ -571,7 +628,6 @@ func TestAccClusterAdvancedClusterConfig_selfManagedSharding(t *testing.T) { } func TestAccClusterAdvancedClusterConfig_selfManagedShardingIncorrectType(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) var ( projectID = acc.ProjectIDExecution(t) clusterName = acc.RandomClusterName() @@ -583,7 +639,7 @@ func TestAccClusterAdvancedClusterConfig_selfManagedShardingIncorrectType(t *tes CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configIncorrectTypeGobalClusterSelfManagedSharding(projectID, clusterName), + Config: configIncorrectTypeGobalClusterSelfManagedSharding(t, true, projectID, clusterName), ExpectError: regexp.MustCompile("CANNOT_SET_SELF_MANAGED_SHARDING_FOR_NON_GLOBAL_CLUSTER"), }, }, @@ -591,7 +647,12 @@ func TestAccClusterAdvancedClusterConfig_selfManagedShardingIncorrectType(t *tes } func TestAccClusterAdvancedClusterConfig_symmetricShardedOldSchema(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + // TODO: Already prepared for TPF but getting this error: + // resource_advanced_cluster_test.go:545: Step 1/2 error: Check failed: Check 3/13 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.0.num_shards' expected "2", got "1" + // Check 9/13 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.0.region_configs.0.electable_specs.0.disk_iops' expected to be set + // Check 10/13 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.0.region_configs.0.analytics_specs.0.disk_iops' expected to be set + // Check 11/13 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.0.region_configs.1.electable_specs.0.disk_iops' expected to be set + acc.SkipIfAdvancedClusterV2Schema(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region @@ -604,24 +665,26 @@ func TestAccClusterAdvancedClusterConfig_symmetricShardedOldSchema(t *testing.T) CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configShardedOldSchemaMultiCloud(orgID, projectName, clusterName, 2, "M10", &configServerManagementModeFixedToDedicated), - Check: checkShardedOldSchemaMultiCloud(clusterName, 2, "M10", false, &configServerManagementModeFixedToDedicated), + Config: configShardedOldSchemaMultiCloud(t, true, orgID, projectName, clusterName, 2, "M10", &configServerManagementModeFixedToDedicated), + Check: checkShardedOldSchemaMultiCloud(true, clusterName, 2, "M10", false, &configServerManagementModeFixedToDedicated), }, { - Config: configShardedOldSchemaMultiCloud(orgID, projectName, clusterName, 2, "M20", &configServerManagementModeAtlasManaged), - Check: checkShardedOldSchemaMultiCloud(clusterName, 2, "M20", false, &configServerManagementModeAtlasManaged), + Config: configShardedOldSchemaMultiCloud(t, true, orgID, projectName, clusterName, 2, "M20", &configServerManagementModeAtlasManaged), + Check: checkShardedOldSchemaMultiCloud(true, clusterName, 2, "M20", false, &configServerManagementModeAtlasManaged), }, }, }) } func TestAccClusterAdvancedClusterConfig_symmetricGeoShardedOldSchema(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) - resource.ParallelTest(t, symmetricGeoShardedOldSchemaTestCase(t)) + resource.ParallelTest(t, symmetricGeoShardedOldSchemaTestCase(t, true)) } -func symmetricGeoShardedOldSchemaTestCase(t *testing.T) resource.TestCase { +func symmetricGeoShardedOldSchemaTestCase(t *testing.T, isAcc bool) resource.TestCase { t.Helper() + // TODO: Already prepared for TPF but getting this error: + // POST: HTTP 400 Bad Request (Error code: "INVALID_ENUM_VALUE") Detail: An invalid enumeration value was specified. Reason: Bad Request. Params: [], + acc.SkipIfAdvancedClusterV2Schema(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region @@ -634,15 +697,15 @@ func symmetricGeoShardedOldSchemaTestCase(t *testing.T) resource.TestCase { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configGeoShardedOldSchema(orgID, projectName, clusterName, 2, 2, false), + Config: configGeoShardedOldSchema(t, isAcc, orgID, projectName, clusterName, 2, 2, false), Check: resource.ComposeAggregateTestCheckFunc( - checkGeoShardedOldSchema(clusterName, 2, 2, true, false), + checkGeoShardedOldSchema(isAcc, clusterName, 2, 2, true, false), checkIndependentShardScalingMode(clusterName, "CLUSTER")), }, { - Config: configGeoShardedOldSchema(orgID, projectName, clusterName, 3, 3, false), + Config: configGeoShardedOldSchema(t, isAcc, orgID, projectName, clusterName, 3, 3, false), Check: resource.ComposeAggregateTestCheckFunc( - checkGeoShardedOldSchema(clusterName, 3, 3, true, false), + checkGeoShardedOldSchema(isAcc, clusterName, 3, 3, true, false), checkIndependentShardScalingMode(clusterName, "CLUSTER")), }, }, @@ -650,7 +713,9 @@ func symmetricGeoShardedOldSchemaTestCase(t *testing.T) resource.TestCase { } func TestAccClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + // TODO: Already prepared for TPF but getting this error: + // Check failed: Check 2/5 error: mongodbatlas_advanced_cluster.test: Attribute 'replication_specs.0.num_shards' expected \"2\", got \"1\" + acc.SkipIfAdvancedClusterV2Schema(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() @@ -663,19 +728,21 @@ func TestAccClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtEl CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configShardedOldSchemaDiskSizeGBElectableLevel(orgID, projectName, clusterName, 50), - Check: checkShardedOldSchemaDiskSizeGBElectableLevel(50), + Config: configShardedOldSchemaDiskSizeGBElectableLevel(t, true, orgID, projectName, clusterName, 50), + Check: checkShardedOldSchemaDiskSizeGBElectableLevel(true, 50), }, { - Config: configShardedOldSchemaDiskSizeGBElectableLevel(orgID, projectName, clusterName, 55), - Check: checkShardedOldSchemaDiskSizeGBElectableLevel(55), + Config: configShardedOldSchemaDiskSizeGBElectableLevel(t, true, orgID, projectName, clusterName, 55), + Check: checkShardedOldSchemaDiskSizeGBElectableLevel(true, 55), }, }, }) } func TestAccClusterAdvancedClusterConfig_symmetricShardedNewSchemaToAsymmetricAddingRemovingShard(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + // TODO: Already prepared for TPF but getting this error: + // PATCH: HTTP 400 Bad Request (Error code: \"AUTO_SCALINGS_MUST_BE_IN_EVERY_REGION_CONFIG\") Detail: If any regionConfigs specify an autoScaling object, all regionConfigs must also specify an autoScaling object. + acc.SkipIfAdvancedClusterV2Schema(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() @@ -688,27 +755,26 @@ func TestAccClusterAdvancedClusterConfig_symmetricShardedNewSchemaToAsymmetricAd CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configShardedNewSchema(orgID, projectName, clusterName, 50, "M10", "M10", nil, nil, false), - Check: checkShardedNewSchema(50, "M10", "M10", nil, nil, false, false), + Config: configShardedNewSchema(t, true, orgID, projectName, clusterName, 50, "M10", "M10", nil, nil, false), + Check: checkShardedNewSchema(true, 50, "M10", "M10", nil, nil, false, false), }, { - Config: configShardedNewSchema(orgID, projectName, clusterName, 55, "M10", "M20", nil, nil, true), // add middle replication spec and transition to asymmetric - Check: checkShardedNewSchema(55, "M10", "M20", nil, nil, true, true), + Config: configShardedNewSchema(t, true, orgID, projectName, clusterName, 55, "M10", "M20", nil, nil, true), // add middle replication spec and transition to asymmetric + Check: checkShardedNewSchema(true, 55, "M10", "M20", nil, nil, true, true), }, { - Config: configShardedNewSchema(orgID, projectName, clusterName, 55, "M10", "M20", nil, nil, false), // removes middle replication spec - Check: checkShardedNewSchema(55, "M10", "M20", nil, nil, true, false), + Config: configShardedNewSchema(t, true, orgID, projectName, clusterName, 55, "M10", "M20", nil, nil, false), // removes middle replication spec + Check: checkShardedNewSchema(true, 55, "M10", "M20", nil, nil, true, false), }, }, }) } func TestAccClusterAdvancedClusterConfig_asymmetricShardedNewSchema(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) - resource.ParallelTest(t, asymmetricShardedNewSchemaTestCase(t)) + resource.ParallelTest(t, asymmetricShardedNewSchemaTestCase(t, true)) } -func asymmetricShardedNewSchemaTestCase(t *testing.T) resource.TestCase { +func asymmetricShardedNewSchemaTestCase(t *testing.T, isAcc bool) resource.TestCase { t.Helper() var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") @@ -722,9 +788,9 @@ func asymmetricShardedNewSchemaTestCase(t *testing.T) resource.TestCase { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configShardedNewSchema(orgID, projectName, clusterName, 50, "M30", "M40", admin.PtrInt(2000), admin.PtrInt(2500), false), + Config: configShardedNewSchema(t, isAcc, orgID, projectName, clusterName, 50, "M30", "M40", admin.PtrInt(2000), admin.PtrInt(2500), false), Check: resource.ComposeAggregateTestCheckFunc( - checkShardedNewSchema(50, "M30", "M40", admin.PtrInt(2000), admin.PtrInt(2500), true, false), + checkShardedNewSchema(isAcc, 50, "M30", "M40", admin.PtrInt(2000), admin.PtrInt(2500), true, false), resource.TestCheckResourceAttr("data.mongodbatlas_advanced_clusters.test-replication-specs-per-shard-false", "results.#", "0"), checkIndependentShardScalingMode(clusterName, "SHARD")), }, @@ -733,7 +799,9 @@ func asymmetricShardedNewSchemaTestCase(t *testing.T) resource.TestCase { } func TestAccClusterAdvancedClusterConfig_asymmetricGeoShardedNewSchemaAddingRemovingShard(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + // TODO: Already prepared for TPF but getting this error: + // POST: HTTP 400 Bad Request (Error code: "ASYMMETRIC_REGION_TOPOLOGY_IN_ZONE"). Detail: All shards in the same zone must have the same region topology. + acc.SkipIfAdvancedClusterV2Schema(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() @@ -746,23 +814,25 @@ func TestAccClusterAdvancedClusterConfig_asymmetricGeoShardedNewSchemaAddingRemo CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configGeoShardedNewSchema(orgID, projectName, clusterName, false), - Check: checkGeoShardedNewSchema(false), + Config: configGeoShardedNewSchema(t, true, orgID, projectName, clusterName, false), + Check: checkGeoShardedNewSchema(true, false), }, { - Config: configGeoShardedNewSchema(orgID, projectName, clusterName, true), - Check: checkGeoShardedNewSchema(true), + Config: configGeoShardedNewSchema(t, true, orgID, projectName, clusterName, true), + Check: checkGeoShardedNewSchema(true, true), }, { - Config: configGeoShardedNewSchema(orgID, projectName, clusterName, false), - Check: checkGeoShardedNewSchema(false), + Config: configGeoShardedNewSchema(t, true, orgID, projectName, clusterName, false), + Check: checkGeoShardedNewSchema(true, false), }, }, }) } func TestAccClusterAdvancedClusterConfig_shardedTransitionFromOldToNewSchema(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + // TODO: Already prepared for TPF but getting this error: + // PATCH: HTTP 400 Bad Request (Error code: "AUTO_SCALINGS_MUST_BE_IN_EVERY_REGION_CONFIG") Detail: If any regionConfigs specify an autoScaling object, all regionConfigs must also specify an autoScaling object. + acc.SkipIfAdvancedClusterV2Schema(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() @@ -775,23 +845,23 @@ func TestAccClusterAdvancedClusterConfig_shardedTransitionFromOldToNewSchema(t * CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, false, false), + Config: configShardedTransitionOldToNewSchema(t, true, orgID, projectName, clusterName, false, false), Check: resource.ComposeAggregateTestCheckFunc( - checkShardedTransitionOldToNewSchema(false), + checkShardedTransitionOldToNewSchema(true, false), checkIndependentShardScalingMode(clusterName, "CLUSTER")), }, { - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, false), - Check: resource.ComposeAggregateTestCheckFunc( - checkShardedTransitionOldToNewSchema(true), - checkIndependentShardScalingMode(clusterName, "CLUSTER")), + Config: configShardedTransitionOldToNewSchema(t, true, orgID, projectName, clusterName, true, false), + Check: checkShardedTransitionOldToNewSchema(true, true), }, }, }) } func TestAccClusterAdvancedClusterConfig_geoShardedTransitionFromOldToNewSchema(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + // TODO: Already prepared for TPF but getting this error: + // POST: HTTP 400 Bad Request (Error code: "ASYMMETRIC_REGION_TOPOLOGY_IN_ZONE"). Detail: All shards in the same zone must have the same region topology. + acc.SkipIfAdvancedClusterV2Schema(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() @@ -804,19 +874,18 @@ func TestAccClusterAdvancedClusterConfig_geoShardedTransitionFromOldToNewSchema( CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configGeoShardedTransitionOldToNewSchema(orgID, projectName, clusterName, false), - Check: checkGeoShardedTransitionOldToNewSchema(false), + Config: configGeoShardedTransitionOldToNewSchema(t, true, orgID, projectName, clusterName, false), + Check: checkGeoShardedTransitionOldToNewSchema(true, false), }, { - Config: configGeoShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true), - Check: checkGeoShardedTransitionOldToNewSchema(true), + Config: configGeoShardedTransitionOldToNewSchema(t, true, orgID, projectName, clusterName, true), + Check: checkGeoShardedTransitionOldToNewSchema(true, true), }, }, }) } func TestAccAdvancedCluster_replicaSetScalingStrategyAndRedactClientLogData(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() @@ -829,27 +898,26 @@ func TestAccAdvancedCluster_replicaSetScalingStrategyAndRedactClientLogData(t *t CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configReplicaSetScalingStrategyAndRedactClientLogData(orgID, projectName, clusterName, "WORKLOAD_TYPE", true), - Check: checkReplicaSetScalingStrategyAndRedactClientLogData("WORKLOAD_TYPE", true), + Config: configReplicaSetScalingStrategyAndRedactClientLogData(t, true, orgID, projectName, clusterName, "WORKLOAD_TYPE", true), + Check: checkReplicaSetScalingStrategyAndRedactClientLogData(true, "WORKLOAD_TYPE", true), }, { - Config: configReplicaSetScalingStrategyAndRedactClientLogData(orgID, projectName, clusterName, "SEQUENTIAL", false), - Check: checkReplicaSetScalingStrategyAndRedactClientLogData("SEQUENTIAL", false), + Config: configReplicaSetScalingStrategyAndRedactClientLogData(t, true, orgID, projectName, clusterName, "SEQUENTIAL", false), + Check: checkReplicaSetScalingStrategyAndRedactClientLogData(true, "SEQUENTIAL", false), }, { - Config: configReplicaSetScalingStrategyAndRedactClientLogData(orgID, projectName, clusterName, "NODE_TYPE", true), - Check: checkReplicaSetScalingStrategyAndRedactClientLogData("NODE_TYPE", true), + Config: configReplicaSetScalingStrategyAndRedactClientLogData(t, true, orgID, projectName, clusterName, "NODE_TYPE", true), + Check: checkReplicaSetScalingStrategyAndRedactClientLogData(true, "NODE_TYPE", true), }, { - Config: configReplicaSetScalingStrategyAndRedactClientLogData(orgID, projectName, clusterName, "NODE_TYPE", false), - Check: checkReplicaSetScalingStrategyAndRedactClientLogData("NODE_TYPE", false), + Config: configReplicaSetScalingStrategyAndRedactClientLogData(t, true, orgID, projectName, clusterName, "NODE_TYPE", false), + Check: checkReplicaSetScalingStrategyAndRedactClientLogData(true, "NODE_TYPE", false), }, }, }) } func TestAccAdvancedCluster_replicaSetScalingStrategyAndRedactClientLogDataOldSchema(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() @@ -862,16 +930,16 @@ func TestAccAdvancedCluster_replicaSetScalingStrategyAndRedactClientLogDataOldSc CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configReplicaSetScalingStrategyAndRedactClientLogDataOldSchema(orgID, projectName, clusterName, "WORKLOAD_TYPE", false), - Check: checkReplicaSetScalingStrategyAndRedactClientLogData("WORKLOAD_TYPE", false), + Config: configReplicaSetScalingStrategyAndRedactClientLogDataOldSchema(t, true, orgID, projectName, clusterName, "WORKLOAD_TYPE", false), + Check: checkReplicaSetScalingStrategyAndRedactClientLogData(true, "WORKLOAD_TYPE", false), }, { - Config: configReplicaSetScalingStrategyAndRedactClientLogDataOldSchema(orgID, projectName, clusterName, "SEQUENTIAL", true), - Check: checkReplicaSetScalingStrategyAndRedactClientLogData("SEQUENTIAL", true), + Config: configReplicaSetScalingStrategyAndRedactClientLogDataOldSchema(t, true, orgID, projectName, clusterName, "SEQUENTIAL", true), + Check: checkReplicaSetScalingStrategyAndRedactClientLogData(true, "SEQUENTIAL", true), }, { - Config: configReplicaSetScalingStrategyAndRedactClientLogDataOldSchema(orgID, projectName, clusterName, "NODE_TYPE", false), - Check: checkReplicaSetScalingStrategyAndRedactClientLogData("NODE_TYPE", false), + Config: configReplicaSetScalingStrategyAndRedactClientLogDataOldSchema(t, true, orgID, projectName, clusterName, "NODE_TYPE", false), + Check: checkReplicaSetScalingStrategyAndRedactClientLogData(true, "NODE_TYPE", false), }, }, }) @@ -879,7 +947,14 @@ func TestAccAdvancedCluster_replicaSetScalingStrategyAndRedactClientLogDataOldSc // TestAccClusterAdvancedCluster_priorityOldSchema will be able to be simplied or deleted in CLOUDP-275825 func TestAccClusterAdvancedCluster_priorityOldSchema(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + // TODO: Already prepared for TPF but getting this error: + // .replication_specs[0].region_configs[0].electable_specs.node_count: was cty.NumberIntVal(1), but now cty.NumberIntVal(2) + // .replication_specs[0].region_configs[0].priority: was cty.NumberIntVal(6), but now cty.NumberIntVal(7). + // .replication_specs[0].region_configs[0].region_name: was cty.StringVal("US_WEST_2"), but now cty.StringVal("US_EAST_1"). + // .replication_specs[0].region_configs[1].electable_specs.node_count: was cty.NumberIntVal(2), but now cty.NumberIntVal(1). + // .replication_specs[0].region_configs[1].priority: was cty.NumberIntVal(7), but now cty.NumberIntVal(6). + // .replication_specs[0].region_configs[1].region_name: was cty.StringVal("US_EAST_1"), but now cty.StringVal("US_WEST_2"). + acc.SkipIfAdvancedClusterV2Schema(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region @@ -892,15 +967,15 @@ func TestAccClusterAdvancedCluster_priorityOldSchema(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configPriority(orgID, projectName, clusterName, true, true), + Config: configPriority(t, true, orgID, projectName, clusterName, true, true), ExpectError: regexp.MustCompile("priority values in region_configs must be in descending order"), }, { - Config: configPriority(orgID, projectName, clusterName, true, false), - Check: resource.TestCheckResourceAttr(resourceName, "replication_specs.0.region_configs.#", "2"), + Config: configPriority(t, true, orgID, projectName, clusterName, true, false), + Check: acc.TestCheckResourceAttrSchemaV2(true, resourceName, "replication_specs.0.region_configs.#", "2"), }, { - Config: configPriority(orgID, projectName, clusterName, true, true), + Config: configPriority(t, true, orgID, projectName, clusterName, true, true), ExpectError: regexp.MustCompile("priority values in region_configs must be in descending order"), }, }, @@ -909,7 +984,9 @@ func TestAccClusterAdvancedCluster_priorityOldSchema(t *testing.T) { // TestAccClusterAdvancedCluster_priorityNewSchema will be able to be simplied or deleted in CLOUDP-275825 func TestAccClusterAdvancedCluster_priorityNewSchema(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + // TODO: Already prepared for TPF but getting this error: + // Error: errorUpdateLegacy. PATCH: HTTP 400 Bad Request (Error code: "AUTO_SCALINGS_MUST_BE_IN_EVERY_REGION_CONFIG") Detail: If any regionConfigs specify an autoScaling object, all regionConfigs must also specify an autoScaling object. + acc.SkipIfAdvancedClusterV2Schema(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region @@ -922,23 +999,99 @@ func TestAccClusterAdvancedCluster_priorityNewSchema(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configPriority(orgID, projectName, clusterName, false, true), + Config: configPriority(t, true, orgID, projectName, clusterName, false, true), ExpectError: regexp.MustCompile("priority values in region_configs must be in descending order"), }, { - Config: configPriority(orgID, projectName, clusterName, false, false), - Check: resource.TestCheckResourceAttr(resourceName, "replication_specs.0.region_configs.#", "2"), + Config: configPriority(t, true, orgID, projectName, clusterName, false, false), + Check: acc.TestCheckResourceAttrSchemaV2(true, resourceName, "replication_specs.0.region_configs.#", "2"), }, { - Config: configPriority(orgID, projectName, clusterName, false, true), + Config: configPriority(t, true, orgID, projectName, clusterName, false, true), ExpectError: regexp.MustCompile("priority values in region_configs must be in descending order"), }, }, }) } +func TestAccClusterAdvancedCluster_biConnectorConfig(t *testing.T) { + var ( + projectID = acc.ProjectIDExecution(t) + clusterName = acc.RandomClusterName() + ) + resource.ParallelTest(t, resource.TestCase{ + PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName), + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configBiConnectorConfig(t, true, projectID, clusterName, false), + Check: checkTenantBiConnectorConfig(true, projectID, clusterName, false), + }, + { + Config: configBiConnectorConfig(t, true, projectID, clusterName, true), + Check: checkTenantBiConnectorConfig(true, projectID, clusterName, true), + }, + }, + }) +} + +func TestAccClusterAdvancedCluster_pinnedFCVWithVersionUpgradeAndDowngrade(t *testing.T) { + acc.SkipIfAdvancedClusterV2Schema(t) + var ( + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acc.RandomProjectName() // Using single project to assert plural data source + clusterName = acc.RandomClusterName() + ) + + now := time.Now() + // Time 7 days from now, truncated to the beginning of the day + sevenDaysFromNow := now.AddDate(0, 0, 7).Truncate(24 * time.Hour) + firstExpirationDate := conversion.TimeToString(sevenDaysFromNow) + // Time 8 days from now + eightDaysFromNow := sevenDaysFromNow.AddDate(0, 0, 1) + updatedExpirationDate := conversion.TimeToString(eightDaysFromNow) + invalidDateFormat := "invalid" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acc.PreCheckBasic(t) }, + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configFCVPinning(orgID, projectName, clusterName, nil, "7.0"), + Check: acc.CheckFCVPinningConfig(resourceName, dataSourceName, dataSourcePluralName, 7, nil, nil), + }, + { // pins fcv + Config: configFCVPinning(orgID, projectName, clusterName, &firstExpirationDate, "7.0"), + Check: acc.CheckFCVPinningConfig(resourceName, dataSourceName, dataSourcePluralName, 7, admin.PtrString(firstExpirationDate), admin.PtrInt(7)), + }, + { // using incorrect format + Config: configFCVPinning(orgID, projectName, clusterName, &invalidDateFormat, "7.0"), + ExpectError: regexp.MustCompile("expiration_date format is incorrect: " + invalidDateFormat), + }, + { // updates expiration date of fcv + Config: configFCVPinning(orgID, projectName, clusterName, &updatedExpirationDate, "7.0"), + Check: acc.CheckFCVPinningConfig(resourceName, dataSourceName, dataSourcePluralName, 7, admin.PtrString(updatedExpirationDate), admin.PtrInt(7)), + }, + { // upgrade mongodb version with fcv pinned + Config: configFCVPinning(orgID, projectName, clusterName, &updatedExpirationDate, "8.0"), + Check: acc.CheckFCVPinningConfig(resourceName, dataSourceName, dataSourcePluralName, 8, admin.PtrString(updatedExpirationDate), admin.PtrInt(7)), + }, + { // downgrade mongodb version with fcv pinned + Config: configFCVPinning(orgID, projectName, clusterName, &updatedExpirationDate, "7.0"), + Check: acc.CheckFCVPinningConfig(resourceName, dataSourceName, dataSourcePluralName, 7, admin.PtrString(updatedExpirationDate), admin.PtrInt(7)), + }, + { // unpins fcv + Config: configFCVPinning(orgID, projectName, clusterName, nil, "7.0"), + Check: acc.CheckFCVPinningConfig(resourceName, dataSourceName, dataSourcePluralName, 7, nil, nil), + }, + }, + }) +} + func TestAccAdvancedCluster_oldToNewSchemaWithAutoscalingEnabled(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + acc.SkipIfAdvancedClusterV2Schema(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() @@ -951,11 +1104,11 @@ func TestAccAdvancedCluster_oldToNewSchemaWithAutoscalingEnabled(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, false, true), + Config: configShardedTransitionOldToNewSchema(t, true, orgID, projectName, clusterName, false, true), Check: checkIndependentShardScalingMode(clusterName, "CLUSTER"), }, { - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, true), + Config: configShardedTransitionOldToNewSchema(t, true, orgID, projectName, clusterName, true, true), Check: checkIndependentShardScalingMode(clusterName, "SHARD"), }, }, @@ -963,7 +1116,7 @@ func TestAccAdvancedCluster_oldToNewSchemaWithAutoscalingEnabled(t *testing.T) { } func TestAccAdvancedCluster_oldToNewSchemaWithAutoscalingDisabledToEnabled(t *testing.T) { - acc.SkipIfTPFAdvancedCluster(t) + acc.SkipIfAdvancedClusterV2Schema(t) var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") projectName = acc.RandomProjectName() @@ -976,15 +1129,15 @@ func TestAccAdvancedCluster_oldToNewSchemaWithAutoscalingDisabledToEnabled(t *te CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, false, false), + Config: configShardedTransitionOldToNewSchema(t, true, orgID, projectName, clusterName, false, false), Check: checkIndependentShardScalingMode(clusterName, "CLUSTER"), }, { - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, false), + Config: configShardedTransitionOldToNewSchema(t, true, orgID, projectName, clusterName, true, false), Check: checkIndependentShardScalingMode(clusterName, "CLUSTER"), }, { - Config: configShardedTransitionOldToNewSchema(orgID, projectName, clusterName, true, true), + Config: configShardedTransitionOldToNewSchema(t, true, orgID, projectName, clusterName, true, true), Check: checkIndependentShardScalingMode(clusterName, "SHARD"), }, }, @@ -1000,8 +1153,8 @@ func checkIndependentShardScalingMode(clusterName, expectedMode string) resource if rs.Primary.ID == "" { return fmt.Errorf("no ID is set") } - ids := conversion.DecodeStateID(rs.Primary.ID) - issMode, _, err := acc.GetIndependentShardScalingMode(context.Background(), ids["project_id"], clusterName) + projectID := rs.Primary.Attributes["project_id"] + issMode, _, err := acc.GetIndependentShardScalingMode(context.Background(), projectID, clusterName) if err != nil { return fmt.Errorf("error getting independent shard scaling mode: %w", err) } @@ -1012,36 +1165,19 @@ func checkIndependentShardScalingMode(clusterName, expectedMode string) resource } } -func checkAggr(attrsSet []string, attrsMap map[string]string, extra ...resource.TestCheckFunc) resource.TestCheckFunc { - checks := []resource.TestCheckFunc{checkExists(resourceName)} - checks = acc.AddAttrChecks(resourceName, checks, attrsMap) - checks = acc.AddAttrChecks(dataSourceName, checks, attrsMap) - checks = acc.AddAttrSetChecks(resourceName, checks, attrsSet...) - checks = acc.AddAttrSetChecks(dataSourceName, checks, attrsSet...) +func checkAggr(isAcc bool, attrsSet []string, attrsMap map[string]string, extra ...resource.TestCheckFunc) resource.TestCheckFunc { + checks := []resource.TestCheckFunc{acc.CheckExistsCluster(resourceName)} + checks = acc.AddAttrChecksSchemaV2(isAcc, resourceName, checks, attrsMap) + checks = acc.AddAttrSetChecksSchemaV2(isAcc, resourceName, checks, attrsSet...) + checks = acc.AddAttrChecksSchemaV2(isAcc, dataSourceName, checks, attrsMap) + checks = acc.AddAttrSetChecksSchemaV2(isAcc, dataSourceName, checks, attrsSet...) checks = append(checks, extra...) return resource.ComposeAggregateTestCheckFunc(checks...) } -func checkExists(resourceName string) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[resourceName] - if !ok { - return fmt.Errorf("not found: %s", resourceName) - } - if rs.Primary.ID == "" { - return fmt.Errorf("no ID is set") - } - ids := conversion.DecodeStateID(rs.Primary.ID) - err := acc.CheckClusterExistsHandlingRetry(ids["project_id"], ids["cluster_name"]) - if err == nil { - return nil - } - return fmt.Errorf("cluster(%s:%s) does not exist: %w", rs.Primary.Attributes["project_id"], rs.Primary.ID, err) - } -} - -func configTenant(projectID, name string) string { - return fmt.Sprintf(` +func configTenant(t *testing.T, isAcc bool, projectID, name string) string { + t.Helper() + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_advanced_cluster" "test" { project_id = %[1]q name = %[2]q @@ -1068,38 +1204,38 @@ func configTenant(projectID, name string) string { data "mongodbatlas_advanced_clusters" "test" { project_id = mongodbatlas_advanced_cluster.test.project_id } - `, projectID, name) + `, projectID, name)) } -func checkTenant(projectID, name string) resource.TestCheckFunc { - pluralChecks := acc.AddAttrSetChecks(dataSourcePluralName, nil, +func checkTenant(isAcc bool, projectID, name string) resource.TestCheckFunc { + pluralChecks := acc.AddAttrSetChecksSchemaV2(isAcc, dataSourcePluralName, nil, []string{"results.#", "results.0.replication_specs.#", "results.0.name", "results.0.termination_protection_enabled", "results.0.global_cluster_self_managed_sharding"}...) - return checkAggr( + return checkAggr(isAcc, []string{"replication_specs.#", "replication_specs.0.id", "replication_specs.0.region_configs.#"}, map[string]string{ "project_id": projectID, "name": name, "termination_protection_enabled": "false", - "global_cluster_self_managed_sharding": "false", - "labels.#": "0"}, + "global_cluster_self_managed_sharding": "false"}, pluralChecks...) } -func configWithTags(orgID, projectName, name string, tags ...map[string]string) string { - var tagsConf string - for _, label := range tags { - tagsConf += fmt.Sprintf(` - tags { - key = "%s" - value = "%s" +func configWithKeyValueBlocks(t *testing.T, isAcc bool, orgID, projectName, clusterName, blockName string, blocks ...map[string]string) string { + t.Helper() + var extraConfig string + for _, block := range blocks { + extraConfig += fmt.Sprintf(` + %[1]s { + key = %[2]q + value = %[3]q } - `, label["key"], label["value"]) + `, blockName, block["key"], block["value"]) } - return fmt.Sprintf(` + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_project" "cluster_project" { - name = %[2]q org_id = %[1]q + name = %[2]q } resource "mongodbatlas_advanced_cluster" "test" { @@ -1134,32 +1270,36 @@ func configWithTags(orgID, projectName, name string, tags ...map[string]string) data "mongodbatlas_advanced_clusters" "test" { project_id = mongodbatlas_advanced_cluster.test.project_id } - `, orgID, projectName, name, tagsConf) + `, orgID, projectName, clusterName, extraConfig)) } -func checkTags(name string, tags ...map[string]string) resource.TestCheckFunc { - lenStr := strconv.Itoa(len(tags)) - tagChecks := []resource.TestCheckFunc{ - resource.TestCheckResourceAttr(resourceName, "tags.#", lenStr), - resource.TestCheckResourceAttr(dataSourceName, "tags.#", lenStr), - resource.TestCheckResourceAttr(dataSourcePluralName, "results.0.tags.#", lenStr), +func checkKeyValueBlocks(isAcc bool, clusterName, blockName string, blocks ...map[string]string) resource.TestCheckFunc { + const pluralPrefix = "results.0." + lenStr := strconv.Itoa(len(blocks)) + keyHash := fmt.Sprintf("%s.#", blockName) + keyStar := fmt.Sprintf("%s.*", blockName) + checks := []resource.TestCheckFunc{ + acc.TestCheckResourceAttrSchemaV2(isAcc, resourceName, keyHash, lenStr), + acc.TestCheckResourceAttrSchemaV2(isAcc, dataSourceName, keyHash, lenStr), + acc.TestCheckResourceAttrSchemaV2(isAcc, dataSourcePluralName, pluralPrefix+keyHash, lenStr), } - for _, tag := range tags { - tagChecks = append(tagChecks, - resource.TestCheckTypeSetElemNestedAttrs(resourceName, "tags.*", tag), - resource.TestCheckTypeSetElemNestedAttrs(dataSourceName, "tags.*", tag), - resource.TestCheckTypeSetElemNestedAttrs(dataSourcePluralName, "results.0.tags.*", tag)) + for _, block := range blocks { + checks = append(checks, + acc.TestCheckTypeSetElemNestedAttrsSchemaV2(isAcc, resourceName, keyStar, block), + acc.TestCheckTypeSetElemNestedAttrsSchemaV2(isAcc, dataSourceName, keyStar, block), + acc.TestCheckTypeSetElemNestedAttrsSchemaV2(isAcc, dataSourcePluralName, pluralPrefix+keyStar, block)) } - return checkAggr( + return checkAggr(isAcc, []string{"project_id"}, map[string]string{ - "name": name, + "name": clusterName, }, - tagChecks...) + checks...) } -func configReplicaSetAWSProvider(projectID, name string, diskSizeGB, nodeCountElectable int) string { - return fmt.Sprintf(` +func configReplicaSetAWSProvider(t *testing.T, isAcc bool, projectID, name string, diskSizeGB, nodeCountElectable int) string { + t.Helper() + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_advanced_cluster" "test" { project_id = %[1]q name = %[2]q @@ -1188,18 +1328,20 @@ func configReplicaSetAWSProvider(projectID, name string, diskSizeGB, nodeCountEl project_id = mongodbatlas_advanced_cluster.test.project_id name = mongodbatlas_advanced_cluster.test.name } - `, projectID, name, diskSizeGB, nodeCountElectable) + `, projectID, name, diskSizeGB, nodeCountElectable)) } -func checkReplicaSetAWSProvider(projectID, name string, diskSizeGB, nodeCountElectable int, checkDiskSizeGBInnerLevel, checkExternalID bool) resource.TestCheckFunc { +func checkReplicaSetAWSProvider(isAcc bool, projectID, name string, diskSizeGB, nodeCountElectable int, checkDiskSizeGBInnerLevel, checkExternalID bool) resource.TestCheckFunc { additionalChecks := []resource.TestCheckFunc{ - resource.TestCheckResourceAttr(resourceName, "retain_backups_enabled", "true"), - resource.TestCheckResourceAttrWith(resourceName, "replication_specs.0.region_configs.0.electable_specs.0.disk_iops", acc.IntGreatThan(0)), - resource.TestCheckResourceAttrWith(dataSourceName, "replication_specs.0.region_configs.0.electable_specs.0.disk_iops", acc.IntGreatThan(0)), + acc.TestCheckResourceAttrSchemaV2(isAcc, resourceName, "retain_backups_enabled", "true"), } + additionalChecks = append(additionalChecks, + acc.TestCheckResourceAttrWithSchemaV2(isAcc, resourceName, "replication_specs.0.region_configs.0.electable_specs.0.disk_iops", acc.IntGreatThan(0)), + acc.TestCheckResourceAttrWithSchemaV2(isAcc, dataSourceName, "replication_specs.0.region_configs.0.electable_specs.0.disk_iops", acc.IntGreatThan(0))) + if checkDiskSizeGBInnerLevel { additionalChecks = append(additionalChecks, - checkAggr([]string{}, map[string]string{ + checkAggr(isAcc, []string{}, map[string]string{ "replication_specs.0.region_configs.0.electable_specs.0.disk_size_gb": fmt.Sprintf("%d", diskSizeGB), "replication_specs.0.region_configs.0.analytics_specs.0.disk_size_gb": fmt.Sprintf("%d", diskSizeGB), }), @@ -1207,10 +1349,10 @@ func checkReplicaSetAWSProvider(projectID, name string, diskSizeGB, nodeCountEle } if checkExternalID { - additionalChecks = append(additionalChecks, resource.TestCheckResourceAttrSet(resourceName, "replication_specs.0.external_id")) + additionalChecks = append(additionalChecks, acc.TestCheckResourceAttrSetSchemaV2(isAcc, resourceName, "replication_specs.0.external_id")) } - return checkAggr( + return checkAggr(isAcc, []string{"replication_specs.#", "replication_specs.0.id", "replication_specs.0.region_configs.#"}, map[string]string{ "project_id": projectID, @@ -1221,8 +1363,9 @@ func checkReplicaSetAWSProvider(projectID, name string, diskSizeGB, nodeCountEle ) } -func configIncorrectTypeGobalClusterSelfManagedSharding(projectID, name string) string { - return fmt.Sprintf(` +func configIncorrectTypeGobalClusterSelfManagedSharding(t *testing.T, isAcc bool, projectID, name string) string { + t.Helper() + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_advanced_cluster" "test" { project_id = %[1]q name = %[2]q @@ -1246,11 +1389,12 @@ func configIncorrectTypeGobalClusterSelfManagedSharding(projectID, name string) } } } - `, projectID, name) + `, projectID, name)) } -func configReplicaSetMultiCloud(orgID, projectName, name string) string { - return fmt.Sprintf(` +func configReplicaSetMultiCloud(t *testing.T, isAcc bool, orgID, projectName, name string) string { + t.Helper() + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_project" "cluster_project" { org_id = %[1]q name = %[2]q @@ -1277,22 +1421,24 @@ func configReplicaSetMultiCloud(orgID, projectName, name string) string { region_name = "EU_WEST_1" } - dynamic "region_configs" { - for_each = [ - "US_EAST_4", - "NORTH_AMERICA_NORTHEAST_1" - ] - - content { - provider_name = "GCP" - priority = 0 - region_name = region_configs.value - - read_only_specs { - instance_size = "M10" - node_count = 2 - } + region_configs { + read_only_specs { + instance_size = "M10" + node_count = 2 + } + provider_name = "GCP" + priority = 0 + region_name = "US_EAST_4" + } + + region_configs { + read_only_specs { + instance_size = "M10" + node_count = 2 } + provider_name = "GCP" + priority = 0 + region_name = "NORTH_AMERICA_NORTHEAST_1" } } } @@ -1305,21 +1451,21 @@ func configReplicaSetMultiCloud(orgID, projectName, name string) string { data "mongodbatlas_advanced_clusters" "test" { project_id = mongodbatlas_advanced_cluster.test.project_id } - `, orgID, projectName, name) + `, orgID, projectName, name)) } -func checkReplicaSetMultiCloud(name string, regionConfigs int) resource.TestCheckFunc { +func checkReplicaSetMultiCloud(isAcc bool, name string, regionConfigs int) resource.TestCheckFunc { additionalChecks := []resource.TestCheckFunc{ - resource.TestCheckResourceAttr(resourceName, "retain_backups_enabled", "false"), - resource.TestCheckResourceAttrWith(resourceName, "replication_specs.0.region_configs.#", acc.JSONEquals(strconv.Itoa(regionConfigs))), - resource.TestCheckResourceAttrWith(dataSourceName, "replication_specs.0.region_configs.#", acc.JSONEquals(strconv.Itoa(regionConfigs))), - resource.TestCheckResourceAttrWith(dataSourcePluralName, "results.0.replication_specs.0.region_configs.#", acc.JSONEquals(strconv.Itoa(regionConfigs))), - resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.#"), - resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.0.replication_specs.#"), - resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.0.name"), - resource.TestCheckResourceAttrSet(resourceName, "replication_specs.0.external_id"), + acc.TestCheckResourceAttrSchemaV2(isAcc, resourceName, "retain_backups_enabled", "false"), + acc.TestCheckResourceAttrWithSchemaV2(isAcc, resourceName, "replication_specs.0.region_configs.#", acc.JSONEquals(strconv.Itoa(regionConfigs))), + acc.TestCheckResourceAttrSetSchemaV2(isAcc, resourceName, "replication_specs.0.external_id"), + acc.TestCheckResourceAttrWithSchemaV2(isAcc, dataSourceName, "replication_specs.0.region_configs.#", acc.JSONEquals(strconv.Itoa(regionConfigs))), + acc.TestCheckResourceAttrWithSchemaV2(isAcc, dataSourcePluralName, "results.0.replication_specs.0.region_configs.#", acc.JSONEquals(strconv.Itoa(regionConfigs))), + acc.TestCheckResourceAttrSetSchemaV2(isAcc, dataSourcePluralName, "results.#"), + acc.TestCheckResourceAttrSetSchemaV2(isAcc, dataSourcePluralName, "results.0.replication_specs.#"), + acc.TestCheckResourceAttrSetSchemaV2(isAcc, dataSourcePluralName, "results.0.name"), } - return checkAggr( + return checkAggr(isAcc, []string{"project_id", "replication_specs.#", "replication_specs.0.id"}, map[string]string{ "name": name}, @@ -1327,7 +1473,8 @@ func checkReplicaSetMultiCloud(name string, regionConfigs int) resource.TestChec ) } -func configShardedOldSchemaMultiCloud(orgID, projectName, name string, numShards int, analyticsSize string, configServerManagementMode *string) string { +func configShardedOldSchemaMultiCloud(t *testing.T, isAcc bool, orgID, projectName, name string, numShards int, analyticsSize string, configServerManagementMode *string) string { + t.Helper() var rootConfig string if configServerManagementMode != nil { // valid values: FIXED_TO_DEDICATED or ATLAS_MANAGED (default) @@ -1338,7 +1485,7 @@ func configShardedOldSchemaMultiCloud(orgID, projectName, name string, numShards config_server_management_mode = %[1]q `, *configServerManagementMode) } - return fmt.Sprintf(` + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_project" "cluster_project" { org_id = %[1]q name = %[2]q @@ -1386,37 +1533,34 @@ func configShardedOldSchemaMultiCloud(orgID, projectName, name string, numShards project_id = mongodbatlas_advanced_cluster.test.project_id depends_on = [mongodbatlas_advanced_cluster.test] } - `, orgID, projectName, name, numShards, analyticsSize, rootConfig) + `, orgID, projectName, name, numShards, analyticsSize, rootConfig)) } -func checkShardedOldSchemaMultiCloud(name string, numShards int, analyticsSize string, verifyExternalID bool, configServerManagementMode *string) resource.TestCheckFunc { +func checkShardedOldSchemaMultiCloud(isAcc bool, name string, numShards int, analyticsSize string, verifyExternalID bool, configServerManagementMode *string) resource.TestCheckFunc { additionalChecks := []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "replication_specs.0.region_configs.0.electable_specs.0.disk_iops", acc.IntGreatThan(0)), - resource.TestCheckResourceAttrWith(resourceName, "replication_specs.0.region_configs.0.analytics_specs.0.disk_iops", acc.IntGreatThan(0)), - resource.TestCheckResourceAttrWith(resourceName, "replication_specs.0.region_configs.1.electable_specs.0.disk_iops", acc.IntGreatThan(0)), - resource.TestCheckResourceAttrWith(dataSourceName, "replication_specs.0.region_configs.0.electable_specs.0.disk_iops", acc.IntGreatThan(0)), - resource.TestCheckResourceAttrWith(dataSourceName, "replication_specs.0.region_configs.0.analytics_specs.0.disk_iops", acc.IntGreatThan(0)), - resource.TestCheckResourceAttrWith(dataSourceName, "replication_specs.0.region_configs.1.electable_specs.0.disk_iops", acc.IntGreatThan(0)), + acc.TestCheckResourceAttrWithSchemaV2(isAcc, resourceName, "replication_specs.0.region_configs.0.electable_specs.0.disk_iops", acc.IntGreatThan(0)), + acc.TestCheckResourceAttrWithSchemaV2(isAcc, resourceName, "replication_specs.0.region_configs.0.analytics_specs.0.disk_iops", acc.IntGreatThan(0)), + acc.TestCheckResourceAttrWithSchemaV2(isAcc, resourceName, "replication_specs.0.region_configs.1.electable_specs.0.disk_iops", acc.IntGreatThan(0)), + acc.TestCheckResourceAttrWithSchemaV2(isAcc, dataSourceName, "replication_specs.0.region_configs.0.electable_specs.0.disk_iops", acc.IntGreatThan(0)), + acc.TestCheckResourceAttrWithSchemaV2(isAcc, dataSourceName, "replication_specs.0.region_configs.0.analytics_specs.0.disk_iops", acc.IntGreatThan(0)), + acc.TestCheckResourceAttrWithSchemaV2(isAcc, dataSourceName, "replication_specs.0.region_configs.1.electable_specs.0.disk_iops", acc.IntGreatThan(0)), } - if verifyExternalID { additionalChecks = append( additionalChecks, - resource.TestCheckResourceAttrSet(resourceName, "replication_specs.0.external_id")) + acc.TestCheckResourceAttrSetSchemaV2(isAcc, resourceName, "replication_specs.0.external_id")) } if configServerManagementMode != nil { - additionalChecks = append( - additionalChecks, - resource.TestCheckResourceAttr(resourceName, "config_server_management_mode", *configServerManagementMode), - resource.TestCheckResourceAttrSet(resourceName, "config_server_type"), - resource.TestCheckResourceAttr(dataSourceName, "config_server_management_mode", *configServerManagementMode), - resource.TestCheckResourceAttrSet(dataSourceName, "config_server_type"), - resource.TestCheckResourceAttr(dataSourcePluralName, "results.0.config_server_management_mode", *configServerManagementMode), - resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.0.config_server_type"), - ) + additionalChecks = append(additionalChecks, + acc.TestCheckResourceAttrSchemaV2(isAcc, resourceName, "config_server_management_mode", *configServerManagementMode), + acc.TestCheckResourceAttrSetSchemaV2(isAcc, resourceName, "config_server_type"), + acc.TestCheckResourceAttrSchemaV2(isAcc, dataSourceName, "config_server_management_mode", *configServerManagementMode), + acc.TestCheckResourceAttrSetSchemaV2(isAcc, dataSourceName, "config_server_type"), + acc.TestCheckResourceAttrSchemaV2(isAcc, dataSourcePluralName, "results.0.config_server_management_mode", *configServerManagementMode), + acc.TestCheckResourceAttrSetSchemaV2(isAcc, dataSourcePluralName, "results.0.config_server_type")) } - return checkAggr( + return checkAggr(isAcc, []string{"project_id", "replication_specs.#", "replication_specs.0.id", "replication_specs.0.region_configs.#"}, map[string]string{ "name": name, @@ -1426,8 +1570,9 @@ func checkShardedOldSchemaMultiCloud(name string, numShards int, analyticsSize s additionalChecks...) } -func configSingleProviderPaused(projectID, clusterName string, paused bool, instanceSize string) string { - return fmt.Sprintf(` +func configSingleProviderPaused(t *testing.T, isAcc bool, projectID, clusterName string, paused bool, instanceSize string) string { + t.Helper() + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_advanced_cluster" "test" { project_id = %[1]q name = %[2]q @@ -1455,27 +1600,41 @@ func configSingleProviderPaused(projectID, clusterName string, paused bool, inst project_id = mongodbatlas_advanced_cluster.test.project_id name = mongodbatlas_advanced_cluster.test.name } - `, projectID, clusterName, paused, instanceSize) + `, projectID, clusterName, paused, instanceSize)) } -func checkSingleProviderPaused(name string, paused bool) resource.TestCheckFunc { - return checkAggr( +func checkSingleProviderPaused(isAcc bool, name string, paused bool) resource.TestCheckFunc { + return checkAggr(isAcc, []string{"project_id", "replication_specs.#", "replication_specs.0.region_configs.#"}, map[string]string{ "name": name, "paused": strconv.FormatBool(paused)}) } -func configAdvanced(projectID, clusterName string, p *admin20240530.ClusterDescriptionProcessArgs, changeStreamOptions *int) string { +func configAdvanced(t *testing.T, isAcc bool, projectID, clusterName, mongoDBMajorVersion string, p20240530 *admin20240530.ClusterDescriptionProcessArgs, p *admin.ClusterDescriptionProcessArgs20240805) string { + t.Helper() changeStreamOptionsString := "" - if changeStreamOptions != nil { - changeStreamOptionsString = fmt.Sprintf(`change_stream_options_pre_and_post_images_expire_after_seconds = %[1]d`, *changeStreamOptions) + defaultMaxTimeString := "" + mongoDBMajorVersionString := "" + + if p != nil { + if p.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds != nil && p.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds != conversion.IntPtr(-1) { + changeStreamOptionsString = fmt.Sprintf(`change_stream_options_pre_and_post_images_expire_after_seconds = %[1]d`, *p.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds) + } + if p.DefaultMaxTimeMS != nil { + defaultMaxTimeString = fmt.Sprintf(`default_max_time_ms = %[1]d`, *p.DefaultMaxTimeMS) + } } - return fmt.Sprintf(` + if mongoDBMajorVersion != "" { + mongoDBMajorVersionString = fmt.Sprintf(`mongo_db_major_version = %[1]q`, mongoDBMajorVersion) + } + + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_advanced_cluster" "test" { project_id = %[1]q name = %[2]q cluster_type = "REPLICASET" + %[13]s replication_specs { region_configs { @@ -1503,6 +1662,7 @@ func configAdvanced(projectID, clusterName string, p *admin20240530.ClusterDescr sample_refresh_interval_bi_connector = %[9]d transaction_lifetime_limit_seconds = %[10]d %[11]s + %[12]s } } @@ -1515,31 +1675,48 @@ func configAdvanced(projectID, clusterName string, p *admin20240530.ClusterDescr project_id = mongodbatlas_advanced_cluster.test.project_id } `, projectID, clusterName, - p.GetFailIndexKeyTooLong(), p.GetJavascriptEnabled(), p.GetMinimumEnabledTlsProtocol(), p.GetNoTableScan(), - p.GetOplogSizeMB(), p.GetSampleSizeBIConnector(), p.GetSampleRefreshIntervalBIConnector(), p.GetTransactionLifetimeLimitSeconds(), changeStreamOptionsString) -} + p20240530.GetFailIndexKeyTooLong(), p20240530.GetJavascriptEnabled(), p20240530.GetMinimumEnabledTlsProtocol(), p20240530.GetNoTableScan(), + p20240530.GetOplogSizeMB(), p20240530.GetSampleSizeBIConnector(), p20240530.GetSampleRefreshIntervalBIConnector(), p20240530.GetTransactionLifetimeLimitSeconds(), + changeStreamOptionsString, defaultMaxTimeString, mongoDBMajorVersionString)) +} + +func checkAdvanced(isAcc bool, name, tls string, processArgs *admin.ClusterDescriptionProcessArgs20240805) resource.TestCheckFunc { + advancedConfig := map[string]string{ + "name": name, + "advanced_configuration.0.minimum_enabled_tls_protocol": tls, + "advanced_configuration.0.fail_index_key_too_long": "false", + "advanced_configuration.0.javascript_enabled": "true", + "advanced_configuration.0.no_table_scan": "false", + "advanced_configuration.0.oplog_size_mb": "1000", + "advanced_configuration.0.sample_refresh_interval_bi_connector": "310", + "advanced_configuration.0.sample_size_bi_connector": "110", + "advanced_configuration.0.transaction_lifetime_limit_seconds": "300", + } -func checkAdvanced(name, tls, changeStreamOptions string) resource.TestCheckFunc { - return checkAggr( + if processArgs.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds != nil { + advancedConfig["advanced_configuration.0.change_stream_options_pre_and_post_images_expire_after_seconds"] = strconv.Itoa(*processArgs.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds) + } + + if processArgs.DefaultMaxTimeMS != nil { + advancedConfig["advanced_configuration.0.default_max_time_ms"] = strconv.Itoa(*processArgs.DefaultMaxTimeMS) + } + + pluralChecks := []resource.TestCheckFunc{ + acc.TestCheckResourceAttrSetSchemaV2(isAcc, dataSourcePluralName, "results.#"), + acc.TestCheckResourceAttrSetSchemaV2(isAcc, dataSourcePluralName, "results.0.replication_specs.#"), + acc.TestCheckResourceAttrSetSchemaV2(isAcc, dataSourcePluralName, "results.0.name"), + } + + return checkAggr(isAcc, []string{"project_id", "replication_specs.#", "replication_specs.0.region_configs.#"}, - map[string]string{ - "name": name, - "advanced_configuration.0.minimum_enabled_tls_protocol": tls, - "advanced_configuration.0.fail_index_key_too_long": "false", - "advanced_configuration.0.javascript_enabled": "true", - "advanced_configuration.0.no_table_scan": "false", - "advanced_configuration.0.oplog_size_mb": "1000", - "advanced_configuration.0.sample_refresh_interval_bi_connector": "310", - "advanced_configuration.0.sample_size_bi_connector": "110", - "advanced_configuration.0.transaction_lifetime_limit_seconds": "300", - "advanced_configuration.0.change_stream_options_pre_and_post_images_expire_after_seconds": changeStreamOptions}, - resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.#"), - resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.0.replication_specs.#"), - resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.0.name")) -} - -func configAdvancedDefaultWrite(projectID, clusterName string, p *admin20240530.ClusterDescriptionProcessArgs) string { - return fmt.Sprintf(` + advancedConfig, + pluralChecks..., + ) +} + +func configAdvancedDefaultWrite(t *testing.T, isAcc bool, projectID, clusterName string, p *admin20240530.ClusterDescriptionProcessArgs) string { + t.Helper() + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_advanced_cluster" "test" { project_id = %[1]q name = %[2]q @@ -1582,11 +1759,16 @@ func configAdvancedDefaultWrite(projectID, clusterName string, p *admin20240530. project_id = mongodbatlas_advanced_cluster.test.project_id } `, projectID, clusterName, p.GetJavascriptEnabled(), p.GetMinimumEnabledTlsProtocol(), p.GetNoTableScan(), - p.GetOplogSizeMB(), p.GetSampleSizeBIConnector(), p.GetSampleRefreshIntervalBIConnector(), p.GetDefaultReadConcern(), p.GetDefaultWriteConcern()) + p.GetOplogSizeMB(), p.GetSampleSizeBIConnector(), p.GetSampleRefreshIntervalBIConnector(), p.GetDefaultReadConcern(), p.GetDefaultWriteConcern())) } -func checkAdvancedDefaultWrite(name, writeConcern, tls string) resource.TestCheckFunc { - return checkAggr( +func checkAdvancedDefaultWrite(isAcc bool, name, writeConcern, tls string) resource.TestCheckFunc { + pluralChecks := []resource.TestCheckFunc{ + acc.TestCheckResourceAttrSetSchemaV2(isAcc, dataSourcePluralName, "results.#"), + acc.TestCheckResourceAttrSetSchemaV2(isAcc, dataSourcePluralName, "results.0.replication_specs.#"), + acc.TestCheckResourceAttrSetSchemaV2(isAcc, dataSourcePluralName, "results.0.name"), + } + return checkAggr(isAcc, []string{"project_id", "replication_specs.#", "replication_specs.0.region_configs.#"}, map[string]string{ "name": name, @@ -1599,13 +1781,12 @@ func checkAdvancedDefaultWrite(name, writeConcern, tls string) resource.TestChec "advanced_configuration.0.oplog_size_mb": "1000", "advanced_configuration.0.sample_refresh_interval_bi_connector": "310", "advanced_configuration.0.sample_size_bi_connector": "110"}, - resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.#"), - resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.0.replication_specs.#"), - resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.0.name")) + pluralChecks...) } -func configReplicationSpecsAutoScaling(projectID, clusterName string, p *admin.AdvancedAutoScalingSettings) string { - return fmt.Sprintf(` +func configReplicationSpecsAutoScaling(t *testing.T, isAcc bool, projectID, clusterName string, p *admin.AdvancedAutoScalingSettings) string { + t.Helper() + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_advanced_cluster" "test" { project_id = %[1]q name = %[2]q @@ -1635,11 +1816,12 @@ func configReplicationSpecsAutoScaling(projectID, clusterName string, p *admin.A oplog_min_retention_hours = 5.5 } } - `, projectID, clusterName, p.Compute.GetEnabled(), p.DiskGB.GetEnabled(), p.Compute.GetMaxInstanceSize()) + `, projectID, clusterName, p.Compute.GetEnabled(), p.DiskGB.GetEnabled(), p.Compute.GetMaxInstanceSize())) } -func configReplicationSpecsAnalyticsAutoScaling(projectID, clusterName string, p *admin.AdvancedAutoScalingSettings) string { - return fmt.Sprintf(` +func configReplicationSpecsAnalyticsAutoScaling(t *testing.T, isAcc bool, projectID, clusterName string, p *admin.AdvancedAutoScalingSettings) string { + t.Helper() + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_advanced_cluster" "test" { project_id = %[1]q name = %[2]q @@ -1666,11 +1848,12 @@ func configReplicationSpecsAnalyticsAutoScaling(projectID, clusterName string, p } } } - `, projectID, clusterName, p.Compute.GetEnabled(), p.DiskGB.GetEnabled(), p.Compute.GetMaxInstanceSize()) + `, projectID, clusterName, p.Compute.GetEnabled(), p.DiskGB.GetEnabled(), p.Compute.GetMaxInstanceSize())) } -func configGeoShardedOldSchema(orgID, projectName, name string, numShardsFirstZone, numShardsSecondZone int, selfManagedSharding bool) string { - return fmt.Sprintf(` +func configGeoShardedOldSchema(t *testing.T, isAcc bool, orgID, projectName, name string, numShardsFirstZone, numShardsSecondZone int, selfManagedSharding bool) string { + t.Helper() + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_project" "cluster_project" { org_id = %[1]q name = %[2]q @@ -1728,18 +1911,18 @@ func configGeoShardedOldSchema(orgID, projectName, name string, numShardsFirstZo project_id = mongodbatlas_advanced_cluster.test.project_id name = mongodbatlas_advanced_cluster.test.name } - `, orgID, projectName, name, numShardsFirstZone, numShardsSecondZone, selfManagedSharding) + `, orgID, projectName, name, numShardsFirstZone, numShardsSecondZone, selfManagedSharding)) } -func checkGeoShardedOldSchema(name string, numShardsFirstZone, numShardsSecondZone int, isLatestProviderVersion, verifyExternalID bool) resource.TestCheckFunc { +func checkGeoShardedOldSchema(isAcc bool, name string, numShardsFirstZone, numShardsSecondZone int, isLatestProviderVersion, verifyExternalID bool) resource.TestCheckFunc { additionalChecks := []resource.TestCheckFunc{} if verifyExternalID { - additionalChecks = append(additionalChecks, resource.TestCheckResourceAttrSet(resourceName, "replication_specs.0.external_id")) + additionalChecks = append(additionalChecks, acc.TestCheckResourceAttrSetSchemaV2(isAcc, resourceName, "replication_specs.0.external_id")) } if isLatestProviderVersion { // checks that will not apply if doing migration test with older version - additionalChecks = append(additionalChecks, checkAggr( + additionalChecks = append(additionalChecks, checkAggr(isAcc, []string{"replication_specs.0.zone_id", "replication_specs.0.zone_id"}, map[string]string{ "replication_specs.0.region_configs.0.electable_specs.0.disk_size_gb": "60", @@ -1747,7 +1930,7 @@ func checkGeoShardedOldSchema(name string, numShardsFirstZone, numShardsSecondZo })) } - return checkAggr( + return checkAggr(isAcc, []string{"project_id", "replication_specs.0.id", "replication_specs.1.id"}, map[string]string{ "name": name, @@ -1759,8 +1942,9 @@ func checkGeoShardedOldSchema(name string, numShardsFirstZone, numShardsSecondZo ) } -func configShardedOldSchemaDiskSizeGBElectableLevel(orgID, projectName, name string, diskSizeGB int) string { - return fmt.Sprintf(` +func configShardedOldSchemaDiskSizeGBElectableLevel(t *testing.T, isAcc bool, orgID, projectName, name string, diskSizeGB int) string { + t.Helper() + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_project" "cluster_project" { org_id = %[1]q name = %[2]q @@ -1798,11 +1982,11 @@ func configShardedOldSchemaDiskSizeGBElectableLevel(orgID, projectName, name str project_id = mongodbatlas_advanced_cluster.test.project_id name = mongodbatlas_advanced_cluster.test.name } - `, orgID, projectName, name, diskSizeGB) + `, orgID, projectName, name, diskSizeGB)) } -func checkShardedOldSchemaDiskSizeGBElectableLevel(diskSizeGB int) resource.TestCheckFunc { - return checkAggr( +func checkShardedOldSchemaDiskSizeGBElectableLevel(isAcc bool, diskSizeGB int) resource.TestCheckFunc { + return checkAggr(isAcc, []string{}, map[string]string{ "replication_specs.0.num_shards": "2", @@ -1812,7 +1996,8 @@ func checkShardedOldSchemaDiskSizeGBElectableLevel(diskSizeGB int) resource.Test }) } -func configShardedNewSchema(orgID, projectName, name string, diskSizeGB int, firstInstanceSize, lastInstanceSize string, firstDiskIOPS, lastDiskIOPS *int, includeMiddleSpec bool) string { +func configShardedNewSchema(t *testing.T, isAcc bool, orgID, projectName, name string, diskSizeGB int, firstInstanceSize, lastInstanceSize string, firstDiskIOPS, lastDiskIOPS *int, includeMiddleSpec bool) string { + t.Helper() var thirdReplicationSpec string if includeMiddleSpec { thirdReplicationSpec = fmt.Sprintf(` @@ -1849,7 +2034,7 @@ func configShardedNewSchema(orgID, projectName, name string, diskSizeGB int, fir ebs_volume_type = "PROVISIONED" `, *lastDiskIOPS) } - return fmt.Sprintf(` + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_project" "cluster_project" { org_id = %[1]q name = %[2]q @@ -1917,10 +2102,10 @@ func configShardedNewSchema(orgID, projectName, name string, diskSizeGB int, fir project_id = mongodbatlas_advanced_cluster.test.project_id use_replication_spec_per_shard = true } - `, orgID, projectName, name, firstInstanceSize, lastInstanceSize, firstDiskIOPSAttrs, lastDiskIOPSAttrs, thirdReplicationSpec, diskSizeGB) + `, orgID, projectName, name, firstInstanceSize, lastInstanceSize, firstDiskIOPSAttrs, lastDiskIOPSAttrs, thirdReplicationSpec, diskSizeGB)) } -func checkShardedNewSchema(diskSizeGB int, firstInstanceSize, lastInstanceSize string, firstDiskIops, lastDiskIops *int, isAsymmetricCluster, includeMiddleSpec bool) resource.TestCheckFunc { +func checkShardedNewSchema(isAcc bool, diskSizeGB int, firstInstanceSize, lastInstanceSize string, firstDiskIops, lastDiskIops *int, isAsymmetricCluster, includeMiddleSpec bool) resource.TestCheckFunc { amtOfReplicationSpecs := 2 if includeMiddleSpec { amtOfReplicationSpecs = 3 @@ -1949,33 +2134,35 @@ func checkShardedNewSchema(diskSizeGB int, firstInstanceSize, lastInstanceSize s } // plural data source checks - additionalChecks := acc.AddAttrSetChecks(dataSourcePluralName, nil, + pluralChecks := acc.AddAttrSetChecksSchemaV2(isAcc, dataSourcePluralName, nil, []string{"results.#", "results.0.replication_specs.#", "results.0.replication_specs.0.region_configs.#", "results.0.name", "results.0.termination_protection_enabled", "results.0.global_cluster_self_managed_sharding"}...) - additionalChecks = acc.AddAttrChecksPrefix(dataSourcePluralName, additionalChecks, clusterChecks, "results.0") + + pluralChecks = acc.AddAttrChecksPrefixSchemaV2(isAcc, dataSourcePluralName, pluralChecks, clusterChecks, "results.0") // expected id attribute only if cluster is symmetric if isAsymmetricCluster { - additionalChecks = append(additionalChecks, checkAggr([]string{}, map[string]string{ + pluralChecks = append(pluralChecks, checkAggr(isAcc, []string{}, map[string]string{ "replication_specs.0.id": "", "replication_specs.1.id": "", })) - additionalChecks = acc.AddAttrChecks(dataSourcePluralName, additionalChecks, map[string]string{ + pluralChecks = acc.AddAttrChecksSchemaV2(isAcc, dataSourcePluralName, pluralChecks, map[string]string{ "results.0.replication_specs.0.id": "", "results.0.replication_specs.1.id": "", }) } else { - additionalChecks = append(additionalChecks, checkAggr([]string{"replication_specs.0.id", "replication_specs.1.id"}, map[string]string{})) - additionalChecks = acc.AddAttrSetChecks(dataSourcePluralName, additionalChecks, "results.0.replication_specs.0.id", "results.0.replication_specs.1.id") + pluralChecks = append(pluralChecks, checkAggr(isAcc, []string{"replication_specs.0.id", "replication_specs.1.id"}, map[string]string{})) + pluralChecks = acc.AddAttrSetChecksSchemaV2(isAcc, dataSourcePluralName, pluralChecks, "results.0.replication_specs.0.id", "results.0.replication_specs.1.id") } - return checkAggr( + return checkAggr(isAcc, []string{"replication_specs.0.external_id", "replication_specs.0.zone_id", "replication_specs.1.external_id", "replication_specs.1.zone_id"}, clusterChecks, - additionalChecks..., + pluralChecks..., ) } -func configGeoShardedNewSchema(orgID, projectName, name string, includeThirdShardInFirstZone bool) string { +func configGeoShardedNewSchema(t *testing.T, isAcc bool, orgID, projectName, name string, includeThirdShardInFirstZone bool) string { + t.Helper() var thirdReplicationSpec string if includeThirdShardInFirstZone { thirdReplicationSpec = ` @@ -1993,7 +2180,7 @@ func configGeoShardedNewSchema(orgID, projectName, name string, includeThirdShar } ` } - return fmt.Sprintf(` + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_project" "cluster_project" { org_id = %[1]q name = %[2]q @@ -2039,10 +2226,10 @@ func configGeoShardedNewSchema(orgID, projectName, name string, includeThirdShar project_id = mongodbatlas_advanced_cluster.test.project_id use_replication_spec_per_shard = true } - `, orgID, projectName, name, thirdReplicationSpec) + `, orgID, projectName, name, thirdReplicationSpec)) } -func checkGeoShardedNewSchema(includeThirdShardInFirstZone bool) resource.TestCheckFunc { +func checkGeoShardedNewSchema(isAcc, includeThirdShardInFirstZone bool) resource.TestCheckFunc { var amtOfReplicationSpecs int if includeThirdShardInFirstZone { amtOfReplicationSpecs = 3 @@ -2053,13 +2240,11 @@ func checkGeoShardedNewSchema(includeThirdShardInFirstZone bool) resource.TestCh "replication_specs.#": fmt.Sprintf("%d", amtOfReplicationSpecs), } - return checkAggr( - []string{}, - clusterChecks, - ) + return checkAggr(isAcc, []string{}, clusterChecks) } -func configShardedTransitionOldToNewSchema(orgID, projectName, name string, useNewSchema, autoscaling bool) string { +func configShardedTransitionOldToNewSchema(t *testing.T, isAcc bool, orgID, projectName, name string, useNewSchema, autoscaling bool) string { + t.Helper() var numShardsStr string if !useNewSchema { numShardsStr = `num_shards = 2` @@ -2107,7 +2292,7 @@ func configShardedTransitionOldToNewSchema(orgID, projectName, name string, useN dataSourceFlag = `use_replication_spec_per_shard = true` } - return fmt.Sprintf(` + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_project" "cluster_project" { org_id = %[1]q name = %[2]q @@ -2132,10 +2317,10 @@ func configShardedTransitionOldToNewSchema(orgID, projectName, name string, useN project_id = mongodbatlas_advanced_cluster.test.project_id %[5]s } - `, orgID, projectName, name, replicationSpecs, dataSourceFlag) + `, orgID, projectName, name, replicationSpecs, dataSourceFlag)) } -func checkShardedTransitionOldToNewSchema(useNewSchema bool) resource.TestCheckFunc { +func checkShardedTransitionOldToNewSchema(isAcc, useNewSchema bool) resource.TestCheckFunc { var amtOfReplicationSpecs int if useNewSchema { amtOfReplicationSpecs = 2 @@ -2145,7 +2330,7 @@ func checkShardedTransitionOldToNewSchema(useNewSchema bool) resource.TestCheckF var checksForNewSchema []resource.TestCheckFunc if useNewSchema { checksForNewSchema = []resource.TestCheckFunc{ - checkAggr([]string{"replication_specs.1.id", "replication_specs.0.external_id", "replication_specs.1.external_id"}, + checkAggr(isAcc, []string{"replication_specs.1.id", "replication_specs.0.external_id", "replication_specs.1.external_id"}, map[string]string{ "replication_specs.#": fmt.Sprintf("%d", amtOfReplicationSpecs), "replication_specs.1.region_configs.0.electable_specs.0.instance_size": "M10", @@ -2154,7 +2339,7 @@ func checkShardedTransitionOldToNewSchema(useNewSchema bool) resource.TestCheckF } } - return checkAggr( + return checkAggr(isAcc, []string{"replication_specs.0.id"}, map[string]string{ "replication_specs.#": fmt.Sprintf("%d", amtOfReplicationSpecs), @@ -2165,7 +2350,8 @@ func checkShardedTransitionOldToNewSchema(useNewSchema bool) resource.TestCheckF ) } -func configGeoShardedTransitionOldToNewSchema(orgID, projectName, name string, useNewSchema bool) string { +func configGeoShardedTransitionOldToNewSchema(t *testing.T, isAcc bool, orgID, projectName, name string, useNewSchema bool) string { + t.Helper() var numShardsStr string if !useNewSchema { numShardsStr = `num_shards = 2` @@ -2211,7 +2397,7 @@ func configGeoShardedTransitionOldToNewSchema(orgID, projectName, name string, u dataSourceFlag = `use_replication_spec_per_shard = true` } - return fmt.Sprintf(` + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_project" "cluster_project" { org_id = %[1]q name = %[2]q @@ -2236,12 +2422,12 @@ func configGeoShardedTransitionOldToNewSchema(orgID, projectName, name string, u project_id = mongodbatlas_advanced_cluster.test.project_id %[5]s } - `, orgID, projectName, name, replicationSpecs, dataSourceFlag) + `, orgID, projectName, name, replicationSpecs, dataSourceFlag)) } -func checkGeoShardedTransitionOldToNewSchema(useNewSchema bool) resource.TestCheckFunc { +func checkGeoShardedTransitionOldToNewSchema(isAcc, useNewSchema bool) resource.TestCheckFunc { if useNewSchema { - return checkAggr( + return checkAggr(isAcc, []string{"replication_specs.0.id", "replication_specs.1.id", "replication_specs.2.id", "replication_specs.3.id", "replication_specs.0.external_id", "replication_specs.1.external_id", "replication_specs.2.external_id", "replication_specs.3.external_id", }, @@ -2254,7 +2440,7 @@ func checkGeoShardedTransitionOldToNewSchema(useNewSchema bool) resource.TestChe }, ) } - return checkAggr( + return checkAggr(isAcc, []string{"replication_specs.0.id", "replication_specs.1.id"}, map[string]string{ "replication_specs.#": "2", @@ -2264,8 +2450,9 @@ func checkGeoShardedTransitionOldToNewSchema(useNewSchema bool) resource.TestChe ) } -func configReplicaSetScalingStrategyAndRedactClientLogData(orgID, projectName, name, replicaSetScalingStrategy string, redactClientLogData bool) string { - return fmt.Sprintf(` +func configReplicaSetScalingStrategyAndRedactClientLogData(t *testing.T, isAcc bool, orgID, projectName, name, replicaSetScalingStrategy string, redactClientLogData bool) string { + t.Helper() + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_project" "cluster_project" { org_id = %[1]q name = %[2]q @@ -2308,11 +2495,12 @@ func configReplicaSetScalingStrategyAndRedactClientLogData(orgID, projectName, n project_id = mongodbatlas_advanced_cluster.test.project_id use_replication_spec_per_shard = true } - `, orgID, projectName, name, replicaSetScalingStrategy, redactClientLogData) + `, orgID, projectName, name, replicaSetScalingStrategy, redactClientLogData)) } -func configReplicaSetScalingStrategyAndRedactClientLogDataOldSchema(orgID, projectName, name, replicaSetScalingStrategy string, redactClientLogData bool) string { - return fmt.Sprintf(` +func configReplicaSetScalingStrategyAndRedactClientLogDataOldSchema(t *testing.T, isAcc bool, orgID, projectName, name, replicaSetScalingStrategy string, redactClientLogData bool) string { + t.Helper() + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_project" "cluster_project" { org_id = %[1]q name = %[2]q @@ -2354,26 +2542,28 @@ func configReplicaSetScalingStrategyAndRedactClientLogDataOldSchema(orgID, proje data "mongodbatlas_advanced_clusters" "test" { project_id = mongodbatlas_advanced_cluster.test.project_id } - `, orgID, projectName, name, replicaSetScalingStrategy, redactClientLogData) + `, orgID, projectName, name, replicaSetScalingStrategy, redactClientLogData)) } -func checkReplicaSetScalingStrategyAndRedactClientLogData(replicaSetScalingStrategy string, redactClientLogData bool) resource.TestCheckFunc { +func checkReplicaSetScalingStrategyAndRedactClientLogData(isAcc bool, replicaSetScalingStrategy string, redactClientLogData bool) resource.TestCheckFunc { clusterChecks := map[string]string{ "replica_set_scaling_strategy": replicaSetScalingStrategy, "redact_client_log_data": strconv.FormatBool(redactClientLogData), } // plural data source checks - additionalChecks := acc.AddAttrSetChecks(dataSourcePluralName, nil, + pluralChecks := acc.AddAttrSetChecksSchemaV2(isAcc, dataSourcePluralName, nil, []string{"results.#", "results.0.replica_set_scaling_strategy", "results.0.redact_client_log_data"}...) - return checkAggr( + + return checkAggr(isAcc, []string{}, clusterChecks, - additionalChecks..., + pluralChecks..., ) } -func configPriority(orgID, projectName, clusterName string, oldSchema, swapPriorities bool) string { +func configPriority(t *testing.T, isAcc bool, orgID, projectName, clusterName string, oldSchema, swapPriorities bool) string { + t.Helper() const ( config7 = ` region_configs { @@ -2407,7 +2597,7 @@ func configPriority(orgID, projectName, clusterName string, oldSchema, swapPrior strConfigs = config6 + config7 } - return fmt.Sprintf(` + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` resource "mongodbatlas_project" "test" { org_id = %[1]q name = %[2]q @@ -2424,5 +2614,123 @@ func configPriority(orgID, projectName, clusterName string, oldSchema, swapPrior %[6]s } } - `, orgID, projectName, clusterName, strType, strNumShards, strConfigs) + `, orgID, projectName, clusterName, strType, strNumShards, strConfigs)) +} + +func configBiConnectorConfig(t *testing.T, isAcc bool, projectID, name string, enabled bool) string { + t.Helper() + additionalConfig := ` + bi_connector_config { + enabled = false + } + ` + if enabled { + additionalConfig = ` + bi_connector_config { + enabled = true + read_preference = "secondary" + } + ` + } + + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` + resource "mongodbatlas_advanced_cluster" "test" { + project_id = %[1]q + name = %[2]q + cluster_type = "REPLICASET" + + replication_specs { + region_configs { + electable_specs { + instance_size = "M10" + node_count = 3 + } + analytics_specs { + instance_size = "M10" + node_count = 1 + } + provider_name = "AWS" + priority = 7 + region_name = "US_WEST_2" + } + } + + %[3]s + } + + data "mongodbatlas_advanced_cluster" "test" { + project_id = mongodbatlas_advanced_cluster.test.project_id + name = mongodbatlas_advanced_cluster.test.name + depends_on = [mongodbatlas_advanced_cluster.test] + } + + data "mongodbatlas_advanced_clusters" "test" { + project_id = mongodbatlas_advanced_cluster.test.project_id + depends_on = [mongodbatlas_advanced_cluster.test] + } + `, projectID, name, additionalConfig)) +} + +func checkTenantBiConnectorConfig(isAcc bool, projectID, name string, enabled bool) resource.TestCheckFunc { + attrsMap := map[string]string{ + "project_id": projectID, + "name": name, + } + if enabled { + attrsMap["bi_connector_config.0.enabled"] = "true" + attrsMap["bi_connector_config.0.read_preference"] = "secondary" + } else { + attrsMap["bi_connector_config.0.enabled"] = "false" + } + return checkAggr(isAcc, nil, attrsMap) +} + +func configFCVPinning(orgID, projectName, clusterName string, pinningExpirationDate *string, mongoDBMajorVersion string) string { + var pinnedFCVAttr string + if pinningExpirationDate != nil { + pinnedFCVAttr = fmt.Sprintf(` + pinned_fcv { + expiration_date = %q + } + `, *pinningExpirationDate) + } + + return fmt.Sprintf(` + resource "mongodbatlas_project" "test" { + org_id = %[1]q + name = %[2]q + } + + resource "mongodbatlas_advanced_cluster" "test" { + project_id = mongodbatlas_project.test.id + name = %[3]q + + cluster_type = "REPLICASET" + + mongo_db_major_version = %[4]q + + %[5]s + + replication_specs { + region_configs { + electable_specs { + instance_size = "M10" + node_count = 3 + } + provider_name = "AWS" + priority = 7 + region_name = "US_WEST_2" + } + } + } + + data "mongodbatlas_advanced_cluster" "test" { + project_id = mongodbatlas_advanced_cluster.test.project_id + name = mongodbatlas_advanced_cluster.test.name + } + + data "mongodbatlas_advanced_clusters" "test" { + project_id = mongodbatlas_advanced_cluster.test.project_id + } + `, orgID, projectName, clusterName, mongoDBMajorVersion, pinnedFCVAttr) } diff --git a/internal/service/advancedcluster/resource_update_logic.go b/internal/service/advancedcluster/resource_update_logic.go index 8caa468583..a8aff3958c 100644 --- a/internal/service/advancedcluster/resource_update_logic.go +++ b/internal/service/advancedcluster/resource_update_logic.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func noIDsPopulatedInReplicationSpecs(replicationSpecs *[]admin.ReplicationSpec20240805) bool { diff --git a/internal/service/advancedcluster/resource_update_logic_test.go b/internal/service/advancedcluster/resource_update_logic_test.go index a53cbce6fd..5d7af23929 100644 --- a/internal/service/advancedcluster/resource_update_logic_test.go +++ b/internal/service/advancedcluster/resource_update_logic_test.go @@ -5,7 +5,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster" "github.com/stretchr/testify/assert" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func TestAddIDsToReplicationSpecs(t *testing.T) { diff --git a/internal/service/advancedclustertpf/README.md b/internal/service/advancedclustertpf/README.md index 7d712dafb4..5f9e8fc7da 100644 --- a/internal/service/advancedclustertpf/README.md +++ b/internal/service/advancedclustertpf/README.md @@ -6,5 +6,7 @@ This package contains the WIP for `mongodbatlas_advanced_cluster` in TPF. Curren ## Changes in advancedcluster that needs to be added here (list changes done in advancedcluster which couldn't also be done here at that moment) +- [PR #2825](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2825) Add new `advanced_configuration.0.default_max_time_ms` attribute to mongodbatlas_advanced_cluster resource and data sources. -- feat: Ensures asymmetric auto-scaling is not defined in the cluster when using the old sharding configuration in mongodbatlas_advanced_cluster (https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2836) \ No newline at end of file +- feat: Ensures asymmetric auto-scaling is not defined in the cluster when using the old sharding configuration in mongodbatlas_advanced_cluster (https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2836) +- `pinned_fcv` attribute was a recently added attribute in `advanced_cluster`. It has been defined in the new tpf schema but we need to make sure that the implementation is also present. diff --git a/internal/service/advancedclustertpf/data_source.go b/internal/service/advancedclustertpf/data_source.go index 2a40b5954d..0bb0905091 100644 --- a/internal/service/advancedclustertpf/data_source.go +++ b/internal/service/advancedclustertpf/data_source.go @@ -4,12 +4,12 @@ import ( "context" "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) -const resourceName = "advanced_cluster" // TODO: if resource exists this can be deleted - var _ datasource.DataSource = &ds{} var _ datasource.DataSourceWithConfigure = &ds{} @@ -26,8 +26,22 @@ type ds struct { } func (d *ds) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), "project_id", "name") + resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.DataSourceSchemaRequest{ + RequiredFields: []string{"project_id", "name"}, + OverridenFields: map[string]schema.Attribute{ + "use_replication_spec_per_shard": schema.BoolAttribute{ // TODO: added as in current resource + Optional: true, + MarkdownDescription: "use_replication_spec_per_shard", // TODO: add documentation + }, + }, + }) } func (d *ds) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { } + +// TODO: see if resource model can be used instead, probably different only in timeouts +type ModelDS struct { + ProjectID types.String `tfsdk:"project_id"` + Name types.String `tfsdk:"name"` +} diff --git a/internal/service/advancedclustertpf/data_source_schema.go b/internal/service/advancedclustertpf/data_source_schema.go deleted file mode 100644 index a44024430c..0000000000 --- a/internal/service/advancedclustertpf/data_source_schema.go +++ /dev/null @@ -1,11 +0,0 @@ -package advancedclustertpf - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -// TODO: see if resource model can be used instead -type ModelDS struct { - ProjectID types.String `tfsdk:"project_id"` - Name types.String `tfsdk:"name"` -} diff --git a/internal/service/advancedclustertpf/model_ClusterDescription20240805.go b/internal/service/advancedclustertpf/model_ClusterDescription20240805.go index 7ca9028df8..6491fc2879 100644 --- a/internal/service/advancedclustertpf/model_ClusterDescription20240805.go +++ b/internal/service/advancedclustertpf/model_ClusterDescription20240805.go @@ -2,19 +2,36 @@ package advancedclustertpf import ( "context" + "fmt" + "slices" + "strings" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) -func NewTFModel(ctx context.Context, input *admin.ClusterDescription20240805, timeout timeouts.Value, diags *diag.Diagnostics) *TFModel { +const ( + errorZoneNameNotSet = "zoneName is required for legacy schema" + errorNumShardsNotSet = "numShards not set for zoneName %s" + errorReplicationSpecIDNotSet = "replicationSpecID not set for zoneName %s" +) + +type ExtraAPIInfo struct { + ZoneNameNumShards map[string]int64 + ZoneNameReplicationSpecIDs map[string]string + RootDiskSize *float64 + ContainerIDs map[string]string + UsingLegacySchema bool +} + +func NewTFModel(ctx context.Context, input *admin.ClusterDescription20240805, timeout timeouts.Value, diags *diag.Diagnostics, apiInfo ExtraAPIInfo) *TFModel { biConnector := NewBiConnectorConfigObjType(ctx, input.BiConnector, diags) connectionStrings := NewConnectionStringsObjType(ctx, input.ConnectionStrings, diags) labels := NewLabelsObjType(ctx, input.Labels, diags) - replicationSpecs := NewReplicationSpecsObjType(ctx, input.ReplicationSpecs, diags) + replicationSpecs := NewReplicationSpecsObjType(ctx, input.ReplicationSpecs, diags, &apiInfo) tags := NewTagsObjType(ctx, input.Tags, diags) if diags.HasError() { return nil @@ -28,6 +45,7 @@ func NewTFModel(ctx context.Context, input *admin.ClusterDescription20240805, ti ConfigServerType: types.StringPointerValue(input.ConfigServerType), ConnectionStrings: connectionStrings, CreateDate: types.StringPointerValue(conversion.TimePtrToStringPtr(input.CreateDate)), + DiskSizeGB: types.Float64PointerValue(findRegionRootDiskSize(input.ReplicationSpecs)), EncryptionAtRestProvider: types.StringPointerValue(input.EncryptionAtRestProvider), GlobalClusterSelfManagedSharding: types.BoolPointerValue(input.GlobalClusterSelfManagedSharding), ProjectID: types.StringPointerValue(input.GroupId), @@ -46,6 +64,7 @@ func NewTFModel(ctx context.Context, input *admin.ClusterDescription20240805, ti Tags: tags, TerminationProtectionEnabled: types.BoolPointerValue(input.TerminationProtectionEnabled), VersionReleaseSystem: types.StringPointerValue(input.VersionReleaseSystem), + PinnedFCV: types.ObjectNull(PinnedFCVObjType.AttrTypes), // TODO static object Timeouts: timeout, } } @@ -96,31 +115,95 @@ func NewLabelsObjType(ctx context.Context, input *[]admin.ComponentLabel, diags return setType } -func NewReplicationSpecsObjType(ctx context.Context, input *[]admin.ReplicationSpec20240805, diags *diag.Diagnostics) types.List { +func NewReplicationSpecsObjType(ctx context.Context, input *[]admin.ReplicationSpec20240805, diags *diag.Diagnostics, apiInfo *ExtraAPIInfo) types.List { if input == nil { return types.ListNull(ReplicationSpecsObjType) } + var tfModels *[]TFReplicationSpecsModel + if apiInfo.UsingLegacySchema { + tfModels = convertReplicationSpecsLegacy(ctx, input, diags, apiInfo) + } else { + tfModels = convertReplicationSpecs(ctx, input, diags, apiInfo) + } + if diags.HasError() { + return types.ListNull(ReplicationSpecsObjType) + } + listType, diagsLocal := types.ListValueFrom(ctx, ReplicationSpecsObjType, *tfModels) + diags.Append(diagsLocal...) + return listType +} + +func convertReplicationSpecs(ctx context.Context, input *[]admin.ReplicationSpec20240805, diags *diag.Diagnostics, apiInfo *ExtraAPIInfo) *[]TFReplicationSpecsModel { tfModels := make([]TFReplicationSpecsModel, len(*input)) for i, item := range *input { regionConfigs := NewRegionConfigsObjType(ctx, item.RegionConfigs, diags) + zoneName := item.GetZoneName() + if zoneName == "" { + diags.AddError(errorZoneNameNotSet, errorZoneNameNotSet) + return &tfModels + } + legacyID := apiInfo.ZoneNameReplicationSpecIDs[zoneName] tfModels[i] = TFReplicationSpecsModel{ - Id: types.StringPointerValue(item.Id), - ExternalId: types.StringNull(), // TODO: Static - NumShards: types.Int64Value(1), // TODO: Static - ContainerId: conversion.ToTFMapOfString(ctx, diags, nil), // TODO: Static + Id: conversion.StringNullIfEmpty(legacyID), + ExternalId: types.StringPointerValue(item.Id), + NumShards: types.Int64Value(1), + ContainerId: conversion.ToTFMapOfString(ctx, diags, &apiInfo.ContainerIDs), RegionConfigs: regionConfigs, ZoneId: types.StringPointerValue(item.ZoneId), ZoneName: types.StringPointerValue(item.ZoneName), } } - listType, diagsLocal := types.ListValueFrom(ctx, ReplicationSpecsObjType, tfModels) - diags.Append(diagsLocal...) - return listType + return &tfModels +} + +func convertReplicationSpecsLegacy(ctx context.Context, input *[]admin.ReplicationSpec20240805, diags *diag.Diagnostics, apiInfo *ExtraAPIInfo) *[]TFReplicationSpecsModel { + tfModels := []TFReplicationSpecsModel{} + tfModelsSkipIndexes := []int{} + for i, item := range *input { + if slices.Contains(tfModelsSkipIndexes, i) { + continue + } + regionConfigs := NewRegionConfigsObjType(ctx, item.RegionConfigs, diags) + zoneName := item.GetZoneName() + if zoneName == "" { + diags.AddError(errorZoneNameNotSet, errorZoneNameNotSet) + return &tfModels + } + numShards, ok := apiInfo.ZoneNameNumShards[zoneName] + errMsg := []string{} + if !ok { + errMsg = append(errMsg, fmt.Sprintf(errorNumShardsNotSet, zoneName)) + } + legacyID, ok := apiInfo.ZoneNameReplicationSpecIDs[zoneName] + if !ok { + errMsg = append(errMsg, fmt.Sprintf(errorReplicationSpecIDNotSet, zoneName)) + } + if len(errMsg) > 0 { + diags.AddError("replicationSpecsLegacySchema", strings.Join(errMsg, ", ")) + return &tfModels + } + if numShards > 1 { + for j := 1; j < int(numShards); j++ { + tfModelsSkipIndexes = append(tfModelsSkipIndexes, i+j) + } + } + tfModels = append(tfModels, TFReplicationSpecsModel{ + ContainerId: conversion.ToTFMapOfString(ctx, diags, &apiInfo.ContainerIDs), + ExternalId: types.StringPointerValue(item.Id), + Id: types.StringValue(legacyID), + RegionConfigs: regionConfigs, + NumShards: types.Int64Value(numShards), + ZoneId: types.StringPointerValue(item.ZoneId), + ZoneName: types.StringPointerValue(item.ZoneName), + }) + } + return &tfModels } func NewTagsObjType(ctx context.Context, input *[]admin.ResourceTag, diags *diag.Diagnostics) types.Set { if input == nil { - return types.SetNull(TagsObjType) + // API Response not consistent, even when not set in POST/PATCH `[]` is returned instead of null + return types.SetValueMust(TagsObjType, nil) } tfModels := make([]TFTagsModel, len(*input)) for i, item := range *input { diff --git a/internal/service/advancedclustertpf/model_ClusterDescriptionProcessArgs20240805.go b/internal/service/advancedclustertpf/model_ClusterDescriptionProcessArgs20240805.go index 22c5026309..dbcd79b6b1 100644 --- a/internal/service/advancedclustertpf/model_ClusterDescriptionProcessArgs20240805.go +++ b/internal/service/advancedclustertpf/model_ClusterDescriptionProcessArgs20240805.go @@ -7,18 +7,23 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func AddAdvancedConfig(ctx context.Context, tfModel *TFModel, input *admin.ClusterDescriptionProcessArgs20240805, inputLegacy *admin20240530.ClusterDescriptionProcessArgs, diags *diag.Diagnostics) { var advancedConfig TFAdvancedConfigurationModel if input != nil && inputLegacy != nil { // Using the new API as source of Truth, only use `inputLegacy` for fields not in `input` + changeStreamOptionsPreAndPostImagesExpireAfterSeconds := input.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds + if changeStreamOptionsPreAndPostImagesExpireAfterSeconds == nil { + // special behavior using -1 when it is unset by the user + changeStreamOptionsPreAndPostImagesExpireAfterSeconds = conversion.Pointer(-1) + } advancedConfig = TFAdvancedConfigurationModel{ - ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: types.Int64PointerValue(conversion.IntPtrToInt64Ptr(input.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds)), + ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: types.Int64PointerValue(conversion.IntPtrToInt64Ptr(changeStreamOptionsPreAndPostImagesExpireAfterSeconds)), DefaultWriteConcern: types.StringPointerValue(input.DefaultWriteConcern), - DefaultReadConcern: types.StringPointerValue(inputLegacy.DefaultReadConcern), // Legacy - FailIndexKeyTooLong: types.BoolPointerValue(inputLegacy.FailIndexKeyTooLong), // TODO: Legacy and not set by the API if version higher than 4.4 + DefaultReadConcern: types.StringPointerValue(inputLegacy.DefaultReadConcern), + FailIndexKeyTooLong: types.BoolPointerValue(inputLegacy.FailIndexKeyTooLong), JavascriptEnabled: types.BoolPointerValue(input.JavascriptEnabled), MinimumEnabledTlsProtocol: types.StringPointerValue(input.MinimumEnabledTlsProtocol), NoTableScan: types.BoolPointerValue(input.NoTableScan), diff --git a/internal/service/advancedclustertpf/model_to_AdvancedClusterDescription.go b/internal/service/advancedclustertpf/model_to_AdvancedClusterDescription.go new file mode 100644 index 0000000000..ab39c77db0 --- /dev/null +++ b/internal/service/advancedclustertpf/model_to_AdvancedClusterDescription.go @@ -0,0 +1,60 @@ +package advancedclustertpf + +import ( + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" + admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" +) + +func newLegacyModel20240530ReplicationSpecsAndDiskGBOnly(specs *[]admin.ReplicationSpec20240805, zoneNameNumShards map[string]int64, oldDiskGB *float64, externalIDToLegacyID map[string]string) *admin20240530.AdvancedClusterDescription { + newDiskGB := findRegionRootDiskSize(specs) + if oldDiskGB != nil && newDiskGB != nil && (*newDiskGB-*oldDiskGB) < 0.01 { + newDiskGB = nil + } + return &admin20240530.AdvancedClusterDescription{ + DiskSizeGB: newDiskGB, + ReplicationSpecs: convertReplicationSpecs20240805to20240530(specs, zoneNameNumShards, externalIDToLegacyID), + } +} + +func convertReplicationSpecs20240805to20240530(replicationSpecs *[]admin.ReplicationSpec20240805, zoneNameNumShards map[string]int64, externalIDToLegacyID map[string]string) *[]admin20240530.ReplicationSpec { + if replicationSpecs == nil { + return nil + } + result := make([]admin20240530.ReplicationSpec, len(*replicationSpecs)) + for i, replicationSpec := range *replicationSpecs { + numShards, ok := zoneNameNumShards[replicationSpec.GetZoneName()] + if !ok { + numShards = 1 + } + legacyID := externalIDToLegacyID[replicationSpec.GetId()] + result[i] = admin20240530.ReplicationSpec{ + NumShards: conversion.Int64PtrToIntPtr(&numShards), + Id: conversion.StringPtr(legacyID), + ZoneName: replicationSpec.ZoneName, + RegionConfigs: convertCloudRegionConfig20240805to20240530(replicationSpec.RegionConfigs), + } + } + return &result +} + +func convertCloudRegionConfig20240805to20240530(cloudRegionConfig *[]admin.CloudRegionConfig20240805) *[]admin20240530.CloudRegionConfig { + if cloudRegionConfig == nil { + return nil + } + result := make([]admin20240530.CloudRegionConfig, len(*cloudRegionConfig)) + for i, regionConfig := range *cloudRegionConfig { + result[i] = admin20240530.CloudRegionConfig{ + ProviderName: regionConfig.ProviderName, + RegionName: regionConfig.RegionName, + BackingProviderName: regionConfig.BackingProviderName, + Priority: regionConfig.Priority, + ElectableSpecs: convertHardwareSpecToOldSDK(regionConfig.ElectableSpecs), + ReadOnlySpecs: convertDedicatedHardwareSpecToOldSDK(regionConfig.ReadOnlySpecs), + AnalyticsSpecs: convertDedicatedHardwareSpecToOldSDK(regionConfig.AnalyticsSpecs), + AutoScaling: convertAdvancedAutoScalingSettingsToOldSDK(regionConfig.AutoScaling), + AnalyticsAutoScaling: convertAdvancedAutoScalingSettingsToOldSDK(regionConfig.AnalyticsAutoScaling), + } + } + return &result +} diff --git a/internal/service/advancedclustertpf/model_to_ClusterDescription20240805.go b/internal/service/advancedclustertpf/model_to_ClusterDescription20240805.go index a3884b38e4..2e3b9f5eb5 100644 --- a/internal/service/advancedclustertpf/model_to_ClusterDescription20240805.go +++ b/internal/service/advancedclustertpf/model_to_ClusterDescription20240805.go @@ -8,14 +8,21 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) +const defaultZoneName = "ZoneName managed by Terraform" + func NewAtlasReq(ctx context.Context, input *TFModel, diags *diag.Diagnostics) *admin.ClusterDescription20240805 { acceptDataRisksAndForceReplicaSetReconfig, ok := conversion.StringPtrToTimePtr(input.AcceptDataRisksAndForceReplicaSetReconfig.ValueStringPointer()) if !ok { diags.AddError("error converting AcceptDataRisksAndForceReplicaSetReconfig", fmt.Sprintf("not a valid time: %s", input.AcceptDataRisksAndForceReplicaSetReconfig.ValueString())) } + majorVersion := conversion.NilForUnknown(input.MongoDBMajorVersion, input.MongoDBMajorVersion.ValueStringPointer()) + if majorVersion != nil { + majorVersionFormatted := FormatMongoDBMajorVersion(*majorVersion) + majorVersion = &majorVersionFormatted + } return &admin.ClusterDescription20240805{ AcceptDataRisksAndForceReplicaSetReconfig: acceptDataRisksAndForceReplicaSetReconfig, BackupEnabled: conversion.NilForUnknown(input.BackupEnabled, input.BackupEnabled.ValueBoolPointer()), @@ -24,9 +31,8 @@ func NewAtlasReq(ctx context.Context, input *TFModel, diags *diag.Diagnostics) * ConfigServerManagementMode: conversion.NilForUnknown(input.ConfigServerManagementMode, input.ConfigServerManagementMode.ValueStringPointer()), EncryptionAtRestProvider: conversion.NilForUnknown(input.EncryptionAtRestProvider, input.EncryptionAtRestProvider.ValueStringPointer()), GlobalClusterSelfManagedSharding: conversion.NilForUnknown(input.GlobalClusterSelfManagedSharding, input.GlobalClusterSelfManagedSharding.ValueBoolPointer()), - GroupId: input.ProjectID.ValueStringPointer(), Labels: newComponentLabel(ctx, input.Labels, diags), - MongoDBMajorVersion: conversion.NilForUnknown(input.MongoDBMajorVersion, input.MongoDBMajorVersion.ValueStringPointer()), + MongoDBMajorVersion: majorVersion, Name: input.Name.ValueStringPointer(), Paused: conversion.NilForUnknown(input.Paused, input.Paused.ValueBoolPointer()), PitEnabled: conversion.NilForUnknown(input.PitEnabled, input.PitEnabled.ValueBoolPointer()), @@ -86,14 +92,23 @@ func newReplicationSpec20240805(ctx context.Context, input types.List, diags *di for i := range elements { item := &elements[i] resp[i] = admin.ReplicationSpec20240805{ - Id: conversion.NilForUnknown(item.Id, item.Id.ValueStringPointer()), + Id: conversion.NilForUnknown(item.ExternalId, item.ExternalId.ValueStringPointer()), ZoneId: conversion.NilForUnknown(item.ZoneId, item.ZoneId.ValueStringPointer()), RegionConfigs: newCloudRegionConfig20240805(ctx, item.RegionConfigs, diags), - ZoneName: item.ZoneName.ValueStringPointer(), + ZoneName: conversion.StringPtr(resolveZoneNameOrUseDefault(item)), } } return &resp } + +func resolveZoneNameOrUseDefault(item *TFReplicationSpecsModel) string { + zoneName := conversion.NilForUnknown(item.ZoneName, item.ZoneName.ValueStringPointer()) + if zoneName == nil { + return defaultZoneName + } + return *zoneName +} + func newResourceTag(ctx context.Context, input types.Set, diags *diag.Diagnostics) *[]admin.ResourceTag { if input.IsUnknown() || input.IsNull() { return nil diff --git a/internal/service/advancedclustertpf/model_to_ClusterDescription20240805_legacy.go b/internal/service/advancedclustertpf/model_to_ClusterDescription20240805_legacy.go new file mode 100644 index 0000000000..be71a94f6e --- /dev/null +++ b/internal/service/advancedclustertpf/model_to_ClusterDescription20240805_legacy.go @@ -0,0 +1,160 @@ +package advancedclustertpf + +import ( + admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" +) + +func newLegacyModel(clusterDescription *admin.ClusterDescription20240805) *admin20240805.ClusterDescription20240805 { + return &admin20240805.ClusterDescription20240805{ + Name: clusterDescription.Name, + ClusterType: clusterDescription.ClusterType, + ReplicationSpecs: convertReplicationSpecs20241023to20240805(clusterDescription.ReplicationSpecs), + BackupEnabled: clusterDescription.BackupEnabled, + BiConnector: convertBiConnector20241023to20240805(clusterDescription.BiConnector), + EncryptionAtRestProvider: clusterDescription.EncryptionAtRestProvider, + Labels: convertLabels20241023to20240805(clusterDescription.Labels), + Tags: convertTag20241023to20240805(clusterDescription.Tags), + MongoDBMajorVersion: clusterDescription.MongoDBMajorVersion, + PitEnabled: clusterDescription.PitEnabled, + RootCertType: clusterDescription.RootCertType, + TerminationProtectionEnabled: clusterDescription.TerminationProtectionEnabled, + VersionReleaseSystem: clusterDescription.VersionReleaseSystem, + GlobalClusterSelfManagedSharding: clusterDescription.GlobalClusterSelfManagedSharding, + ReplicaSetScalingStrategy: clusterDescription.ReplicaSetScalingStrategy, + RedactClientLogData: clusterDescription.RedactClientLogData, + ConfigServerManagementMode: clusterDescription.ConfigServerManagementMode, + } +} + +func convertReplicationSpecs20241023to20240805(replicationSpecs *[]admin.ReplicationSpec20240805) *[]admin20240805.ReplicationSpec20240805 { + if replicationSpecs == nil { + return nil + } + result := make([]admin20240805.ReplicationSpec20240805, len(*replicationSpecs)) + for i, replicationSpec := range *replicationSpecs { + result[i] = admin20240805.ReplicationSpec20240805{ + Id: replicationSpec.Id, + ZoneName: replicationSpec.ZoneName, + ZoneId: replicationSpec.ZoneId, + RegionConfigs: convertCloudRegionConfig20241023to20240805(replicationSpec.RegionConfigs), + } + } + return &result +} + +func convertCloudRegionConfig20241023to20240805(cloudRegionConfig *[]admin.CloudRegionConfig20240805) *[]admin20240805.CloudRegionConfig20240805 { + if cloudRegionConfig == nil { + return nil + } + result := make([]admin20240805.CloudRegionConfig20240805, len(*cloudRegionConfig)) + for i, regionConfig := range *cloudRegionConfig { + result[i] = admin20240805.CloudRegionConfig20240805{ + ProviderName: regionConfig.ProviderName, + RegionName: regionConfig.RegionName, + BackingProviderName: regionConfig.BackingProviderName, + Priority: regionConfig.Priority, + ElectableSpecs: convertHardwareSpec20241023to20240805(regionConfig.ElectableSpecs), + ReadOnlySpecs: convertDedicatedHardwareSpec20241023to20240805(regionConfig.ReadOnlySpecs), + AnalyticsSpecs: convertDedicatedHardwareSpec20241023to20240805(regionConfig.AnalyticsSpecs), + AutoScaling: convertAdvancedAutoScalingSettings20241023to20240805(regionConfig.AutoScaling), + AnalyticsAutoScaling: convertAdvancedAutoScalingSettings20241023to20240805(regionConfig.AnalyticsAutoScaling), + } + } + return &result +} + +func convertAdvancedAutoScalingSettings20241023to20240805(advancedAutoScalingSettings *admin.AdvancedAutoScalingSettings) *admin20240805.AdvancedAutoScalingSettings { + if advancedAutoScalingSettings == nil { + return nil + } + return &admin20240805.AdvancedAutoScalingSettings{ + Compute: convertAdvancedComputeAutoScaling20241023to20240805(advancedAutoScalingSettings.Compute), + DiskGB: convertDiskGBAutoScaling20241023to20240805(advancedAutoScalingSettings.DiskGB), + } +} + +func convertDiskGBAutoScaling20241023to20240805(diskGBAutoScaling *admin.DiskGBAutoScaling) *admin20240805.DiskGBAutoScaling { + if diskGBAutoScaling == nil { + return nil + } + return &admin20240805.DiskGBAutoScaling{ + Enabled: diskGBAutoScaling.Enabled, + } +} + +func convertAdvancedComputeAutoScaling20241023to20240805(advancedComputeAutoScaling *admin.AdvancedComputeAutoScaling) *admin20240805.AdvancedComputeAutoScaling { + if advancedComputeAutoScaling == nil { + return nil + } + return &admin20240805.AdvancedComputeAutoScaling{ + Enabled: advancedComputeAutoScaling.Enabled, + MaxInstanceSize: advancedComputeAutoScaling.MaxInstanceSize, + MinInstanceSize: advancedComputeAutoScaling.MinInstanceSize, + ScaleDownEnabled: advancedComputeAutoScaling.ScaleDownEnabled, + } +} + +func convertHardwareSpec20241023to20240805(hardwareSpec *admin.HardwareSpec20240805) *admin20240805.HardwareSpec20240805 { + if hardwareSpec == nil { + return nil + } + return &admin20240805.HardwareSpec20240805{ + DiskSizeGB: hardwareSpec.DiskSizeGB, + NodeCount: hardwareSpec.NodeCount, + DiskIOPS: hardwareSpec.DiskIOPS, + EbsVolumeType: hardwareSpec.EbsVolumeType, + InstanceSize: hardwareSpec.InstanceSize, + } +} + +func convertDedicatedHardwareSpec20241023to20240805(hardwareSpec *admin.DedicatedHardwareSpec20240805) *admin20240805.DedicatedHardwareSpec20240805 { + if hardwareSpec == nil { + return nil + } + return &admin20240805.DedicatedHardwareSpec20240805{ + DiskSizeGB: hardwareSpec.DiskSizeGB, + NodeCount: hardwareSpec.NodeCount, + DiskIOPS: hardwareSpec.DiskIOPS, + EbsVolumeType: hardwareSpec.EbsVolumeType, + InstanceSize: hardwareSpec.InstanceSize, + } +} + +func convertBiConnector20241023to20240805(biConnector *admin.BiConnector) *admin20240805.BiConnector { + if biConnector == nil { + return nil + } + return &admin20240805.BiConnector{ + ReadPreference: biConnector.ReadPreference, + Enabled: biConnector.Enabled, + } +} + +func convertLabels20241023to20240805(labels *[]admin.ComponentLabel) *[]admin20240805.ComponentLabel { + if labels == nil { + return nil + } + result := make([]admin20240805.ComponentLabel, len(*labels)) + for i, label := range *labels { + result[i] = admin20240805.ComponentLabel{ + Key: label.Key, + Value: label.Value, + } + } + return &result +} + +func convertTag20241023to20240805(tags *[]admin.ResourceTag) *[]admin20240805.ResourceTag { + if tags == nil { + return nil + } + result := make([]admin20240805.ResourceTag, len(*tags)) + for i, tag := range *tags { + result[i] = admin20240805.ResourceTag{ + Key: tag.Key, + Value: tag.Value, + } + } + return &result +} diff --git a/internal/service/advancedclustertpf/model_to_ClusterDescriptionProcessArgs20240805.go b/internal/service/advancedclustertpf/model_to_ClusterDescriptionProcessArgs20240805.go index 41db894b8f..f23ff302f8 100644 --- a/internal/service/advancedclustertpf/model_to_ClusterDescriptionProcessArgs20240805.go +++ b/internal/service/advancedclustertpf/model_to_ClusterDescriptionProcessArgs20240805.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func NewAtlasReqAdvancedConfiguration(ctx context.Context, objInput *types.Object, diags *diag.Diagnostics) *admin.ClusterDescriptionProcessArgs20240805 { diff --git a/internal/service/advancedclustertpf/move_state.go b/internal/service/advancedclustertpf/move_state.go index 106d2ce46b..33b1e6987a 100644 --- a/internal/service/advancedclustertpf/move_state.go +++ b/internal/service/advancedclustertpf/move_state.go @@ -2,182 +2,31 @@ package advancedclustertpf import ( "context" - "encoding/json" - "os" "strings" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-go/tftypes" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) -const ( - MoveModeEnvVarName = "MONGODB_ATLAS_TEST_MOVE_MODE" - MoveModeValPreferred = "preferred" - MoveModeValRawState = "rawstate" - MoveModeValJSON = "json" -) - -// TODO: We temporarily use mongodbatlas_database_user instead of mongodbatlas_cluster to set up the initial environment func (r *rs) MoveState(context.Context) []resource.StateMover { - return []resource.StateMover{ - { - SourceSchema: &schema.Schema{ - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "project_id": schema.StringAttribute{ - Required: true, - }, - "auth_database_name": schema.StringAttribute{ - Required: true, - }, - "username": schema.StringAttribute{ - Required: true, - }, - "password": schema.StringAttribute{ - Optional: true, - Sensitive: true, - }, - "x509_type": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - "oidc_auth_type": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - "ldap_auth_type": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - "aws_iam_type": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - }, - Blocks: map[string]schema.Block{ - "roles": schema.SetNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "collection_name": schema.StringAttribute{ - Optional: true, - }, - "database_name": schema.StringAttribute{ - Required: true, - }, - "role_name": schema.StringAttribute{ - Required: true, - }, - }, - }, - }, - "labels": schema.SetNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "key": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - "value": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - }, - }, - }, - "scopes": schema.SetNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "name": schema.StringAttribute{ - Optional: true, - }, - "type": schema.StringAttribute{ - Optional: true, - }, - }, - }, - }, - }, - }, - StateMover: stateMoverTemporaryPreferred, - }, - { - StateMover: stateMoverTemporaryRawState, - }, - { - StateMover: stateMoverTemporaryJSON, - }, - } -} - -func stateMoverTemporaryPreferred(ctx context.Context, req resource.MoveStateRequest, resp *resource.MoveStateResponse) { - if !isSource(req, "database_user", MoveModeValPreferred) { - return - } - type model struct { - ID types.String `tfsdk:"id"` - ProjectID types.String `tfsdk:"project_id"` - AuthDatabaseName types.String `tfsdk:"auth_database_name"` - Username types.String `tfsdk:"username"` - Password types.String `tfsdk:"password"` - X509Type types.String `tfsdk:"x509_type"` - OIDCAuthType types.String `tfsdk:"oidc_auth_type"` - LDAPAuthType types.String `tfsdk:"ldap_auth_type"` - AWSIAMType types.String `tfsdk:"aws_iam_type"` - Roles types.Set `tfsdk:"roles"` - Labels types.Set `tfsdk:"labels"` - Scopes types.Set `tfsdk:"scopes"` - } - var state model - resp.Diagnostics.Append(req.SourceState.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - setMoveState(ctx, state.ProjectID.String(), state.Username.String(), resp) + return []resource.StateMover{{StateMover: stateMover}} } -func stateMoverTemporaryRawState(ctx context.Context, req resource.MoveStateRequest, resp *resource.MoveStateResponse) { - if !isSource(req, "database_user", MoveModeValRawState) { +func stateMover(ctx context.Context, req resource.MoveStateRequest, resp *resource.MoveStateResponse) { + if req.SourceTypeName != "mongodbatlas_cluster" || !strings.HasSuffix(req.SourceProviderAddress, "/mongodbatlas") { return } - // TODO: not need to define the full model if using IgnoreUndefinedAttributes, as in JSON case rawStateValue, err := req.SourceRawState.UnmarshalWithOpts(tftypes.Object{ AttributeTypes: map[string]tftypes.Type{ - "id": tftypes.String, - "project_id": tftypes.String, - "auth_database_name": tftypes.String, - "username": tftypes.String, - "password": tftypes.String, - "x509_type": tftypes.String, - "oidc_auth_type": tftypes.String, - "ldap_auth_type": tftypes.String, - "aws_iam_type": tftypes.String, - "roles": tftypes.Set{ElementType: tftypes.Object{ - AttributeTypes: map[string]tftypes.Type{ - "collection_name": tftypes.String, - "database_name": tftypes.String, - "role_name": tftypes.String, - }, - }}, - "labels": tftypes.Set{ElementType: tftypes.Object{ - AttributeTypes: map[string]tftypes.Type{ - "key": tftypes.String, - "value": tftypes.String, - }, - }}, - "scopes": tftypes.Set{ElementType: tftypes.Object{ - AttributeTypes: map[string]tftypes.Type{ - "name": tftypes.String, - "type": tftypes.String, - }, - }}, + "project_id": tftypes.String, + "name": tftypes.String, }, }, tfprotov6.UnmarshalOpts{ValueFromJSONOpts: tftypes.ValueFromJSONOpts{IgnoreUndefinedAttributes: true}}) if err != nil { @@ -189,45 +38,26 @@ func stateMoverTemporaryRawState(ctx context.Context, req resource.MoveStateRequ resp.Diagnostics.AddError("Unable to Convert Source State", err.Error()) return } - var projectID *string // TODO: take username as the cluster name + var projectID *string if err := rawState["project_id"].As(&projectID); err != nil { - resp.Diagnostics.AddAttributeError(path.Root("project_id"), "Unable to Convert Source State", err.Error()) + resp.Diagnostics.AddAttributeError(path.Root("project_id"), "Unable to read cluster project_id", err.Error()) return } - var clusterName *string // TODO: take username as the cluster name - if err := rawState["username"].As(&clusterName); err != nil { - resp.Diagnostics.AddAttributeError(path.Root("username"), "Unable to Convert Source State", err.Error()) + var name *string + if err := rawState["name"].As(&name); err != nil { + resp.Diagnostics.AddAttributeError(path.Root("name"), "Unable to Convert read cluster name", err.Error()) return } - setMoveState(ctx, *projectID, *clusterName, resp) -} -func stateMoverTemporaryJSON(ctx context.Context, req resource.MoveStateRequest, resp *resource.MoveStateResponse) { - if !isSource(req, "database_user", MoveModeValJSON) { - return - } - type model struct { - ProjectID string `json:"project_id"` - ClusterName string `json:"username"` // TODO: take username as the cluster name - } - var state model - if err := json.Unmarshal(req.SourceRawState.JSON, &state); err != nil { - resp.Diagnostics.AddError("Unable to Unmarshal Source State", err.Error()) + if !conversion.IsStringPresent(projectID) || !conversion.IsStringPresent(name) { + resp.Diagnostics.AddError("Unable to read project_id or name", "") return } - setMoveState(ctx, state.ProjectID, state.ClusterName, resp) + setMoveStateResponse(ctx, *projectID, *name, resp) } -func isSource(req resource.MoveStateRequest, resourceName, moveMode string) bool { - return os.Getenv(MoveModeEnvVarName) == moveMode && - req.SourceTypeName == "mongodbatlas_"+resourceName && - req.SourceSchemaVersion == 0 && - strings.HasSuffix(req.SourceProviderAddress, "/mongodbatlas") -} - -func setMoveState(ctx context.Context, projectID, clusterName string, resp *resource.MoveStateResponse) { - // TODO: timeout should be read from source if provided - timeout := timeouts.Value{ +func setMoveStateResponse(ctx context.Context, projectID, clusterName string, resp *resource.MoveStateResponse) { + validTimeout := timeouts.Value{ Object: types.ObjectValueMust( map[string]attr.Type{ "create": types.StringType, @@ -240,13 +70,16 @@ func setMoveState(ctx context.Context, projectID, clusterName string, resp *reso "delete": types.StringValue("30m"), }), } - // TODO: we need to have a good state (all attributes known or null) but not need to be the final ones as Read is called after - tfNewModel, shouldReturn := mockedSDK(ctx, &resp.Diagnostics, timeout) - if shouldReturn { + model := NewTFModel(ctx, &admin.ClusterDescription20240805{ + GroupId: conversion.StringPtr(projectID), + Name: conversion.StringPtr(clusterName), + }, validTimeout, &resp.Diagnostics, ExtraAPIInfo{}) + if resp.Diagnostics.HasError() { + return + } + AddAdvancedConfig(ctx, model, nil, nil, &resp.Diagnostics) + if resp.Diagnostics.HasError() { return } - // TODO: setting attributed needed by Read, confirm if ClusterID is needed - tfNewModel.ProjectID = types.StringValue(projectID) - tfNewModel.Name = types.StringValue(clusterName) - resp.Diagnostics.Append(resp.TargetState.Set(ctx, tfNewModel)...) + resp.Diagnostics.Append(resp.TargetState.Set(ctx, model)...) } diff --git a/internal/service/advancedclustertpf/move_state_test.go b/internal/service/advancedclustertpf/move_state_test.go index 6547b92b9c..5e8072491c 100644 --- a/internal/service/advancedclustertpf/move_state_test.go +++ b/internal/service/advancedclustertpf/move_state_test.go @@ -6,42 +6,21 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedclustertpf" + "github.com/hashicorp/terraform-plugin-testing/tfversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" ) -func TestAccAdvancedCluster_move_preferred(t *testing.T) { +func TestAccAdvancedCluster_moveBasic(t *testing.T) { var ( projectID = acc.ProjectIDExecution(t) clusterName = acc.RandomClusterName() ) - t.Setenv(advancedclustertpf.MoveModeEnvVarName, advancedclustertpf.MoveModeValPreferred) - // TODO: temporary no parallel tests so t.Setenv can be used - resource.Test(t, resource.TestCase{ - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Steps: []resource.TestStep{ - { - Config: configMoveFirst(projectID, clusterName), - }, - { - Config: configMoveSecond(projectID, clusterName), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "name", clusterName), - resource.TestCheckResourceAttr(resourceName, "project_id", projectID), - ), - }, + resource.ParallelTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), }, - }) -} - -func TestAccAdvancedCluster_move_rawstate(t *testing.T) { - var ( - projectID = acc.ProjectIDExecution(t) - clusterName = acc.RandomClusterName() - ) - t.Setenv(advancedclustertpf.MoveModeEnvVarName, advancedclustertpf.MoveModeValRawState) - resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { Config: configMoveFirst(projectID, clusterName), @@ -49,65 +28,66 @@ func TestAccAdvancedCluster_move_rawstate(t *testing.T) { { Config: configMoveSecond(projectID, clusterName), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "project_id", projectID), - ), - }, - }, - }) -} - -func TestAccAdvancedCluster_move_json(t *testing.T) { - var ( - projectID = acc.ProjectIDExecution(t) - clusterName = acc.RandomClusterName() - ) - t.Setenv(advancedclustertpf.MoveModeEnvVarName, advancedclustertpf.MoveModeValJSON) - resource.Test(t, resource.TestCase{ - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Steps: []resource.TestStep{ - { - Config: configMoveFirst(projectID, clusterName), - }, - { - Config: configMoveSecond(projectID, clusterName), - Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "name", clusterName), - resource.TestCheckResourceAttr(resourceName, "project_id", projectID), ), }, }, }) } -func TestAccAdvancedCluster_move_invalid(t *testing.T) { +func TestAccAdvancedCluster_moveInvalid(t *testing.T) { var ( projectID = acc.ProjectIDExecution(t) clusterName = acc.RandomClusterName() ) - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configMoveFirst(projectID, clusterName), + Config: configMoveFirstInvalid(projectID, clusterName), }, { - Config: configMoveSecond(projectID, clusterName), + Config: configMoveSecondInvalid(projectID, clusterName), ExpectError: regexp.MustCompile("Unable to Move Resource State"), }, { - Config: configMoveFirst(projectID, clusterName), + Config: configMoveFirstInvalid(projectID, clusterName), }, }, }) } -// TODO: We temporarily use mongodbatlas_database_user instead of mongodbatlas_cluster to set up the initial environment func configMoveFirst(projectID, clusterName string) string { return fmt.Sprintf(` - resource "mongodbatlas_database_user" "oldtpf" { + resource "mongodbatlas_cluster" "old" { + project_id = %[1]q + name = %[2]q + disk_size_gb = 10 + cluster_type = "REPLICASET" + provider_name = "AWS" + provider_instance_size_name = "M10" + replication_specs { + num_shards = 1 + regions_config { + region_name = "US_EAST_1" + electable_nodes = 3 + priority = 7 + } + } + } + `, projectID, clusterName) +} + +func configMoveFirstInvalid(projectID, clusterName string) string { + return fmt.Sprintf(` + resource "mongodbatlas_database_user" "old" { project_id = %[1]q - username = %[2]q # TODO: temporarily we use the username in database_user source as the cluster name in destination + username = %[2]q # use cluster name as username password = "test-acc-password" auth_database_name = "admin" roles { @@ -121,7 +101,16 @@ func configMoveFirst(projectID, clusterName string) string { func configMoveSecond(projectID, clusterName string) string { return ` moved { - from = mongodbatlas_database_user.oldtpf + from = mongodbatlas_cluster.old + to = mongodbatlas_advanced_cluster.test + } + ` + configBasic(projectID, clusterName, "") +} + +func configMoveSecondInvalid(projectID, clusterName string) string { + return ` + moved { + from = mongodbatlas_database_user.old to = mongodbatlas_advanced_cluster.test } ` + configBasic(projectID, clusterName, "") diff --git a/internal/service/advancedclustertpf/plural_data_source.go b/internal/service/advancedclustertpf/plural_data_source.go index 4f3152ce3b..5da1ba424f 100644 --- a/internal/service/advancedclustertpf/plural_data_source.go +++ b/internal/service/advancedclustertpf/plural_data_source.go @@ -5,6 +5,8 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) @@ -25,9 +27,26 @@ type pluralDS struct { } func (d *pluralDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = PluralDataSourceSchema(ctx) - conversion.UpdateSchemaDescription(&resp.Schema) + resp.Schema = conversion.PluralDataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.PluralDataSourceSchemaRequest{ + RequiredFields: []string{"project_id"}, + OverridenRootFields: map[string]schema.Attribute{ + "use_replication_spec_per_shard": schema.BoolAttribute{ // TODO: added as in current resource + Optional: true, + MarkdownDescription: "use_replication_spec_per_shard", // TODO: add documentation + }, + "include_deleted_with_retained_backups": schema.BoolAttribute{ // TODO: not in current resource, decide if keep + Optional: true, + MarkdownDescription: "Flag that indicates whether to return Clusters with retain backups.", + }, + }, + }) } func (d *pluralDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { } + +type AdvancedClustersModel struct { + ProjectID types.String `tfsdk:"project_id"` + UseReplicationSpecPerShard types.Bool `tfsdk:"use_replication_spec_per_shard"` // TODO: added as in current resource + IncludeDeletedWithRetainedBackups types.Bool `tfsdk:"include_deleted_with_retained_backups"` // TODO: not in current resource, decide if keep +} diff --git a/internal/service/advancedclustertpf/plural_data_source_schema.go b/internal/service/advancedclustertpf/plural_data_source_schema.go deleted file mode 100644 index a9104f0587..0000000000 --- a/internal/service/advancedclustertpf/plural_data_source_schema.go +++ /dev/null @@ -1,57 +0,0 @@ -package advancedclustertpf - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -// TODO: see if we can leverage on resource or singular data source schema, e.g. have a func to add computed -func PluralDataSourceSchema(ctx context.Context) schema.Schema { - return schema.Schema{ - Attributes: map[string]schema.Attribute{ - "project_id": schema.StringAttribute{ - Required: true, - MarkdownDescription: "Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.\n\n**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups.", - }, - "use_replication_spec_per_shard": schema.BoolAttribute{ // TODO: added as in current resource - Optional: true, - MarkdownDescription: "use_replication_spec_per_shard", // TODO: add documentation - }, - "include_deleted_with_retained_backups": schema.BoolAttribute{ // TODO: not in current resource, decide if keep - Optional: true, - MarkdownDescription: "Flag that indicates whether to return Clusters with retain backups.", - }, - "results": schema.ListNestedAttribute{ - Computed: true, - MarkdownDescription: "List of returned documents that MongoDB Cloud provides when completing this request.", - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "project_id": schema.StringAttribute{ - Computed: true, - MarkdownDescription: "Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.\n\n**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups.", - }, - "name": schema.StringAttribute{ - Computed: true, - MarkdownDescription: "Human-readable label that identifies this cluster.", - }, - }, - }, - }, - "total_count": schema.Int64Attribute{ - Computed: true, - MarkdownDescription: "Total number of documents available. MongoDB Cloud omits this value if `includeCount` is set to `false`.", - }, - }, - } -} - -type AdvancedClustersModel struct { - ProjectID types.String `tfsdk:"project_id"` - ItemsPerPage types.Int64 `tfsdk:"items_per_page"` - PageNum types.Int64 `tfsdk:"page_num"` - TotalCount types.Int64 `tfsdk:"total_count"` - IncludeCount types.Bool `tfsdk:"include_count"` - IncludeDeletedWithRetainedBackups types.Bool `tfsdk:"include_deleted_with_retained_backups"` -} diff --git a/internal/service/advancedclustertpf/resource.go b/internal/service/advancedclustertpf/resource.go index 59feb9e994..95cd97d716 100644 --- a/internal/service/advancedclustertpf/resource.go +++ b/internal/service/advancedclustertpf/resource.go @@ -3,14 +3,20 @@ package advancedclustertpf import ( "context" "fmt" + "reflect" + "time" - "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/update" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" + admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" + admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) var _ resource.ResourceWithConfigure = &rs{} @@ -18,6 +24,7 @@ var _ resource.ResourceWithImportState = &rs{} var _ resource.ResourceWithMoveState = &rs{} const ( + resourceName = "advanced_cluster" errorCreate = "error creating advanced cluster: %s" errorRead = "error reading advanced cluster (%s): %s" errorDelete = "error deleting advanced cluster (%s): %s" @@ -31,9 +38,18 @@ const ( ErrorOperationNotPermitted = "error operation not permitted" ignoreLabel = "Infrastructure Tool" DeprecationOldSchemaAction = "Please refer to our examples, documentation, and 1.18.0 migration guide for more details at https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/1.18.0-upgrade-guide.html.markdown" + defaultTimeout = 3 * time.Hour + ErrorCodeClusterNotFound = "CLUSTER_NOT_FOUND" + changeReasonUpdate = "update" + changeReasonCreate = "create" + changeReasonDelete = "delete" ) -var DeprecationMsgOldSchema = fmt.Sprintf("%s %s", constant.DeprecationParam, DeprecationOldSchemaAction) +var ( + DeprecationMsgOldSchema = fmt.Sprintf("%s %s", constant.DeprecationParam, DeprecationOldSchemaAction) + pauseRequest = admin.ClusterDescription20240805{Paused: conversion.Pointer(true)} + resumeRequest = admin.ClusterDescription20240805{Paused: conversion.Pointer(false)} +) func Resource() resource.Resource { return &rs{ @@ -54,40 +70,27 @@ func (r *rs) Schema(ctx context.Context, req resource.SchemaRequest, resp *resou func (r *rs) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var plan TFModel - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - sdkReq := NewAtlasReq(ctx, &plan, &resp.Diagnostics) - if resp.Diagnostics.HasError() { - return - } - err := StoreCreatePayload(sdkReq) - if err != nil { - resp.Diagnostics.AddError("errorCreate", fmt.Sprintf(errorCreate, err.Error())) + diags := &resp.Diagnostics + diags.Append(req.Plan.Get(ctx, &plan)...) + if diags.HasError() { return } - tfNewModel, shouldReturn := mockedSDK(ctx, &resp.Diagnostics, plan.Timeouts) - if shouldReturn { - return + model := r.createCluster(ctx, &plan, diags) + if model != nil { + diags.Append(resp.State.Set(ctx, model)...) } - resp.Diagnostics.Append(resp.State.Set(ctx, tfNewModel)...) } func (r *rs) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var state TFModel - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { + diags := &resp.Diagnostics + diags.Append(req.State.Get(ctx, &state)...) + if diags.HasError() { return } - if state.ClusterID.IsNull() { - tfModel, shouldReturn := mockedSDK(ctx, &resp.Diagnostics, state.Timeouts) - if shouldReturn { - return - } - resp.Diagnostics.Append(resp.State.Set(ctx, tfModel)...) - } else { - resp.Diagnostics.Append(resp.State.Set(ctx, state)...) + model := r.readCluster(ctx, &state, &resp.State, diags, true) + if model != nil { + diags.Append(resp.State.Set(ctx, model)...) } } @@ -99,80 +102,343 @@ func (r *rs) Update(ctx context.Context, req resource.UpdateRequest, resp *resou if diags.HasError() { return } - patchReq := update.PatchPayloadTpf(ctx, diags, &state, &plan, NewAtlasReq) - if patchReq != nil { - err := StoreUpdatePayload(patchReq) - if err != nil { - diags.AddError("error storing update payload", fmt.Sprintf("error storing update payload: %s", err.Error())) - } + stateReq := normalizeFromTFModel(ctx, &state, diags, false) + planReq := normalizeFromTFModel(ctx, &plan, diags, false) + if diags.HasError() { + return } - patchReqProcessArgs := update.PatchPayloadTpf(ctx, diags, &state.AdvancedConfiguration, &plan.AdvancedConfiguration, NewAtlasReqAdvancedConfiguration) - if patchReqProcessArgs != nil { - err := StoreUpdatePayloadProcessArgs(patchReqProcessArgs) - if err != nil { - diags.AddError("error storing update payload advanced config", fmt.Sprintf("error storing update payload: %s", err.Error())) - } + normalizePatchState(stateReq) + patchReq, err := update.PatchPayload(stateReq, planReq) + if err != nil { + diags.AddError("errorPatchPayload", err.Error()) + return } - patchReqProcessArgsLegacy := update.PatchPayloadTpf(ctx, diags, &state.AdvancedConfiguration, &plan.AdvancedConfiguration, NewAtlasReqAdvancedConfigurationLegacy) - if patchReqProcessArgsLegacy != nil { - err := StoreUpdatePayloadProcessArgsLegacy(patchReqProcessArgsLegacy) - if err != nil { - diags.AddError("error storing update payload advanced config legacy", fmt.Sprintf("error storing update payload: %s", err.Error())) + var cluster *admin.ClusterDescription20240805 + if !update.IsZeroValues(patchReq) { + upgradeRequest := getTenantUpgradeRequest(stateReq, patchReq) + if upgradeRequest != nil { + cluster = r.applyTenantUpgrade(ctx, &plan, upgradeRequest, diags) + } else { + cluster = r.applyClusterChanges(ctx, diags, &state, &plan, patchReq) + } + if diags.HasError() { + return } } + legacyAdvConfig, advConfig, advConfigChanged := r.applyAdvancedConfigurationChanges(ctx, diags, &state, &plan) if diags.HasError() { return } - - // TODO: Use requests to do actual updates with Admin API - tfNewModel, shouldReturn := mockedSDK(ctx, diags, plan.Timeouts) - // TODO: keep project_id and name from plan to avoid overwriting for move_state tests. We should probably do the same with the rest of attributes - tfNewModel.Name = plan.Name - tfNewModel.ProjectID = plan.ProjectID - if shouldReturn { - return + var model *TFModel + if cluster == nil { + r.updateAdvConfig(ctx, legacyAdvConfig, advConfig, &state, diags) + if diags.HasError() { + return + } + model = &state + } else { + var stateAdvConfig types.Object + if !advConfigChanged { + stateAdvConfig = state.AdvancedConfiguration + } + model = r.convertClusterAddAdvConfig(ctx, legacyAdvConfig, advConfig, cluster, &plan, &stateAdvConfig, diags) + } + if model != nil { + diags.Append(resp.State.Set(ctx, model)...) } - diags.Append(resp.State.Set(ctx, tfNewModel)...) } func (r *rs) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { var state TFModel - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { + diags := &resp.Diagnostics + diags.Append(req.State.Get(ctx, &state)...) + if diags.HasError() { return } - name := state.Name.ValueString() - clusterID := state.ClusterID.ValueString() - if clusterID == "" { - resp.Diagnostics.AddError("errorDelete", fmt.Sprintf(errorDelete, name, "clusterID is empty")) + clusterName := state.Name.ValueString() + projectID := state.ProjectID.ValueString() + api := r.Client.AtlasV2.ClustersApi + params := &admin.DeleteClusterApiParams{ + GroupId: projectID, + ClusterName: clusterName, + } + if retainBackups := conversion.NilForUnknown(state.RetainBackupsEnabled, state.RetainBackupsEnabled.ValueBoolPointer()); retainBackups != nil { + params.RetainBackups = retainBackups + } + _, err := api.DeleteClusterWithParams(ctx, params).Execute() + if err != nil { + diags.AddError("errorDelete", fmt.Sprintf(errorDelete, clusterName, err.Error())) return } + _ = AwaitChanges(ctx, r.Client.AtlasV2.ClustersApi, &state.Timeouts, diags, projectID, clusterName, changeReasonDelete) } func (r *rs) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { conversion.ImportStateProjectIDClusterName(ctx, req, resp, "project_id", "name") } -func mockedSDK(ctx context.Context, diags *diag.Diagnostics, timeout timeouts.Value) (*TFModel, bool) { - sdkResp, err := ReadClusterResponse() +func (r *rs) createCluster(ctx context.Context, plan *TFModel, diags *diag.Diagnostics) *TFModel { + latestReq := normalizeFromTFModel(ctx, plan, diags, true) + if diags.HasError() { + return nil + } + var ( + projectID = plan.ProjectID.ValueString() + clusterName = plan.Name.ValueString() + api20240530 = r.Client.AtlasV220240530.ClustersApi + api = r.Client.AtlasV2.ClustersApi + err error + pauseAfter = latestReq.GetPaused() + ) + if pauseAfter { + latestReq.Paused = nil + } + _, _, err = api.CreateCluster(ctx, projectID, latestReq).Execute() if err != nil { diags.AddError("errorCreate", fmt.Sprintf(errorCreate, err.Error())) - return nil, true + return nil + } + cluster := AwaitChanges(ctx, api, &plan.Timeouts, diags, projectID, clusterName, changeReasonCreate) + if diags.HasError() { + return nil } - tfNewModel := NewTFModel(ctx, sdkResp, timeout, diags) - sdkAdvConfig, err := ReadClusterProcessArgsResponse() + if pauseAfter { + cluster = r.updateAndWait(ctx, &pauseRequest, diags, plan) + } + var legacyAdvConfig *admin20240530.ClusterDescriptionProcessArgs + legacyAdvConfigUpdate := NewAtlasReqAdvancedConfigurationLegacy(ctx, &plan.AdvancedConfiguration, diags) + if !update.IsZeroValues(legacyAdvConfigUpdate) { + legacyAdvConfig, _, err = api20240530.UpdateClusterAdvancedConfiguration(ctx, projectID, clusterName, legacyAdvConfigUpdate).Execute() + if err != nil { + // Maybe should be warning instead of error to avoid having to re-create the cluster + diags.AddError("errorUpdateeAdvConfigLegacy", fmt.Sprintf(errorCreate, err.Error())) + return nil + } + } + + advConfigUpdate := NewAtlasReqAdvancedConfiguration(ctx, &plan.AdvancedConfiguration, diags) + var advConfig *admin.ClusterDescriptionProcessArgs20240805 + if !update.IsZeroValues(advConfigUpdate) { + advConfig, _, err = api.UpdateClusterAdvancedConfiguration(ctx, projectID, clusterName, advConfigUpdate).Execute() + if err != nil { + // Maybe should be warning instead of error to avoid having to re-create the cluster + diags.AddError("errorUpdateAdvConfig", fmt.Sprintf(errorCreate, err.Error())) + return nil + } + } + return r.convertClusterAddAdvConfig(ctx, legacyAdvConfig, advConfig, cluster, plan, nil, diags) +} + +func (r *rs) readCluster(ctx context.Context, model *TFModel, state *tfsdk.State, diags *diag.Diagnostics, allowNotFound bool) *TFModel { + clusterName := model.Name.ValueString() + projectID := model.ProjectID.ValueString() + api := r.Client.AtlasV2.ClustersApi + readResp, _, err := api.GetCluster(ctx, projectID, clusterName).Execute() if err != nil { - diags.AddError("errorCreateAdvConfig", fmt.Sprintf(errorCreate, err.Error())) - return nil, true + if admin.IsErrorCode(err, ErrorCodeClusterNotFound) && allowNotFound { + state.RemoveResource(ctx) + return nil + } + diags.AddError("errorRead", fmt.Sprintf(errorRead, clusterName, err.Error())) + return nil } - sdkAdvConfigLegacy, err := ReadClusterProcessArgsResponseLegacy() + return r.convertClusterAddAdvConfig(ctx, nil, nil, readResp, model, nil, diags) +} +func (r *rs) applyAdvancedConfigurationChanges(ctx context.Context, diags *diag.Diagnostics, state, plan *TFModel) (legacy *admin20240530.ClusterDescriptionProcessArgs, latest *admin.ClusterDescriptionProcessArgs20240805, changed bool) { + var ( + api = r.Client.AtlasV2.ClustersApi + projectID = plan.ProjectID.ValueString() + clusterName = plan.Name.ValueString() + err error + advConfig *admin.ClusterDescriptionProcessArgs20240805 + legacyAdvConfig *admin20240530.ClusterDescriptionProcessArgs + ) + patchReqProcessArgs := update.PatchPayloadTpf(ctx, diags, &state.AdvancedConfiguration, &plan.AdvancedConfiguration, NewAtlasReqAdvancedConfiguration) + if !update.IsZeroValues(patchReqProcessArgs) { + changed = true + advConfig, _, err = api.UpdateClusterAdvancedConfiguration(ctx, projectID, clusterName, patchReqProcessArgs).Execute() + if err != nil { + diags.AddError("errorUpdateAdvancedConfig", fmt.Sprintf(errorConfigUpdate, clusterName, err.Error())) + return legacyAdvConfig, advConfig, changed + } + } + patchReqProcessArgsLegacy := update.PatchPayloadTpf(ctx, diags, &state.AdvancedConfiguration, &plan.AdvancedConfiguration, NewAtlasReqAdvancedConfigurationLegacy) + if !update.IsZeroValues(patchReqProcessArgsLegacy) { + changed = true + legacyAdvConfig, _, err = r.Client.AtlasV220240530.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, clusterName, patchReqProcessArgsLegacy).Execute() + if err != nil { + diags.AddError("errorUpdateAdvancedConfigLegacy", fmt.Sprintf(errorConfigUpdate, clusterName, err.Error())) + } + } + return legacyAdvConfig, advConfig, changed +} + +func (r *rs) applyClusterChanges(ctx context.Context, diags *diag.Diagnostics, state, plan *TFModel, patchReq *admin.ClusterDescription20240805) *admin.ClusterDescription20240805 { + var cluster *admin.ClusterDescription20240805 + if usingLegacySchema(ctx, plan.ReplicationSpecs, diags) { + // Only updates of replication specs will be done with legacy API + legacySpecsChanged := r.updateLegacyReplicationSpecs(ctx, state, plan, diags, patchReq.ReplicationSpecs) + if diags.HasError() { + return nil + } + patchReq.ReplicationSpecs = nil // Already updated by legacy API + if legacySpecsChanged && update.IsZeroValues(patchReq) { + return AwaitChanges(ctx, r.Client.AtlasV2.ClustersApi, &plan.Timeouts, diags, plan.ProjectID.ValueString(), plan.Name.ValueString(), changeReasonUpdate) + } + } + if update.IsZeroValues(patchReq) { + return cluster + } + pauseAfter := false + if patchReq.Paused != nil && patchReq.GetPaused() { + // More changes than pause, need to pause after + if !reflect.DeepEqual(pauseRequest, *patchReq) { + pauseAfter = true + patchReq.Paused = nil + } + } else if patchReq.Paused != nil && !patchReq.GetPaused() { + // More changes than pause, need to resume before applying changes + if !reflect.DeepEqual(resumeRequest, *patchReq) { + patchReq.Paused = nil + _ = r.updateAndWait(ctx, &resumeRequest, diags, plan) + } + } + if diags.HasError() { + return nil + } + replicationSpecsUpdated := patchReq.ReplicationSpecs != nil + if replicationSpecsUpdated { + // Cannot call latest API (2024-10-23 or newer) as it can enable ISS autoscaling + legacyPatch := newLegacyModel(patchReq) + cluster = r.updateAndWaitLegacy(ctx, legacyPatch, diags, plan) + } else { + cluster = r.updateAndWait(ctx, patchReq, diags, plan) + } + if pauseAfter && cluster != nil { + cluster = r.updateAndWait(ctx, &pauseRequest, diags, plan) + } + return cluster +} + +func (r *rs) updateLegacyReplicationSpecs(ctx context.Context, state, plan *TFModel, diags *diag.Diagnostics, specChanges *[]admin.ReplicationSpec20240805) bool { + numShardsUpdates := findNumShardsUpdates(ctx, state, plan, diags) + if diags.HasError() { + return false + } + if specChanges == nil && numShardsUpdates == nil { // No changes to replication specs + return false + } + if specChanges == nil { + // Use state replication specs as there are no changes in plan except for numShards updates + specChanges = newReplicationSpec20240805(ctx, state.ReplicationSpecs, diags) + if diags.HasError() { + return false + } + } + numShardsPlan := numShardsMap(ctx, plan.ReplicationSpecs, diags) + legacyIDs := externalIDToLegacyID(ctx, state.ReplicationSpecs, diags) + if diags.HasError() { + return false + } + legacyPatch := newLegacyModel20240530ReplicationSpecsAndDiskGBOnly(specChanges, numShardsPlan, state.DiskSizeGB.ValueFloat64Pointer(), legacyIDs) + if diags.HasError() { + return false + } + api20240530 := r.Client.AtlasV220240530.ClustersApi + api20240530.UpdateCluster(ctx, plan.ProjectID.ValueString(), plan.Name.ValueString(), legacyPatch) + _, _, err := api20240530.UpdateCluster(ctx, plan.ProjectID.ValueString(), plan.Name.ValueString(), legacyPatch).Execute() if err != nil { - diags.AddError("errorCreateAdvConfigLegacy", fmt.Sprintf(errorCreate, err.Error())) - return nil, true + diags.AddError("errorUpdateLegacy", fmt.Sprintf(errorUpdate, plan.Name.ValueString(), err.Error())) + return false } - AddAdvancedConfig(ctx, tfNewModel, sdkAdvConfig, sdkAdvConfigLegacy, diags) + return true +} + +func (r *rs) updateAndWait(ctx context.Context, patchReq *admin.ClusterDescription20240805, diags *diag.Diagnostics, tfModel *TFModel) *admin.ClusterDescription20240805 { + api := r.Client.AtlasV2.ClustersApi + projectID := tfModel.ProjectID.ValueString() + clusterName := tfModel.Name.ValueString() + _, _, err := api.UpdateCluster(ctx, projectID, clusterName, patchReq).Execute() + if err != nil { + diags.AddError("errorUpdate", fmt.Sprintf(errorUpdate, clusterName, err.Error())) + return nil + } + return AwaitChanges(ctx, r.Client.AtlasV2.ClustersApi, &tfModel.Timeouts, diags, projectID, clusterName, changeReasonUpdate) +} +func (r *rs) updateAndWaitLegacy(ctx context.Context, patchReq *admin20240805.ClusterDescription20240805, diags *diag.Diagnostics, plan *TFModel) *admin.ClusterDescription20240805 { + api20240805 := r.Client.AtlasV220240805.ClustersApi + projectID := plan.ProjectID.ValueString() + clusterName := plan.Name.ValueString() + _, _, err := api20240805.UpdateCluster(ctx, projectID, clusterName, patchReq).Execute() + if err != nil { + diags.AddError("errorUpdateLegacy", fmt.Sprintf(errorUpdate, clusterName, err.Error())) + return nil + } + return AwaitChanges(ctx, r.Client.AtlasV2.ClustersApi, &plan.Timeouts, diags, projectID, clusterName, changeReasonUpdate) +} + +func (r *rs) applyTenantUpgrade(ctx context.Context, plan *TFModel, upgradeRequest *admin.LegacyAtlasTenantClusterUpgradeRequest, diags *diag.Diagnostics) *admin.ClusterDescription20240805 { + api := r.Client.AtlasV2.ClustersApi + projectID := plan.ProjectID.ValueString() + clusterName := plan.Name.ValueString() + upgradeRequest.Name = clusterName + _, _, err := api.UpgradeSharedCluster(ctx, projectID, upgradeRequest).Execute() + if err != nil { + diags.AddError("errorTenantUpgrade", fmt.Sprintf(errorUpdate, clusterName, err.Error())) + return nil + } + return AwaitChanges(ctx, api, &plan.Timeouts, diags, projectID, clusterName, changeReasonUpdate) +} + +func (r *rs) convertClusterAddAdvConfig(ctx context.Context, legacyAdvConfig *admin20240530.ClusterDescriptionProcessArgs, advConfig *admin.ClusterDescriptionProcessArgs20240805, cluster *admin.ClusterDescription20240805, modelIn *TFModel, oldAdvConfig *types.Object, diags *diag.Diagnostics) *TFModel { + apiInfo := resolveAPIInfo(ctx, modelIn, diags, cluster, r.Client) + if diags.HasError() { + return nil + } + modelOut := NewTFModel(ctx, cluster, modelIn.Timeouts, diags, *apiInfo) + if diags.HasError() { + return nil + } + if oldAdvConfig != nil { + modelOut.AdvancedConfiguration = *oldAdvConfig + } else { + legacyAdvConfig, advConfig = readUnsetAdvancedConfiguration(ctx, r.Client, modelOut, legacyAdvConfig, advConfig, diags) + AddAdvancedConfig(ctx, modelOut, advConfig, legacyAdvConfig, diags) + if diags.HasError() { + return nil + } + } + overrideAttributesWithPrevStateValue(modelIn, modelOut) + return modelOut +} + +func (r *rs) updateAdvConfig(ctx context.Context, legacyAdvConfig *admin20240530.ClusterDescriptionProcessArgs, advConfig *admin.ClusterDescriptionProcessArgs20240805, state *TFModel, diags *diag.Diagnostics) { + legacyAdvConfig, advConfig = readUnsetAdvancedConfiguration(ctx, r.Client, state, legacyAdvConfig, advConfig, diags) if diags.HasError() { - return nil, true + return + } + AddAdvancedConfig(ctx, state, advConfig, legacyAdvConfig, diags) +} + +func readUnsetAdvancedConfiguration(ctx context.Context, client *config.MongoDBClient, model *TFModel, legacyAdvConfig *admin20240530.ClusterDescriptionProcessArgs, advConfig *admin.ClusterDescriptionProcessArgs20240805, diags *diag.Diagnostics) (*admin20240530.ClusterDescriptionProcessArgs, *admin.ClusterDescriptionProcessArgs20240805) { + api := client.AtlasV2.ClustersApi + api20240530 := client.AtlasV220240530.ClustersApi + projectID := model.ProjectID.ValueString() + clusterName := model.Name.ValueString() + var err error + if legacyAdvConfig == nil { + legacyAdvConfig, _, err = api20240530.GetClusterAdvancedConfiguration(ctx, projectID, clusterName).Execute() + if err != nil { + diags.AddError("errorReadAdvConfigLegacy", fmt.Sprintf(errorRead, clusterName, err.Error())) + return nil, nil + } + } + if advConfig == nil { + advConfig, _, err = api.GetClusterAdvancedConfiguration(ctx, projectID, clusterName).Execute() + if err != nil { + diags.AddError("errorReadAdvConfig", fmt.Sprintf(errorRead, clusterName, err.Error())) + return nil, nil + } } - return tfNewModel, false + return legacyAdvConfig, advConfig } diff --git a/internal/service/advancedclustertpf/resource_compatibility_reuse.go b/internal/service/advancedclustertpf/resource_compatibility_reuse.go new file mode 100644 index 0000000000..b827444670 --- /dev/null +++ b/internal/service/advancedclustertpf/resource_compatibility_reuse.go @@ -0,0 +1,179 @@ +package advancedclustertpf + +import ( + "context" + "fmt" + "strconv" + "strings" + + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" + "github.com/spf13/cast" + admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" +) + +type MajorVersionOperator int + +const ( + EqualOrHigher MajorVersionOperator = iota + Higher + EqualOrLower + Lower +) + +func MajorVersionCompatible(input *string, version float64, operator MajorVersionOperator) *bool { + if !conversion.IsStringPresent(input) { + return nil + } + value, err := strconv.ParseFloat(*input, 64) + if err != nil { + return nil + } + var result bool + switch operator { + case EqualOrHigher: + result = value >= version + case Higher: + result = value > version + case EqualOrLower: + result = value <= version + case Lower: + result = value < version + default: + return nil + } + return &result +} + +func FormatMongoDBMajorVersion(version string) string { + if strings.Contains(version, ".") { + return version + } + return fmt.Sprintf("%.1f", cast.ToFloat32(version)) +} + +// based on flattenAdvancedReplicationSpecRegionConfigs in model_advanced_cluster.go +func resolveContainerIDs(ctx context.Context, projectID string, cluster *admin.ClusterDescription20240805, api admin.NetworkPeeringApi) (map[string]string, error) { + containerIDs := map[string]string{} + responseCache := map[string]*admin.PaginatedCloudProviderContainer{} + for _, spec := range cluster.GetReplicationSpecs() { + for _, regionConfig := range spec.GetRegionConfigs() { + providerName := regionConfig.GetProviderName() + if providerName == constant.TENANT { + continue + } + params := &admin.ListPeeringContainerByCloudProviderApiParams{ + GroupId: projectID, + ProviderName: &providerName, + } + containerIDKey := fmt.Sprintf("%s:%s", providerName, regionConfig.GetRegionName()) + if _, ok := containerIDs[containerIDKey]; ok { + continue + } + var containersResponse *admin.PaginatedCloudProviderContainer + var err error + if response, ok := responseCache[providerName]; ok { + containersResponse = response + } else { + containersResponse, _, err = api.ListPeeringContainerByCloudProviderWithParams(ctx, params).Execute() + if err != nil { + return nil, err + } + responseCache[providerName] = containersResponse + } + if results := getAdvancedClusterContainerID(containersResponse.GetResults(), ®ionConfig); results != "" { + containerIDs[containerIDKey] = results + } else { + return nil, fmt.Errorf("container id not found for %s", containerIDKey) + } + } + } + return containerIDs, nil +} + +// copied from model_advanced_cluster.go +func getAdvancedClusterContainerID(containers []admin.CloudProviderContainer, cluster *admin.CloudRegionConfig20240805) string { + for i, container := range containers { + gpc := cluster.GetProviderName() == constant.GCP + azure := container.GetProviderName() == cluster.GetProviderName() && container.GetRegion() == cluster.GetRegionName() + aws := container.GetRegionName() == cluster.GetRegionName() + if gpc || azure || aws { + return containers[i].GetId() + } + } + return "" +} + +func getReplicationSpecIDsFromOldAPI(ctx context.Context, projectID, clusterName string, api admin20240530.ClustersApi) (map[string]string, error) { + clusterOldAPI, _, err := api.GetCluster(ctx, projectID, clusterName).Execute() + if err != nil { + if apiError, ok := admin20240530.AsError(err); ok { + if apiError.GetErrorCode() == "ASYMMETRIC_SHARD_UNSUPPORTED" { + return nil, nil // if its the case of an asymmetric shard an error is expected in old API, replication_specs.*.id attribute will not be populated + } + } + return nil, fmt.Errorf("error reading advanced cluster with 2023-02-01 API (%s): %s", clusterName, err) + } + specs := clusterOldAPI.GetReplicationSpecs() + result := make(map[string]string, len(specs)) + for _, spec := range specs { + result[spec.GetZoneName()] = spec.GetId() + } + return result, nil +} + +func convertHardwareSpecToOldSDK(hwspec *admin.HardwareSpec20240805) *admin20240530.HardwareSpec { + if hwspec == nil { + return nil + } + return &admin20240530.HardwareSpec{ + DiskIOPS: hwspec.DiskIOPS, + EbsVolumeType: hwspec.EbsVolumeType, + InstanceSize: hwspec.InstanceSize, + NodeCount: hwspec.NodeCount, + } +} + +func convertAdvancedAutoScalingSettingsToOldSDK(settings *admin.AdvancedAutoScalingSettings) *admin20240530.AdvancedAutoScalingSettings { + if settings == nil { + return nil + } + return &admin20240530.AdvancedAutoScalingSettings{ + Compute: convertAdvancedComputeAutoScalingToOldSDK(settings.Compute), + DiskGB: convertDiskGBAutoScalingToOldSDK(settings.DiskGB), + } +} + +func convertAdvancedComputeAutoScalingToOldSDK(settings *admin.AdvancedComputeAutoScaling) *admin20240530.AdvancedComputeAutoScaling { + if settings == nil { + return nil + } + return &admin20240530.AdvancedComputeAutoScaling{ + Enabled: settings.Enabled, + MaxInstanceSize: settings.MaxInstanceSize, + MinInstanceSize: settings.MinInstanceSize, + ScaleDownEnabled: settings.ScaleDownEnabled, + } +} + +func convertDiskGBAutoScalingToOldSDK(settings *admin.DiskGBAutoScaling) *admin20240530.DiskGBAutoScaling { + if settings == nil { + return nil + } + return &admin20240530.DiskGBAutoScaling{ + Enabled: settings.Enabled, + } +} + +func convertDedicatedHardwareSpecToOldSDK(spec *admin.DedicatedHardwareSpec20240805) *admin20240530.DedicatedHardwareSpec { + if spec == nil { + return nil + } + return &admin20240530.DedicatedHardwareSpec{ + NodeCount: spec.NodeCount, + DiskIOPS: spec.DiskIOPS, + EbsVolumeType: spec.EbsVolumeType, + InstanceSize: spec.InstanceSize, + } +} diff --git a/internal/service/advancedclustertpf/resource_compatiblity.go b/internal/service/advancedclustertpf/resource_compatiblity.go new file mode 100644 index 0000000000..e3ac60561b --- /dev/null +++ b/internal/service/advancedclustertpf/resource_compatiblity.go @@ -0,0 +1,246 @@ +package advancedclustertpf + +import ( + "context" + "reflect" + + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" + "go.mongodb.org/atlas-sdk/v20241113003/admin" +) + +func overrideAttributesWithPrevStateValue(modelIn, modelOut *TFModel) { + beforeVersion := conversion.NilForUnknown(modelIn.MongoDBMajorVersion, modelIn.MongoDBMajorVersion.ValueStringPointer()) + if beforeVersion != nil && !modelIn.MongoDBMajorVersion.Equal(modelOut.MongoDBMajorVersion) { + modelOut.MongoDBMajorVersion = types.StringPointerValue(beforeVersion) + } + retainBackups := conversion.NilForUnknown(modelIn.RetainBackupsEnabled, modelIn.RetainBackupsEnabled.ValueBoolPointer()) + if retainBackups != nil && !modelIn.RetainBackupsEnabled.Equal(modelOut.RetainBackupsEnabled) { + modelOut.RetainBackupsEnabled = types.BoolPointerValue(retainBackups) + } +} + +func findNumShardsUpdates(ctx context.Context, state, plan *TFModel, diags *diag.Diagnostics) map[string]int64 { + if !usingLegacySchema(ctx, plan.ReplicationSpecs, diags) { + return nil + } + stateCounts := numShardsMap(ctx, state.ReplicationSpecs, diags) + planCounts := numShardsMap(ctx, plan.ReplicationSpecs, diags) + if diags.HasError() { + return nil + } + if reflect.DeepEqual(stateCounts, planCounts) { + return nil + } + return planCounts +} + +func resolveAPIInfo(ctx context.Context, plan *TFModel, diags *diag.Diagnostics, clusterLatest *admin.ClusterDescription20240805, client *config.MongoDBClient) *ExtraAPIInfo { + rootDiskSize := conversion.NilForUnknown(plan.DiskSizeGB, plan.DiskSizeGB.ValueFloat64Pointer()) + projectID := plan.ProjectID.ValueString() + zoneNameSpecIDs, err := getReplicationSpecIDsFromOldAPI(ctx, projectID, plan.Name.ValueString(), client.AtlasV220240530.ClustersApi) + if err != nil { + diags.AddError("getReplicationSpecIDsFromOldAPI", err.Error()) + return nil + } + if rootDiskSize == nil { + rootDiskSize = findRegionRootDiskSize(clusterLatest.ReplicationSpecs) + } + containerIDs, err := resolveContainerIDs(ctx, projectID, clusterLatest, client.AtlasV2.NetworkPeeringApi) + if err != nil { + diags.AddError("resolveContainerIDs failed", err.Error()) + return nil + } + return &ExtraAPIInfo{ + ContainerIDs: containerIDs, + UsingLegacySchema: usingLegacySchema(ctx, plan.ReplicationSpecs, diags), + ZoneNameNumShards: numShardsMap(ctx, plan.ReplicationSpecs, diags), + RootDiskSize: rootDiskSize, + ZoneNameReplicationSpecIDs: zoneNameSpecIDs, + } +} + +// instead of using `num_shards` explode the replication specs, and set disk_size_gb +func normalizeFromTFModel(ctx context.Context, model *TFModel, diags *diag.Diagnostics, shoudlExplodeNumShards bool) *admin.ClusterDescription20240805 { + latestModel := NewAtlasReq(ctx, model, diags) + if diags.HasError() { + return nil + } + counts := numShardsCounts(ctx, model.ReplicationSpecs, diags) + if diags.HasError() { + return nil + } + usingLegacySchema := isNumShardsGreaterThanOne(counts) + if usingLegacySchema && shoudlExplodeNumShards { + explodeNumShards(latestModel, counts) + } + diskSize := normalizeDiskSize(model, latestModel, diags) + if diags.HasError() { + return nil + } + if diskSize != nil { + setDiskSize(latestModel, diskSize) + } + return latestModel +} + +func normalizeDiskSize(model *TFModel, latestModel *admin.ClusterDescription20240805, diags *diag.Diagnostics) *float64 { + rootDiskSize := conversion.NilForUnknown(model.DiskSizeGB, model.DiskSizeGB.ValueFloat64Pointer()) + regionRootDiskSize := findRegionRootDiskSize(latestModel.ReplicationSpecs) + if rootDiskSize != nil && regionRootDiskSize != nil && (*regionRootDiskSize-*rootDiskSize) > 0.01 { + errMsg := "disk_size_gb @ root != disk_size_gb @ region (%.2f!=%.2f)" + diags.AddError(errMsg, errMsg) + return nil + } + // Prefer regionRootDiskSize over rootDiskSize + if regionRootDiskSize != nil { + return regionRootDiskSize + } + return rootDiskSize +} + +// Set "Computed" Specs to nil to avoid unnecessary diffs +func normalizePatchState(cluster *admin.ClusterDescription20240805) { + for i, specCopy := range cluster.GetReplicationSpecs() { + for j := range specCopy.GetRegionConfigs() { + spec := cluster.GetReplicationSpecs()[i] + regionConfigs := *spec.RegionConfigs + actualConfig := ®ionConfigs[j] + analyticsSpecs := actualConfig.AnalyticsSpecs + if analyticsSpecs != nil && analyticsSpecs.NodeCount != nil && *analyticsSpecs.NodeCount == 0 { + actualConfig.AnalyticsSpecs = nil + } + readonly := actualConfig.ReadOnlySpecs + if readonly != nil && readonly.NodeCount != nil && *readonly.NodeCount == 0 { + actualConfig.ReadOnlySpecs = nil + } + } + } +} + +func explodeNumShards(req *admin.ClusterDescription20240805, counts []int64) { + specs := req.GetReplicationSpecs() + newSpecs := []admin.ReplicationSpec20240805{} + for i, spec := range specs { + newSpecs = append(newSpecs, spec) + for range counts[i] - 1 { + newSpecs = append(newSpecs, *repSpecNoIDs(spec)) + } + } + req.ReplicationSpecs = &newSpecs +} + +func repSpecNoIDs(repspec admin.ReplicationSpec20240805) *admin.ReplicationSpec20240805 { + repspec.Id = nil + repspec.ZoneId = nil + return &repspec +} + +func numShardsCounts(ctx context.Context, input types.List, diags *diag.Diagnostics) []int64 { + elements := make([]TFReplicationSpecsModel, len(input.Elements())) + if localDiags := input.ElementsAs(ctx, &elements, false); len(localDiags) > 0 { + diags.Append(localDiags...) + return nil + } + counts := make([]int64, len(elements)) + for i := range elements { + item := &elements[i] + counts[i] = item.NumShards.ValueInt64() + } + return counts +} + +func usingLegacySchema(ctx context.Context, input types.List, diags *diag.Diagnostics) bool { + counts := numShardsCounts(ctx, input, diags) + if diags.HasError() { + return false + } + return isNumShardsGreaterThanOne(counts) +} + +func numShardsMap(ctx context.Context, input types.List, diags *diag.Diagnostics) map[string]int64 { + elements := make([]TFReplicationSpecsModel, len(input.Elements())) + if localDiags := input.ElementsAs(ctx, &elements, false); len(localDiags) > 0 { + diags.Append(localDiags...) + return nil + } + counts := map[string]int64{} + for i := range elements { + e := elements[i] + zoneName := resolveZoneNameOrUseDefault(&e) + counts[zoneName] = e.NumShards.ValueInt64() + } + return counts +} + +func isNumShardsGreaterThanOne(counts []int64) bool { + for _, count := range counts { + if count > 1 { + return true + } + } + return false +} + +func setDiskSize(req *admin.ClusterDescription20240805, size *float64) { + for i, spec := range req.GetReplicationSpecs() { + for j := range spec.GetRegionConfigs() { + actualConfig := req.GetReplicationSpecs()[i].GetRegionConfigs()[j] + analyticsSpecs := actualConfig.AnalyticsSpecs + if analyticsSpecs != nil { + analyticsSpecs.DiskSizeGB = size + } + electable := actualConfig.ElectableSpecs + if electable != nil { + electable.DiskSizeGB = size + } + readonly := actualConfig.ReadOnlySpecs + if readonly != nil { + readonly.DiskSizeGB = size + } + } + } +} + +func findRegionRootDiskSize(specs *[]admin.ReplicationSpec20240805) *float64 { + if specs == nil { + return nil + } + for _, spec := range *specs { + for _, regionConfig := range spec.GetRegionConfigs() { + analyticsSpecs := regionConfig.AnalyticsSpecs + if analyticsSpecs != nil && analyticsSpecs.DiskSizeGB != nil { + return analyticsSpecs.DiskSizeGB + } + electable := regionConfig.ElectableSpecs + if electable != nil && electable.DiskSizeGB != nil { + return electable.DiskSizeGB + } + readonly := regionConfig.ReadOnlySpecs + if readonly != nil && readonly.DiskSizeGB != nil { + return readonly.DiskSizeGB + } + } + } + return nil +} + +func externalIDToLegacyID(ctx context.Context, input types.List, diags *diag.Diagnostics) map[string]string { + elements := make([]TFReplicationSpecsModel, len(input.Elements())) + if localDiags := input.ElementsAs(ctx, &elements, false); len(localDiags) > 0 { + diags.Append(localDiags...) + return nil + } + idsMapped := map[string]string{} + for i := range elements { + e := elements[i] + externalID := e.ExternalId.ValueString() + legacyID := e.Id.ValueString() + if externalID != "" && legacyID != "" { + idsMapped[externalID] = legacyID + } + } + return idsMapped +} diff --git a/internal/service/advancedclustertpf/resource_schema.go b/internal/service/advancedclustertpf/resource_schema.go index 4bee9a8782..247a1d1b5b 100644 --- a/internal/service/advancedclustertpf/resource_schema.go +++ b/internal/service/advancedclustertpf/resource_schema.go @@ -2,23 +2,25 @@ package advancedclustertpf import ( "context" + "regexp" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" + "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/setdefault" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/schemafunc" ) func ResourceSchema(ctx context.Context) schema.Schema { return schema.Schema{ - Version: 1, // TODO: as in current resource + Version: 1, Attributes: map[string]schema.Attribute{ "accept_data_risks_and_force_replica_set_reconfig": schema.StringAttribute{ Optional: true, @@ -31,7 +33,6 @@ func ResourceSchema(ctx context.Context) schema.Schema { MarkdownDescription: "Flag that indicates whether the cluster can perform backups. If set to `true`, the cluster can perform backups. You must set this value to `true` for NVMe clusters. Backup uses [Cloud Backups](https://docs.atlas.mongodb.com/backup/cloud-backup/overview/) for dedicated clusters and [Shared Cluster Backups](https://docs.atlas.mongodb.com/backup/shared-tier/overview/) for tenant clusters. If set to `false`, the cluster doesn't use backups.", }, "bi_connector_config": schema.SingleNestedAttribute{ - // TODO: MaxItems: 1 Computed: true, Optional: true, MarkdownDescription: "Settings needed to configure the MongoDB Connector for Business Intelligence for this cluster.", @@ -128,10 +129,7 @@ func ResourceSchema(ctx context.Context) schema.Schema { }, }, "create_date": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, + Computed: true, MarkdownDescription: "Date and time when MongoDB Cloud created this cluster. This parameter expresses its value in ISO 8601 format in UTC.", }, "encryption_at_rest_provider": schema.StringAttribute{ @@ -144,19 +142,19 @@ func ResourceSchema(ctx context.Context) schema.Schema { Optional: true, MarkdownDescription: "Set this field to configure the Sharding Management Mode when creating a new Global Cluster.\n\nWhen set to false, the management mode is set to Atlas-Managed Sharding. This mode fully manages the sharding of your Global Cluster and is built to provide a seamless deployment experience.\n\nWhen set to true, the management mode is set to Self-Managed Sharding. This mode leaves the management of shards in your hands and is built to provide an advanced and flexible deployment experience.\n\nThis setting cannot be changed once the cluster is deployed.", }, - "project_id": schema.StringAttribute{ // TODO: fail if trying to update + "project_id": schema.StringAttribute{ Required: true, MarkdownDescription: "Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.\n\n**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups.", - }, - "cluster_id": schema.StringAttribute{ // TODO: was generated as id - Computed: true, PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), }, + }, + "cluster_id": schema.StringAttribute{ + Computed: true, MarkdownDescription: "Unique 24-hexadecimal digit string that identifies the cluster.", }, "labels": schema.SetNestedAttribute{ - Computed: true, // TODO: must be computed since backend returns "[]" when it is not specified using "Default" to avoid plan changes + Computed: true, Optional: true, Default: setdefault.StaticValue(types.SetValueMust(LabelsObjType, nil)), MarkdownDescription: "Collection of key-value pairs between 1 to 255 characters in length that tag and categorize the cluster. The MongoDB Cloud console doesn't display your labels.\n\nCluster labels are deprecated and will be removed in a future release. We strongly recommend that you use [resource tags](https://dochub.mongodb.org/core/add-cluster-tag-atlas) instead.", @@ -173,22 +171,24 @@ func ResourceSchema(ctx context.Context) schema.Schema { }, }, }, - "mongo_db_major_version": schema.StringAttribute{ // TODO: was generated as mongo_dbmajor_version + "mongo_db_major_version": schema.StringAttribute{ Computed: true, Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), + Validators: []validator.String{ + stringvalidator.RegexMatches(regexp.MustCompile(`^([0-9]+)\.?([0-9]+)?$`), "MongoDB major version must be in the format \"8\" or \"8.0\""), }, - // TODO: StateFunc: FormatMongoDBMajorVersion, MarkdownDescription: "MongoDB major version of the cluster.\n\nOn creation: Choose from the available versions of MongoDB, or leave unspecified for the current recommended default in the MongoDB Cloud platform. The recommended version is a recent Long Term Support version. The default is not guaranteed to be the most recently released version throughout the entire release cycle. For versions available in a specific project, see the linked documentation or use the API endpoint for [project LTS versions endpoint](#tag/Projects/operation/getProjectLTSVersions).\n\n On update: Increase version only by 1 major version at a time. If the cluster is pinned to a MongoDB feature compatibility version exactly one major version below the current MongoDB version, the MongoDB version can be downgraded to the previous major version.", }, - "mongo_db_version": schema.StringAttribute{ // TODO: was generated as mongo_dbversion + "mongo_db_version": schema.StringAttribute{ Computed: true, MarkdownDescription: "Version of MongoDB that the cluster runs.", }, - "name": schema.StringAttribute{ // TODO: fail if trying to update + "name": schema.StringAttribute{ Required: true, MarkdownDescription: "Human-readable label that identifies this cluster.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, }, "paused": schema.BoolAttribute{ Computed: true, @@ -211,7 +211,7 @@ func ResourceSchema(ctx context.Context) schema.Schema { MarkdownDescription: "Set this field to configure the replica set scaling mode for your cluster.\n\nBy default, Atlas scales under WORKLOAD_TYPE. This mode allows Atlas to scale your analytics nodes in parallel to your operational nodes.\n\nWhen configured as SEQUENTIAL, Atlas scales all nodes sequentially. This mode is intended for steady-state workloads and applications performing latency-sensitive secondary reads.\n\nWhen configured as NODE_TYPE, Atlas scales your electable nodes in parallel with your read-only and analytics nodes. This mode is intended for large, dynamic workloads requiring frequent and timely cluster tier scaling. This is the fastest scaling strategy, but it might impact latency of workloads when performing extensive secondary reads.", }, "replication_specs": schema.ListNestedAttribute{ - Required: true, // TODO: wrong computability + Required: true, MarkdownDescription: "List of settings that configure your cluster regions. This array has one object per shard representing node configurations in each shard. For replica sets there is only one object representing node configurations.", NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -220,25 +220,24 @@ func ResourceSchema(ctx context.Context) schema.Schema { Computed: true, MarkdownDescription: "Unique 24-hexadecimal digit string that identifies the replication object for a shard in a Cluster. If you include existing shard replication configurations in the request, you must specify this parameter. If you add a new shard to an existing Cluster, you may specify this parameter. The request deletes any existing shards in the Cluster that you exclude from the request. This corresponds to Shard ID displayed in the UI.", }, - "container_id": schema.MapAttribute{ // TODO: added as in current resource + "container_id": schema.MapAttribute{ ElementType: types.StringType, Computed: true, MarkdownDescription: "container_id", // TODO: add description }, - "external_id": schema.StringAttribute{ // TODO: added as in current resource + "external_id": schema.StringAttribute{ Computed: true, MarkdownDescription: "external_id", // TODO: add description }, - "num_shards": schema.Int64Attribute{ // TODO: added as in current resource - DeprecationMessage: DeprecationMsgOldSchema, - // TODO: not sure if add valitadation here: ValidateFunc: validation.IntBetween(1, 50), + "num_shards": schema.Int64Attribute{ + DeprecationMessage: DeprecationMsgOldSchema, Default: int64default.StaticInt64(1), - Computed: true, // must be computed to allow default 1 + Computed: true, Optional: true, MarkdownDescription: "num_shards", // TODO: add description }, "region_configs": schema.ListNestedAttribute{ - Required: true, // TODO: wrong computability + Required: true, MarkdownDescription: "Hardware specifications for nodes set for a given region. Each **regionConfigs** object describes the region's priority in elections and the number and type of MongoDB nodes that MongoDB Cloud deploys to the region. Each **regionConfigs** object must have either an **analyticsSpecs** object, **electableSpecs** object, or **readOnlySpecs** object. Tenant clusters only require **electableSpecs. Dedicated** clusters can specify any of these specifications, but must have at least one **electableSpecs** object within a **replicationSpec**.\n\n**Example:**\n\nIf you set `\"replicationSpecs[n].regionConfigs[m].analyticsSpecs.instanceSize\" : \"M30\"`, set `\"replicationSpecs[n].regionConfigs[m].electableSpecs.instanceSize\" : `\"M30\"` if you have electable nodes and `\"replicationSpecs[n].regionConfigs[m].readOnlySpecs.instanceSize\" : `\"M30\"` if you have read-only nodes.", NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -255,13 +254,11 @@ func ResourceSchema(ctx context.Context) schema.Schema { MarkdownDescription: "Precedence is given to this region when a primary election occurs. If your **regionConfigs** has only **readOnlySpecs**, **analyticsSpecs**, or both, set this value to `0`. If you have multiple **regionConfigs** objects (your cluster is multi-region or multi-cloud), they must have priorities in descending order. The highest priority is `7`.\n\n**Example:** If you have three regions, their priorities would be `7`, `6`, and `5` respectively. If you added two more regions for supporting electable nodes, the priorities of those regions would be `4` and `3` respectively.", }, "provider_name": schema.StringAttribute{ - // TODO: probably leave validation just in the server, ValidateDiagFunc: validate.StringIsUppercase(), Required: true, MarkdownDescription: "Cloud service provider on which MongoDB Cloud provisions the hosts. Set dedicated clusters to `AWS`, `GCP`, `AZURE` or `TENANT`.", }, "read_only_specs": SpecsSchema("Hardware specifications for read-only nodes in the region. Read-only nodes can never become the primary member, but can enable local reads. If you don't specify this parameter, no read-only nodes are deployed to the region."), "region_name": schema.StringAttribute{ - // TODO: probably leave validation just in the server, ValidateDiagFunc: validate.StringIsUppercase(), Required: true, MarkdownDescription: "Physical location of your MongoDB cluster nodes. The region you choose can affect network latency for clients accessing your databases. The region name is only returned in the response for single-region clusters. When MongoDB Cloud deploys a dedicated cluster, it checks if a VPC or VPC connection exists for that provider and region. If not, MongoDB Cloud creates them as part of the deployment. It assigns the VPC a Classless Inter-Domain Routing (CIDR) block. To limit a new VPC peering connection to one Classless Inter-Domain Routing (CIDR) block and region, create the connection first. Deploy the cluster after the connection starts. GCP Clusters and Multi-region clusters require one VPC peering connection for each region. MongoDB nodes can use only the peering connection that resides in the same region as the nodes to communicate with the peered VPC.", }, @@ -273,9 +270,8 @@ func ResourceSchema(ctx context.Context) schema.Schema { MarkdownDescription: "Unique 24-hexadecimal digit string that identifies the zone in a Global Cluster. This value can be used to configure Global Cluster backup policies.", }, "zone_name": schema.StringAttribute{ - Computed: true, // must be computed to have a Default + Computed: true, Optional: true, - Default: stringdefault.StaticString("ZoneName managed by Terraform"), // TODO: as in current resource MarkdownDescription: "Human-readable label that describes the zone this shard belongs to in a Global Cluster. Provide this value only if \"clusterType\" : \"GEOSHARDED\" but not \"selfManagedSharding\" : true.", }, }, @@ -290,7 +286,6 @@ func ResourceSchema(ctx context.Context) schema.Schema { Computed: true, MarkdownDescription: "Human-readable label that indicates the current operating condition of this cluster.", }, - // TODO: We want to avoid breaking changes even though it is incompatible with flex cluster and project resource "tags": schema.SetNestedAttribute{ Computed: true, Optional: true, @@ -310,33 +305,40 @@ func ResourceSchema(ctx context.Context) schema.Schema { }, }, "termination_protection_enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.UseStateForUnknown(), - }, + Computed: true, + Optional: true, MarkdownDescription: "Flag that indicates whether termination protection is enabled on the cluster. If set to `true`, MongoDB Cloud won't delete the cluster. If set to `false`, MongoDB Cloud will delete the cluster.", }, "version_release_system": schema.StringAttribute{ - // TODO: probably leave validation just in the server, ValidateFunc: validation.StringInSlice([]string{"LTS", "CONTINUOUS"}, false), - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, + Computed: true, + Optional: true, MarkdownDescription: "Method by which the cluster maintains the MongoDB versions. If value is `CONTINUOUS`, you must not specify **mongoDBMajorVersion**.", }, - "retain_backups_enabled": schema.BoolAttribute{ // TODO: not exposed in API, used in Delete operation + "retain_backups_enabled": schema.BoolAttribute{ Optional: true, MarkdownDescription: "Flag that indicates whether to retain backup snapshots for the deleted dedicated cluster.", }, - "disk_size_gb": schema.Float64Attribute{ // TODO: not exposed in latest API, deprecated in root in current resource + "disk_size_gb": schema.Float64Attribute{ DeprecationMessage: DeprecationMsgOldSchema, Computed: true, Optional: true, MarkdownDescription: "Storage capacity of instance data volumes expressed in gigabytes. Increase this number to add capacity.\n\n This value must be equal for all shards and node types.\n\n This value is not configurable on M0/M2/M5 clusters.\n\n MongoDB Cloud requires this parameter if you set **replicationSpecs**.\n\n If you specify a disk size below the minimum (10 GB), this parameter defaults to the minimum disk size value. \n\n Storage charge calculations depend on whether you choose the default value or a custom value.\n\n The maximum value for disk storage cannot exceed 50 times the maximum RAM for the selected cluster. If you require more storage space, consider upgrading your cluster to a higher tier.", }, "advanced_configuration": AdvancedConfigurationSchema(ctx), + "pinned_fcv": schema.SingleNestedAttribute{ + Optional: true, + MarkdownDescription: "Pins the Feature Compatibility Version (FCV) to the current MongoDB version with a provided expiration date. To unpin the FCV the `pinned_fcv` attribute must be removed. This operation can take several minutes as the request processes through the MongoDB data plane. Once FCV is unpinned it will not be possible to downgrade the `mongo_db_major_version`. It is advised that updates to `pinned_fcv` are done isolated from other cluster changes. If a plan contains multiple changes, the FCV change will be applied first. If FCV is unpinned past the expiration date the `pinned_fcv` attribute must be removed. The following [knowledge hub article](https://kb.corp.mongodb.com/article/000021785/) and [FCV documentation](https://www.mongodb.com/docs/atlas/tutorial/major-version-change/#manage-feature-compatibility--fcv--during-upgrades) can be referenced for more details.", + Attributes: map[string]schema.Attribute{ + "version": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "Feature compatibility version of the cluster.", + }, + "expiration_date": schema.StringAttribute{ + Required: true, + MarkdownDescription: "Expiration date of the fixed FCV. This value is in the ISO 8601 timestamp format (e.g. 2024-12-04T16:25:00Z). Note that this field cannot exceed 4 weeks from the pinned date.", + }, + }, + }, "timeouts": timeouts.Attributes(ctx, timeouts.Opts{ Create: true, Update: true, @@ -347,34 +349,32 @@ func ResourceSchema(ctx context.Context) schema.Schema { } func AutoScalingSchema() schema.SingleNestedAttribute { - // todo: computed, analytics_auto_scaling is not returned by default, so it cannot be computed return schema.SingleNestedAttribute{ - // TODO: MaxItems: 1 Computed: true, Optional: true, MarkdownDescription: "Options that determine how this cluster handles resource scaling.", Attributes: map[string]schema.Attribute{ - "compute_enabled": schema.BoolAttribute{ // TODO: was nested in compute + "compute_enabled": schema.BoolAttribute{ Computed: true, Optional: true, MarkdownDescription: "Flag that indicates whether someone enabled instance size auto-scaling.\n\n- Set to `true` to enable instance size auto-scaling. If enabled, you must specify a value for **replicationSpecs[n].regionConfigs[m].autoScaling.compute.maxInstanceSize**.\n- Set to `false` to disable instance size automatic scaling.", }, - "compute_max_instance_size": schema.StringAttribute{ // TODO: was nested in compute + "compute_max_instance_size": schema.StringAttribute{ Computed: true, Optional: true, MarkdownDescription: "Minimum instance size to which your cluster can automatically scale. MongoDB Cloud requires this parameter if `\"replicationSpecs[n].regionConfigs[m].autoScaling.compute.scaleDownEnabled\" : true`.", }, - "compute_min_instance_size": schema.StringAttribute{ // TODO: was nested in compute + "compute_min_instance_size": schema.StringAttribute{ Computed: true, Optional: true, MarkdownDescription: "Minimum instance size to which your cluster can automatically scale. MongoDB Cloud requires this parameter if `\"replicationSpecs[n].regionConfigs[m].autoScaling.compute.scaleDownEnabled\" : true`.", }, - "compute_scale_down_enabled": schema.BoolAttribute{ // TODO: was nested in compute + "compute_scale_down_enabled": schema.BoolAttribute{ Computed: true, Optional: true, MarkdownDescription: "Flag that indicates whether the instance size may scale down. MongoDB Cloud requires this parameter if `\"replicationSpecs[n].regionConfigs[m].autoScaling.compute.enabled\" : true`. If you enable this option, specify a value for **replicationSpecs[n].regionConfigs[m].autoScaling.compute.minInstanceSize**.", }, - "disk_gb_enabled": schema.BoolAttribute{ // TODO: was nested in disk_gb + "disk_gb_enabled": schema.BoolAttribute{ Computed: true, Optional: true, MarkdownDescription: "Flag that indicates whether this cluster enables disk auto-scaling. The maximum memory allowed for the selected cluster tier and the oplog size can limit storage auto-scaling.", @@ -385,7 +385,6 @@ func AutoScalingSchema() schema.SingleNestedAttribute { func SpecsSchema(markdownDescription string) schema.SingleNestedAttribute { return schema.SingleNestedAttribute{ - // TODO: MaxItems: 1 Computed: true, Optional: true, MarkdownDescription: markdownDescription, @@ -419,18 +418,20 @@ func SpecsSchema(markdownDescription string) schema.SingleNestedAttribute { } } -// TODO: generated from processArgs API endpoint func AdvancedConfigurationSchema(ctx context.Context) schema.SingleNestedAttribute { return schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - // TODO: MaxItems: 1, + Computed: true, + Optional: true, MarkdownDescription: "advanced_configuration", // TODO: add description Attributes: map[string]schema.Attribute{ "change_stream_options_pre_and_post_images_expire_after_seconds": schema.Int64Attribute{ - Optional: true, - // Default: int64default.StaticInt64(-1), // TODO: think if default in the server only + Optional: true, + Computed: true, MarkdownDescription: "The minimum pre- and post-image retention time in seconds.", + Default: int64default.StaticInt64(-1), // in case the user removes the value, we should set it to -1, a special value used by the backend to use its default behavior + PlanModifiers: []planmodifier.Int64{ + PlanMustUseMongoDBVersion(7.0, EqualOrHigher), + }, }, "default_write_concern": schema.StringAttribute{ Computed: true, @@ -453,20 +454,24 @@ func AdvancedConfigurationSchema(ctx context.Context) schema.SingleNestedAttribu MarkdownDescription: "Flag that indicates whether the cluster disables executing any query that requires a collection scan to return results.", }, "oplog_min_retention_hours": schema.Float64Attribute{ + Computed: true, Optional: true, MarkdownDescription: "Minimum retention window for cluster's oplog expressed in hours. A value of null indicates that the cluster uses the default minimum oplog window that MongoDB Cloud calculates.", }, "oplog_size_mb": schema.Int64Attribute{ - Optional: true, - Computed: true, + Optional: true, + Computed: true, + Validators: []validator.Int64{ + int64validator.AtLeast(0), + }, MarkdownDescription: "Storage limit of cluster's oplog expressed in megabytes. A value of null indicates that the cluster uses the default oplog size that MongoDB Cloud calculates.", }, - "sample_refresh_interval_bi_connector": schema.Int64Attribute{ // TODO was sample_refresh_interval_biconnector + "sample_refresh_interval_bi_connector": schema.Int64Attribute{ Computed: true, Optional: true, MarkdownDescription: "Interval in seconds at which the mongosqld process re-samples data to create its relational schema.", }, - "sample_size_bi_connector": schema.Int64Attribute{ // TODO was sample_size_biconnector + "sample_size_bi_connector": schema.Int64Attribute{ Computed: true, Optional: true, MarkdownDescription: "Number of documents per database to sample when gathering schema information.", @@ -476,16 +481,19 @@ func AdvancedConfigurationSchema(ctx context.Context) schema.SingleNestedAttribu Optional: true, MarkdownDescription: "Lifetime, in seconds, of multi-document transactions. Atlas considers the transactions that exceed this limit as expired and so aborts them through a periodic cleanup process.", }, - "default_read_concern": schema.StringAttribute{ // TODO: not exposed in latest API, deprecated in current resource + "default_read_concern": schema.StringAttribute{ DeprecationMessage: DeprecationMsgOldSchema, Computed: true, Optional: true, MarkdownDescription: "default_read_concern", // TODO: add description }, - "fail_index_key_too_long": schema.BoolAttribute{ // TODO: not exposed in latest API, deprecated in current resource - DeprecationMessage: DeprecationMsgOldSchema, - Computed: true, - Optional: true, + "fail_index_key_too_long": schema.BoolAttribute{ + DeprecationMessage: DeprecationMsgOldSchema, + Computed: true, + Optional: true, + PlanModifiers: []planmodifier.Bool{ + PlanMustUseMongoDBVersion(4.4, EqualOrLower), + }, MarkdownDescription: "fail_index_key_too_long", // TODO: add description }, }, @@ -516,13 +524,14 @@ type TFModel struct { ClusterType types.String `tfsdk:"cluster_type"` RootCertType types.String `tfsdk:"root_cert_type"` AdvancedConfiguration types.Object `tfsdk:"advanced_configuration"` - PitEnabled types.Bool `tfsdk:"pit_enabled"` + PinnedFCV types.Object `tfsdk:"pinned_fcv"` TerminationProtectionEnabled types.Bool `tfsdk:"termination_protection_enabled"` Paused types.Bool `tfsdk:"paused"` RetainBackupsEnabled types.Bool `tfsdk:"retain_backups_enabled"` BackupEnabled types.Bool `tfsdk:"backup_enabled"` GlobalClusterSelfManagedSharding types.Bool `tfsdk:"global_cluster_self_managed_sharding"` RedactClientLogData types.Bool `tfsdk:"redact_client_log_data"` + PitEnabled types.Bool `tfsdk:"pit_enabled"` } type TFBiConnectorModel struct { @@ -704,3 +713,13 @@ var AdvancedConfigurationObjType = types.ObjectType{AttrTypes: map[string]attr.T "sample_size_bi_connector": types.Int64Type, "transaction_lifetime_limit_seconds": types.Int64Type, }} + +type TFPinnedFCVModel struct { + Version types.String `tfsdk:"version"` + ExpirationDate types.String `tfsdk:"expiration_date"` +} + +var PinnedFCVObjType = types.ObjectType{AttrTypes: map[string]attr.Type{ + "version": types.StringType, + "expiration_date": types.StringType, +}} diff --git a/internal/service/advancedclustertpf/resource_schema_test.go b/internal/service/advancedclustertpf/resource_schema_test.go index 91cdef59af..01f7cdf8fd 100644 --- a/internal/service/advancedclustertpf/resource_schema_test.go +++ b/internal/service/advancedclustertpf/resource_schema_test.go @@ -1,6 +1,7 @@ package advancedclustertpf_test import ( + "fmt" "regexp" "testing" @@ -8,7 +9,43 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" ) +func TestAdvancedCluster_ValidationErrors(t *testing.T) { + resource.ParallelTest(t, resource.TestCase{ + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + Steps: []resource.TestStep{ + { + Config: configBasic(projectID, clusterName, "mongo_db_major_version = \"8a\""), + ExpectError: regexp.MustCompile("Invalid Attribute Value Match"), + }, + { + Config: configBasic(projectID, clusterName, "advanced_configuration = {oplog_size_mb = -1}"), + ExpectError: regexp.MustCompile("Invalid Attribute Value"), + }, + }, + }) +} + func TestAdvancedCluster_PlanModifierErrors(t *testing.T) { + resource.ParallelTest(t, resource.TestCase{ + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + Steps: []resource.TestStep{ + { + Config: configBasic(projectID, clusterName, "advanced_configuration = { change_stream_options_pre_and_post_images_expire_after_seconds = 100 }\nmongo_db_major_version=\"6\""), + ExpectError: regexp.MustCompile("`advanced_configuration.change_stream_options_pre_and_post_images_expire_after_seconds` can only be configured if the mongo_db_major_version is 7.0 or higher"), + }, + { + Config: configBasic(projectID, clusterName, "advanced_configuration = { fail_index_key_too_long = true }"), + ExpectError: regexp.MustCompile("`advanced_configuration.fail_index_key_too_long` can only be configured if the mongo_db_major_version is 4.4 or lower"), + }, + { + Config: configBasic(projectID, clusterName, "accept_data_risks_and_force_replica_set_reconfig = \"2006-01-02T15:04:05Z\""), + ExpectError: regexp.MustCompile("Update only attribute set on create: accept_data_risks_and_force_replica_set_reconfig"), + }, + }, + }) +} + +func TestAdvancedCluster_PlanModifierValid(t *testing.T) { var ( projectID = "111111111111111111111111" clusterName = "test" @@ -17,9 +54,56 @@ func TestAdvancedCluster_PlanModifierErrors(t *testing.T) { ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, Steps: []resource.TestStep{ { - Config: configBasic(projectID, clusterName, "accept_data_risks_and_force_replica_set_reconfig = \"2006-01-02T15:04:05Z\""), - ExpectError: regexp.MustCompile("Update only attribute set on create: accept_data_risks_and_force_replica_set_reconfig"), + Config: configBasic(projectID, clusterName, "advanced_configuration = { change_stream_options_pre_and_post_images_expire_after_seconds = 100 }\nmongo_db_major_version=\"7\""), + PlanOnly: true, + ExpectNonEmptyPlan: true, + }, + { + Config: configBasic(projectID, clusterName, "advanced_configuration = { change_stream_options_pre_and_post_images_expire_after_seconds = 100 }\nmongo_db_major_version=\"7.0\""), + PlanOnly: true, + ExpectNonEmptyPlan: true, + }, + { + Config: configBasic(projectID, clusterName, "advanced_configuration = { change_stream_options_pre_and_post_images_expire_after_seconds = 100 }"), // mongo_db_major_version is not set should also work + PlanOnly: true, + ExpectNonEmptyPlan: true, + }, + { + Config: configBasic(projectID, clusterName, "advanced_configuration = { fail_index_key_too_long = true }\nmongo_db_major_version=\"4\""), + PlanOnly: true, + ExpectNonEmptyPlan: true, }, }, }) } + +func configBasic(projectID, clusterName, extra string) string { + return fmt.Sprintf(` + resource "mongodbatlas_advanced_cluster" "test" { + timeouts = { + create = "20s" + } + project_id = %[1]q + name = %[2]q + cluster_type = "REPLICASET" + replication_specs = [{ + region_configs = [{ + priority = 7 + provider_name = "AWS" + region_name = "US_EAST_1" + auto_scaling = { + compute_scale_down_enabled = false # necessary to have similar SDKv2 request + compute_enabled = false # necessary to have similar SDKv2 request + disk_gb_enabled = true + } + electable_specs = { + node_count = 3 + instance_size = "M10" + disk_size_gb = 10 + } + }] + }] + %[3]s + } + `, projectID, clusterName, extra) +} diff --git a/internal/service/advancedclustertpf/resource_test.go b/internal/service/advancedclustertpf/resource_test.go index f5321d5575..efe29be364 100644 --- a/internal/service/advancedclustertpf/resource_test.go +++ b/internal/service/advancedclustertpf/resource_test.go @@ -1,294 +1,53 @@ package advancedclustertpf_test import ( - "fmt" - "strings" + "os" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/sebdah/goldie/v2" - "github.com/stretchr/testify/require" - - "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedclustertpf" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/tc" ) const ( - resourceName = "mongodbatlas_advanced_cluster.test" - processResponseOnly = "processResponseOnly" + resourceName = "mongodbatlas_advanced_cluster.test" ) -func ChangeMockData(data *advancedclustertpf.MockData, extraFlags ...string) resource.TestCheckFunc { - changer := func(*terraform.State) error { - if len(extraFlags) > 0 && extraFlags[0] == processResponseOnly { - return data.NextResponse(false, true) - } - return data.NextResponse(true, false) - } - return changer -} - -func CheckRequestPayload(t *testing.T, requestName string) resource.TestCheckFunc { - t.Helper() - return func(state *terraform.State) error { - g := goldie.New(t, goldie.WithNameSuffix(".json")) - lastPayload, err := advancedclustertpf.ReadLastCreatePayload() - if err != nil { - return err - } - g.Assert(t, requestName, []byte(lastPayload)) - return nil - } -} - -func CheckUpdatePayload(t *testing.T, requestName string) resource.TestCheckFunc { - t.Helper() - return func(state *terraform.State) error { - g := goldie.New(t, goldie.WithNameSuffix(".json")) - lastPayload, err := advancedclustertpf.ReadLastUpdatePayload() - if err != nil { - return err - } - g.Assert(t, requestName, []byte(lastPayload)) - return nil - } -} - -func CheckUpdatePayloadProcessArgs(t *testing.T, requestName string) resource.TestCheckFunc { - t.Helper() - return func(state *terraform.State) error { - g := goldie.New(t, goldie.WithNameSuffix(".json")) - lastPayload, err := advancedclustertpf.ReadLastUpdatePayloadProcessArgs() - if err != nil { - return err - } - g.Assert(t, requestName, []byte(lastPayload)) - requestNameLegacy := requestName + "_legacy" - lastPayload, err = advancedclustertpf.ReadLastUpdatePayloadProcessArgsLegacy() - if err != nil { - return err - } - g.Assert(t, requestNameLegacy, []byte(lastPayload)) - return nil - } -} - -func TestAccAdvancedCluster_basic(t *testing.T) { +func TestAccClusterAdvancedCluster_basicTenant(t *testing.T) { var ( - projectID = "111111111111111111111111" - clusterName = "test" - mockData = &advancedclustertpf.MockData{ - ClusterResponse: "replicaset", - } - oneNewVariable = "accept_data_risks_and_force_replica_set_reconfig = \"2006-01-02T15:04:05Z\"" - fullUpdate = ` - backup_enabled = false - bi_connector_config = { - enabled = true - } - config_server_management_mode = "ATLAS_MANAGED" - labels = [{ - key = "env" - value = "test" - }] - tags = [{ - key = "env" - value = "test" - }] - mongo_db_major_version = "8.0" - paused = true - pit_enabled = true - redact_client_log_data = true - replica_set_scaling_strategy = "NODE_TYPE" - # retain_backups_enabled = true # only set on delete - root_cert_type = "ISRGROOTX1" - termination_protection_enabled = true - version_release_system = "CONTINUOUS" - ` - advClusterConfig = ` - advanced_configuration = { - change_stream_options_pre_and_post_images_expire_after_seconds = 100 - default_read_concern = "available" - default_write_concern = "majority" - fail_index_key_too_long = true - javascript_enabled = false - minimum_enabled_tls_protocol = "TLS1_0" - no_table_scan = true - oplog_min_retention_hours = 5.5 - oplog_size_mb = 1000 - sample_refresh_interval_bi_connector = 310 - sample_size_bi_connector = 110 - transaction_lifetime_limit_seconds = 300 - } - ` + projectID = acc.ProjectIDExecution(t) + clusterName = acc.RandomClusterName() + clusterNameUpdated = acc.RandomClusterName() ) - err := advancedclustertpf.SetMockDataResetResponses(mockData) - require.NoError(t, err) - resource.Test(t, resource.TestCase{ // Sequential as it is using global variables - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Steps: []resource.TestStep{ - { - Config: configBasic(projectID, clusterName, ""), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "state_name", "CREATING"), - CheckRequestPayload(t, "replicaset_create"), - ChangeMockData(mockData), // For the next test step - ), - }, - { - Config: configBasic(projectID, clusterName, oneNewVariable), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "accept_data_risks_and_force_replica_set_reconfig", "2006-01-02T15:04:05Z"), - CheckUpdatePayload(t, "replicaset_update1"), - ChangeMockData(mockData), // For the next test step - ), - }, - { - Config: configBasic(projectID, clusterName, fullUpdate), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "mongo_db_major_version", "8.0"), - CheckUpdatePayload(t, "replicaset_update2"), - ChangeMockData(mockData, processResponseOnly), // For the next test step - ), - }, - { - Config: configBasic(projectID, clusterName, fullUpdate+advClusterConfig), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "mongo_db_major_version", "8.0"), - resource.TestCheckResourceAttr(resourceName, "advanced_configuration.change_stream_options_pre_and_post_images_expire_after_seconds", "100"), - CheckUpdatePayloadProcessArgs(t, "process_args_2_request"), - ), - }, - { - ResourceName: resourceName, - ImportStateIdFunc: acc.ImportStateIDFuncProjectIDClusterName(resourceName, "project_id", "name"), - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIdentifierAttribute: "name", - }, - }, - }) + testCase := tc.BasicTenantTestCase(t, projectID, clusterName, clusterNameUpdated) + resource.ParallelTest(t, *testCase) } -func TestAccAdvancedCluster_configSharded(t *testing.T) { +func TestAccClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel(t *testing.T) { var ( - projectID = "111111111111111111111111" - clusterName = "sharded-multi-replication" - mockData = &advancedclustertpf.MockData{ - ClusterResponse: "sharded", - } + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acc.RandomProjectName() + clusterName = acc.RandomClusterName() ) - err := advancedclustertpf.SetMockDataResetResponses(mockData) - require.NoError(t, err) - resource.Test(t, resource.TestCase{ // Sequential as it is using global variables - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - Steps: []resource.TestStep{ - { - Config: configSharded(projectID, clusterName, false), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "state_name", "CREATING"), - CheckRequestPayload(t, "sharded_create"), - ChangeMockData(mockData), // For the next test step - ), - }, - { - Config: configSharded(projectID, clusterName, true), - Check: resource.ComposeTestCheckFunc( - CheckUpdatePayload(t, "sharded_update1"), - ), - }, - { - ResourceName: resourceName, - ImportStateIdFunc: acc.ImportStateIDFuncProjectIDClusterName(resourceName, "project_id", "name"), - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIdentifierAttribute: "name", - }, - }, - }) + testCase := tc.SymmetricShardedOldSchemaDiskSizeGBAtElectableLevel(t, orgID, projectName, clusterName) + resource.ParallelTest(t, *testCase) } -func configBasic(projectID, clusterName, extra string) string { - return fmt.Sprintf(` - resource "mongodbatlas_advanced_cluster" "test" { - project_id = %[1]q - name = %[2]q - cluster_type = "REPLICASET" - replication_specs = [{ - region_configs = [{ - priority = 7 - provider_name = "AWS" - region_name = "US_EAST_1" - electable_specs = { - node_count = 3 - instance_size = "M10" - disk_size_gb = 10 - } - }] - }] - %[3]s - } - `, projectID, clusterName, extra) +func TestAccClusterAdvancedClusterConfig_symmetricShardedOldSchema(t *testing.T) { + var ( + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acc.RandomProjectName() + clusterName = acc.RandomClusterName() + ) + testCase := tc.SymmetricShardedOldSchema(t, orgID, projectName, clusterName) + resource.ParallelTest(t, *testCase) } -func configSharded(projectID, clusterName string, withUpdate bool) string { - var autoScaling, analyticsSpecs string - if withUpdate { - autoScaling = ` - auto_scaling = { - disk_gb_enabled = true - }` - analyticsSpecs = ` - analytics_specs = { - instance_size = "M30" - node_count = 1 - ebs_volume_type = "PROVISIONED" - disk_iops = 2000 - }` - } - // SDK v2 Implementation receives many warnings, one of them: `.replication_specs[1].region_configs[0].analytics_specs[0].disk_iops: was cty.NumberIntVal(2000), but now cty.NumberIntVal(1000)` - // Therefore, in TPF we are forced to set the value that will be returned by the API (1000) - // The rule is: For any replication spec, the `(analytics|electable|read_only)_spec.disk_iops` must be the same across all region_configs - // The API raises no errors, but the response reflects this rule - analyticsSpecsForSpec2 := strings.ReplaceAll(analyticsSpecs, "2000", "1000") - return fmt.Sprintf(` - resource "mongodbatlas_advanced_cluster" "test" { - project_id = %[1]q - name = %[2]q - cluster_type = "SHARDED" - replication_specs = [ - { # shard 1 - region_configs = [{ - electable_specs = { - instance_size = "M30" - disk_iops = 2000 - node_count = 3 - ebs_volume_type = "PROVISIONED" - } - %[3]s - %[4]s - provider_name = "AWS" - priority = 7 - region_name = "EU_WEST_1" - }] - }, - { # shard 2 - region_configs = [{ - electable_specs = { - instance_size = "M30" - ebs_volume_type = "PROVISIONED" - disk_iops = 1000 - node_count = 3 - } - %[5]s - provider_name = "AWS" - priority = 7 - region_name = "EU_WEST_1" - }] - }] - } - - - `, projectID, clusterName, autoScaling, analyticsSpecs, analyticsSpecsForSpec2) +func TestAccClusterAdvancedCluster_tenantUpgrade(t *testing.T) { + var ( + projectID = acc.ProjectIDExecution(t) + clusterName = acc.RandomClusterName() + ) + testCase := tc.TenantUpgrade(t, projectID, clusterName) + resource.ParallelTest(t, *testCase) } diff --git a/internal/service/advancedclustertpf/resource_unit_test.go b/internal/service/advancedclustertpf/resource_unit_test.go new file mode 100644 index 0000000000..f1fcd2cad0 --- /dev/null +++ b/internal/service/advancedclustertpf/resource_unit_test.go @@ -0,0 +1,270 @@ +package advancedclustertpf_test + +import ( + "fmt" + "strings" + "testing" + "time" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedclustertpf" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/tc" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/unit" +) + +const ( + processResponseOnly = "processResponseOnly" + projectID = "111111111111111111111111" + clusterName = "test" +) + +func TestMockAdvancedCluster_replicaset(t *testing.T) { + var ( + oneNewVariable = "backup_enabled = false" + fullUpdate = ` + backup_enabled = true + bi_connector_config = { + enabled = true + } + # config_server_management_mode = "ATLAS_MANAGED" UNSTABLE: After applying this test step, the non-refresh plan was not empty + labels = [{ + key = "env" + value = "test" + }] + tags = [{ + key = "env" + value = "test" + }] + mongo_db_major_version = "8.0" + paused = true + pit_enabled = true + redact_client_log_data = true + replica_set_scaling_strategy = "NODE_TYPE" + # retain_backups_enabled = true # only set on delete + root_cert_type = "ISRGROOTX1" + # termination_protection_enabled = true # must be reset to false to enable delete + version_release_system = "CONTINUOUS" + ` + // # oplog_min_retention_hours = 5.5 + // # oplog_size_mb = 1000 + // # fail_index_key_too_long = true # only valid for MongoDB version 4.4 and earlier + advClusterConfig = ` + advanced_configuration = { + change_stream_options_pre_and_post_images_expire_after_seconds = 100 + default_read_concern = "available" + default_write_concern = "majority" + javascript_enabled = true + minimum_enabled_tls_protocol = "TLS1_0" + no_table_scan = true + sample_refresh_interval_bi_connector = 310 + sample_size_bi_connector = 110 + transaction_lifetime_limit_seconds = 300 + } + ` + fullUpdateResumed = strings.Replace(fullUpdate, "paused = true", "paused = false", 1) + vars = map[string]string{ + "groupId": projectID, + "clusterName": clusterName, + } + ) + shortenRetries() + testCase := resource.TestCase{ + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + Steps: []resource.TestStep{ + { + Config: configBasic(projectID, clusterName, ""), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "state_name", "IDLE"), + resource.TestCheckResourceAttr(resourceName, "timeouts.create", "20s"), + resource.TestCheckResourceAttr(resourceName, "replication_specs.0.container_id.AWS:US_EAST_1", "67345bd9905b8c30c54fd220"), + ), + }, + { + Config: configBasic(projectID, clusterName, oneNewVariable), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "backup_enabled", "false"), + resource.TestCheckResourceAttr(resourceName, "state_name", "IDLE"), + ), + }, + { + Config: configBasic(projectID, clusterName, fullUpdate), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "state_name", "IDLE"), + resource.TestCheckResourceAttr(resourceName, "mongo_db_major_version", "8.0"), + resource.TestCheckResourceAttr(resourceName, "backup_enabled", "true"), + resource.TestCheckResourceAttr(resourceName, "paused", "true"), + ), + }, + { + Config: configBasic(projectID, clusterName, fullUpdateResumed), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "state_name", "IDLE"), + resource.TestCheckResourceAttr(resourceName, "backup_enabled", "true"), + resource.TestCheckResourceAttr(resourceName, "paused", "false"), + ), + }, + { + Config: configBasic(projectID, clusterName, fullUpdateResumed+advClusterConfig), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "mongo_db_major_version", "8.0"), + resource.TestCheckResourceAttr(resourceName, "advanced_configuration.change_stream_options_pre_and_post_images_expire_after_seconds", "100"), + ), + }, + acc.TestStepImportCluster(resourceName), + }, + } + unit.MockTestCaseAndRun(t, vars, &unit.MockHTTPDataConfig{AllowMissingRequests: true, AllowReReadGet: true}, &testCase) +} + +func shortenRetries() { + advancedclustertpf.RetryMinTimeout = 100 * time.Millisecond + advancedclustertpf.RetryDelay = 100 * time.Millisecond + advancedclustertpf.RetryPollInterval = 100 * time.Millisecond +} + +func TestMockAdvancedCluster_configSharded(t *testing.T) { + var ( + clusterName = "sharded-multi-replication" + vars = map[string]string{ + "groupId": projectID, + "clusterName": clusterName, + } + ) + shortenRetries() + testCase := resource.TestCase{ + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + Steps: []resource.TestStep{ + { + Config: configSharded(projectID, clusterName, false), + Check: resource.TestCheckResourceAttr(resourceName, "project_id", projectID), + }, + { + Config: configSharded(projectID, clusterName, true), + Check: resource.TestCheckResourceAttr(resourceName, "name", clusterName), + }, + acc.TestStepImportCluster(resourceName), + }, + } + unit.MockTestCaseAndRun(t, vars, &unit.MockHTTPDataConfig{AllowMissingRequests: true, AllowReReadGet: true}, &testCase) +} + +func configSharded(projectID, clusterName string, withUpdate bool) string { + var autoScaling, analyticsSpecs string + if withUpdate { + autoScaling = ` + auto_scaling = { + disk_gb_enabled = true + }` + analyticsSpecs = ` + analytics_specs = { + instance_size = "M30" + node_count = 1 + ebs_volume_type = "PROVISIONED" + disk_iops = 2000 + }` + } + // SDK v2 Implementation receives many warnings, one of them: `.replication_specs[1].region_configs[0].analytics_specs[0].disk_iops: was cty.NumberIntVal(2000), but now cty.NumberIntVal(1000)` + // Therefore, in TPF we are forced to set the value that will be returned by the API (1000) + // The rule is: For any replication spec, the `(analytics|electable|read_only)_spec.disk_iops` must be the same across all region_configs + // The API raises no errors, but the response reflects this rule + analyticsSpecsForSpec2 := strings.ReplaceAll(analyticsSpecs, "2000", "1000") + return fmt.Sprintf(` + resource "mongodbatlas_advanced_cluster" "test" { + project_id = %[1]q + name = %[2]q + cluster_type = "SHARDED" + + replication_specs = [ + { # shard 1 + region_configs = [{ + electable_specs = { + instance_size = "M30" + disk_iops = 2000 + node_count = 3 + ebs_volume_type = "PROVISIONED" + } + %[3]s + %[4]s + provider_name = "AWS" + priority = 7 + region_name = "EU_WEST_1" + }] + }, + { # shard 2 + region_configs = [{ + electable_specs = { + instance_size = "M30" + ebs_volume_type = "PROVISIONED" + disk_iops = 1000 + node_count = 3 + } + %[3]s + %[5]s + provider_name = "AWS" + priority = 7 + region_name = "EU_WEST_1" + }] + }] + } + `, projectID, clusterName, autoScaling, analyticsSpecs, analyticsSpecsForSpec2) +} + +func TestMockClusterAdvancedCluster_basicTenant(t *testing.T) { + var ( + clusterName = "test-acc-tf-c-8049930413007488732" + clusterNameUpdated = "test-acc-tf-c-91771214182147246" + vars = map[string]string{ + "groupId": projectID, + "clusterName": clusterName, + "clusterName2": clusterNameUpdated, + } + ) + shortenRetries() + testCase := tc.BasicTenantTestCase(t, projectID, clusterName, clusterNameUpdated) + unit.MockTestCaseAndRun(t, vars, &unit.MockHTTPDataConfig{AllowMissingRequests: true, AllowReReadGet: true}, testCase) +} + +func TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel(t *testing.T) { + var ( + clusterName = "6746cee8aef48d1cb265882d" + projectName = "test-acc-tf-p-4311574251574843475" + orgID = "65def6ce0f722a1507105aa5" + vars = map[string]string{ + "groupId": projectID, + "clusterName": clusterName, + } + ) + shortenRetries() + testCase := tc.SymmetricShardedOldSchemaDiskSizeGBAtElectableLevel(t, orgID, projectName, clusterName) + unit.MockTestCaseAndRun(t, vars, &unit.MockHTTPDataConfig{AllowMissingRequests: true, AllowReReadGet: true}, testCase) +} + +func TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema(t *testing.T) { + var ( + clusterName = "test-acc-tf-c-6025103075771235151" + projectName = "test-acc-tf-p-7889034782442569766" + orgID = "65def6ce0f722a1507105aa5" + vars = map[string]string{ + "groupId": projectID, + "clusterName": clusterName, + } + ) + shortenRetries() + testCase := tc.SymmetricShardedOldSchema(t, orgID, projectName, clusterName) + unit.MockTestCaseAndRun(t, vars, &unit.MockHTTPDataConfig{AllowMissingRequests: true, AllowReReadGet: true}, testCase) +} + +func TestMockClusterAdvancedCluster_tenantUpgrade(t *testing.T) { + var ( + clusterName = "test-acc-tf-c-878317177498266511" + vars = map[string]string{ + "groupId": projectID, + "clusterName": clusterName, + } + ) + shortenRetries() + testCase := tc.TenantUpgrade(t, projectID, clusterName) + unit.MockTestCaseAndRun(t, vars, &unit.MockHTTPDataConfig{AllowMissingRequests: true, AllowReReadGet: true}, testCase) +} diff --git a/internal/service/advancedclustertpf/resource_upgrade.go b/internal/service/advancedclustertpf/resource_upgrade.go new file mode 100644 index 0000000000..7ffb3fb0ae --- /dev/null +++ b/internal/service/advancedclustertpf/resource_upgrade.go @@ -0,0 +1,27 @@ +package advancedclustertpf + +import ( + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" + "go.mongodb.org/atlas-sdk/v20241113003/admin" +) + +func getTenantUpgradeRequest(state, patch *admin.ClusterDescription20240805) *admin.LegacyAtlasTenantClusterUpgradeRequest { + if patch.ReplicationSpecs == nil { + return nil + } + oldRegion := state.GetReplicationSpecs()[0].GetRegionConfigs()[0] + oldProviderName := oldRegion.GetProviderName() + newRegion := patch.GetReplicationSpecs()[0].GetRegionConfigs()[0] + newProviderName := newRegion.GetProviderName() + if oldProviderName != constant.TENANT || newProviderName == constant.TENANT { + return nil + } + return &admin.LegacyAtlasTenantClusterUpgradeRequest{ + Name: state.GetName(), + ProviderSettings: &admin.ClusterProviderSettings{ + ProviderName: newProviderName, + RegionName: newRegion.RegionName, + InstanceSizeName: newRegion.GetElectableSpecs().InstanceSize, + }, + } +} diff --git a/internal/service/advancedclustertpf/responses.go b/internal/service/advancedclustertpf/responses.go deleted file mode 100644 index 001b2fc80c..0000000000 --- a/internal/service/advancedclustertpf/responses.go +++ /dev/null @@ -1,256 +0,0 @@ -package advancedclustertpf - -import ( - _ "embed" - "encoding/json" - "fmt" - "strings" - - admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" - "go.mongodb.org/atlas-sdk/v20241023002/admin" -) - -var ( - //go:embed testdata/replicaset_create_resp1.json - createReplicasetResp1 string - //go:embed testdata/replicaset_create_resp1_final.json - createReplicasetResp1Final string - //go:embed testdata/replicaset_update1_resp.json - updateReplicasetResp1 string - - //go:embed testdata/replicaset_update2_resp.json - updateReplicasetResp2 string - - //go:embed testdata/sharded_create_resp1.json - createSharded1 string - - //go:embed testdata/sharded_create_resp1_final.json - createSharded2 string - - //go:embed testdata/sharded_update_resp1.json - updateSharded1 string - - //go:embed testdata/sharded_update_resp1_final.json - updateSharded2 string - - //go:embed testdata/process_args_1.json - processArgs1 string - - //go:embed testdata/process_args_2.json - processArgs2 string - - //go:embed testdata/process_args_1_legacy.json - processArgsLegacy1 string - - //go:embed testdata/process_args_2_legacy.json - processArgsLegacy2 string - - responsesCreate = map[string][]string{ - "replicaset": {createReplicasetResp1, createReplicasetResp1Final}, - "sharded": {createSharded1, createSharded2}, - } - responsesUpdate = map[string][]string{ - "replicaset": {updateReplicasetResp1, updateReplicasetResp2}, - "sharded": {updateSharded1, updateSharded2}, - } - - responsesProcessArgs = map[int]string{ - 0: processArgs1, - 1: processArgs2, - } - - responsesProcessArgsLegacy = map[int]string{ - 0: processArgsLegacy1, - 1: processArgsLegacy2, - } -) - -type MockData struct { - ClusterResponse string - ResponseIndex int - IsUpdate bool - ProcessArgsIndex int - ProcessArgsIndexLegacy int -} - -func (m *MockData) NextResponse(isUpdate, isProcessResponse bool) error { - switch { - case isProcessResponse: - m.ProcessArgsIndex++ - m.ProcessArgsIndexLegacy++ - case isUpdate && !m.IsUpdate: - m.IsUpdate = true - m.ResponseIndex = 0 - default: - m.ResponseIndex++ - } - mockCallData = MockCallData{} // reset call data - return validateResponsesResetRequests() -} - -func (m *MockData) GetResponse() string { - var responses map[string][]string - if m.IsUpdate { - responses = responsesUpdate - } else { - responses = responsesCreate - } - responseJSON, ok := responses[m.ClusterResponse] - if !ok { - return "" - } - return responseJSON[m.ResponseIndex] -} -func (m *MockData) GetProcessArgsResponse() string { - responseJSON, ok := responsesProcessArgs[m.ProcessArgsIndex] - if !ok { - return "" - } - return responseJSON -} - -func (m *MockData) GetProcessArgsResponseLegacy() string { - responseJSON, ok := responsesProcessArgsLegacy[m.ProcessArgsIndexLegacy] - if !ok { - return "" - } - return responseJSON -} - -var mockData = &MockData{ - ClusterResponse: "replicaset", -} - -type MockCallData struct { - ReqCreate string - ReqUpdate string - ReqProcessArgs string - ReqProcessArgsUpdate string - ReqProcessArgsUpdateLegacy string -} - -var mockCallData = MockCallData{} - -func SetMockDataResetResponses(data *MockData) error { - mockData = data - err := validateResponsesResetRequests() - if err != nil { - return err - } - return err -} - -func validateResponsesResetRequests() error { - _, err := ReadClusterResponse() - if err != nil { - return err - } - _, err = ReadClusterProcessArgsResponse() - mockCallData = MockCallData{} // Reset the call data - return err -} - -func ReadClusterResponse() (*admin.ClusterDescription20240805, error) { - response := mockData.GetResponse() - if response == "" { - return nil, fmt.Errorf("unknown cluster response for %s[%d]", mockData.ClusterResponse, mockData.ResponseIndex) - } - var SDKModel admin.ClusterDescription20240805 - err := json.Unmarshal([]byte(response), &SDKModel) - return &SDKModel, err -} - -func ReadClusterProcessArgsResponse() (*admin.ClusterDescriptionProcessArgs20240805, error) { - response := mockData.GetProcessArgsResponse() - if response == "" { - return nil, fmt.Errorf("unknown process args response number %d", mockData.ProcessArgsIndex) - } - var SDKModel admin.ClusterDescriptionProcessArgs20240805 - err := json.Unmarshal([]byte(response), &SDKModel) - return &SDKModel, err -} - -func ReadClusterProcessArgsResponseLegacy() (*admin20240530.ClusterDescriptionProcessArgs, error) { - response := mockData.GetProcessArgsResponseLegacy() - if response == "" { - return nil, fmt.Errorf("unknown process args response number %d", mockData.ProcessArgsIndex) - } - var SDKModel admin20240530.ClusterDescriptionProcessArgs - err := json.Unmarshal([]byte(response), &SDKModel) - return &SDKModel, err -} - -func StoreCreatePayload(payload *admin.ClusterDescription20240805) error { - localPayload, err := dumpJSON(payload) - if err != nil { - return err - } - mockCallData.ReqCreate = localPayload - return nil -} - -func StoreUpdatePayload(payload *admin.ClusterDescription20240805) error { - localPayload, err := dumpJSON(payload) - if err != nil { - return err - } - mockCallData.ReqUpdate = localPayload - return nil -} - -func StoreUpdatePayloadProcessArgs(payload *admin.ClusterDescriptionProcessArgs20240805) error { - localPayload, err := dumpJSON(payload) - if err != nil { - return err - } - mockCallData.ReqProcessArgsUpdate = localPayload - return nil -} - -func StoreUpdatePayloadProcessArgsLegacy(payload *admin20240530.ClusterDescriptionProcessArgs) error { - localPayload, err := dumpJSON(payload) - if err != nil { - return err - } - mockCallData.ReqProcessArgsUpdateLegacy = localPayload - return nil -} - -func ReadLastCreatePayload() (string, error) { - if mockCallData.ReqCreate == "" { - return "", fmt.Errorf("no create payload has been stored") - } - return mockCallData.ReqCreate, nil -} - -func ReadLastUpdatePayload() (string, error) { - if mockCallData.ReqUpdate == "" { - return "", fmt.Errorf("no update payload has been stored") - } - return mockCallData.ReqUpdate, nil -} - -func ReadLastUpdatePayloadProcessArgs() (string, error) { - if mockCallData.ReqProcessArgsUpdate == "" { - return "", fmt.Errorf("no update payload has been stored") - } - return mockCallData.ReqProcessArgsUpdate, nil -} - -func ReadLastUpdatePayloadProcessArgsLegacy() (string, error) { - if mockCallData.ReqProcessArgsUpdate == "" { - return "", fmt.Errorf("no update payload has been stored") - } - return mockCallData.ReqProcessArgsUpdateLegacy, nil -} - -func dumpJSON(payload any) (string, error) { - jsonPayload := strings.Builder{} - encoder := json.NewEncoder(&jsonPayload) - encoder.SetIndent("", " ") - err := encoder.Encode(payload) - if err != nil { - return "", err - } - return jsonPayload.String(), nil -} diff --git a/internal/service/advancedclustertpf/state_transition.go b/internal/service/advancedclustertpf/state_transition.go new file mode 100644 index 0000000000..5bf2cc0526 --- /dev/null +++ b/internal/service/advancedclustertpf/state_transition.go @@ -0,0 +1,111 @@ +package advancedclustertpf + +import ( + "context" + "fmt" + "slices" + "strings" + "time" + + "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/retrystrategy" + "go.mongodb.org/atlas-sdk/v20241113003/admin" +) + +var ( + RetryMinTimeout = 1 * time.Minute + RetryDelay = 30 * time.Second + RetryPollInterval = 30 * time.Second +) + +func AwaitChanges(ctx context.Context, api admin.ClustersApi, t *timeouts.Value, diags *diag.Diagnostics, projectID, clusterName, changeReason string) (cluster *admin.ClusterDescription20240805) { + var ( + timeoutDuration time.Duration + localDiags diag.Diagnostics + targetState = retrystrategy.RetryStrategyIdleState + extraPending = []string{} + ) + switch changeReason { + case changeReasonCreate: + timeoutDuration, localDiags = t.Create(ctx, defaultTimeout) + diags.Append(localDiags...) + case changeReasonUpdate: + timeoutDuration, localDiags = t.Update(ctx, defaultTimeout) + diags.Append(localDiags...) + case changeReasonDelete: + timeoutDuration, localDiags = t.Delete(ctx, defaultTimeout) + diags.Append(localDiags...) + targetState = retrystrategy.RetryStrategyDeletedState + extraPending = append(extraPending, retrystrategy.RetryStrategyIdleState) + default: + diags.AddError("errorAwaitingChanges", "unknown change reason "+changeReason) + } + if diags.HasError() { + return nil + } + stateConf := CreateStateChangeConfig(ctx, api, projectID, clusterName, targetState, timeoutDuration, extraPending...) + clusterAny, err := stateConf.WaitForStateContext(ctx) + if err != nil { + if admin.IsErrorCode(err, ErrorCodeClusterNotFound) && changeReason == "delete" { + return nil + } + diags.AddError("errorAwaitingCluster", fmt.Sprintf(errorCreate, err)) + return nil + } + if targetState == retrystrategy.RetryStrategyDeletedState { + return nil + } + cluster, ok := clusterAny.(*admin.ClusterDescription20240805) + if !ok { + diags.AddError("errorAwaitingCluster", fmt.Sprintf(errorCreate, "unexpected type from WaitForStateContext")) + return nil + } + return cluster +} + +func CreateStateChangeConfig(ctx context.Context, api admin.ClustersApi, projectID, name, targetState string, timeout time.Duration, extraPending ...string) retry.StateChangeConf { + return retry.StateChangeConf{ + Pending: slices.Concat([]string{ + retrystrategy.RetryStrategyCreatingState, + retrystrategy.RetryStrategyUpdatingState, + retrystrategy.RetryStrategyRepairingState, + retrystrategy.RetryStrategyRepeatingState, + retrystrategy.RetryStrategyPendingState, + retrystrategy.RetryStrategyDeletingState, + }, extraPending), + Target: []string{targetState}, + Refresh: resourceRefreshFunc(ctx, name, projectID, api), + Timeout: timeout, + MinTimeout: RetryMinTimeout, + Delay: RetryDelay, + PollInterval: RetryPollInterval, + } +} + +func resourceRefreshFunc(ctx context.Context, name, projectID string, api admin.ClustersApi) retry.StateRefreshFunc { + return func() (any, string, error) { + cluster, resp, err := api.GetCluster(ctx, projectID, name).Execute() + if err != nil && strings.Contains(err.Error(), "reset by peer") { + return nil, retrystrategy.RetryStrategyRepeatingState, nil + } + + if err != nil && cluster == nil && resp == nil { + return nil, "", err + } + + if err != nil { + if resp.StatusCode == 404 { + return "", retrystrategy.RetryStrategyDeletedState, nil + } + if resp.StatusCode == 503 { + return "", retrystrategy.RetryStrategyPendingState, nil + } + return nil, "", err + } + + state := cluster.GetStateName() + return cluster, state, nil + } +} diff --git a/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded.yaml b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded.yaml new file mode 100644 index 0000000000..a3c5b28e53 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded.yaml @@ -0,0 +1,216 @@ +step_count: 3 +steps: +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"SHARDED\",\n \"labels\": [],\n \"name\": \"{clusterName}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"regionConfigs\": [\n {\n \"electableSpecs\": {\n \"diskIOPS\": 1000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 0 + status: 201 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": []\n },\n \"createDate\": \"2024-11-19T18:20:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673cd6d2fb19da739ae2d4bc\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a8\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"673cd6d2fb19da739ae2d4aa\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"SHARDED\",\n \"labels\": [],\n \"name\": \"{clusterName}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"regionConfigs\": [\n {\n \"electableSpecs\": {\n \"diskIOPS\": 1000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 0 + status: 201 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": []\n },\n \"createDate\": \"2024-11-19T18:20:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673cd6d2fb19da739ae2d4bc\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a8\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"673cd6d2fb19da739ae2d4aa\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 1 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": []\n },\n \"createDate\": \"2024-11-19T18:20:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673cd6d2fb19da739ae2d4bc\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a8\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"673cd6d2fb19da739ae2d4aa\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 6 + - response_index: 8 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://sharded-multi-replicati-shard-00-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-02.jciib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://sharded-multi-replicati.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-19T18:20:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673cd6d2fb19da739ae2d4bc\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a8\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"673cd6d2fb19da739ae2d4aa\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 10 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://sharded-multi-replicati-shard-00-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-02.jciib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://sharded-multi-replicati.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-19T18:20:02Z\",\n \"diskSizeGB\": 40.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673cd6d2fb19da739ae2d4bc\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a7\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/containers + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 11 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.240.0/21\",\n \"id\": \"67345bd9905b8c30c54fd220\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"US_EAST_1\",\n \"vpcId\": \"vpc-0375d5f3c074577a0\"\n },\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"673cb9d90e17de7b126a6751\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": \"vpc-096b0b372bff6116c\"\n }\n ],\n \"totalCount\": 2\n}" + duplicate_responses: 3 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 13 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 14 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 1 +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: PATCH + version: '2024-08-05' + text: "{\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a8\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"673cd6d2fb19da739ae2d4aa\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 1000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ]\n}" + responses: + - response_index: 27 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://sharded-multi-replicati-shard-00-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-02.jciib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://sharded-multi-replicati.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-19T18:20:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673cd6d2fb19da739ae2d4bc\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a8\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"673cd6d2fb19da739ae2d4aa\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 21 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://sharded-multi-replicati-shard-00-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-02.jciib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://sharded-multi-replicati.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-19T18:20:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673cd6d2fb19da739ae2d4bc\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a8\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"673cd6d2fb19da739ae2d4aa\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - response_index: 28 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://sharded-multi-replicati-shard-00-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-02.jciib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://sharded-multi-replicati.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-19T18:20:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673cd6d2fb19da739ae2d4bc\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a8\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"673cd6d2fb19da739ae2d4aa\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 19 + - response_index: 48 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://sharded-multi-replicati-shard-00-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-03.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-03.jciib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://sharded-multi-replicati.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-19T18:20:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673cd6d2fb19da739ae2d4bc\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a8\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"673cd6d2fb19da739ae2d4aa\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 22 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://sharded-multi-replicati-shard-00-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-02.jciib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://sharded-multi-replicati.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-19T18:20:02Z\",\n \"diskSizeGB\": 40.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673cd6d2fb19da739ae2d4bc\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a7\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - response_index: 50 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://sharded-multi-replicati-shard-00-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-03.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-03.jciib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://sharded-multi-replicati.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-19T18:20:02Z\",\n \"diskSizeGB\": 40.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673cd6d2fb19da739ae2d4bc\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a7\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/containers + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 23 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.240.0/21\",\n \"id\": \"67345bd9905b8c30c54fd220\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"US_EAST_1\",\n \"vpcId\": \"vpc-0375d5f3c074577a0\"\n },\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"673cb9d90e17de7b126a6751\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": \"vpc-096b0b372bff6116c\"\n }\n ],\n \"totalCount\": 2\n}" + duplicate_responses: 1 + - response_index: 51 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.240.0/21\",\n \"id\": \"67345bd9905b8c30c54fd220\",\n \"providerName\": \"AWS\",\n \"provisioned\": false,\n \"regionName\": \"US_EAST_1\",\n \"vpcId\": null\n },\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"673cb9d90e17de7b126a6751\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": \"vpc-096b0b372bff6116c\"\n }\n ],\n \"totalCount\": 2\n}" + duplicate_responses: 3 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 25 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 26 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: PATCH + version: '2024-08-05' + text: "{\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a8\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"673cd6d2fb19da739ae2d4aa\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 1000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ]\n}" + responses: + - response_index: 27 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://sharded-multi-replicati-shard-00-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-02.jciib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://sharded-multi-replicati.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-19T18:20:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673cd6d2fb19da739ae2d4bc\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a8\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"673cd6d2fb19da739ae2d4aa\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 68 + status: 202 + text: '{}' + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 61 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://sharded-multi-replicati-shard-00-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-03.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-03.jciib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://sharded-multi-replicati.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-19T18:20:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673cd6d2fb19da739ae2d4bc\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a8\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"673cd6d2fb19da739ae2d4aa\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 1 + - response_index: 69 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://sharded-multi-replicati-shard-00-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-03.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-03.jciib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://sharded-multi-replicati.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-19T18:20:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673cd6d2fb19da739ae2d4bc\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a8\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 2000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"673cd6d2fb19da739ae2d4aa\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 1000,\n \"diskSizeGB\": 40.0,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"DELETING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 6 + - response_index: 76 + status: 404 + text: "{\n \"detail\": \"No cluster named {clusterName} exists in group {groupId}.\",\n \"error\": 404,\n \"errorCode\": \"CLUSTER_NOT_FOUND\",\n \"parameters\": [\n \"{clusterName}\",\n \"{groupId}\"\n ],\n \"reason\": \"Not Found\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 63 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://sharded-multi-replicati-shard-00-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-03.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-03.jciib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://sharded-multi-replicati.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-19T18:20:02Z\",\n \"diskSizeGB\": 40.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673cd6d2fb19da739ae2d4bc\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673cd6d2fb19da739ae2d4a7\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 2000,\n \"ebsVolumeType\": \"PROVISIONED\",\n \"instanceSize\": \"M30\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n }\n ],\n \"zoneId\": \"673cd6d2fb19da739ae2d4a6\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/containers + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 64 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.240.0/21\",\n \"id\": \"67345bd9905b8c30c54fd220\",\n \"providerName\": \"AWS\",\n \"provisioned\": false,\n \"regionName\": \"US_EAST_1\",\n \"vpcId\": null\n },\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"673cb9d90e17de7b126a6751\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": \"vpc-096b0b372bff6116c\"\n }\n ],\n \"totalCount\": 2\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 66 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 67 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 68 + status: 202 + text: '{}' +variables: + groupId: 664619d870c247237f4b86a6 + clusterName: sharded-multi-replication diff --git a/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json new file mode 100644 index 0000000000..9ea2b82c24 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json @@ -0,0 +1,40 @@ +{ + "clusterType": "SHARDED", + "labels": [], + "name": "sharded-multi-replication", + "replicationSpecs": [ + { + "regionConfigs": [ + { + "electableSpecs": { + "diskIOPS": 2000, + "ebsVolumeType": "PROVISIONED", + "instanceSize": "M30", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "EU_WEST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + }, + { + "regionConfigs": [ + { + "electableSpecs": { + "diskIOPS": 1000, + "ebsVolumeType": "PROVISIONED", + "instanceSize": "M30", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "EU_WEST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ], + "tags": [] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-08-05.json b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-08-05.json new file mode 100644 index 0000000000..6148eee5d3 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-08-05.json @@ -0,0 +1,70 @@ +{ + "replicationSpecs": [ + { + "id": "673cd6d2fb19da739ae2d4a8", + "regionConfigs": [ + { + "analyticsSpecs": { + "diskIOPS": 2000, + "ebsVolumeType": "PROVISIONED", + "instanceSize": "M30", + "nodeCount": 1 + }, + "autoScaling": { + "compute": { + "enabled": false, + "scaleDownEnabled": false + }, + "diskGB": { + "enabled": true + } + }, + "electableSpecs": { + "diskIOPS": 2000, + "diskSizeGB": 40, + "ebsVolumeType": "PROVISIONED", + "instanceSize": "M30", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "EU_WEST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + }, + { + "id": "673cd6d2fb19da739ae2d4aa", + "regionConfigs": [ + { + "analyticsSpecs": { + "diskIOPS": 1000, + "ebsVolumeType": "PROVISIONED", + "instanceSize": "M30", + "nodeCount": 1 + }, + "autoScaling": { + "compute": { + "enabled": false, + "scaleDownEnabled": false + }, + "diskGB": { + "enabled": true + } + }, + "electableSpecs": { + "diskIOPS": 1000, + "diskSizeGB": 40, + "ebsVolumeType": "PROVISIONED", + "instanceSize": "M30", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "EU_WEST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-08-05_manual.json b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-08-05_manual.json new file mode 100644 index 0000000000..7506fd4ef6 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-08-05_manual.json @@ -0,0 +1,72 @@ +{ + "replicationSpecs": [ + { + "id": "673cd6d2fb19da739ae2d4a8", + "regionConfigs": [ + { + "analyticsSpecs": { + "diskIOPS": 2000, + "ebsVolumeType": "PROVISIONED", + "instanceSize": "M30", + "nodeCount": 1 + }, + "autoScaling": { + "compute": { + "enabled": false, + "scaleDownEnabled": false + }, + "diskGB": { + "enabled": true + } + }, + "electableSpecs": { + "diskIOPS": 2000, + "diskSizeGB": 40, + "ebsVolumeType": "PROVISIONED", + "instanceSize": "M30", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "EU_WEST_1" + } + ], + "zoneId": "673cd6d2fb19da739ae2d4a6", + "zoneName": "ZoneName managed by Terraform" + }, + { + "id": "673cd6d2fb19da739ae2d4aa", + "regionConfigs": [ + { + "analyticsSpecs": { + "diskIOPS": 1000, + "ebsVolumeType": "PROVISIONED", + "instanceSize": "M30", + "nodeCount": 1 + }, + "autoScaling": { + "compute": { + "enabled": false, + "scaleDownEnabled": false + }, + "diskGB": { + "enabled": true + } + }, + "electableSpecs": { + "diskIOPS": 1000, + "diskSizeGB": 40, + "ebsVolumeType": "PROVISIONED", + "instanceSize": "M30", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "EU_WEST_1" + } + ], + "zoneId": "673cd6d2fb19da739ae2d4a6", + "zoneName": "ZoneName managed by Terraform" + } + ] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded/03_01_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_configSharded/03_01_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset.yaml b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset.yaml new file mode 100644 index 0000000000..089310b5d0 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset.yaml @@ -0,0 +1,431 @@ +step_count: 6 +steps: +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"REPLICASET\",\n \"labels\": [],\n \"name\": \"{clusterName}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskSizeGB\": 10,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 0 + status: 201 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {},\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"REPLICASET\",\n \"labels\": [],\n \"name\": \"{clusterName}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskSizeGB\": 10,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 0 + status: 201 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {},\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 1 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {},\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 12 + - response_index: 14 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 16 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskSizeGB\": 10.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc6\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/containers + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 17 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.240.0/21\",\n \"id\": \"67345bd9905b8c30c54fd220\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"US_EAST_1\",\n \"vpcId\": \"vpc-04f360947fe6956c1\"\n },\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"673cb9d90e17de7b126a6751\",\n \"providerName\": \"AWS\",\n \"provisioned\": false,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": null\n }\n ],\n \"totalCount\": 2\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 18 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": \"available\",\n \"defaultWriteConcern\": \"majority\",\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": false,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 19 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": \"majority\",\n \"javascriptEnabled\": false,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + duplicate_responses: 1 +- diff_requests: [] + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 25 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 26 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskSizeGB\": 10.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc6\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/containers + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 27 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.240.0/21\",\n \"id\": \"67345bd9905b8c30c54fd220\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"US_EAST_1\",\n \"vpcId\": \"vpc-04f360947fe6956c1\"\n },\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"673cb9d90e17de7b126a6751\",\n \"providerName\": \"AWS\",\n \"provisioned\": false,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": null\n }\n ],\n \"totalCount\": 2\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 28 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": \"available\",\n \"defaultWriteConcern\": \"majority\",\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": false,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 29 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": \"majority\",\n \"javascriptEnabled\": false,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + duplicate_responses: 1 +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: PATCH + version: '2024-10-23' + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + responses: + - response_index: 40 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: PATCH + version: '2024-10-23' + text: "{\n \"paused\": true\n}" + responses: + - response_index: 47 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": true,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 35 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - response_index: 41 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + duplicate_responses: 4 + - response_index: 46 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + - response_index: 48 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": true,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"REPAIRING\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + duplicate_responses: 3 + - response_index: 52 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": true,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 36 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskSizeGB\": 10.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc6\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - response_index: 54 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskSizeGB\": 10.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": true,\n \"pitEnabled\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc6\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/containers + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 37 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.240.0/21\",\n \"id\": \"67345bd9905b8c30c54fd220\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"US_EAST_1\",\n \"vpcId\": \"vpc-04f360947fe6956c1\"\n },\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"673cb9d90e17de7b126a6751\",\n \"providerName\": \"AWS\",\n \"provisioned\": false,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": null\n }\n ],\n \"totalCount\": 2\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 38 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": \"available\",\n \"defaultWriteConcern\": \"majority\",\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": false,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + - response_index: 56 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": \"available\",\n \"defaultWriteConcern\": \"majority\",\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": false,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 39 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": \"majority\",\n \"javascriptEnabled\": false,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + - response_index: 57 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": \"majority\",\n \"javascriptEnabled\": false,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: PATCH + version: '2024-10-23' + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + responses: + - response_index: 40 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: PATCH + version: '2024-10-23' + text: "{\n \"paused\": true\n}" + responses: + - response_index: 47 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": true,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: PATCH + version: '2024-10-23' + text: "{\n \"paused\": false\n}" + responses: + - response_index: 68 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 63 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": true,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + - response_index: 69 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"REPAIRING\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + duplicate_responses: 8 + - response_index: 78 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 64 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskSizeGB\": 10.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": true,\n \"pitEnabled\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc6\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + - response_index: 80 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskSizeGB\": 10.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc6\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/containers + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 65 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.240.0/21\",\n \"id\": \"67345bd9905b8c30c54fd220\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"US_EAST_1\",\n \"vpcId\": \"vpc-04f360947fe6956c1\"\n },\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"673cb9d90e17de7b126a6751\",\n \"providerName\": \"AWS\",\n \"provisioned\": false,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": null\n }\n ],\n \"totalCount\": 2\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 66 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": \"available\",\n \"defaultWriteConcern\": \"majority\",\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": false,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 67 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": \"majority\",\n \"javascriptEnabled\": false,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: PATCH + version: '2024-10-23' + text: "{\n \"paused\": false\n}" + responses: + - response_index: 68 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: PATCH + version: '2024-08-05' + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": 100,\n \"javascriptEnabled\": true\n}" + responses: + - response_index: 94 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": 100,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": \"majority\",\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: PATCH + version: '2024-08-05' + text: "{\n \"javascriptEnabled\": true\n}" + responses: + - response_index: 94 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": 100,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": \"majority\",\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 89 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 90 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskSizeGB\": 10.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc6\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/containers + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 91 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.240.0/21\",\n \"id\": \"67345bd9905b8c30c54fd220\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"US_EAST_1\",\n \"vpcId\": \"vpc-04f360947fe6956c1\"\n },\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"673cb9d90e17de7b126a6751\",\n \"providerName\": \"AWS\",\n \"provisioned\": false,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": null\n }\n ],\n \"totalCount\": 2\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 92 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": \"available\",\n \"defaultWriteConcern\": \"majority\",\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": false,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + duplicate_responses: 1 + - response_index: 95 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": 100,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": \"available\",\n \"defaultWriteConcern\": \"majority\",\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 93 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": \"majority\",\n \"javascriptEnabled\": false,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + duplicate_responses: 1 + - response_index: 96 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": 100,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": \"majority\",\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + duplicate_responses: 1 +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 105 + status: 202 + text: '{}' + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 99 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + duplicate_responses: 1 + - response_index: 106 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": true,\n \"redactClientLogData\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"DELETING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + duplicate_responses: 6 + - response_index: 113 + status: 404 + text: "{\n \"detail\": \"No cluster named {clusterName} exists in group {groupId}.\",\n \"error\": 404,\n \"errorCode\": \"CLUSTER_NOT_FOUND\",\n \"parameters\": [\n \"{clusterName}\",\n \"{groupId}\"\n ],\n \"reason\": \"Not Found\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 101 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": true,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://{clusterName}-shard-00-00.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-01.jciib.mongodb-dev.net:27017,{clusterName}-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0\",\n \"standardSrv\": \"mongodb+srv://{clusterName}.jciib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-20T10:41:51Z\",\n \"diskSizeGB\": 10.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673dbcef6b13675d681b3fcf\",\n \"labels\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": true,\n \"replicaSetScalingStrategy\": \"NODE_TYPE\",\n \"replicationSpecs\": [\n {\n \"id\": \"673dbcef6b13675d681b3fc6\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673dbcef6b13675d681b3fc5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [\n {\n \"key\": \"env\",\n \"value\": \"{clusterName}\"\n }\n ],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"CONTINUOUS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/containers + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 102 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.240.0/21\",\n \"id\": \"67345bd9905b8c30c54fd220\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"US_EAST_1\",\n \"vpcId\": \"vpc-04f360947fe6956c1\"\n },\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"673cb9d90e17de7b126a6751\",\n \"providerName\": \"AWS\",\n \"provisioned\": false,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": null\n }\n ],\n \"totalCount\": 2\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 103 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": 100,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": \"available\",\n \"defaultWriteConcern\": \"majority\",\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 104 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": 100,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": \"majority\",\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_0\",\n \"noTableScan\": true,\n \"oplogMinRetentionHours\": 0.0,\n \"oplogSizeMB\": 1000,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": 310,\n \"sampleSizeBIConnector\": 110,\n \"transactionLifetimeLimitSeconds\": 300\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 105 + status: 202 + text: '{}' +variables: + groupId: 664619d870c247237f4b86a6 + clusterName: test diff --git a/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json new file mode 100644 index 0000000000..2620d81aca --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json @@ -0,0 +1,32 @@ +{ + "clusterType": "REPLICASET", + "labels": [], + "name": "test", + "replicationSpecs": [ + { + "regionConfigs": [ + { + "autoScaling": { + "compute": { + "enabled": false, + "scaleDownEnabled": false + }, + "diskGB": { + "enabled": true + } + }, + "electableSpecs": { + "diskSizeGB": 10, + "instanceSize": "M10", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ], + "tags": [] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/03_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/03_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json new file mode 100644 index 0000000000..2149b7dd55 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/03_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json @@ -0,0 +1,24 @@ +{ + "backupEnabled": true, + "biConnector": { + "enabled": true, + "readPreference": "secondary" + }, + "labels": [ + { + "key": "env", + "value": "test" + } + ], + "mongoDBMajorVersion": "8.0", + "pitEnabled": true, + "redactClientLogData": true, + "replicaSetScalingStrategy": "NODE_TYPE", + "tags": [ + { + "key": "env", + "value": "test" + } + ], + "versionReleaseSystem": "CONTINUOUS" +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/03_02_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/03_02_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json new file mode 100644 index 0000000000..54e0e21edd --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/03_02_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json @@ -0,0 +1,3 @@ +{ + "paused": true +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/04_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/04_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json new file mode 100644 index 0000000000..78c40e9687 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/04_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json @@ -0,0 +1,3 @@ +{ + "paused": false +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/05_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_processArgs_2024-08-05.json b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/05_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_processArgs_2024-08-05.json new file mode 100644 index 0000000000..ea39aa862e --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/05_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_processArgs_2024-08-05.json @@ -0,0 +1,4 @@ +{ + "changeStreamOptionsPreAndPostImagesExpireAfterSeconds": 100, + "javascriptEnabled": true +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/06_01_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json b/internal/service/advancedclustertpf/testdata/TestMockAdvancedCluster_replicaset/06_01_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema.yaml b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema.yaml new file mode 100644 index 0000000000..cd38497596 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema.yaml @@ -0,0 +1,371 @@ +step_count: 2 +steps: +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"FIXED_TO_DEDICATED\",\n \"labels\": [],\n \"mongoDBMajorVersion\": \"8.0\",\n \"name\": \"{clusterName}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"electableSpecs\": {\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"electableSpecs\": {\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"electableSpecs\": {\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"electableSpecs\": {\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 9 + status: 201 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"FIXED_TO_DEDICATED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": []\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746cefbaef48d1cb2658ba9\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + request_responses: + - path: /api/atlas/v2/groups + method: POST + version: '2023-01-01' + text: "{\n \"clusterCount\": 0,\n \"created\": \"0001-01-01T00:00:00Z\",\n \"name\": \"test-acc-tf-p-7889034782442569766\",\n \"orgId\": \"65def6ce0f722a1507105aa5\",\n \"tags\": [],\n \"withDefaultAlertsSettings\": true\n}" + responses: + - response_index: 0 + status: 201 + text: "{\n \"clusterCount\": 0,\n \"created\": \"2024-11-27T07:49:10Z\",\n \"id\": \"{groupId}\",\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers\",\n \"rel\": \"https://cloud.mongodb.com/containers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters\",\n \"rel\": \"https://cloud.mongodb.com/clusters\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/databaseUsers\",\n \"rel\": \"https://cloud.mongodb.com/databaseUsers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/peers\",\n \"rel\": \"https://cloud.mongodb.com/peers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/processes\",\n \"rel\": \"https://cloud.mongodb.com/processes\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/whitelist\",\n \"rel\": \"https://cloud.mongodb.com/whitelist\"\n }\n ],\n \"name\": \"test-acc-tf-p-7889034782442569766\",\n \"orgId\": \"65def6ce0f722a1507105aa5\",\n \"tags\": []\n}" + - path: /api/atlas/v2/groups/{groupId}/settings + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 1 + status: 200 + text: "{\n \"isCollectDatabaseSpecificsStatisticsEnabled\": true,\n \"isDataExplorerEnabled\": true,\n \"isExtendedStorageSizesEnabled\": false,\n \"isPerformanceAdvisorEnabled\": true,\n \"isRealtimePerformancePanelEnabled\": true,\n \"isSchemaAdvisorEnabled\": true\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/settings + method: PATCH + version: '2023-01-01' + text: "{\n \"isCollectDatabaseSpecificsStatisticsEnabled\": true,\n \"isDataExplorerEnabled\": true,\n \"isExtendedStorageSizesEnabled\": false,\n \"isPerformanceAdvisorEnabled\": true,\n \"isRealtimePerformancePanelEnabled\": true,\n \"isSchemaAdvisorEnabled\": true\n}" + responses: + - response_index: 2 + status: 200 + text: "{\n \"isCollectDatabaseSpecificsStatisticsEnabled\": true,\n \"isDataExplorerEnabled\": true,\n \"isExtendedStorageSizesEnabled\": false,\n \"isPerformanceAdvisorEnabled\": true,\n \"isRealtimePerformancePanelEnabled\": true,\n \"isSchemaAdvisorEnabled\": true\n}" + - path: /api/atlas/v2/groups/{groupId} + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 3 + status: 200 + text: "{\n \"clusterCount\": 0,\n \"created\": \"2024-11-27T07:49:10Z\",\n \"id\": \"{groupId}\",\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers\",\n \"rel\": \"https://cloud.mongodb.com/containers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters\",\n \"rel\": \"https://cloud.mongodb.com/clusters\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/databaseUsers\",\n \"rel\": \"https://cloud.mongodb.com/databaseUsers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/peers\",\n \"rel\": \"https://cloud.mongodb.com/peers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/processes\",\n \"rel\": \"https://cloud.mongodb.com/processes\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/whitelist\",\n \"rel\": \"https://cloud.mongodb.com/whitelist\"\n }\n ],\n \"name\": \"test-acc-tf-p-7889034782442569766\",\n \"orgId\": \"65def6ce0f722a1507105aa5\",\n \"tags\": []\n}" + - response_index: 56 + status: 200 + text: "{\n \"clusterCount\": 1,\n \"created\": \"2024-11-27T07:49:10Z\",\n \"id\": \"{groupId}\",\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers\",\n \"rel\": \"https://cloud.mongodb.com/containers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters\",\n \"rel\": \"https://cloud.mongodb.com/clusters\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/databaseUsers\",\n \"rel\": \"https://cloud.mongodb.com/databaseUsers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/peers\",\n \"rel\": \"https://cloud.mongodb.com/peers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/processes\",\n \"rel\": \"https://cloud.mongodb.com/processes\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/whitelist\",\n \"rel\": \"https://cloud.mongodb.com/whitelist\"\n }\n ],\n \"name\": \"test-acc-tf-p-7889034782442569766\",\n \"orgId\": \"65def6ce0f722a1507105aa5\",\n \"tags\": []\n}" + - path: /api/atlas/v2/groups/{groupId}/teams + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 4 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/teams?includeCount=true&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [],\n \"totalCount\": 0\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/limits + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 5 + status: 200 + text: "[\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 900,\n \"name\": \"atlas.project.security.databaseAccess.users\",\n \"value\": 100\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 25,\n \"maximumLimit\": 90,\n \"name\": \"atlas.project.deployment.clusters\",\n \"value\": 25\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.serverlessMTMs\",\n \"value\": 100\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 1400,\n \"name\": \"atlas.project.security.databaseAccess.customRoles\",\n \"value\": 100\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 200,\n \"maximumLimit\": 220,\n \"name\": \"atlas.project.security.networkAccess.entries\",\n \"value\": 200\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 40,\n \"maximumLimit\": 220,\n \"name\": \"atlas.project.security.networkAccess.crossRegionEntries\",\n \"value\": 40\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 50,\n \"maximumLimit\": 90,\n \"name\": \"atlas.project.deployment.nodesPerPrivateLinkRegion\",\n \"value\": 50\n },\n {\n \"defaultLimit\": 50,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.privateServiceConnectionsPerRegionGroup\",\n \"value\": 6\n },\n {\n \"defaultLimit\": 27,\n \"maximumLimit\": 27,\n \"name\": \"atlas.project.deployment.privateServiceConnectionsSubnetMask\",\n \"value\": 27\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.salesSoldM0s\",\n \"value\": 100\n }\n]" + - response_index: 58 + status: 200 + text: "[\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 900,\n \"name\": \"atlas.project.security.databaseAccess.users\",\n \"value\": 100\n },\n {\n \"currentUsage\": 1,\n \"defaultLimit\": 25,\n \"maximumLimit\": 90,\n \"name\": \"atlas.project.deployment.clusters\",\n \"value\": 25\n },\n {\n \"currentUsage\": 1,\n \"defaultLimit\": 100,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.serverlessMTMs\",\n \"value\": 100\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 1400,\n \"name\": \"atlas.project.security.databaseAccess.customRoles\",\n \"value\": 100\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 200,\n \"maximumLimit\": 220,\n \"name\": \"atlas.project.security.networkAccess.entries\",\n \"value\": 200\n },\n {\n \"currentUsage\": 10,\n \"defaultLimit\": 40,\n \"maximumLimit\": 220,\n \"name\": \"atlas.project.security.networkAccess.crossRegionEntries\",\n \"value\": 40\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 50,\n \"maximumLimit\": 90,\n \"name\": \"atlas.project.deployment.nodesPerPrivateLinkRegion\",\n \"value\": 50\n },\n {\n \"defaultLimit\": 50,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.privateServiceConnectionsPerRegionGroup\",\n \"value\": 6\n },\n {\n \"defaultLimit\": 27,\n \"maximumLimit\": 27,\n \"name\": \"atlas.project.deployment.privateServiceConnectionsSubnetMask\",\n \"value\": 27\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.salesSoldM0s\",\n \"value\": 100\n }\n]" + - path: /api/atlas/v2/groups/{groupId}/ipAddresses + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 7 + status: 200 + text: "{\n \"groupId\": \"{groupId}\",\n \"services\": {\n \"clusters\": []\n }\n}" + - response_index: 60 + status: 200 + text: "{\n \"groupId\": \"{groupId}\",\n \"services\": {\n \"clusters\": [\n {\n \"clusterName\": \"{clusterName}\",\n \"inbound\": [\n \"34.246.188.184\",\n \"52.209.244.62\",\n \"99.80.110.196\",\n \"52.31.136.123\",\n \"48.211.168.65\",\n \"20.14.220.66\",\n \"52.50.165.92\",\n \"54.75.58.195\",\n \"54.75.145.38\",\n \"54.72.45.73\",\n \"48.211.168.194\",\n \"20.14.220.107\",\n \"63.33.141.215\",\n \"52.208.19.70\",\n \"48.211.169.27\"\n ],\n \"outbound\": [\n \"34.246.188.184\",\n \"52.209.244.62\",\n \"99.80.110.196\",\n \"52.31.136.123\",\n \"48.211.168.65\",\n \"20.14.220.66\",\n \"52.50.165.92\",\n \"54.75.58.195\",\n \"54.75.145.38\",\n \"54.72.45.73\",\n \"48.211.168.194\",\n \"20.14.220.107\",\n \"63.33.141.215\",\n \"52.208.19.70\",\n \"48.211.169.27\"\n ]\n }\n ]\n }\n}" + - path: /api/atlas/v2/groups/{groupId}/managedSlowMs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 8 + status: 200 + text: 'true' + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"FIXED_TO_DEDICATED\",\n \"labels\": [],\n \"mongoDBMajorVersion\": \"8.0\",\n \"name\": \"{clusterName}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"electableSpecs\": {\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"electableSpecs\": {\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"electableSpecs\": {\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"electableSpecs\": {\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 9 + status: 201 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"FIXED_TO_DEDICATED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": []\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746cefbaef48d1cb2658ba9\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 10 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"FIXED_TO_DEDICATED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": []\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746cefbaef48d1cb2658ba9\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 13 + - response_index: 24 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"FIXED_TO_DEDICATED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-602510307-shard-00-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-05.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-05.d2nwr.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-602510307.d2nwr.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746cefbaef48d1cb2658ba9\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 8 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 25 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"FIXED_TO_DEDICATED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-602510307-shard-00-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-05.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-05.d2nwr.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-602510307.d2nwr.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskSizeGB\": 8.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba6\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 4 + - path: /api/atlas/v2/groups/{groupId}/containers + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 27 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"6746cefbaef48d1cb2658bbc\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": \"vpc-0dd32328690ba0813\"\n }\n ],\n \"totalCount\": 1\n}" + duplicate_responses: 7 + - response_index: 28 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AZURE&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"azureSubscriptionId\": \"591236d43d098d433845860f\",\n \"id\": \"6746cefbaef48d1cb2658bbb\",\n \"providerName\": \"AZURE\",\n \"provisioned\": true,\n \"region\": \"US_EAST_2\",\n \"vnetName\": \"vnet_6746cefbaef48d1cb2658bbb_ykngkrlx\"\n }\n ],\n \"totalCount\": 1\n}" + duplicate_responses: 7 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 29 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 6 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 30 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 7 + - response_index: 34 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"FIXED_TO_DEDICATED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-602510307-shard-00-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-05.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-05.d2nwr.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-602510307.d2nwr.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746cefbaef48d1cb2658ba9\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 32 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters?includeCount=true&includeDeletedWithRetainedBackups=false&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"FIXED_TO_DEDICATED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-602510307-shard-00-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-05.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-05.d2nwr.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-602510307.d2nwr.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskSizeGB\": 8.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba6\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n }\n ],\n \"totalCount\": 1\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 33 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: PATCH + version: '2023-02-01' + text: "{\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba6\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ]\n}" + responses: + - response_index: 92 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"FIXED_TO_DEDICATED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-602510307-shard-00-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-05.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-05.d2nwr.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-602510307.d2nwr.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskSizeGB\": 8.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba6\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: PATCH + version: '2024-10-23' + text: "{\n \"configServerManagementMode\": \"ATLAS_MANAGED\"\n}" + responses: + - response_index: 93 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-602510307-shard-00-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-05.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-05.d2nwr.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-602510307.d2nwr.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746cefbaef48d1cb2658ba9\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 174 + status: 202 + text: '{}' + request_responses: + - path: /api/atlas/v2/groups/{groupId} + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 80 + status: 200 + text: "{\n \"clusterCount\": 1,\n \"created\": \"2024-11-27T07:49:10Z\",\n \"id\": \"{groupId}\",\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers\",\n \"rel\": \"https://cloud.mongodb.com/containers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters\",\n \"rel\": \"https://cloud.mongodb.com/clusters\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/databaseUsers\",\n \"rel\": \"https://cloud.mongodb.com/databaseUsers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/peers\",\n \"rel\": \"https://cloud.mongodb.com/peers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/processes\",\n \"rel\": \"https://cloud.mongodb.com/processes\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/whitelist\",\n \"rel\": \"https://cloud.mongodb.com/whitelist\"\n }\n ],\n \"name\": \"test-acc-tf-p-7889034782442569766\",\n \"orgId\": \"65def6ce0f722a1507105aa5\",\n \"tags\": []\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/teams + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 81 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/teams?includeCount=true&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [],\n \"totalCount\": 0\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/limits + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 82 + status: 200 + text: "[\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 900,\n \"name\": \"atlas.project.security.databaseAccess.users\",\n \"value\": 100\n },\n {\n \"currentUsage\": 1,\n \"defaultLimit\": 25,\n \"maximumLimit\": 90,\n \"name\": \"atlas.project.deployment.clusters\",\n \"value\": 25\n },\n {\n \"currentUsage\": 1,\n \"defaultLimit\": 100,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.serverlessMTMs\",\n \"value\": 100\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 1400,\n \"name\": \"atlas.project.security.databaseAccess.customRoles\",\n \"value\": 100\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 200,\n \"maximumLimit\": 220,\n \"name\": \"atlas.project.security.networkAccess.entries\",\n \"value\": 200\n },\n {\n \"currentUsage\": 10,\n \"defaultLimit\": 40,\n \"maximumLimit\": 220,\n \"name\": \"atlas.project.security.networkAccess.crossRegionEntries\",\n \"value\": 40\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 50,\n \"maximumLimit\": 90,\n \"name\": \"atlas.project.deployment.nodesPerPrivateLinkRegion\",\n \"value\": 50\n },\n {\n \"defaultLimit\": 50,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.privateServiceConnectionsPerRegionGroup\",\n \"value\": 6\n },\n {\n \"defaultLimit\": 27,\n \"maximumLimit\": 27,\n \"name\": \"atlas.project.deployment.privateServiceConnectionsSubnetMask\",\n \"value\": 27\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.salesSoldM0s\",\n \"value\": 100\n }\n]" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/settings + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 83 + status: 200 + text: "{\n \"isCollectDatabaseSpecificsStatisticsEnabled\": true,\n \"isDataExplorerEnabled\": true,\n \"isExtendedStorageSizesEnabled\": false,\n \"isPerformanceAdvisorEnabled\": true,\n \"isRealtimePerformancePanelEnabled\": true,\n \"isSchemaAdvisorEnabled\": true\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/ipAddresses + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 84 + status: 200 + text: "{\n \"groupId\": \"{groupId}\",\n \"services\": {\n \"clusters\": [\n {\n \"clusterName\": \"{clusterName}\",\n \"inbound\": [\n \"34.246.188.184\",\n \"52.209.244.62\",\n \"99.80.110.196\",\n \"52.31.136.123\",\n \"48.211.168.65\",\n \"20.14.220.66\",\n \"52.50.165.92\",\n \"54.75.58.195\",\n \"54.75.145.38\",\n \"54.72.45.73\",\n \"48.211.168.194\",\n \"20.14.220.107\",\n \"63.33.141.215\",\n \"52.208.19.70\",\n \"48.211.169.27\"\n ],\n \"outbound\": [\n \"34.246.188.184\",\n \"52.209.244.62\",\n \"99.80.110.196\",\n \"52.31.136.123\",\n \"48.211.168.65\",\n \"20.14.220.66\",\n \"52.50.165.92\",\n \"54.75.58.195\",\n \"54.75.145.38\",\n \"54.72.45.73\",\n \"48.211.168.194\",\n \"20.14.220.107\",\n \"63.33.141.215\",\n \"52.208.19.70\",\n \"48.211.169.27\"\n ]\n }\n ]\n }\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/managedSlowMs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 85 + status: 200 + text: 'true' + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 86 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"FIXED_TO_DEDICATED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-602510307-shard-00-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-05.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-05.d2nwr.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-602510307.d2nwr.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskSizeGB\": 8.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba6\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - response_index: 119 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-602510307-shard-00-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-05.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-05.d2nwr.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-602510307.d2nwr.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskSizeGB\": 8.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba6\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 4 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 87 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"FIXED_TO_DEDICATED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-602510307-shard-00-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-05.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-05.d2nwr.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-602510307.d2nwr.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746cefbaef48d1cb2658ba9\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - response_index: 94 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-602510307-shard-00-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-05.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-05.d2nwr.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-602510307.d2nwr.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746cefbaef48d1cb2658ba9\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 23 + - response_index: 118 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-602510307-shard-00-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-05.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-05.d2nwr.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-602510307.d2nwr.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746cefbaef48d1cb2658ba9\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 9 + - response_index: 175 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-602510307-shard-00-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-05.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-05.d2nwr.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-602510307.d2nwr.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746cefbaef48d1cb2658ba9\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"DELETING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 9 + - response_index: 185 + status: 404 + text: "{\n \"detail\": \"No cluster named {clusterName} exists in group {groupId}.\",\n \"error\": 404,\n \"errorCode\": \"CLUSTER_NOT_FOUND\",\n \"parameters\": [\n \"{clusterName}\",\n \"{groupId}\"\n ],\n \"reason\": \"Not Found\"\n}" + - path: /api/atlas/v2/groups/{groupId}/containers + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 88 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AZURE&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"6746cefbaef48d1cb2658bbc\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": \"vpc-0dd32328690ba0813\"\n }, {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"azureSubscriptionId\": \"591236d43d098d433845860f\",\n \"id\": \"6746cefbaef48d1cb2658bbb\",\n \"providerName\": \"AZURE\",\n \"provisioned\": true,\n \"region\": \"US_EAST_2\",\n \"vnetName\": \"vnet_6746cefbaef48d1cb2658bbb_ykngkrlx\"\n }\n ],\n \"totalCount\": 2\n}" + duplicate_responses: 8 + - response_index: 89 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AZURE&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"6746cefbaef48d1cb2658bbc\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": \"vpc-0dd32328690ba0813\"\n }, {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"azureSubscriptionId\": \"591236d43d098d433845860f\",\n \"id\": \"6746cefbaef48d1cb2658bbb\",\n \"providerName\": \"AZURE\",\n \"provisioned\": true,\n \"region\": \"US_EAST_2\",\n \"vnetName\": \"vnet_6746cefbaef48d1cb2658bbb_ykngkrlx\"\n }\n ],\n \"totalCount\": 2\n}" + duplicate_responses: 8 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 90 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 8 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 91 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 8 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: PATCH + version: '2023-02-01' + text: "{\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba6\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ]\n}" + responses: + - response_index: 92 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"FIXED_TO_DEDICATED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-602510307-shard-00-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-05.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-05.d2nwr.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-602510307.d2nwr.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskSizeGB\": 8.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba6\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: PATCH + version: '2024-10-23' + text: "{\n \"configServerManagementMode\": \"ATLAS_MANAGED\"\n}" + responses: + - response_index: 93 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-602510307-shard-00-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-05.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-05.d2nwr.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-602510307.d2nwr.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba7\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746cefbaef48d1cb2658ba9\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 8.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskSizeGB\": 8.0,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 125 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters?includeCount=true&includeDeletedWithRetainedBackups=false&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-602510307-shard-00-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-00-05.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-00.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-01.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-02.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-03.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-04.d2nwr.mongodb-dev.net:27016,test-acc-tf-c-602510307-shard-01-05.d2nwr.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-602510307.d2nwr.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:15Z\",\n \"diskSizeGB\": 8.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746cefbaef48d1cb2658bbd\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746cefbaef48d1cb2658ba6\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M20\",\n \"nodeCount\": 1\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"EU_WEST_1\"\n },\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M20\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 2\n },\n \"priority\": 6,\n \"providerName\": \"AZURE\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3500,\n \"diskThroughput\": 125,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_2\"\n }\n ],\n \"zoneId\": \"6746cefbaef48d1cb2658ba5\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n }\n ],\n \"totalCount\": 1\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 174 + status: 202 + text: '{}' + - path: /api/atlas/v2/groups/{groupId}/clusters + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 186 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters?includeCount=true&includeDeletedWithRetainedBackups=false&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [],\n \"totalCount\": 0\n}" + - response_index: 188 + status: 404 + text: "{\n \"detail\": \"No group with ID {groupId} exists.\",\n \"error\": 404,\n \"errorCode\": \"GROUP_NOT_FOUND\",\n \"parameters\": [\n \"{groupId}\"\n ],\n \"reason\": \"Not Found\"\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId} + method: DELETE + version: '2023-01-01' + text: '' + responses: + - response_index: 187 + status: 202 + text: '{}' +variables: + groupId: 6746cef5aef48d1cb2658a7f + clusterName: test-acc-tf-c-6025103075771235151 diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json new file mode 100644 index 0000000000..b7a0b7706f --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json @@ -0,0 +1,64 @@ +{ + "clusterType": "SHARDED", + "configServerManagementMode": "FIXED_TO_DEDICATED", + "labels": [], + "mongoDBMajorVersion": "8.0", + "name": "test-acc-tf-c-6025103075771235151", + "replicationSpecs": [ + { + "regionConfigs": [ + { + "analyticsSpecs": { + "instanceSize": "M10", + "nodeCount": 1 + }, + "electableSpecs": { + "instanceSize": "M10", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "EU_WEST_1" + }, + { + "electableSpecs": { + "instanceSize": "M10", + "nodeCount": 2 + }, + "priority": 6, + "providerName": "AZURE", + "regionName": "US_EAST_2" + } + ], + "zoneName": "ZoneName managed by Terraform" + }, + { + "regionConfigs": [ + { + "analyticsSpecs": { + "instanceSize": "M10", + "nodeCount": 1 + }, + "electableSpecs": { + "instanceSize": "M10", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "EU_WEST_1" + }, + { + "electableSpecs": { + "instanceSize": "M10", + "nodeCount": 2 + }, + "priority": 6, + "providerName": "AZURE", + "regionName": "US_EAST_2" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ], + "tags": [] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json new file mode 100644 index 0000000000..3cf5db54d3 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json @@ -0,0 +1,36 @@ +{ + "replicationSpecs": [ + { + "id": "6746cefbaef48d1cb2658ba6", + "numShards": 2, + "regionConfigs": [ + { + "analyticsSpecs": { + "diskIOPS": 3000, + "instanceSize": "M20", + "nodeCount": 1 + }, + "electableSpecs": { + "diskIOPS": 3000, + "instanceSize": "M10", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "EU_WEST_1" + }, + { + "electableSpecs": { + "diskIOPS": 3500, + "instanceSize": "M10", + "nodeCount": 2 + }, + "priority": 6, + "providerName": "AZURE", + "regionName": "US_EAST_2" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01_manual.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01_manual.json new file mode 100644 index 0000000000..356cf5676b --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01_manual.json @@ -0,0 +1,56 @@ +{ + "replicationSpecs": [ + { + "id": "6746cefbaef48d1cb2658ba6", + "numShards": 2, + "regionConfigs": [ + { + "analyticsSpecs": { + "diskIOPS": 3000, + "ebsVolumeType": "STANDARD", + "instanceSize": "M20", + "nodeCount": 1 + }, + "autoScaling": { + "compute": { + "enabled": false, + "scaleDownEnabled": false + }, + "diskGB": { + "enabled": false + } + }, + "electableSpecs": { + "diskIOPS": 3000, + "ebsVolumeType": "STANDARD", + "instanceSize": "M10", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "EU_WEST_1" + }, + { + "autoScaling": { + "compute": { + "enabled": false, + "scaleDownEnabled": false + }, + "diskGB": { + "enabled": false + } + }, + "electableSpecs": { + "diskIOPS": 3500, + "instanceSize": "M10", + "nodeCount": 2 + }, + "priority": 6, + "providerName": "AZURE", + "regionName": "US_EAST_2" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/02_02_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/02_02_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json new file mode 100644 index 0000000000..da2e2327ee --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/02_02_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2024-10-23.json @@ -0,0 +1,3 @@ +{ + "configServerManagementMode": "ATLAS_MANAGED" +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/02_03_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema/02_03_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel.yaml b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel.yaml new file mode 100644 index 0000000000..52c3812567 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel.yaml @@ -0,0 +1,318 @@ +step_count: 2 +steps: +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"SHARDED\",\n \"labels\": [],\n \"mongoDBMajorVersion\": \"7.0\",\n \"name\": \"{clusterName}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskSizeGB\": 50,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"electableSpecs\": {\n \"diskSizeGB\": 50,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskSizeGB\": 50,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"electableSpecs\": {\n \"diskSizeGB\": 50,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 9 + status: 201 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": []\n },\n \"createDate\": \"2024-11-27T07:49:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746ceeeaef48d1cb2658a1a\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746ceeeaef48d1cb26589eb\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746ceeeaef48d1cb26589ed\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + request_responses: + - path: /api/atlas/v2/groups + method: POST + version: '2023-01-01' + text: "{\n \"clusterCount\": 0,\n \"created\": \"0001-01-01T00:00:00Z\",\n \"name\": \"test-acc-tf-p-4311574251574843475\",\n \"orgId\": \"65def6ce0f722a1507105aa5\",\n \"tags\": [],\n \"withDefaultAlertsSettings\": true\n}" + responses: + - response_index: 0 + status: 201 + text: "{\n \"clusterCount\": 0,\n \"created\": \"2024-11-27T07:48:58Z\",\n \"id\": \"{groupId}\",\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers\",\n \"rel\": \"https://cloud.mongodb.com/containers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters\",\n \"rel\": \"https://cloud.mongodb.com/clusters\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/databaseUsers\",\n \"rel\": \"https://cloud.mongodb.com/databaseUsers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/peers\",\n \"rel\": \"https://cloud.mongodb.com/peers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/processes\",\n \"rel\": \"https://cloud.mongodb.com/processes\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/whitelist\",\n \"rel\": \"https://cloud.mongodb.com/whitelist\"\n }\n ],\n \"name\": \"test-acc-tf-p-4311574251574843475\",\n \"orgId\": \"65def6ce0f722a1507105aa5\",\n \"tags\": []\n}" + - path: /api/atlas/v2/groups/{groupId}/settings + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 1 + status: 200 + text: "{\n \"isCollectDatabaseSpecificsStatisticsEnabled\": true,\n \"isDataExplorerEnabled\": true,\n \"isExtendedStorageSizesEnabled\": false,\n \"isPerformanceAdvisorEnabled\": true,\n \"isRealtimePerformancePanelEnabled\": true,\n \"isSchemaAdvisorEnabled\": true\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/settings + method: PATCH + version: '2023-01-01' + text: "{\n \"isCollectDatabaseSpecificsStatisticsEnabled\": true,\n \"isDataExplorerEnabled\": true,\n \"isExtendedStorageSizesEnabled\": false,\n \"isPerformanceAdvisorEnabled\": true,\n \"isRealtimePerformancePanelEnabled\": true,\n \"isSchemaAdvisorEnabled\": true\n}" + responses: + - response_index: 2 + status: 200 + text: "{\n \"isCollectDatabaseSpecificsStatisticsEnabled\": true,\n \"isDataExplorerEnabled\": true,\n \"isExtendedStorageSizesEnabled\": false,\n \"isPerformanceAdvisorEnabled\": true,\n \"isRealtimePerformancePanelEnabled\": true,\n \"isSchemaAdvisorEnabled\": true\n}" + - path: /api/atlas/v2/groups/{groupId} + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 3 + status: 200 + text: "{\n \"clusterCount\": 0,\n \"created\": \"2024-11-27T07:48:58Z\",\n \"id\": \"{groupId}\",\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers\",\n \"rel\": \"https://cloud.mongodb.com/containers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters\",\n \"rel\": \"https://cloud.mongodb.com/clusters\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/databaseUsers\",\n \"rel\": \"https://cloud.mongodb.com/databaseUsers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/peers\",\n \"rel\": \"https://cloud.mongodb.com/peers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/processes\",\n \"rel\": \"https://cloud.mongodb.com/processes\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/whitelist\",\n \"rel\": \"https://cloud.mongodb.com/whitelist\"\n }\n ],\n \"name\": \"test-acc-tf-p-4311574251574843475\",\n \"orgId\": \"65def6ce0f722a1507105aa5\",\n \"tags\": []\n}" + - response_index: 40 + status: 200 + text: "{\n \"clusterCount\": 1,\n \"created\": \"2024-11-27T07:48:58Z\",\n \"id\": \"{groupId}\",\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers\",\n \"rel\": \"https://cloud.mongodb.com/containers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters\",\n \"rel\": \"https://cloud.mongodb.com/clusters\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/databaseUsers\",\n \"rel\": \"https://cloud.mongodb.com/databaseUsers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/peers\",\n \"rel\": \"https://cloud.mongodb.com/peers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/processes\",\n \"rel\": \"https://cloud.mongodb.com/processes\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/whitelist\",\n \"rel\": \"https://cloud.mongodb.com/whitelist\"\n }\n ],\n \"name\": \"test-acc-tf-p-4311574251574843475\",\n \"orgId\": \"65def6ce0f722a1507105aa5\",\n \"tags\": []\n}" + - path: /api/atlas/v2/groups/{groupId}/teams + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 4 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/teams?includeCount=true&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [],\n \"totalCount\": 0\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/limits + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 5 + status: 200 + text: "[\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 900,\n \"name\": \"atlas.project.security.databaseAccess.users\",\n \"value\": 100\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 25,\n \"maximumLimit\": 90,\n \"name\": \"atlas.project.deployment.clusters\",\n \"value\": 25\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.serverlessMTMs\",\n \"value\": 100\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 1400,\n \"name\": \"atlas.project.security.databaseAccess.customRoles\",\n \"value\": 100\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 200,\n \"maximumLimit\": 220,\n \"name\": \"atlas.project.security.networkAccess.entries\",\n \"value\": 200\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 40,\n \"maximumLimit\": 220,\n \"name\": \"atlas.project.security.networkAccess.crossRegionEntries\",\n \"value\": 40\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 50,\n \"maximumLimit\": 90,\n \"name\": \"atlas.project.deployment.nodesPerPrivateLinkRegion\",\n \"value\": 50\n },\n {\n \"defaultLimit\": 50,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.privateServiceConnectionsPerRegionGroup\",\n \"value\": 6\n },\n {\n \"defaultLimit\": 27,\n \"maximumLimit\": 27,\n \"name\": \"atlas.project.deployment.privateServiceConnectionsSubnetMask\",\n \"value\": 27\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.salesSoldM0s\",\n \"value\": 100\n }\n]" + - response_index: 42 + status: 200 + text: "[\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 900,\n \"name\": \"atlas.project.security.databaseAccess.users\",\n \"value\": 100\n },\n {\n \"currentUsage\": 1,\n \"defaultLimit\": 25,\n \"maximumLimit\": 90,\n \"name\": \"atlas.project.deployment.clusters\",\n \"value\": 25\n },\n {\n \"currentUsage\": 1,\n \"defaultLimit\": 100,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.serverlessMTMs\",\n \"value\": 100\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 1400,\n \"name\": \"atlas.project.security.databaseAccess.customRoles\",\n \"value\": 100\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 200,\n \"maximumLimit\": 220,\n \"name\": \"atlas.project.security.networkAccess.entries\",\n \"value\": 200\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 40,\n \"maximumLimit\": 220,\n \"name\": \"atlas.project.security.networkAccess.crossRegionEntries\",\n \"value\": 40\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 50,\n \"maximumLimit\": 90,\n \"name\": \"atlas.project.deployment.nodesPerPrivateLinkRegion\",\n \"value\": 50\n },\n {\n \"defaultLimit\": 50,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.privateServiceConnectionsPerRegionGroup\",\n \"value\": 6\n },\n {\n \"defaultLimit\": 27,\n \"maximumLimit\": 27,\n \"name\": \"atlas.project.deployment.privateServiceConnectionsSubnetMask\",\n \"value\": 27\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.salesSoldM0s\",\n \"value\": 100\n }\n]" + - path: /api/atlas/v2/groups/{groupId}/ipAddresses + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 7 + status: 200 + text: "{\n \"groupId\": \"{groupId}\",\n \"services\": {\n \"clusters\": []\n }\n}" + - response_index: 44 + status: 200 + text: "{\n \"groupId\": \"{groupId}\",\n \"services\": {\n \"clusters\": [\n {\n \"clusterName\": \"{clusterName}\",\n \"inbound\": [\n \"3.231.192.60\",\n \"54.174.182.121\",\n \"54.162.241.21\",\n \"35.168.217.111\",\n \"34.206.28.101\",\n \"54.175.35.15\",\n \"54.144.51.160\",\n \"98.84.253.100\",\n \"54.221.230.85\"\n ],\n \"outbound\": [\n \"3.231.192.60\",\n \"54.174.182.121\",\n \"54.162.241.21\",\n \"35.168.217.111\",\n \"34.206.28.101\",\n \"54.175.35.15\",\n \"54.144.51.160\",\n \"98.84.253.100\",\n \"54.221.230.85\"\n ]\n }\n ]\n }\n}" + - path: /api/atlas/v2/groups/{groupId}/managedSlowMs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 8 + status: 200 + text: 'true' + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"SHARDED\",\n \"labels\": [],\n \"mongoDBMajorVersion\": \"7.0\",\n \"name\": \"{clusterName}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskSizeGB\": 50,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"electableSpecs\": {\n \"diskSizeGB\": 50,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskSizeGB\": 50,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"electableSpecs\": {\n \"diskSizeGB\": 50,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 9 + status: 201 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": []\n },\n \"createDate\": \"2024-11-27T07:49:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746ceeeaef48d1cb2658a1a\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746ceeeaef48d1cb26589eb\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746ceeeaef48d1cb26589ed\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 10 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": []\n },\n \"createDate\": \"2024-11-27T07:49:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746ceeeaef48d1cb2658a1a\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746ceeeaef48d1cb26589eb\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746ceeeaef48d1cb26589ed\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 12 + - response_index: 23 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-461133128-shard-00-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-02.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-02.7r2ib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-461133128.7r2ib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746ceeeaef48d1cb2658a1a\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746ceeeaef48d1cb26589eb\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746ceeeaef48d1cb26589ed\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 6 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 24 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-461133128-shard-00-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-02.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-02.7r2ib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-461133128.7r2ib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:02Z\",\n \"diskSizeGB\": 50.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746ceeeaef48d1cb2658a1a\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746ceeeaef48d1cb26589ea\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 4 + - path: /api/atlas/v2/groups/{groupId}/containers + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 26 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"6746ceeeaef48d1cb2658a15\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"US_EAST_1\",\n \"vpcId\": \"vpc-0740d97a9534f73e5\"\n }\n ],\n \"totalCount\": 1\n}" + duplicate_responses: 4 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 27 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 4 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 28 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 4 +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: PATCH + version: '2023-02-01' + text: "{\n \"diskSizeGB\": 55,\n \"replicationSpecs\": [\n {\n \"id\": \"6746ceeeaef48d1cb26589ea\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ]\n}" + responses: + - response_index: 67 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-461133128-shard-00-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-02.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-02.7r2ib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-461133128.7r2ib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:02Z\",\n \"diskSizeGB\": 55.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746ceeeaef48d1cb2658a1a\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746ceeeaef48d1cb26589ea\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 108 + status: 202 + text: '{}' + request_responses: + - path: /api/atlas/v2/groups/{groupId} + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 56 + status: 200 + text: "{\n \"clusterCount\": 1,\n \"created\": \"2024-11-27T07:48:58Z\",\n \"id\": \"{groupId}\",\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers\",\n \"rel\": \"https://cloud.mongodb.com/containers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters\",\n \"rel\": \"https://cloud.mongodb.com/clusters\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/databaseUsers\",\n \"rel\": \"https://cloud.mongodb.com/databaseUsers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/peers\",\n \"rel\": \"https://cloud.mongodb.com/peers\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/processes\",\n \"rel\": \"https://cloud.mongodb.com/processes\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/whitelist\",\n \"rel\": \"https://cloud.mongodb.com/whitelist\"\n }\n ],\n \"name\": \"test-acc-tf-p-4311574251574843475\",\n \"orgId\": \"65def6ce0f722a1507105aa5\",\n \"tags\": []\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/teams + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 57 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/teams?includeCount=true&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [],\n \"totalCount\": 0\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/limits + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 58 + status: 200 + text: "[\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 900,\n \"name\": \"atlas.project.security.databaseAccess.users\",\n \"value\": 100\n },\n {\n \"currentUsage\": 1,\n \"defaultLimit\": 25,\n \"maximumLimit\": 90,\n \"name\": \"atlas.project.deployment.clusters\",\n \"value\": 25\n },\n {\n \"currentUsage\": 1,\n \"defaultLimit\": 100,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.serverlessMTMs\",\n \"value\": 100\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 1400,\n \"name\": \"atlas.project.security.databaseAccess.customRoles\",\n \"value\": 100\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 200,\n \"maximumLimit\": 220,\n \"name\": \"atlas.project.security.networkAccess.entries\",\n \"value\": 200\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 40,\n \"maximumLimit\": 220,\n \"name\": \"atlas.project.security.networkAccess.crossRegionEntries\",\n \"value\": 40\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 50,\n \"maximumLimit\": 90,\n \"name\": \"atlas.project.deployment.nodesPerPrivateLinkRegion\",\n \"value\": 50\n },\n {\n \"defaultLimit\": 50,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.privateServiceConnectionsPerRegionGroup\",\n \"value\": 6\n },\n {\n \"defaultLimit\": 27,\n \"maximumLimit\": 27,\n \"name\": \"atlas.project.deployment.privateServiceConnectionsSubnetMask\",\n \"value\": 27\n },\n {\n \"currentUsage\": 0,\n \"defaultLimit\": 100,\n \"maximumLimit\": 100,\n \"name\": \"atlas.project.deployment.salesSoldM0s\",\n \"value\": 100\n }\n]" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/settings + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 59 + status: 200 + text: "{\n \"isCollectDatabaseSpecificsStatisticsEnabled\": true,\n \"isDataExplorerEnabled\": true,\n \"isExtendedStorageSizesEnabled\": false,\n \"isPerformanceAdvisorEnabled\": true,\n \"isRealtimePerformancePanelEnabled\": true,\n \"isSchemaAdvisorEnabled\": true\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/ipAddresses + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 60 + status: 200 + text: "{\n \"groupId\": \"{groupId}\",\n \"services\": {\n \"clusters\": [\n {\n \"clusterName\": \"{clusterName}\",\n \"inbound\": [\n \"3.231.192.60\",\n \"54.174.182.121\",\n \"54.162.241.21\",\n \"35.168.217.111\",\n \"34.206.28.101\",\n \"54.175.35.15\",\n \"54.144.51.160\",\n \"98.84.253.100\",\n \"54.221.230.85\"\n ],\n \"outbound\": [\n \"3.231.192.60\",\n \"54.174.182.121\",\n \"54.162.241.21\",\n \"35.168.217.111\",\n \"34.206.28.101\",\n \"54.175.35.15\",\n \"54.144.51.160\",\n \"98.84.253.100\",\n \"54.221.230.85\"\n ]\n }\n ]\n }\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/managedSlowMs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 61 + status: 200 + text: 'true' + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 62 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-461133128-shard-00-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-02.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-02.7r2ib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-461133128.7r2ib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:02Z\",\n \"diskSizeGB\": 50.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746ceeeaef48d1cb2658a1a\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746ceeeaef48d1cb26589ea\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - response_index: 76 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-461133128-shard-00-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-02.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-02.7r2ib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-461133128.7r2ib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:02Z\",\n \"diskSizeGB\": 55.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746ceeeaef48d1cb2658a1a\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746ceeeaef48d1cb26589ea\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 4 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 63 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-461133128-shard-00-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-02.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-02.7r2ib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-461133128.7r2ib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746ceeeaef48d1cb2658a1a\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746ceeeaef48d1cb26589eb\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746ceeeaef48d1cb26589ed\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 50.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - response_index: 68 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-461133128-shard-00-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-02.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-02.7r2ib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-461133128.7r2ib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746ceeeaef48d1cb2658a1a\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746ceeeaef48d1cb26589eb\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746ceeeaef48d1cb26589ed\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 6 + - response_index: 75 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-461133128-shard-00-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-02.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-02.7r2ib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-461133128.7r2ib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746ceeeaef48d1cb2658a1a\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746ceeeaef48d1cb26589eb\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746ceeeaef48d1cb26589ed\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 6 + - response_index: 109 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-461133128-shard-00-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-02.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-02.7r2ib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-461133128.7r2ib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:02Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"7.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746ceeeaef48d1cb2658a1a\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746ceeeaef48d1cb26589eb\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n },\n {\n \"id\": \"6746ceeeaef48d1cb26589ed\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 55.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"DELETING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 6 + - response_index: 116 + status: 404 + text: "{\n \"detail\": \"No cluster named {clusterName} exists in group {groupId}.\",\n \"error\": 404,\n \"errorCode\": \"CLUSTER_NOT_FOUND\",\n \"parameters\": [\n \"{clusterName}\",\n \"{groupId}\"\n ],\n \"reason\": \"Not Found\"\n}" + - path: /api/atlas/v2/groups/{groupId}/containers + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 64 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"6746ceeeaef48d1cb2658a15\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"US_EAST_1\",\n \"vpcId\": \"vpc-0740d97a9534f73e5\"\n }\n ],\n \"totalCount\": 1\n}" + duplicate_responses: 5 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 65 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 5 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 66 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": null,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 5 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: PATCH + version: '2023-02-01' + text: "{\n \"diskSizeGB\": 55,\n \"replicationSpecs\": [\n {\n \"id\": \"6746ceeeaef48d1cb26589ea\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ]\n}" + responses: + - response_index: 67 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"SHARDED\",\n \"configServerManagementMode\": \"ATLAS_MANAGED\",\n \"configServerType\": \"DEDICATED\",\n \"connectionStrings\": {\n \"awsPrivateLinkSrv\": {},\n \"privateEndpoint\": [],\n \"standard\": \"mongodb://test-acc-tf-c-461133128-shard-00-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-00-02.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-00.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-01.7r2ib.mongodb-dev.net:27016,test-acc-tf-c-461133128-shard-01-02.7r2ib.mongodb-dev.net:27016/?ssl=true&authSource=admin\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-461133128.7r2ib.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-27T07:49:02Z\",\n \"diskSizeGB\": 55.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"6746ceeeaef48d1cb2658a1a\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"7.0\",\n \"mongoDBVersion\": \"7.0.15\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"6746ceeeaef48d1cb26589ea\",\n \"numShards\": 2,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": false\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"6746ceeeaef48d1cb26589e9\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 108 + status: 202 + text: '{}' + - path: /api/atlas/v2/groups/{groupId}/clusters + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 117 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters?includeCount=true&includeDeletedWithRetainedBackups=false&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [],\n \"totalCount\": 0\n}" + - response_index: 119 + status: 404 + text: "{\n \"detail\": \"No group with ID {groupId} exists.\",\n \"error\": 404,\n \"errorCode\": \"GROUP_NOT_FOUND\",\n \"parameters\": [\n \"{groupId}\"\n ],\n \"reason\": \"Not Found\"\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId} + method: DELETE + version: '2023-01-01' + text: '' + responses: + - response_index: 118 + status: 202 + text: '{}' +variables: + groupId: 6746cee8aef48d1cb265882d + clusterName: test-acc-tf-c-4611331288451668238 diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json new file mode 100644 index 0000000000..0a396b72b3 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json @@ -0,0 +1,49 @@ +{ + "clusterType": "SHARDED", + "labels": [], + "mongoDBMajorVersion": "7.0", + "name": "6746cee8aef48d1cb265882d", + "replicationSpecs": [ + { + "regionConfigs": [ + { + "analyticsSpecs": { + "diskSizeGB": 50, + "instanceSize": "M10", + "nodeCount": 0 + }, + "electableSpecs": { + "diskSizeGB": 50, + "instanceSize": "M10", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + }, + { + "regionConfigs": [ + { + "analyticsSpecs": { + "diskSizeGB": 50, + "instanceSize": "M10", + "nodeCount": 0 + }, + "electableSpecs": { + "diskSizeGB": 50, + "instanceSize": "M10", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ], + "tags": [] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json new file mode 100644 index 0000000000..8a4993c06c --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json @@ -0,0 +1,50 @@ +{ + "backupEnabled": false, + "clusterType": "SHARDED", + "labels": [], + "mongoDBMajorVersion": "7.0", + "name": "6746cee8aef48d1cb265882d", + "replicationSpecs": [ + { + "regionConfigs": [ + { + "analyticsSpecs": { + "diskSizeGB": 50, + "instanceSize": "M10", + "nodeCount": 0 + }, + "electableSpecs": { + "diskSizeGB": 50, + "instanceSize": "M10", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + }, + { + "regionConfigs": [ + { + "analyticsSpecs": { + "diskSizeGB": 50, + "instanceSize": "M10", + "nodeCount": 0 + }, + "electableSpecs": { + "diskSizeGB": 50, + "instanceSize": "M10", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ], + "tags": [] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_02_PATCH__api_atlas_v2_groups_{groupId}_settings_2023-01-01.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_02_PATCH__api_atlas_v2_groups_{groupId}_settings_2023-01-01.json new file mode 100644 index 0000000000..a624f89040 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_02_PATCH__api_atlas_v2_groups_{groupId}_settings_2023-01-01.json @@ -0,0 +1,8 @@ +{ + "isCollectDatabaseSpecificsStatisticsEnabled": true, + "isDataExplorerEnabled": true, + "isExtendedStorageSizesEnabled": false, + "isPerformanceAdvisorEnabled": true, + "isRealtimePerformancePanelEnabled": true, + "isSchemaAdvisorEnabled": true +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_03_POST__api_atlas_v2_groups_{groupId}_clusters_2024-08-05.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_03_POST__api_atlas_v2_groups_{groupId}_clusters_2024-08-05.json new file mode 100644 index 0000000000..e261b7ecfd --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/01_03_POST__api_atlas_v2_groups_{groupId}_clusters_2024-08-05.json @@ -0,0 +1,47 @@ +{ + "clusterType": "SHARDED", + "mongoDBMajorVersion": "7.0", + "name": "6746cee8aef48d1cb265882d", + "replicationSpecs": [ + { + "regionConfigs": [ + { + "analyticsSpecs": { + "diskSizeGB": 50, + "instanceSize": "M10", + "nodeCount": 0 + }, + "electableSpecs": { + "diskSizeGB": 50, + "instanceSize": "M10", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + }, + { + "regionConfigs": [ + { + "analyticsSpecs": { + "diskSizeGB": 50, + "instanceSize": "M10", + "nodeCount": 0 + }, + "electableSpecs": { + "diskSizeGB": 50, + "instanceSize": "M10", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json new file mode 100644 index 0000000000..2f268bd6b7 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json @@ -0,0 +1,27 @@ +{ + "diskSizeGB": 55, + "replicationSpecs": [ + { + "id": "6746ceeeaef48d1cb26589ea", + "numShards": 2, + "regionConfigs": [ + { + "analyticsSpecs": { + "diskIOPS": 3000, + "instanceSize": "M10", + "nodeCount": 0 + }, + "electableSpecs": { + "diskIOPS": 3000, + "instanceSize": "M10", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01_manual.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01_manual.json new file mode 100644 index 0000000000..a3f212eb22 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/02_01_PATCH__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01_manual.json @@ -0,0 +1,36 @@ +{ + "diskSizeGB": 55, + "replicationSpecs": [ + { + "id": "6746ceeeaef48d1cb26589ea", + "numShards": 2, + "regionConfigs": [ + { + "analyticsSpecs": { + "instanceSize": "M10", + "nodeCount": 0 + }, + "autoScaling": { + "compute": { + "enabled": false, + "scaleDownEnabled": false + }, + "diskGB": { + "enabled": false + } + }, + "electableSpecs": { + "diskIOPS": 3000, + "ebsVolumeType": "STANDARD", + "instanceSize": "M10", + "nodeCount": 3 + }, + "priority": 7, + "providerName": "AWS", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/02_02_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel/02_02_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant.yaml b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant.yaml new file mode 100644 index 0000000000..2f2d65840b --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant.yaml @@ -0,0 +1,286 @@ +step_count: 3 +steps: +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"REPLICASET\",\n \"labels\": [],\n \"name\": \"{clusterName}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\",\n \"nodeCount\": 0\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 0 + status: 201 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {},\n \"createDate\": \"2024-11-21T07:56:25Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee7a92d375c3a36e8e429\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee7a92d375c3a36e8e424\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee7a92d375c3a36e8e422\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"REPLICASET\",\n \"labels\": [],\n \"name\": \"{clusterName}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\",\n \"nodeCount\": 0\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 0 + status: 201 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {},\n \"createDate\": \"2024-11-21T07:56:25Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee7a92d375c3a36e8e429\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee7a92d375c3a36e8e424\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee7a92d375c3a36e8e422\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 1 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-uuhgbda-shard-00-00.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-01.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-02.jadffef.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-o3cq7y-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-917712141.jadffef.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T07:56:25Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee7a92d375c3a36e8e429\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee7a92d375c3a36e8e424\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee7a92d375c3a36e8e422\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 8 + - response_index: 34 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 3 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-uuhgbda-shard-00-00.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-01.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-02.jadffef.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-o3cq7y-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-917712141.jadffef.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T07:56:25Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee7a92d375c3a36e8e429\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee7a92d375c3a36e8e423\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee7a92d375c3a36e8e422\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 3 + - response_index: 16 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters?includeCount=true&includeDeletedWithRetainedBackups=false&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-uuhgbda-shard-00-00.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-01.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-02.jadffef.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-o3cq7y-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-917712141.jadffef.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T07:56:25Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee7a92d375c3a36e8e429\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee7a92d375c3a36e8e423\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee7a92d375c3a36e8e422\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n }\n ],\n \"totalCount\": 1\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 4 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 7 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 5 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 6 + - response_index: 33 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-uuhgbda-shard-00-00.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-01.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-02.jadffef.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-o3cq7y-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-917712141.jadffef.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T07:56:25Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee7a92d375c3a36e8e429\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee7a92d375c3a36e8e424\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee7a92d375c3a36e8e422\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 6 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters?includeCount=true&includeDeletedWithRetainedBackups=false&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-uuhgbda-shard-00-00.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-01.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-02.jadffef.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-o3cq7y-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-917712141.jadffef.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T07:56:25Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee7a92d375c3a36e8e429\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee7a92d375c3a36e8e423\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee7a92d375c3a36e8e422\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n }\n ],\n \"totalCount\": 1\n}" + duplicate_responses: 1 + - response_index: 15 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-uuhgbda-shard-00-00.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-01.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-02.jadffef.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-o3cq7y-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-917712141.jadffef.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T07:56:25Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee7a92d375c3a36e8e429\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee7a92d375c3a36e8e423\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee7a92d375c3a36e8e422\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 39 + status: 202 + text: '{}' + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"REPLICASET\",\n \"labels\": [],\n \"name\": \"{clusterName2}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\",\n \"nodeCount\": 0\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 41 + status: 201 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {},\n \"createDate\": \"2024-11-21T08:00:44Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee8ac2d375c3a36e8e4b9\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName2}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee8ac2d375c3a36e8e4b3\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee8ac2d375c3a36e8e4b1\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 35 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-uuhgbda-shard-00-00.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-01.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-02.jadffef.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-o3cq7y-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-917712141.jadffef.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T07:56:25Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee7a92d375c3a36e8e429\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee7a92d375c3a36e8e424\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee7a92d375c3a36e8e422\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - response_index: 40 + status: 404 + text: "{\n \"detail\": \"No cluster named {clusterName} exists in group {groupId}.\",\n \"error\": 404,\n \"errorCode\": \"CLUSTER_NOT_FOUND\",\n \"parameters\": [\n \"{clusterName}\",\n \"{groupId}\"\n ],\n \"reason\": \"Not Found\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 36 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-uuhgbda-shard-00-00.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-01.jadffef.mongodb-dev.net:27017,ac-uuhgbda-shard-00-02.jadffef.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-o3cq7y-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-917712141.jadffef.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T07:56:25Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee7a92d375c3a36e8e429\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee7a92d375c3a36e8e423\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee7a92d375c3a36e8e422\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 37 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 38 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 39 + status: 202 + text: '{}' + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"REPLICASET\",\n \"labels\": [],\n \"name\": \"{clusterName2}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\",\n \"nodeCount\": 0\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 41 + status: 201 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {},\n \"createDate\": \"2024-11-21T08:00:44Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee8ac2d375c3a36e8e4b9\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName2}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee8ac2d375c3a36e8e4b3\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee8ac2d375c3a36e8e4b1\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName2} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 42 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-guyvosp-shard-00-00.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-01.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-02.qnrmzgh.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-12rjya-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-804993041.qnrmzgh.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T08:00:44Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee8ac2d375c3a36e8e4b9\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName2}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee8ac2d375c3a36e8e4b3\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee8ac2d375c3a36e8e4b1\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 8 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName2} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 44 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-guyvosp-shard-00-00.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-01.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-02.qnrmzgh.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-12rjya-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-804993041.qnrmzgh.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T08:00:44Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee8ac2d375c3a36e8e4b9\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName2}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee8ac2d375c3a36e8e4b2\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee8ac2d375c3a36e8e4b1\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 3 + - response_index: 69 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters?includeCount=true&includeDeletedWithRetainedBackups=false&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-guyvosp-shard-00-00.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-01.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-02.qnrmzgh.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-12rjya-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-804993041.qnrmzgh.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T08:00:44Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee8ac2d375c3a36e8e4b9\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName2}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee8ac2d375c3a36e8e4b2\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee8ac2d375c3a36e8e4b1\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n }\n ],\n \"totalCount\": 1\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 45 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 6 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 46 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 7 + - response_index: 49 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-guyvosp-shard-00-00.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-01.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-02.qnrmzgh.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-12rjya-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-804993041.qnrmzgh.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T08:00:44Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee8ac2d375c3a36e8e4b9\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName2}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee8ac2d375c3a36e8e4b3\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee8ac2d375c3a36e8e4b1\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 47 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters?includeCount=true&includeDeletedWithRetainedBackups=false&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-guyvosp-shard-00-00.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-01.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-02.qnrmzgh.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-12rjya-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-804993041.qnrmzgh.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T08:00:44Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee8ac2d375c3a36e8e4b9\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName2}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee8ac2d375c3a36e8e4b2\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee8ac2d375c3a36e8e4b1\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n }\n ],\n \"totalCount\": 1\n}" + duplicate_responses: 1 + - response_index: 68 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-guyvosp-shard-00-00.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-01.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-02.qnrmzgh.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-12rjya-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-804993041.qnrmzgh.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T08:00:44Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee8ac2d375c3a36e8e4b9\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName2}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee8ac2d375c3a36e8e4b2\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee8ac2d375c3a36e8e4b1\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName2} + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 50 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName2} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 89 + status: 202 + text: '{}' + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName2} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 76 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-guyvosp-shard-00-00.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-01.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-02.qnrmzgh.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-12rjya-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-804993041.qnrmzgh.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T08:00:44Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee8ac2d375c3a36e8e4b9\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName2}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee8ac2d375c3a36e8e4b3\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee8ac2d375c3a36e8e4b1\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 3 + - response_index: 90 + status: 404 + text: "{\n \"detail\": \"No cluster named {clusterName2} exists in group {groupId}.\",\n \"error\": 404,\n \"errorCode\": \"CLUSTER_NOT_FOUND\",\n \"parameters\": [\n \"{clusterName2}\",\n \"{groupId}\"\n ],\n \"reason\": \"Not Found\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName2} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 78 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-guyvosp-shard-00-00.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-01.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-02.qnrmzgh.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-12rjya-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-804993041.qnrmzgh.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T08:00:44Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee8ac2d375c3a36e8e4b9\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName2}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee8ac2d375c3a36e8e4b2\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee8ac2d375c3a36e8e4b1\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 79 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 80 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 81 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters?includeCount=true&includeDeletedWithRetainedBackups=false&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-guyvosp-shard-00-00.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-01.qnrmzgh.mongodb-dev.net:27017,ac-guyvosp-shard-00-02.qnrmzgh.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-12rjya-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-804993041.qnrmzgh.mongodb-dev.net\"\n },\n \"createDate\": \"2024-11-21T08:00:44Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"673ee8ac2d375c3a36e8e4b9\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName2}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName2}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"673ee8ac2d375c3a36e8e4b2\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"673ee8ac2d375c3a36e8e4b1\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n }\n ],\n \"totalCount\": 1\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName2} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 89 + status: 202 + text: '{}' + - path: /api/atlas/v2/groups/{groupId}/clusters + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 91 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/?pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [],\n \"totalCount\": 0\n}" + duplicate_responses: 1 +variables: + groupId: 664619d870c247237f4b86a6 + clusterName: test-acc-tf-c-91771214182147246 + clusterName2: test-acc-tf-c-8049930413007488732 diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json new file mode 100644 index 0000000000..dbc668f294 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json @@ -0,0 +1,23 @@ +{ + "clusterType": "REPLICASET", + "labels": [], + "name": "test-acc-tf-c-8049930413007488732", + "replicationSpecs": [ + { + "regionConfigs": [ + { + "backingProviderName": "AWS", + "electableSpecs": { + "instanceSize": "M5", + "nodeCount": 0 + }, + "priority": 7, + "providerName": "TENANT", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ], + "tags": [] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json new file mode 100644 index 0000000000..ca09d36805 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json @@ -0,0 +1,22 @@ +{ + "clusterType": "REPLICASET", + "labels": [], + "name": "test-acc-tf-c-8049930413007488732", + "replicationSpecs": [ + { + "regionConfigs": [ + { + "backingProviderName": "AWS", + "electableSpecs": { + "instanceSize": "M5" + }, + "priority": 7, + "providerName": "TENANT", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ], + "tags": [] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/02_01_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/02_01_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/02_02_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/02_02_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json new file mode 100644 index 0000000000..678c9b1fe4 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/02_02_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json @@ -0,0 +1,23 @@ +{ + "clusterType": "REPLICASET", + "labels": [], + "name": "test-acc-tf-c-91771214182147246", + "replicationSpecs": [ + { + "regionConfigs": [ + { + "backingProviderName": "AWS", + "electableSpecs": { + "instanceSize": "M5", + "nodeCount": 0 + }, + "priority": 7, + "providerName": "TENANT", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ], + "tags": [] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/02_02_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/02_02_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json new file mode 100644 index 0000000000..aae97823e8 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/02_02_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json @@ -0,0 +1,22 @@ +{ + "clusterType": "REPLICASET", + "labels": [], + "name": "test-acc-tf-c-91771214182147246", + "replicationSpecs": [ + { + "regionConfigs": [ + { + "backingProviderName": "AWS", + "electableSpecs": { + "instanceSize": "M5" + }, + "priority": 7, + "providerName": "TENANT", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ], + "tags": [] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/03_01_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName2}_2023-02-01.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_basicTenant/03_01_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName2}_2023-02-01.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade.yaml b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade.yaml new file mode 100644 index 0000000000..39fd92c8c8 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade.yaml @@ -0,0 +1,186 @@ +step_count: 2 +steps: +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"REPLICASET\",\n \"labels\": [],\n \"name\": \"{clusterName}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\",\n \"nodeCount\": 0\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 0 + status: 201 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {},\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b42\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"REPLICASET\",\n \"labels\": [],\n \"name\": \"{clusterName}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\",\n \"nodeCount\": 0\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 0 + status: 201 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {},\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b42\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 1 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b42\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 8 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 3 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b41\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 4 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 4 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"customOpensslCipherConfigTls12\": [],\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"tlsCipherConfigMode\": \"DEFAULT\",\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 6 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 5 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"customOpensslCipherConfigTls12\": [],\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"tlsCipherConfigMode\": \"DEFAULT\",\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 7 + - response_index: 8 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b42\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 6 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters?includeCount=true&includeDeletedWithRetainedBackups=false&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b41\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n }\n ],\n \"totalCount\": 1\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 9 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"customOpensslCipherConfigTls12\": [],\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"tlsCipherConfigMode\": \"DEFAULT\",\n \"transactionLifetimeLimitSeconds\": null\n}" +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters/tenantUpgrade + method: POST + version: '2023-01-01' + text: "{\n \"name\": \"{clusterName}\",\n \"providerSettings\": {\n \"instanceSizeName\": \"M10\",\n \"providerName\": \"AWS\",\n \"regionName\": \"US_EAST_1\"\n }\n}" + responses: + - response_index: 39 + status: 200 + text: "{\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGBEnabled\": false\n },\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"mongoURI\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017\",\n \"mongoURIUpdated\": \"2024-12-03T16:54:43Z\",\n \"mongoURIWithOptions\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"name\": \"{clusterName}\",\n \"numShards\": 1,\n \"paused\": false,\n \"pitEnabled\": false,\n \"providerBackupEnabled\": false,\n \"providerSettings\": {\n \"autoScaling\": {\n \"compute\": {\n \"maxInstanceSize\": null,\n \"minInstanceSize\": null\n }\n },\n \"backingProviderName\": \"AWS\",\n \"effectiveInstanceSizeName\": \"M5\",\n \"instanceSizeName\": \"M5\",\n \"nextBackupDate\": \"2024-12-04T16:54:26Z\",\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\",\n \"tenantBackupEnabled\": true\n },\n \"replicationFactor\": 3,\n \"replicationSpec\": {\n \"US_EAST_1\": {\n \"analyticsNodes\": 0,\n \"electableNodes\": 3,\n \"priority\": 7,\n \"readOnlyNodes\": 0\n }\n },\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b41\",\n \"numShards\": 1,\n \"regionsConfig\": {\n \"US_EAST_1\": {\n \"analyticsNodes\": 0,\n \"electableNodes\": 3,\n \"priority\": 7,\n \"readOnlyNodes\": 0\n }\n },\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"srvAddress\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 76 + status: 202 + text: '{}' + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 35 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b42\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - response_index: 40 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {},\n \"createDate\": \"2024-12-03T16:57:44Z\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f388843ca6e2ab9803e84\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f388843ca6e2ab9803e83\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f388843ca6e2ab9803e82\",\n \"zoneName\": \"Zone 1\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 26 + - response_index: 67 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:57:44Z\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f388843ca6e2ab9803e84\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f388843ca6e2ab9803e83\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f388843ca6e2ab9803e82\",\n \"zoneName\": \"Zone 1\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 1 + - response_index: 69 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:57:44Z\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f388843ca6e2ab9803e84\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f388843ca6e2ab9803e83\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f388843ca6e2ab9803e82\",\n \"zoneName\": \"Zone 1\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 2 + - response_index: 77 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:57:44Z\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f388843ca6e2ab9803e84\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f388843ca6e2ab9803e83\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f388843ca6e2ab9803e82\",\n \"zoneName\": \"Zone 1\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"DELETING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 6 + - response_index: 84 + status: 404 + text: "{\n \"detail\": \"No cluster named {clusterName} exists in group {groupId}.\",\n \"error\": 404,\n \"errorCode\": \"CLUSTER_NOT_FOUND\",\n \"parameters\": [\n \"{clusterName}\",\n \"{groupId}\"\n ],\n \"reason\": \"Not Found\"\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 36 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b41\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - response_index: 71 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:57:44Z\",\n \"diskSizeGB\": 10.0,\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f388843ca6e2ab9803e84\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f388843ca6e2ab9803e79\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f388843ca6e2ab9803e82\",\n \"zoneName\": \"Zone 1\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 37 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"customOpensslCipherConfigTls12\": [],\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"tlsCipherConfigMode\": \"DEFAULT\",\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 38 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"customOpensslCipherConfigTls12\": [],\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"tlsCipherConfigMode\": \"DEFAULT\",\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/tenantUpgrade + method: POST + version: '2023-01-01' + text: "{\n \"name\": \"{clusterName}\",\n \"providerSettings\": {\n \"instanceSizeName\": \"M10\",\n \"providerName\": \"AWS\",\n \"regionName\": \"US_EAST_1\"\n }\n}" + responses: + - response_index: 39 + status: 200 + text: "{\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGBEnabled\": false\n },\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"mongoURI\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017\",\n \"mongoURIUpdated\": \"2024-12-03T16:54:43Z\",\n \"mongoURIWithOptions\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"name\": \"{clusterName}\",\n \"numShards\": 1,\n \"paused\": false,\n \"pitEnabled\": false,\n \"providerBackupEnabled\": false,\n \"providerSettings\": {\n \"autoScaling\": {\n \"compute\": {\n \"maxInstanceSize\": null,\n \"minInstanceSize\": null\n }\n },\n \"backingProviderName\": \"AWS\",\n \"effectiveInstanceSizeName\": \"M5\",\n \"instanceSizeName\": \"M5\",\n \"nextBackupDate\": \"2024-12-04T16:54:26Z\",\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\",\n \"tenantBackupEnabled\": true\n },\n \"replicationFactor\": 3,\n \"replicationSpec\": {\n \"US_EAST_1\": {\n \"analyticsNodes\": 0,\n \"electableNodes\": 3,\n \"priority\": 7,\n \"readOnlyNodes\": 0\n }\n },\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b41\",\n \"numShards\": 1,\n \"regionsConfig\": {\n \"US_EAST_1\": {\n \"analyticsNodes\": 0,\n \"electableNodes\": 3,\n \"priority\": 7,\n \"readOnlyNodes\": 0\n }\n },\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"srvAddress\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/containers + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 72 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"674f388843ca6e2ab9803e89\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"US_EAST_1\",\n \"vpcId\": \"vpc-0a59ad5152645bea7\"\n }\n ],\n \"totalCount\": 1\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 76 + status: 202 + text: '{}' + - path: /api/atlas/v2/groups/{groupId} + method: DELETE + version: '2023-01-01' + text: '' + responses: + - response_index: 86 + status: 202 + text: '{}' +variables: + groupId: 674f37b888864967c85f6ad7 + clusterName: test-acc-tf-c-878317177498266511 diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json new file mode 100644 index 0000000000..6778b1311a --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json @@ -0,0 +1,23 @@ +{ + "clusterType": "REPLICASET", + "labels": [], + "name": "test-acc-tf-c-878317177498266511", + "replicationSpecs": [ + { + "regionConfigs": [ + { + "backingProviderName": "AWS", + "electableSpecs": { + "instanceSize": "M5", + "nodeCount": 0 + }, + "priority": 7, + "providerName": "TENANT", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ], + "tags": [] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json new file mode 100644 index 0000000000..71905d7b89 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json @@ -0,0 +1,22 @@ +{ + "clusterType": "REPLICASET", + "labels": [], + "name": "test-acc-tf-c-878317177498266511", + "replicationSpecs": [ + { + "regionConfigs": [ + { + "backingProviderName": "AWS", + "electableSpecs": { + "instanceSize": "M5" + }, + "priority": 7, + "providerName": "TENANT", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ], + "tags": [] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/02_01_POST__api_atlas_v2_groups_{groupId}_clusters_tenantUpgrade_2023-01-01.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/02_01_POST__api_atlas_v2_groups_{groupId}_clusters_tenantUpgrade_2023-01-01.json new file mode 100644 index 0000000000..a3ce19b271 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/02_01_POST__api_atlas_v2_groups_{groupId}_clusters_tenantUpgrade_2023-01-01.json @@ -0,0 +1,8 @@ +{ + "name": "test-acc-tf-c-878317177498266511", + "providerSettings": { + "instanceSizeName": "M10", + "providerName": "AWS", + "regionName": "US_EAST_1" + } +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/02_02_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/02_02_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/internal/service/advancedclustertpf/testdata/process_args_1.json b/internal/service/advancedclustertpf/testdata/process_args_1.json deleted file mode 100644 index c9ece536b5..0000000000 --- a/internal/service/advancedclustertpf/testdata/process_args_1.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "changeStreamOptionsPreAndPostImagesExpireAfterSeconds": null, - "chunkMigrationConcurrency": null, - "defaultMaxTimeMS": null, - "defaultWriteConcern": null, - "javascriptEnabled": true, - "minimumEnabledTlsProtocol": "TLS1_2", - "noTableScan": false, - "oplogMinRetentionHours": null, - "oplogSizeMB": null, - "queryStatsLogVerbosity": null, - "sampleRefreshIntervalBIConnector": null, - "sampleSizeBIConnector": null, - "transactionLifetimeLimitSeconds": null -} diff --git a/internal/service/advancedclustertpf/testdata/process_args_1_legacy.json b/internal/service/advancedclustertpf/testdata/process_args_1_legacy.json deleted file mode 100644 index 3865fe5d7c..0000000000 --- a/internal/service/advancedclustertpf/testdata/process_args_1_legacy.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "changeStreamOptionsPreAndPostImagesExpireAfterSeconds": null, - "chunkMigrationConcurrency": null, - "defaultMaxTimeMS": null, - "defaultReadConcern": null, - "defaultWriteConcern": null, - "failIndexKeyTooLong": null, - "javascriptEnabled": true, - "minimumEnabledTlsProtocol": "TLS1_2", - "noTableScan": false, - "oplogMinRetentionHours": null, - "oplogSizeMB": null, - "queryStatsLogVerbosity": null, - "sampleRefreshIntervalBIConnector": null, - "sampleSizeBIConnector": null, - "transactionLifetimeLimitSeconds": null -} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/process_args_2.json b/internal/service/advancedclustertpf/testdata/process_args_2.json deleted file mode 100644 index b119665916..0000000000 --- a/internal/service/advancedclustertpf/testdata/process_args_2.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "changeStreamOptionsPreAndPostImagesExpireAfterSeconds": 100, - "chunkMigrationConcurrency": null, - "defaultMaxTimeMS": null, - "defaultWriteConcern": "majority", - "javascriptEnabled": false, - "minimumEnabledTlsProtocol": "TLS1_0", - "noTableScan": true, - "oplogMinRetentionHours": 5.5, - "oplogSizeMB": 1000, - "queryStatsLogVerbosity": null, - "sampleRefreshIntervalBIConnector": 310, - "sampleSizeBIConnector": 110, - "transactionLifetimeLimitSeconds": 300 -} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/process_args_2_legacy.json b/internal/service/advancedclustertpf/testdata/process_args_2_legacy.json deleted file mode 100644 index 339ccbf32a..0000000000 --- a/internal/service/advancedclustertpf/testdata/process_args_2_legacy.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "changeStreamOptionsPreAndPostImagesExpireAfterSeconds": null, - "chunkMigrationConcurrency": null, - "defaultMaxTimeMS": null, - "defaultReadConcern": "available", - "defaultWriteConcern": "majority", - "failIndexKeyTooLong": true, - "javascriptEnabled": false, - "minimumEnabledTlsProtocol": "TLS1_2", - "noTableScan": true, - "oplogMinRetentionHours": 5.5, - "oplogSizeMB": 1000, - "queryStatsLogVerbosity": null, - "sampleRefreshIntervalBIConnector": 310, - "sampleSizeBIConnector": 110, - "transactionLifetimeLimitSeconds": 300 -} diff --git a/internal/service/advancedclustertpf/testdata/process_args_2_request.json b/internal/service/advancedclustertpf/testdata/process_args_2_request.json deleted file mode 100644 index e464bbcd4a..0000000000 --- a/internal/service/advancedclustertpf/testdata/process_args_2_request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "changeStreamOptionsPreAndPostImagesExpireAfterSeconds": 100, - "defaultWriteConcern": "majority", - "javascriptEnabled": false, - "minimumEnabledTlsProtocol": "TLS1_0", - "noTableScan": true, - "oplogMinRetentionHours": 5.5, - "oplogSizeMB": 1000, - "sampleRefreshIntervalBIConnector": 310, - "sampleSizeBIConnector": 110, - "transactionLifetimeLimitSeconds": 300 -} diff --git a/internal/service/advancedclustertpf/testdata/process_args_2_request_legacy.json b/internal/service/advancedclustertpf/testdata/process_args_2_request_legacy.json deleted file mode 100644 index 10e8c9c067..0000000000 --- a/internal/service/advancedclustertpf/testdata/process_args_2_request_legacy.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "defaultReadConcern": "available", - "failIndexKeyTooLong": true -} diff --git a/internal/service/advancedclustertpf/testdata/replicaset_create.json b/internal/service/advancedclustertpf/testdata/replicaset_create.json deleted file mode 100644 index 33a5c5d7eb..0000000000 --- a/internal/service/advancedclustertpf/testdata/replicaset_create.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "clusterType": "REPLICASET", - "groupId": "111111111111111111111111", - "labels": [], - "name": "test", - "replicationSpecs": [ - { - "regionConfigs": [ - { - "electableSpecs": { - "diskSizeGB": 10, - "instanceSize": "M10", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "regionName": "US_EAST_1" - } - ], - "zoneName": "ZoneName managed by Terraform" - } - ], - "tags": [] -} diff --git a/internal/service/advancedclustertpf/testdata/replicaset_create_resp1.json b/internal/service/advancedclustertpf/testdata/replicaset_create_resp1.json deleted file mode 100644 index 09deb4d687..0000000000 --- a/internal/service/advancedclustertpf/testdata/replicaset_create_resp1.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "backupEnabled": true, - "biConnector": { - "enabled": false, - "readPreference": "secondary" - }, - "clusterType": "REPLICASET", - "connectionStrings": {}, - "createDate": "2024-11-06T06:52:28Z", - "diskWarmingMode": "FULLY_WARMED", - "encryptionAtRestProvider": "NONE", - "globalClusterSelfManagedSharding": false, - "groupId": "111111111111111111111111", - "id": "672b122c5ed804369706f178", - "labels": [], - "links": [ - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/atlas-init", - "rel": "self" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/atlas-init/backup/restoreJobs", - "rel": "https://cloud.mongodb.com/restoreJobs" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/atlas-init/backup/snapshots", - "rel": "https://cloud.mongodb.com/snapshots" - } - ], - "mongoDBMajorVersion": "7.0", - "mongoDBVersion": "7.0.15", - "name": "test", - "paused": false, - "pitEnabled": false, - "redactClientLogData": false, - "replicationSpecs": [ - { - "id": "672b122c5ed804369706f16e", - "regionConfigs": [ - { - "analyticsSpecs": { - "instanceSize": "M10", - "diskIOPS": 3000, - "diskSizeGB": 10.0, - "ebsVolumeType": "STANDARD", - "nodeCount": 0 - }, - "autoScaling": { - "compute": { - "enabled": false, - "scaleDownEnabled": false - }, - "diskGB": { - "enabled": false - } - }, - "electableSpecs": { - "instanceSize": "M10", - "diskIOPS": 3000, - "diskSizeGB": 10.0, - "ebsVolumeType": "STANDARD", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "readOnlySpecs": { - "instanceSize": "M10", - "diskIOPS": 3000, - "diskSizeGB": 10.0, - "ebsVolumeType": "STANDARD", - "nodeCount": 0 - }, - "regionName": "US_EAST_1" - } - ], - "zoneId": "672b122c5ed804369706f16c", - "zoneName": "ZoneName managed by Terraform" - } - ], - "rootCertType": "ISRGROOTX1", - "stateName": "CREATING", - "tags": [], - "terminationProtectionEnabled": false, - "versionReleaseSystem": "LTS" -} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/replicaset_create_resp1_final.json b/internal/service/advancedclustertpf/testdata/replicaset_create_resp1_final.json deleted file mode 100644 index e4cbedaead..0000000000 --- a/internal/service/advancedclustertpf/testdata/replicaset_create_resp1_final.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "backupEnabled": true, - "biConnector": { - "enabled": false, - "readPreference": "secondary" - }, - "clusterType": "REPLICASET", - "connectionStrings": { - "standard": "mongodb://atlas-init-shard-00-00.jciib.mongodb-dev.net:27017,atlas-init-shard-00-01.jciib.mongodb-dev.net:27017,atlas-init-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-v8ck2g-shard-0", - "standardSrv": "mongodb+srv://atlas-init.jciib.mongodb-dev.net" - }, - "createDate": "2024-11-06T06:52:28Z", - "diskSizeGB": 10.0, - "diskWarmingMode": "FULLY_WARMED", - "encryptionAtRestProvider": "NONE", - "globalClusterSelfManagedSharding": false, - "groupId": "111111111111111111111111", - "id": "672b122c5ed804369706f178", - "labels": [], - "links": [ - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/atlas-init", - "rel": "self" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/atlas-init/backup/restoreJobs", - "rel": "https://cloud.mongodb.com/restoreJobs" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/atlas-init/backup/snapshots", - "rel": "https://cloud.mongodb.com/snapshots" - } - ], - "mongoDBMajorVersion": "7.0", - "mongoDBVersion": "7.0.15", - "name": "test", - "paused": false, - "pitEnabled": false, - "replicationSpecs": [ - { - "id": "672b122c5ed804369706f16d", - "numShards": 1, - "regionConfigs": [ - { - "analyticsSpecs": { - "instanceSize": "M10", - "diskIOPS": 3000, - "ebsVolumeType": "STANDARD", - "nodeCount": 0 - }, - "autoScaling": { - "compute": { - "enabled": false, - "scaleDownEnabled": false - }, - "diskGB": { - "enabled": false - } - }, - "electableSpecs": { - "instanceSize": "M10", - "diskIOPS": 3000, - "ebsVolumeType": "STANDARD", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "readOnlySpecs": { - "instanceSize": "M10", - "diskIOPS": 3000, - "ebsVolumeType": "STANDARD", - "nodeCount": 0 - }, - "regionName": "US_EAST_1" - } - ], - "zoneId": "672b122c5ed804369706f16c", - "zoneName": "ZoneName managed by Terraform" - } - ], - "rootCertType": "ISRGROOTX1", - "stateName": "IDLE", - "tags": [], - "terminationProtectionEnabled": false, - "versionReleaseSystem": "LTS" -} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/replicaset_update1.json b/internal/service/advancedclustertpf/testdata/replicaset_update1.json deleted file mode 100644 index 506485b4e3..0000000000 --- a/internal/service/advancedclustertpf/testdata/replicaset_update1.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "acceptDataRisksAndForceReplicaSetReconfig": "2006-01-02T15:04:05Z" -} diff --git a/internal/service/advancedclustertpf/testdata/replicaset_update1_resp.json b/internal/service/advancedclustertpf/testdata/replicaset_update1_resp.json deleted file mode 100644 index 6c9be39cad..0000000000 --- a/internal/service/advancedclustertpf/testdata/replicaset_update1_resp.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "acceptDataRisksAndForceReplicaSetReconfig": "2006-01-02T15:04:05Z", - "backupEnabled": true, - "biConnector": { - "enabled": false, - "readPreference": "secondary" - }, - "clusterType": "REPLICASET", - "connectionStrings": {}, - "createDate": "2024-11-06T06:52:28Z", - "diskWarmingMode": "FULLY_WARMED", - "encryptionAtRestProvider": "NONE", - "globalClusterSelfManagedSharding": false, - "groupId": "111111111111111111111111", - "id": "672b122c5ed804369706f178", - "labels": [], - "links": [ - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/atlas-init", - "rel": "self" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/atlas-init/backup/restoreJobs", - "rel": "https://cloud.mongodb.com/restoreJobs" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/atlas-init/backup/snapshots", - "rel": "https://cloud.mongodb.com/snapshots" - } - ], - "mongoDBMajorVersion": "7.0", - "mongoDBVersion": "7.0.15", - "name": "test", - "paused": false, - "pitEnabled": false, - "redactClientLogData": false, - "replicationSpecs": [ - { - "id": "672b122c5ed804369706f16e", - "regionConfigs": [ - { - "analyticsSpecs": { - "instanceSize": "M10", - "diskIOPS": 3000, - "diskSizeGB": 10.0, - "ebsVolumeType": "STANDARD", - "nodeCount": 0 - }, - "autoScaling": { - "compute": { - "enabled": false, - "scaleDownEnabled": false - }, - "diskGB": { - "enabled": false - } - }, - "electableSpecs": { - "instanceSize": "M10", - "diskIOPS": 3000, - "diskSizeGB": 10.0, - "ebsVolumeType": "STANDARD", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "readOnlySpecs": { - "instanceSize": "M10", - "diskIOPS": 3000, - "diskSizeGB": 10.0, - "ebsVolumeType": "STANDARD", - "nodeCount": 0 - }, - "regionName": "US_EAST_1" - } - ], - "zoneId": "672b122c5ed804369706f16c", - "zoneName": "ZoneName managed by Terraform" - } - ], - "rootCertType": "ISRGROOTX1", - "stateName": "CREATING", - "tags": [], - "terminationProtectionEnabled": false, - "versionReleaseSystem": "LTS" -} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/replicaset_update2.json b/internal/service/advancedclustertpf/testdata/replicaset_update2.json deleted file mode 100644 index 9275b30174..0000000000 --- a/internal/service/advancedclustertpf/testdata/replicaset_update2.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "backupEnabled": false, - "biConnector": { - "enabled": true, - "readPreference": "secondary" - }, - "configServerManagementMode": "ATLAS_MANAGED", - "labels": [ - { - "key": "env", - "value": "test" - } - ], - "mongoDBMajorVersion": "8.0", - "paused": true, - "pitEnabled": true, - "redactClientLogData": true, - "replicaSetScalingStrategy": "NODE_TYPE", - "tags": [ - { - "key": "env", - "value": "test" - } - ], - "terminationProtectionEnabled": true, - "versionReleaseSystem": "CONTINUOUS" -} diff --git a/internal/service/advancedclustertpf/testdata/replicaset_update2_resp.json b/internal/service/advancedclustertpf/testdata/replicaset_update2_resp.json deleted file mode 100644 index e1f0de5409..0000000000 --- a/internal/service/advancedclustertpf/testdata/replicaset_update2_resp.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "backupEnabled": false, - "biConnector": { - "enabled": true, - "readPreference": "secondary" - }, - "clusterType": "REPLICASET", - "configServerManagementMode": "ATLAS_MANAGED", - "connectionStrings": { - "standard": "mongodb://test-shard-00-00.jciib.mongodb-dev.net:27017,test-shard-00-01.jciib.mongodb-dev.net:27017,test-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0", - "standardSrv": "mongodb+srv://test.jciib.mongodb-dev.net" - }, - "createDate": "2024-11-06T06:52:28Z", - "diskWarmingMode": "FULLY_WARMED", - "encryptionAtRestProvider": "NONE", - "globalClusterSelfManagedSharding": false, - "groupId": "111111111111111111111111", - "id": "672b122c5ed804369706f178", - "labels": [ - { - "key": "env", - "value": "test" - } - ], - "links": [ - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/test", - "rel": "self" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/test/backup/restoreJobs", - "rel": "https://cloud.mongodb.com/restoreJobs" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/test/backup/snapshots", - "rel": "https://cloud.mongodb.com/snapshots" - } - ], - "mongoDBMajorVersion": "8.0", - "mongoDBVersion": "8.0.3", - "name": "test", - "paused": true, - "pitEnabled": true, - "redactClientLogData": true, - "replicaSetScalingStrategy": "NODE_TYPE", - "replicationSpecs": [ - { - "id": "6735ffbafb2c0b6431487b84", - "regionConfigs": [ - { - "analyticsSpecs": { - "instanceSize": "M10", - "diskIOPS": 3000, - "diskSizeGB": 10.0, - "ebsVolumeType": "STANDARD", - "nodeCount": 0 - }, - "autoScaling": { - "compute": { - "enabled": false, - "scaleDownEnabled": false - }, - "diskGB": { - "enabled": false - } - }, - "electableSpecs": { - "instanceSize": "M10", - "diskIOPS": 3000, - "diskSizeGB": 10.0, - "ebsVolumeType": "STANDARD", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "readOnlySpecs": { - "instanceSize": "M10", - "diskIOPS": 3000, - "diskSizeGB": 10.0, - "ebsVolumeType": "STANDARD", - "nodeCount": 0 - }, - "regionName": "US_EAST_1" - } - ], - "zoneId": "6735ffbafb2c0b6431487b82", - "zoneName": "ZoneName managed by Terraform" - } - ], - "rootCertType": "ISRGROOTX1", - "stateName": "UPDATING", - "tags": [ - { - "key": "env", - "value": "test" - } - ], - "terminationProtectionEnabled": true, - "versionReleaseSystem": "CONTINUOUS" -} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/replicaset_update2_resp_final.json b/internal/service/advancedclustertpf/testdata/replicaset_update2_resp_final.json deleted file mode 100644 index f6983adb5d..0000000000 --- a/internal/service/advancedclustertpf/testdata/replicaset_update2_resp_final.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "backupEnabled": false, - "biConnector": { - "enabled": true, - "readPreference": "secondary" - }, - "clusterType": "REPLICASET", - "configServerManagementMode": "ATLAS_MANAGED", - "connectionStrings": { - "standard": "mongodb://test-shard-00-00.jciib.mongodb-dev.net:27017,test-shard-00-01.jciib.mongodb-dev.net:27017,test-shard-00-02.jciib.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-h20vfw-shard-0", - "standardSrv": "mongodb+srv://test.jciib.mongodb-dev.net" - }, - "createDate": "2024-11-06T06:52:28Z", - "diskWarmingMode": "FULLY_WARMED", - "encryptionAtRestProvider": "NONE", - "globalClusterSelfManagedSharding": false, - "groupId": "111111111111111111111111", - "id": "672b122c5ed804369706f178", - "labels": [ - { - "key": "env", - "value": "test" - } - ], - "links": [ - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/test", - "rel": "self" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/test/backup/restoreJobs", - "rel": "https://cloud.mongodb.com/restoreJobs" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/test/backup/snapshots", - "rel": "https://cloud.mongodb.com/snapshots" - } - ], - "mongoDBMajorVersion": "8.0", - "mongoDBVersion": "8.0.3", - "name": "test", - "paused": true, - "pitEnabled": true, - "redactClientLogData": true, - "replicaSetScalingStrategy": "NODE_TYPE", - "replicationSpecs": [ - { - "id": "6735ffbafb2c0b6431487b83", - "regionConfigs": [ - { - "analyticsSpecs": { - "instanceSize": "M10", - "diskIOPS": 3000, - "diskSizeGB": 10.0, - "ebsVolumeType": "STANDARD", - "nodeCount": 0 - }, - "autoScaling": { - "compute": { - "enabled": false, - "scaleDownEnabled": false - }, - "diskGB": { - "enabled": false - } - }, - "electableSpecs": { - "instanceSize": "M10", - "diskIOPS": 3000, - "diskSizeGB": 10.0, - "ebsVolumeType": "STANDARD", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "readOnlySpecs": { - "instanceSize": "M10", - "diskIOPS": 3000, - "diskSizeGB": 10.0, - "ebsVolumeType": "STANDARD", - "nodeCount": 0 - }, - "regionName": "US_EAST_1" - } - ], - "zoneId": "6735ffbafb2c0b6431487b82", - "zoneName": "ZoneName managed by Terraform" - } - ], - "rootCertType": "ISRGROOTX1", - "stateName": "IDLE", - "tags": [ - { - "key": "env", - "value": "test" - } - ], - "terminationProtectionEnabled": true, - "versionReleaseSystem": "CONTINUOUS" -} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/sharded_create.json b/internal/service/advancedclustertpf/testdata/sharded_create.json deleted file mode 100644 index d78fa83f25..0000000000 --- a/internal/service/advancedclustertpf/testdata/sharded_create.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "clusterType": "SHARDED", - "groupId": "111111111111111111111111", - "labels": [], - "name": "sharded-multi-replication", - "replicationSpecs": [ - { - "regionConfigs": [ - { - "electableSpecs": { - "diskIOPS": 2000, - "ebsVolumeType": "PROVISIONED", - "instanceSize": "M30", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "regionName": "EU_WEST_1" - } - ], - "zoneName": "ZoneName managed by Terraform" - }, - { - "regionConfigs": [ - { - "electableSpecs": { - "diskIOPS": 1000, - "ebsVolumeType": "PROVISIONED", - "instanceSize": "M30", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "regionName": "EU_WEST_1" - } - ], - "zoneName": "ZoneName managed by Terraform" - } - ], - "tags": [] -} diff --git a/internal/service/advancedclustertpf/testdata/sharded_create_resp1.json b/internal/service/advancedclustertpf/testdata/sharded_create_resp1.json deleted file mode 100644 index a802c24b0e..0000000000 --- a/internal/service/advancedclustertpf/testdata/sharded_create_resp1.json +++ /dev/null @@ -1,132 +0,0 @@ -{ - "backupEnabled": true, - "biConnector": { - "enabled": false, - "readPreference": "secondary" - }, - "clusterType": "SHARDED", - "configServerManagementMode": "ATLAS_MANAGED", - "configServerType": "DEDICATED", - "connectionStrings": { - "awsPrivateLinkSrv": {}, - "privateEndpoint": [] - }, - "createDate": "2024-11-14T08:17:47Z", - "diskWarmingMode": "FULLY_WARMED", - "encryptionAtRestProvider": "NONE", - "globalClusterSelfManagedSharding": false, - "groupId": "111111111111111111111111", - "id": "6735b22b3549b05320e92662", - "labels": [], - "links": [ - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/sharded-multi-replication", - "rel": "self" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/sharded-multi-replication/backup/restoreJobs", - "rel": "https://cloud.mongodb.com/restoreJobs" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/sharded-multi-replication/backup/snapshots", - "rel": "https://cloud.mongodb.com/snapshots" - } - ], - "mongoDBMajorVersion": "7.0", - "mongoDBVersion": "7.0.15", - "name": "sharded-multi-replication", - "paused": false, - "pitEnabled": false, - "redactClientLogData": false, - "replicationSpecs": [ - { - "id": "6735b22a3549b05320e9264e", - "regionConfigs": [ - { - "analyticsSpecs": { - "instanceSize": "M30", - "diskIOPS": 2000, - "diskSizeGB": 40.0, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 0 - }, - "autoScaling": { - "compute": { - "enabled": false, - "scaleDownEnabled": false - }, - "diskGB": { - "enabled": false - } - }, - "electableSpecs": { - "instanceSize": "M30", - "diskIOPS": 2000, - "diskSizeGB": 40.0, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "readOnlySpecs": { - "instanceSize": "M30", - "diskIOPS": 2000, - "diskSizeGB": 40.0, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 0 - }, - "regionName": "EU_WEST_1" - } - ], - "zoneId": "6735b22a3549b05320e9264c", - "zoneName": "ZoneName managed by Terraform" - }, - { - "id": "6735b22a3549b05320e92650", - "regionConfigs": [ - { - "analyticsSpecs": { - "instanceSize": "M30", - "diskIOPS": 1000, - "diskSizeGB": 40.0, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 0 - }, - "autoScaling": { - "compute": { - "enabled": false, - "scaleDownEnabled": false - }, - "diskGB": { - "enabled": false - } - }, - "electableSpecs": { - "instanceSize": "M30", - "diskIOPS": 1000, - "diskSizeGB": 40.0, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "readOnlySpecs": { - "instanceSize": "M30", - "diskIOPS": 1000, - "diskSizeGB": 40.0, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 0 - }, - "regionName": "EU_WEST_1" - } - ], - "zoneId": "6735b22a3549b05320e9264c", - "zoneName": "ZoneName managed by Terraform" - } - ], - "rootCertType": "ISRGROOTX1", - "stateName": "CREATING", - "terminationProtectionEnabled": false, - "tags": [], - "versionReleaseSystem": "LTS" -} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/sharded_create_resp1_final.json b/internal/service/advancedclustertpf/testdata/sharded_create_resp1_final.json deleted file mode 100644 index f3061403dc..0000000000 --- a/internal/service/advancedclustertpf/testdata/sharded_create_resp1_final.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "backupEnabled": true, - "biConnector": { - "enabled": false, - "readPreference": "secondary" - }, - "clusterType": "SHARDED", - "configServerManagementMode": "ATLAS_MANAGED", - "configServerType": "DEDICATED", - "connectionStrings": { - "awsPrivateLinkSrv": {}, - "privateEndpoint": [], - "standard": "mongodb://sharded-multi-replicati-shard-00-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-02.jciib.mongodb-dev.net:27016/?ssl=true&authSource=admin", - "standardSrv": "mongodb+srv://sharded-multi-replicati.jciib.mongodb-dev.net" - }, - "createDate": "2024-11-14T08:17:47Z", - "diskSizeGB": 40.0, - "diskWarmingMode": "FULLY_WARMED", - "encryptionAtRestProvider": "NONE", - "globalClusterSelfManagedSharding": false, - "groupId": "111111111111111111111111", - "id": "6735b22b3549b05320e92662", - "labels": [], - "links": [ - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/sharded-multi-replication", - "rel": "self" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/sharded-multi-replication/backup/restoreJobs", - "rel": "https://cloud.mongodb.com/restoreJobs" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/sharded-multi-replication/backup/snapshots", - "rel": "https://cloud.mongodb.com/snapshots" - } - ], - "mongoDBMajorVersion": "7.0", - "mongoDBVersion": "7.0.15", - "name": "sharded-multi-replication", - "paused": false, - "pitEnabled": false, - "replicationSpecs": [ - { - "id": "6735b22a3549b05320e9264d", - "numShards": 2, - "regionConfigs": [ - { - "analyticsSpecs": { - "instanceSize": "M30", - "diskIOPS": 2000, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 0 - }, - "autoScaling": { - "compute": { - "enabled": false, - "scaleDownEnabled": false - }, - "diskGB": { - "enabled": false - } - }, - "electableSpecs": { - "instanceSize": "M30", - "diskIOPS": 2000, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "readOnlySpecs": { - "instanceSize": "M30", - "diskIOPS": 2000, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 0 - }, - "regionName": "EU_WEST_1" - } - ], - "zoneId": "6735b22a3549b05320e9264c", - "zoneName": "ZoneName managed by Terraform" - } - ], - "rootCertType": "ISRGROOTX1", - "stateName": "IDLE", - "tags": [], - "terminationProtectionEnabled": false, - "versionReleaseSystem": "LTS" -} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/sharded_update1.json b/internal/service/advancedclustertpf/testdata/sharded_update1.json deleted file mode 100644 index b3fc1d1cbd..0000000000 --- a/internal/service/advancedclustertpf/testdata/sharded_update1.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "replicationSpecs": [ - { - "id": "6735b22a3549b05320e9264e", - "regionConfigs": [ - { - "electableSpecs": { - "diskSizeGB": 40, - "diskIOPS": 2000, - "ebsVolumeType": "PROVISIONED", - "instanceSize": "M30", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "regionName": "EU_WEST_1", - "analyticsSpecs": { - "diskSizeGB": 40, - "nodeCount": 1, - "diskIOPS": 2000, - "ebsVolumeType": "PROVISIONED", - "instanceSize": "M30" - }, - "autoScaling": { - "compute": { - "enabled": false, - "scaleDownEnabled": false - }, - "diskGB": { - "enabled": true - } - }, - "readOnlySpecs": { - "diskSizeGB": 40, - "nodeCount": 0, - "diskIOPS": 2000, - "ebsVolumeType": "PROVISIONED", - "instanceSize": "M30" - } - } - ], - "zoneId": "6735b22a3549b05320e9264c", - "zoneName": "ZoneName managed by Terraform" - }, - { - "id": "6735b22a3549b05320e92650", - "regionConfigs": [ - { - "electableSpecs": { - "diskSizeGB": 40, - "diskIOPS": 1000, - "ebsVolumeType": "PROVISIONED", - "instanceSize": "M30", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "regionName": "EU_WEST_1", - "analyticsSpecs": { - "diskSizeGB": 40, - "nodeCount": 1, - "diskIOPS": 1000, - "ebsVolumeType": "PROVISIONED", - "instanceSize": "M30" - }, - "autoScaling": { - "compute": { - "enabled": false, - "scaleDownEnabled": false - }, - "diskGB": { - "enabled": false - } - }, - "readOnlySpecs": { - "diskSizeGB": 40, - "nodeCount": 0, - "diskIOPS": 1000, - "ebsVolumeType": "PROVISIONED", - "instanceSize": "M30" - } - } - ], - "zoneId": "6735b22a3549b05320e9264c", - "zoneName": "ZoneName managed by Terraform" - } - ] -} diff --git a/internal/service/advancedclustertpf/testdata/sharded_update_resp1.json b/internal/service/advancedclustertpf/testdata/sharded_update_resp1.json deleted file mode 100644 index e88fd7396d..0000000000 --- a/internal/service/advancedclustertpf/testdata/sharded_update_resp1.json +++ /dev/null @@ -1,134 +0,0 @@ -{ - "backupEnabled": true, - "biConnector": { - "enabled": false, - "readPreference": "secondary" - }, - "clusterType": "SHARDED", - "configServerManagementMode": "ATLAS_MANAGED", - "configServerType": "DEDICATED", - "connectionStrings": { - "awsPrivateLinkSrv": {}, - "privateEndpoint": [], - "standard": "mongodb://sharded-multi-replicati-shard-00-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-02.jciib.mongodb-dev.net:27016/?ssl=true&authSource=admin", - "standardSrv": "mongodb+srv://sharded-multi-replicati.jciib.mongodb-dev.net" - }, - "createDate": "2024-11-14T08:17:47Z", - "diskWarmingMode": "FULLY_WARMED", - "encryptionAtRestProvider": "NONE", - "globalClusterSelfManagedSharding": false, - "groupId": "111111111111111111111111", - "id": "6735b22b3549b05320e92662", - "labels": [], - "links": [ - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/sharded-multi-replication", - "rel": "self" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/sharded-multi-replication/backup/restoreJobs", - "rel": "https://cloud.mongodb.com/restoreJobs" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/sharded-multi-replication/backup/snapshots", - "rel": "https://cloud.mongodb.com/snapshots" - } - ], - "mongoDBMajorVersion": "7.0", - "mongoDBVersion": "7.0.15", - "name": "sharded-multi-replication", - "paused": false, - "pitEnabled": false, - "redactClientLogData": false, - "replicationSpecs": [ - { - "id": "6735b22a3549b05320e9264e", - "regionConfigs": [ - { - "analyticsSpecs": { - "instanceSize": "M30", - "diskIOPS": 2000, - "diskSizeGB": 40.0, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 1 - }, - "autoScaling": { - "compute": { - "enabled": false, - "scaleDownEnabled": false - }, - "diskGB": { - "enabled": true - } - }, - "electableSpecs": { - "instanceSize": "M30", - "diskIOPS": 2000, - "diskSizeGB": 40.0, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "readOnlySpecs": { - "instanceSize": "M30", - "diskIOPS": 2000, - "diskSizeGB": 40.0, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 0 - }, - "regionName": "EU_WEST_1" - } - ], - "zoneId": "6735b22a3549b05320e9264c", - "zoneName": "ZoneName managed by Terraform" - }, - { - "id": "6735b22a3549b05320e92650", - "regionConfigs": [ - { - "analyticsSpecs": { - "instanceSize": "M30", - "diskIOPS": 1000, - "diskSizeGB": 40.0, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 1 - }, - "autoScaling": { - "compute": { - "enabled": false, - "scaleDownEnabled": false - }, - "diskGB": { - "enabled": true - } - }, - "electableSpecs": { - "instanceSize": "M30", - "diskIOPS": 1000, - "diskSizeGB": 40.0, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "readOnlySpecs": { - "instanceSize": "M30", - "diskIOPS": 1000, - "diskSizeGB": 40.0, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 0 - }, - "regionName": "EU_WEST_1" - } - ], - "zoneId": "6735b22a3549b05320e9264c", - "zoneName": "ZoneName managed by Terraform" - } - ], - "rootCertType": "ISRGROOTX1", - "stateName": "UPDATING", - "tags": [], - "terminationProtectionEnabled": false, - "versionReleaseSystem": "LTS" -} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/sharded_update_resp1_final.json b/internal/service/advancedclustertpf/testdata/sharded_update_resp1_final.json deleted file mode 100644 index 81e9900609..0000000000 --- a/internal/service/advancedclustertpf/testdata/sharded_update_resp1_final.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "backupEnabled": true, - "biConnector": { - "enabled": false, - "readPreference": "secondary" - }, - "clusterType": "SHARDED", - "configServerManagementMode": "ATLAS_MANAGED", - "configServerType": "DEDICATED", - "connectionStrings": { - "awsPrivateLinkSrv": {}, - "privateEndpoint": [], - "standard": "mongodb://sharded-multi-replicati-shard-00-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-00-03.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-00.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-01.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-02.jciib.mongodb-dev.net:27016,sharded-multi-replicati-shard-01-03.jciib.mongodb-dev.net:27016/?ssl=true&authSource=admin", - "standardSrv": "mongodb+srv://sharded-multi-replicati.jciib.mongodb-dev.net" - }, - "createDate": "2024-11-14T08:17:47Z", - "diskSizeGB": 40.0, - "diskWarmingMode": "FULLY_WARMED", - "encryptionAtRestProvider": "NONE", - "globalClusterSelfManagedSharding": false, - "groupId": "111111111111111111111111", - "id": "6735b22b3549b05320e92662", - "labels": [], - "links": [ - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/sharded-multi-replication", - "rel": "self" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/sharded-multi-replication/backup/restoreJobs", - "rel": "https://cloud.mongodb.com/restoreJobs" - }, - { - "href": "https://cloud-dev.mongodb.com/api/atlas/v2/groups/111111111111111111111111/clusters/sharded-multi-replication/backup/snapshots", - "rel": "https://cloud.mongodb.com/snapshots" - } - ], - "mongoDBMajorVersion": "7.0", - "mongoDBVersion": "7.0.15", - "name": "sharded-multi-replication", - "paused": false, - "pitEnabled": false, - "replicationSpecs": [ - { - "id": "6735b22a3549b05320e9264d", - "numShards": 2, - "regionConfigs": [ - { - "analyticsSpecs": { - "instanceSize": "M30", - "diskIOPS": 2000, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 1 - }, - "autoScaling": { - "compute": { - "enabled": false, - "scaleDownEnabled": false - }, - "diskGB": { - "enabled": true - } - }, - "electableSpecs": { - "instanceSize": "M30", - "diskIOPS": 2000, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 3 - }, - "priority": 7, - "providerName": "AWS", - "readOnlySpecs": { - "instanceSize": "M30", - "diskIOPS": 2000, - "ebsVolumeType": "PROVISIONED", - "nodeCount": 0 - }, - "regionName": "EU_WEST_1" - } - ], - "zoneId": "6735b22a3549b05320e9264c", - "zoneName": "ZoneName managed by Terraform" - } - ], - "rootCertType": "ISRGROOTX1", - "stateName": "IDLE", - "tags": [], - "terminationProtectionEnabled": false, - "versionReleaseSystem": "LTS" -} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/validate_schema.go b/internal/service/advancedclustertpf/validate_schema.go new file mode 100644 index 0000000000..71cf4abdd7 --- /dev/null +++ b/internal/service/advancedclustertpf/validate_schema.go @@ -0,0 +1,84 @@ +package advancedclustertpf + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +var defaultMongoDBMajorVersion = "8.0" + +func PlanMustUseMongoDBVersion(version float64, operator MajorVersionOperator) FailOnIncompatibleMongoDBVersion { + return FailOnIncompatibleMongoDBVersion{ + Version: version, + Operator: operator, + } +} + +type FailOnIncompatibleMongoDBVersion struct { + Version float64 + Operator MajorVersionOperator +} + +func (v FailOnIncompatibleMongoDBVersion) Description(ctx context.Context) string { + return v.MarkdownDescription(ctx) +} + +func (v FailOnIncompatibleMongoDBVersion) MarkdownDescription(_ context.Context) string { + switch v.Operator { + case EqualOrHigher: + return fmt.Sprintf("can only be configured if the mongo_db_major_version is %.1f or higher", v.Version) + case Higher: + return fmt.Sprintf("can only be configured if the mongo_db_major_version is higher than %.1f", v.Version) + case EqualOrLower: + return fmt.Sprintf("can only be configured if the mongo_db_major_version is %.1f or lower", v.Version) + case Lower: + return fmt.Sprintf("can only be configured if the mongo_db_major_version is lower than %.1f", v.Version) + default: + return "unknown operator used" + } +} + +func (v FailOnIncompatibleMongoDBVersion) PlanModifyInt64(ctx context.Context, req planmodifier.Int64Request, resp *planmodifier.Int64Response) { + if req.ConfigValue.IsUnknown() || req.ConfigValue.IsNull() { + return + } + performValidation(ctx, &req.State, &req.Plan, &resp.Diagnostics, v, req.Path) +} + +func (v FailOnIncompatibleMongoDBVersion) PlanModifyBool(ctx context.Context, req planmodifier.BoolRequest, resp *planmodifier.BoolResponse) { + if req.ConfigValue.IsUnknown() || req.ConfigValue.IsNull() { + return + } + performValidation(ctx, &req.State, &req.Plan, &resp.Diagnostics, v, req.Path) +} + +func performValidation(ctx context.Context, state *tfsdk.State, plan *tfsdk.Plan, diags *diag.Diagnostics, v FailOnIncompatibleMongoDBVersion, validationPath path.Path) { + var mongoDbMajorVersion types.String + var mongoDbMajorVersionState types.String + diags.Append(plan.GetAttribute(ctx, path.Root("mongo_db_major_version"), &mongoDbMajorVersion)...) + diags.Append(state.GetAttribute(ctx, path.Root("mongo_db_major_version"), &mongoDbMajorVersionState)...) + if diags.HasError() { + return + } + mongoDbMajorVersionString := mongoDbMajorVersion.ValueString() + if mongoDbMajorVersionString == "" { + mongoDbMajorVersionString = mongoDbMajorVersionState.ValueString() + } + if mongoDbMajorVersionString == "" { + mongoDbMajorVersionString = defaultMongoDBMajorVersion + } + isCompatible := MajorVersionCompatible(&mongoDbMajorVersionString, v.Version, v.Operator) + if isCompatible == nil { + diags.AddWarning("Unable to parse mongo_db_major_version", "") + return + } + if !*isCompatible { + diags.AddError(fmt.Sprintf("`%s` %s", validationPath, v.Description(ctx)), "") + } +} diff --git a/internal/service/alertconfiguration/data_source_alert_configuration.go b/internal/service/alertconfiguration/data_source_alert_configuration.go index a43e8ef6de..4a9e812c6c 100644 --- a/internal/service/alertconfiguration/data_source_alert_configuration.go +++ b/internal/service/alertconfiguration/data_source_alert_configuration.go @@ -14,7 +14,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/zclconf/go-cty/cty" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) var _ datasource.DataSource = &alertConfigurationDS{} diff --git a/internal/service/alertconfiguration/data_source_alert_configurations.go b/internal/service/alertconfiguration/data_source_alert_configurations.go index 24bfaebb9c..e2bf39a871 100644 --- a/internal/service/alertconfiguration/data_source_alert_configurations.go +++ b/internal/service/alertconfiguration/data_source_alert_configurations.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const alertConfigurationsDataSourceName = "alert_configurations" diff --git a/internal/service/alertconfiguration/model_alert_configuration.go b/internal/service/alertconfiguration/model_alert_configuration.go index cd1d6d999e..311310a0d1 100644 --- a/internal/service/alertconfiguration/model_alert_configuration.go +++ b/internal/service/alertconfiguration/model_alert_configuration.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-framework/types" diff --git a/internal/service/alertconfiguration/model_alert_configuration_test.go b/internal/service/alertconfiguration/model_alert_configuration_test.go index a1ca859613..80d9d7d36c 100644 --- a/internal/service/alertconfiguration/model_alert_configuration_test.go +++ b/internal/service/alertconfiguration/model_alert_configuration_test.go @@ -7,7 +7,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/alertconfiguration" "github.com/stretchr/testify/assert" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/alertconfiguration/resource_alert_configuration.go b/internal/service/alertconfiguration/resource_alert_configuration.go index 0203888d74..a5fbbbfb2b 100644 --- a/internal/service/alertconfiguration/resource_alert_configuration.go +++ b/internal/service/alertconfiguration/resource_alert_configuration.go @@ -6,7 +6,7 @@ import ( "reflect" "strings" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" diff --git a/internal/service/apikey/data_source_api_keys.go b/internal/service/apikey/data_source_api_keys.go index 0998c6e192..7381d8104b 100644 --- a/internal/service/apikey/data_source_api_keys.go +++ b/internal/service/apikey/data_source_api_keys.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { diff --git a/internal/service/apikey/resource_api_key.go b/internal/service/apikey/resource_api_key.go index 4b7dcdc684..1fa728a4f6 100644 --- a/internal/service/apikey/resource_api_key.go +++ b/internal/service/apikey/resource_api_key.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func Resource() *schema.Resource { @@ -76,7 +76,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. } if err := d.Set("private_key", apiKey.GetPrivateKey()); err != nil { - return diag.FromErr(fmt.Errorf("error setting `public_key`: %s", err)) + return diag.FromErr(fmt.Errorf("error setting `private_key`: %s", err)) } d.SetId(conversion.EncodeStateID(map[string]string{ diff --git a/internal/service/atlasuser/data_source_atlas_user.go b/internal/service/atlasuser/data_source_atlas_user.go index 4c4f3dcecc..5637a82534 100644 --- a/internal/service/atlasuser/data_source_atlas_user.go +++ b/internal/service/atlasuser/data_source_atlas_user.go @@ -10,9 +10,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" + "go.mongodb.org/atlas-sdk/v20241113003/admin" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" ) const ( @@ -137,6 +138,7 @@ func (d *atlasUserDS) Schema(ctx context.Context, req datasource.SchemaRequest, }, }, } + conversion.UpdateSchemaDescription(&resp.Schema) } func (d *atlasUserDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/service/atlasuser/data_source_atlas_user_test.go b/internal/service/atlasuser/data_source_atlas_user_test.go index 2bfaca068d..6c52c79da8 100644 --- a/internal/service/atlasuser/data_source_atlas_user_test.go +++ b/internal/service/atlasuser/data_source_atlas_user_test.go @@ -8,9 +8,10 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "go.mongodb.org/atlas-sdk/v20241113003/admin" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" - "go.mongodb.org/atlas-sdk/v20241023002/admin" ) func TestAccConfigDSAtlasUser_ByUserID(t *testing.T) { diff --git a/internal/service/atlasuser/data_source_atlas_users.go b/internal/service/atlasuser/data_source_atlas_users.go index fada235fd6..140b67e7f7 100644 --- a/internal/service/atlasuser/data_source_atlas_users.go +++ b/internal/service/atlasuser/data_source_atlas_users.go @@ -4,6 +4,8 @@ import ( "context" "fmt" + "go.mongodb.org/atlas-sdk/v20241113003/admin" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -13,7 +15,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" ) const ( @@ -158,6 +159,7 @@ func (d *atlasUsersDS) Schema(ctx context.Context, req datasource.SchemaRequest, }, }, } + conversion.UpdateSchemaDescription(&resp.Schema) } func (d *atlasUsersDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/service/atlasuser/data_source_atlas_users_test.go b/internal/service/atlasuser/data_source_atlas_users_test.go index bf52b97f2b..1f534403b8 100644 --- a/internal/service/atlasuser/data_source_atlas_users_test.go +++ b/internal/service/atlasuser/data_source_atlas_users_test.go @@ -9,9 +9,10 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" + "go.mongodb.org/atlas-sdk/v20241113003/admin" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/atlasuser" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" - "go.mongodb.org/atlas-sdk/v20241023002/admin" ) func TestAccConfigDSAtlasUsers_ByOrgID(t *testing.T) { diff --git a/internal/service/auditing/resource_auditing.go b/internal/service/auditing/resource_auditing.go index 3fe983eaaa..557bfe9089 100644 --- a/internal/service/auditing/resource_auditing.go +++ b/internal/service/auditing/resource_auditing.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/backupcompliancepolicy/resource_backup_compliance_policy.go b/internal/service/backupcompliancepolicy/resource_backup_compliance_policy.go index 1b3fd7d3a9..b7ffea9e41 100644 --- a/internal/service/backupcompliancepolicy/resource_backup_compliance_policy.go +++ b/internal/service/backupcompliancepolicy/resource_backup_compliance_policy.go @@ -8,7 +8,7 @@ import ( "net/http" "strings" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/internal/service/cloudbackupschedule/data_source_cloud_backup_schedule.go b/internal/service/cloudbackupschedule/data_source_cloud_backup_schedule.go index 456f161850..4dcbc1ebf1 100644 --- a/internal/service/cloudbackupschedule/data_source_cloud_backup_schedule.go +++ b/internal/service/cloudbackupschedule/data_source_cloud_backup_schedule.go @@ -8,7 +8,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/cloudbackupschedule/model_cloud_backup_schedule.go b/internal/service/cloudbackupschedule/model_cloud_backup_schedule.go index 1867bb68e4..b9ab739734 100644 --- a/internal/service/cloudbackupschedule/model_cloud_backup_schedule.go +++ b/internal/service/cloudbackupschedule/model_cloud_backup_schedule.go @@ -2,7 +2,7 @@ package cloudbackupschedule import ( admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func FlattenPolicyItem(items []admin.DiskBackupApiPolicyItem, frequencyType string) []map[string]any { diff --git a/internal/service/cloudbackupschedule/model_cloud_backup_schedule_test.go b/internal/service/cloudbackupschedule/model_cloud_backup_schedule_test.go index 53b5e8f047..13d85ecde9 100644 --- a/internal/service/cloudbackupschedule/model_cloud_backup_schedule_test.go +++ b/internal/service/cloudbackupschedule/model_cloud_backup_schedule_test.go @@ -6,7 +6,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cloudbackupschedule" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func TestFlattenPolicyItem(t *testing.T) { diff --git a/internal/service/cloudbackupschedule/model_sdk_version_conversion.go b/internal/service/cloudbackupschedule/model_sdk_version_conversion.go index baecfca6df..51e2098139 100644 --- a/internal/service/cloudbackupschedule/model_sdk_version_conversion.go +++ b/internal/service/cloudbackupschedule/model_sdk_version_conversion.go @@ -2,7 +2,7 @@ package cloudbackupschedule import ( admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) // Conversions from one SDK model version to another are used to avoid duplicating our flatten/expand conversion functions. diff --git a/internal/service/cloudbackupschedule/resource_cloud_backup_schedule.go b/internal/service/cloudbackupschedule/resource_cloud_backup_schedule.go index 6d51305d7f..352bae3762 100644 --- a/internal/service/cloudbackupschedule/resource_cloud_backup_schedule.go +++ b/internal/service/cloudbackupschedule/resource_cloud_backup_schedule.go @@ -14,7 +14,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/spf13/cast" admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/cloudbackupsnapshot/data_source_cloud_backup_snapshots.go b/internal/service/cloudbackupsnapshot/data_source_cloud_backup_snapshots.go index 2de7ad892b..281f5ba0d9 100644 --- a/internal/service/cloudbackupsnapshot/data_source_cloud_backup_snapshots.go +++ b/internal/service/cloudbackupsnapshot/data_source_cloud_backup_snapshots.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { diff --git a/internal/service/cloudbackupsnapshot/model_cloud_backup_snapshot.go b/internal/service/cloudbackupsnapshot/model_cloud_backup_snapshot.go index aba5b8954a..5bf40aa4c5 100644 --- a/internal/service/cloudbackupsnapshot/model_cloud_backup_snapshot.go +++ b/internal/service/cloudbackupsnapshot/model_cloud_backup_snapshot.go @@ -4,7 +4,7 @@ import ( "errors" "regexp" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func SplitSnapshotImportID(id string) (*admin.GetReplicaSetBackupApiParams, error) { diff --git a/internal/service/cloudbackupsnapshot/model_cloud_backup_snapshot_test.go b/internal/service/cloudbackupsnapshot/model_cloud_backup_snapshot_test.go index d9601d9311..15eab4f363 100644 --- a/internal/service/cloudbackupsnapshot/model_cloud_backup_snapshot_test.go +++ b/internal/service/cloudbackupsnapshot/model_cloud_backup_snapshot_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cloudbackupsnapshot" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func TestSplitSnapshotImportID(t *testing.T) { diff --git a/internal/service/cloudbackupsnapshot/resource_cloud_backup_snapshot.go b/internal/service/cloudbackupsnapshot/resource_cloud_backup_snapshot.go index 1a4fe8849b..c9074b695e 100644 --- a/internal/service/cloudbackupsnapshot/resource_cloud_backup_snapshot.go +++ b/internal/service/cloudbackupsnapshot/resource_cloud_backup_snapshot.go @@ -14,7 +14,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func Resource() *schema.Resource { diff --git a/internal/service/cloudbackupsnapshot/resource_cloud_backup_snapshot_test.go b/internal/service/cloudbackupsnapshot/resource_cloud_backup_snapshot_test.go index 3e306ddc60..35929cd691 100644 --- a/internal/service/cloudbackupsnapshot/resource_cloud_backup_snapshot_test.go +++ b/internal/service/cloudbackupsnapshot/resource_cloud_backup_snapshot_test.go @@ -113,7 +113,7 @@ func checkExists(resourceName string) resource.TestCheckFunc { return fmt.Errorf("cloudBackupSnapshot (%s) does not exist", rs.Primary.Attributes["snapshot_id"]) } // needed as first call to cluster with new API will fail due to transition to ISS feature flag - if err := acc.CheckClusterExistsHandlingRetry(ids["project_id"], ids["cluster_name"]); err != nil { + if err := acc.CheckExistsClusterHandlingRetry(ids["project_id"], ids["cluster_name"]); err != nil { return fmt.Errorf("cluster (%s : %s) does not exist", ids["project_id"], ids["cluster_name"]) } return nil diff --git a/internal/service/cloudbackupsnapshotexportbucket/data_source_cloud_backup_snapshot_export_buckets.go b/internal/service/cloudbackupsnapshotexportbucket/data_source_cloud_backup_snapshot_export_buckets.go index 5a7f5a0280..032ad6c44b 100644 --- a/internal/service/cloudbackupsnapshotexportbucket/data_source_cloud_backup_snapshot_export_buckets.go +++ b/internal/service/cloudbackupsnapshotexportbucket/data_source_cloud_backup_snapshot_export_buckets.go @@ -3,7 +3,7 @@ package cloudbackupsnapshotexportbucket import ( "context" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" diff --git a/internal/service/cloudbackupsnapshotexportbucket/resource_cloud_backup_snapshot_export_bucket.go b/internal/service/cloudbackupsnapshotexportbucket/resource_cloud_backup_snapshot_export_bucket.go index ea9cea71c8..edc86f034e 100644 --- a/internal/service/cloudbackupsnapshotexportbucket/resource_cloud_backup_snapshot_export_bucket.go +++ b/internal/service/cloudbackupsnapshotexportbucket/resource_cloud_backup_snapshot_export_bucket.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" diff --git a/internal/service/cloudbackupsnapshotexportjob/data_source_cloud_backup_snapshot_export_jobs.go b/internal/service/cloudbackupsnapshotexportjob/data_source_cloud_backup_snapshot_export_jobs.go index 25acb84a00..05790699a1 100644 --- a/internal/service/cloudbackupsnapshotexportjob/data_source_cloud_backup_snapshot_export_jobs.go +++ b/internal/service/cloudbackupsnapshotexportjob/data_source_cloud_backup_snapshot_export_jobs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { diff --git a/internal/service/cloudbackupsnapshotexportjob/resource_cloud_backup_snapshot_export_job.go b/internal/service/cloudbackupsnapshotexportjob/resource_cloud_backup_snapshot_export_job.go index 9e7862ca58..ea34d54c97 100644 --- a/internal/service/cloudbackupsnapshotexportjob/resource_cloud_backup_snapshot_export_job.go +++ b/internal/service/cloudbackupsnapshotexportjob/resource_cloud_backup_snapshot_export_job.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func Resource() *schema.Resource { diff --git a/internal/service/cloudbackupsnapshotrestorejob/data_source_cloud_backup_snapshot_restore_jobs.go b/internal/service/cloudbackupsnapshotrestorejob/data_source_cloud_backup_snapshot_restore_jobs.go index 0bde1b5f10..ba8de45e1f 100644 --- a/internal/service/cloudbackupsnapshotrestorejob/data_source_cloud_backup_snapshot_restore_jobs.go +++ b/internal/service/cloudbackupsnapshotrestorejob/data_source_cloud_backup_snapshot_restore_jobs.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { diff --git a/internal/service/cloudbackupsnapshotrestorejob/resource_cloud_backup_snapshot_restore_job.go b/internal/service/cloudbackupsnapshotrestorejob/resource_cloud_backup_snapshot_restore_job.go index 8318d97c1d..bb3f0ce5df 100644 --- a/internal/service/cloudbackupsnapshotrestorejob/resource_cloud_backup_snapshot_restore_job.go +++ b/internal/service/cloudbackupsnapshotrestorejob/resource_cloud_backup_snapshot_restore_job.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func Resource() *schema.Resource { diff --git a/internal/service/cloudprovideraccess/resource_cloud_provider_access_authorization.go b/internal/service/cloudprovideraccess/resource_cloud_provider_access_authorization.go index 2b7b7a0c8c..7f06839e49 100644 --- a/internal/service/cloudprovideraccess/resource_cloud_provider_access_authorization.go +++ b/internal/service/cloudprovideraccess/resource_cloud_provider_access_authorization.go @@ -12,7 +12,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) /* diff --git a/internal/service/cloudprovideraccess/resource_cloud_provider_access_setup.go b/internal/service/cloudprovideraccess/resource_cloud_provider_access_setup.go index bc604e96c3..decf93d192 100644 --- a/internal/service/cloudprovideraccess/resource_cloud_provider_access_setup.go +++ b/internal/service/cloudprovideraccess/resource_cloud_provider_access_setup.go @@ -6,7 +6,7 @@ import ( "net/http" "regexp" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/internal/service/cluster/data_source_cluster.go b/internal/service/cluster/data_source_cluster.go index a1154e48ca..6f92f4101d 100644 --- a/internal/service/cluster/data_source_cluster.go +++ b/internal/service/cluster/data_source_cluster.go @@ -319,6 +319,22 @@ func DataSource() *schema.Resource { Type: schema.TypeBool, Computed: true, }, + "pinned_fcv": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "version": { + Type: schema.TypeString, + Computed: true, + }, + "expiration_date": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, }, } } @@ -386,10 +402,6 @@ func dataSourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag. return diag.FromErr(fmt.Errorf(advancedcluster.ErrorClusterSetting, "encryption_at_rest_provider", clusterName, err)) } - if err := d.Set("mongo_db_major_version", cluster.MongoDBMajorVersion); err != nil { - return diag.FromErr(fmt.Errorf(advancedcluster.ErrorClusterSetting, "mongo_db_major_version", clusterName, err)) - } - // Avoid Global Cluster issues. (NumShards is not present in Global Clusters) if cluster.NumShards != nil { if err := d.Set("num_shards", cluster.NumShards); err != nil { @@ -491,14 +503,23 @@ func dataSourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag. return diag.FromErr(err) } - redactClientLogData, err := newAtlasGet(ctx, connV2, projectID, clusterName) + latestClusterModel, err := newAtlasGet(ctx, connV2, projectID, clusterName) if err != nil { return diag.FromErr(fmt.Errorf(errorClusterRead, clusterName, err)) } - if err := d.Set("redact_client_log_data", redactClientLogData); err != nil { + + if err := d.Set("mongo_db_major_version", latestClusterModel.MongoDBMajorVersion); err != nil { // uses 2024-08-05 or above as it has fix for correct value when FCV is active + return diag.FromErr(fmt.Errorf(advancedcluster.ErrorClusterSetting, "mongo_db_major_version", clusterName, err)) + } + + if err := d.Set("redact_client_log_data", latestClusterModel.GetRedactClientLogData()); err != nil { return diag.FromErr(fmt.Errorf(advancedcluster.ErrorClusterSetting, "redact_client_log_data", clusterName, err)) } + if err := d.Set("pinned_fcv", advancedcluster.FlattenPinnedFCV(latestClusterModel)); err != nil { + return diag.FromErr(fmt.Errorf(advancedcluster.ErrorClusterSetting, "pinned_fcv", clusterName, err)) + } + d.SetId(cluster.ID) return nil diff --git a/internal/service/cluster/data_source_clusters.go b/internal/service/cluster/data_source_clusters.go index 7012274d78..32b376c92c 100644 --- a/internal/service/cluster/data_source_clusters.go +++ b/internal/service/cluster/data_source_clusters.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster" + "go.mongodb.org/atlas-sdk/v20241113003/admin" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -322,6 +323,22 @@ func PluralDataSource() *schema.Resource { Type: schema.TypeBool, Computed: true, }, + "pinned_fcv": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "version": { + Type: schema.TypeString, + Computed: true, + }, + "expiration_date": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, }, }, }, @@ -343,7 +360,7 @@ func dataSourcePluralRead(ctx context.Context, d *schema.ResourceData, meta any) return diag.FromErr(fmt.Errorf("error reading cluster list for project(%s): %s", projectID, err)) } - redactClientLogDataMap, err := newAtlasList(ctx, connV2, projectID) + latestClusterModels, err := newAtlasList(ctx, connV2, projectID) if err != nil { if resp != nil && resp.StatusCode == http.StatusNotFound { return nil @@ -351,14 +368,14 @@ func dataSourcePluralRead(ctx context.Context, d *schema.ResourceData, meta any) return diag.FromErr(fmt.Errorf("error reading new cluster list for project(%s): %s", projectID, err)) } - if err := d.Set("results", flattenClusters(ctx, d, conn, clusters, redactClientLogDataMap)); err != nil { + if err := d.Set("results", flattenClusters(ctx, d, conn, clusters, latestClusterModels)); err != nil { return diag.FromErr(fmt.Errorf(advancedcluster.ErrorClusterSetting, "results", d.Id(), err)) } return nil } -func flattenClusters(ctx context.Context, d *schema.ResourceData, conn *matlas.Client, clusters []matlas.Cluster, redactClientLogDataMap map[string]bool) []map[string]any { +func flattenClusters(ctx context.Context, d *schema.ResourceData, conn *matlas.Client, clusters []matlas.Cluster, latestClusterModels map[string]*admin.ClusterDescription20240805) []map[string]any { results := make([]map[string]any, 0) for i := range clusters { @@ -391,7 +408,7 @@ func flattenClusters(ctx context.Context, d *schema.ResourceData, conn *matlas.C "connection_strings": flattenConnectionStrings(clusters[i].ConnectionStrings), "disk_size_gb": clusters[i].DiskSizeGB, "encryption_at_rest_provider": clusters[i].EncryptionAtRestProvider, - "mongo_db_major_version": clusters[i].MongoDBMajorVersion, + "mongo_db_major_version": latestClusterModels[clusters[i].Name].MongoDBMajorVersion, // uses 2024-08-05 or above as it has fix for correct value when FCV is active "name": clusters[i].Name, "num_shards": clusters[i].NumShards, "mongo_db_version": clusters[i].MongoDBVersion, @@ -420,7 +437,8 @@ func flattenClusters(ctx context.Context, d *schema.ResourceData, conn *matlas.C "termination_protection_enabled": clusters[i].TerminationProtectionEnabled, "version_release_system": clusters[i].VersionReleaseSystem, "container_id": containerID, - "redact_client_log_data": redactClientLogDataMap[clusters[i].Name], + "redact_client_log_data": latestClusterModels[clusters[i].Name].GetRedactClientLogData(), + "pinned_fcv": advancedcluster.FlattenPinnedFCV(latestClusterModels[clusters[i].Name]), } results = append(results, result) } diff --git a/internal/service/cluster/new_atlas.go b/internal/service/cluster/new_atlas.go index 91d5cfd1c0..8f5b3b22ab 100644 --- a/internal/service/cluster/new_atlas.go +++ b/internal/service/cluster/new_atlas.go @@ -6,7 +6,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster" admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func newAtlasUpdate(ctx context.Context, timeout time.Duration, connV2 *admin.APIClient, connV220240805 *admin20240805.APIClient, projectID, clusterName string, redactClientLogData bool) error { @@ -14,7 +14,7 @@ func newAtlasUpdate(ctx context.Context, timeout time.Duration, connV2 *admin.AP if err != nil { return err } - if current == redactClientLogData { + if current.GetRedactClientLogData() == redactClientLogData { return nil } req := &admin20240805.ClusterDescription20240805{ @@ -31,20 +31,20 @@ func newAtlasUpdate(ctx context.Context, timeout time.Duration, connV2 *admin.AP return nil } -func newAtlasGet(ctx context.Context, connV2 *admin.APIClient, projectID, clusterName string) (redactClientLogData bool, err error) { +func newAtlasGet(ctx context.Context, connV2 *admin.APIClient, projectID, clusterName string) (*admin.ClusterDescription20240805, error) { cluster, _, err := connV2.ClustersApi.GetCluster(ctx, projectID, clusterName).Execute() - return cluster.GetRedactClientLogData(), err + return cluster, err } -func newAtlasList(ctx context.Context, connV2 *admin.APIClient, projectID string) (map[string]bool, error) { +func newAtlasList(ctx context.Context, connV2 *admin.APIClient, projectID string) (map[string]*admin.ClusterDescription20240805, error) { clusters, _, err := connV2.ClustersApi.ListClusters(ctx, projectID).Execute() if err != nil { return nil, err } results := clusters.GetResults() - list := make(map[string]bool) + list := make(map[string]*admin.ClusterDescription20240805) for i := range results { - list[results[i].GetName()] = results[i].GetRedactClientLogData() + list[results[i].GetName()] = &results[i] } return list, nil } diff --git a/internal/service/cluster/resource_cluster.go b/internal/service/cluster/resource_cluster.go index 43b77fc33d..d6b527b20a 100644 --- a/internal/service/cluster/resource_cluster.go +++ b/internal/service/cluster/resource_cluster.go @@ -11,7 +11,7 @@ import ( "regexp" "time" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" matlas "go.mongodb.org/atlas/mongodbatlas" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -354,6 +354,23 @@ func Resource() *schema.Resource { Optional: true, Computed: true, }, + "pinned_fcv": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "version": { + Type: schema.TypeString, + Computed: true, + }, + "expiration_date": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, }, CustomizeDiff: resourceClusterCustomizeDiff, Timeouts: &schema.ResourceTimeout{ @@ -570,7 +587,6 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. clusterRequest = &matlas.Cluster{ Paused: conversion.Pointer(v), } - _, _, err = updateCluster(ctx, conn, connV2, clusterRequest, projectID, clusterName, timeout) if err != nil { return diag.FromErr(fmt.Errorf(errorClusterUpdate, clusterName, err)) @@ -583,6 +599,16 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. } } + if pinnedFCVBlock, _ := d.Get("pinned_fcv").([]any); len(pinnedFCVBlock) > 0 { + if diags := advancedcluster.PinFCV(ctx, connV2, projectID, clusterName, pinnedFCVBlock[0]); diags.HasError() { + return diags + } + stateConf := advancedcluster.CreateStateChangeConfig(ctx, connV2, projectID, clusterName, timeout) + if _, err = stateConf.WaitForStateContext(ctx); err != nil { + return diag.FromErr(fmt.Errorf(errorClusterUpdate, clusterName, err)) + } + } + d.SetId(conversion.EncodeStateID(map[string]string{ "cluster_id": cluster.ID, "project_id": projectID, @@ -659,10 +685,6 @@ func resourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Di return diag.FromErr(fmt.Errorf(advancedcluster.ErrorClusterSetting, "encryption_at_rest_provider", clusterName, err)) } - if err := d.Set("mongo_db_major_version", cluster.MongoDBMajorVersion); err != nil { - return diag.FromErr(fmt.Errorf(advancedcluster.ErrorClusterSetting, "mongo_db_major_version", clusterName, err)) - } - // Avoid Global Cluster issues. (NumShards is not present in Global Clusters) if cluster.NumShards != nil { if err := d.Set("num_shards", cluster.NumShards); err != nil { @@ -776,15 +798,25 @@ func resourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Di return diag.FromErr(err) } - redactClientLogData, err := newAtlasGet(ctx, connV2, projectID, clusterName) + latestClusterModel, err := newAtlasGet(ctx, connV2, projectID, clusterName) if err != nil { return diag.FromErr(fmt.Errorf(errorClusterRead, clusterName, err)) } - if err := d.Set("redact_client_log_data", redactClientLogData); err != nil { + if err := d.Set("redact_client_log_data", latestClusterModel.GetRedactClientLogData()); err != nil { return diag.FromErr(fmt.Errorf(advancedcluster.ErrorClusterSetting, "redact_client_log_data", clusterName, err)) } - return nil + if err := d.Set("mongo_db_major_version", latestClusterModel.MongoDBMajorVersion); err != nil { // uses 2024-08-05 or above as it has fix for correct value when FCV is active + return diag.FromErr(fmt.Errorf(advancedcluster.ErrorClusterSetting, "mongo_db_major_version", clusterName, err)) + } + + warning := advancedcluster.WarningIfFCVExpiredOrUnpinnedExternally(d, latestClusterModel) // has to be called before pinned_fcv value is updated in ResourceData to know prior state value + + if err := d.Set("pinned_fcv", advancedcluster.FlattenPinnedFCV(latestClusterModel)); err != nil { + return diag.FromErr(fmt.Errorf(advancedcluster.ErrorClusterSetting, "pinned_fcv", clusterName, err)) + } + + return warning } func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { @@ -795,6 +827,7 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. ids = conversion.DecodeStateID(d.Id()) projectID = ids["project_id"] clusterName = ids["cluster_name"] + timeout = d.Timeout(schema.TimeoutUpdate) cluster = new(matlas.Cluster) clusterChangeDetect = &matlas.Cluster{ AutoScaling: &matlas.AutoScaling{ @@ -803,6 +836,11 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. } ) + // FCV update is intentionally handled before other cluster updates, and will wait for cluster to reach IDLE state before continuing + if diags := advancedcluster.HandlePinnedFCVUpdate(ctx, connV2, projectID, clusterName, d, timeout); diags != nil { + return diags + } + if d.HasChange("name") { cluster.Name, _ = d.Get("name").(string) } @@ -933,8 +971,6 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. cluster.Paused = conversion.Pointer(d.Get("paused").(bool)) } - timeout := d.Timeout(schema.TimeoutUpdate) - /* Check if advaced configuration option has a changes to update it */ diff --git a/internal/service/cluster/resource_cluster_test.go b/internal/service/cluster/resource_cluster_test.go index 9e4789fc5c..4aade4c540 100644 --- a/internal/service/cluster/resource_cluster_test.go +++ b/internal/service/cluster/resource_cluster_test.go @@ -1,15 +1,13 @@ package cluster_test import ( - "context" "fmt" - "log" "os" "regexp" "testing" + "time" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" clustersvc "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cluster" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" @@ -42,7 +40,7 @@ func basicTestCase(tb testing.TB) *resource.TestCase { { Config: configAWS(projectID, clusterName, true, true), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "100"), @@ -64,7 +62,7 @@ func basicTestCase(tb testing.TB) *resource.TestCase { { Config: configAWS(projectID, clusterName, false, false), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "100"), @@ -77,13 +75,7 @@ func basicTestCase(tb testing.TB) *resource.TestCase { resource.TestCheckResourceAttr(resourceName, "auto_scaling_disk_gb_enabled", "false"), ), }, - { - ResourceName: resourceName, - ImportStateIdFunc: acc.ImportStateClusterIDFunc(resourceName), - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"cloud_backup", "retain_backups_enabled"}, - }, + acc.TestStepImportCluster(resourceName, "cloud_backup", "retain_backups_enabled"), }, } } @@ -116,7 +108,7 @@ func partialAdvancedConfTestCase(tb testing.TB) *resource.TestCase { TransactionLifetimeLimitSeconds: conversion.Pointer[int64](300), }), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.fail_index_key_too_long", "false"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.javascript_enabled", "true"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.minimum_enabled_tls_protocol", "TLS1_1"), @@ -141,7 +133,7 @@ func partialAdvancedConfTestCase(tb testing.TB) *resource.TestCase { MinimumEnabledTLSProtocol: "TLS1_2", }), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.fail_index_key_too_long", "false"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.javascript_enabled", "true"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.minimum_enabled_tls_protocol", "TLS1_2"), @@ -181,7 +173,7 @@ func TestAccCluster_basic_DefaultWriteRead_AdvancedConf(t *testing.T) { ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: conversion.Pointer[int64](113), }), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.default_read_concern", "available"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.default_write_concern", "1"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.javascript_enabled", "true"), @@ -198,7 +190,7 @@ func TestAccCluster_basic_DefaultWriteRead_AdvancedConf(t *testing.T) { MinimumEnabledTLSProtocol: "TLS1_2", }), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.default_read_concern", "available"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.default_write_concern", "1"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.javascript_enabled", "true"), @@ -279,7 +271,7 @@ func TestAccCluster_basicAdvancedConf(t *testing.T) { TransactionLifetimeLimitSeconds: conversion.Pointer[int64](300), }), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.fail_index_key_too_long", "false"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.javascript_enabled", "true"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.minimum_enabled_tls_protocol", "TLS1_2"), @@ -302,7 +294,7 @@ func TestAccCluster_basicAdvancedConf(t *testing.T) { TransactionLifetimeLimitSeconds: conversion.Pointer[int64](60), }), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.fail_index_key_too_long", "false"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.javascript_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.minimum_enabled_tls_protocol", "TLS1_1"), @@ -333,7 +325,7 @@ func TestAccCluster_basicAzure(t *testing.T) { { Config: configAzure(orgID, projectName, clusterName, "true", "M30", true), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttrSet(resourceName, "mongo_uri"), @@ -344,7 +336,7 @@ func TestAccCluster_basicAzure(t *testing.T) { { Config: configAzure(orgID, projectName, clusterName, "false", "M30", true), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttrSet(resourceName, "mongo_uri"), @@ -372,7 +364,7 @@ func TestAccCluster_basicGCP(t *testing.T) { { Config: configGCP(orgID, projectName, clusterName, "true"), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "40"), @@ -384,7 +376,7 @@ func TestAccCluster_basicGCP(t *testing.T) { { Config: configGCP(orgID, projectName, clusterName, "false"), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "40"), @@ -413,7 +405,7 @@ func TestAccCluster_WithBiConnectorGCP(t *testing.T) { { Config: configGCPWithBiConnector(orgID, projectName, clusterName, "true", false), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "40"), @@ -426,7 +418,7 @@ func TestAccCluster_WithBiConnectorGCP(t *testing.T) { { Config: configGCPWithBiConnector(orgID, projectName, clusterName, "false", true), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "40"), @@ -482,7 +474,7 @@ func TestAccCluster_MultiRegion(t *testing.T) { { Config: configMultiRegion(orgID, projectName, clusterName, "true", createRegionsConfig), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "mongo_uri"), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttrSet(resourceName, "replication_specs.#"), @@ -497,7 +489,7 @@ func TestAccCluster_MultiRegion(t *testing.T) { { Config: configMultiRegion(orgID, projectName, clusterName, "false", updatedRegionsConfig), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "mongo_uri"), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttrSet(resourceName, "replication_specs.#"), @@ -552,7 +544,7 @@ func TestAccCluster_ProviderRegionName(t *testing.T) { { Config: configSingleRegionWithProviderRegionName(orgID, projectName, clusterName, "false"), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "mongo_uri"), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttrSet(resourceName, "replication_specs.#"), @@ -567,7 +559,7 @@ func TestAccCluster_ProviderRegionName(t *testing.T) { { Config: configMultiRegion(orgID, projectName, clusterName, "false", updatedRegionsConfig), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "mongo_uri"), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttrSet(resourceName, "replication_specs.#"), @@ -598,7 +590,7 @@ func TestAccCluster_Global(t *testing.T) { { Config: configClusterGlobal(orgID, projectName, clusterName), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "mongo_uri"), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttrSet(resourceName, "replication_specs.#"), @@ -631,7 +623,7 @@ func TestAccCluster_AWSWithLabels(t *testing.T) { { Config: testAccMongoDBAtlasClusterAWSConfigdWithLabels(projectID, clusterName, "false", "M10", "US_WEST_2", []matlas.Label{}), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "10"), @@ -657,7 +649,7 @@ func TestAccCluster_AWSWithLabels(t *testing.T) { }, ), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "10"), @@ -679,7 +671,7 @@ func TestAccCluster_AWSWithLabels(t *testing.T) { }, ), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "10"), @@ -706,7 +698,7 @@ func TestAccCluster_WithTags(t *testing.T) { { Config: configWithTags(orgID, projectName, clusterName, "false", "M10", "US_WEST_2", []matlas.Tag{}), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttrSet(resourceName, "mongo_uri"), @@ -729,7 +721,7 @@ func TestAccCluster_WithTags(t *testing.T) { }, ), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttrSet(resourceName, "mongo_uri"), @@ -754,7 +746,7 @@ func TestAccCluster_WithTags(t *testing.T) { }, ), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttrSet(resourceName, "mongo_uri"), @@ -798,7 +790,7 @@ func TestAccCluster_withPrivateEndpointLink(t *testing.T) { Config: configWithPrivateEndpointLink( awsAccessKey, awsSecretKey, projectID, providerName, region, vpcID, subnetID, securityGroupID, clusterName), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), ), }, @@ -832,7 +824,7 @@ func TestAccCluster_withAzureNetworkPeering(t *testing.T) { { Config: configAzureWithNetworkPeering(projectID, providerName, directoryID, subcrptionID, resourceGroupName, vNetName, clusterName, atlasCidrBlock, region), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttrSet(resourceName, "name"), ), @@ -862,7 +854,7 @@ func TestAccCluster_withGCPNetworkPeering(t *testing.T) { { Config: configGCPWithNetworkPeering(gcpProjectID, gcpRegion, projectID, providerName, gcpPeeringName, clusterName, gcpClusterRegion), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "5"), @@ -992,7 +984,7 @@ func TestAccCluster_withAutoScalingAWS(t *testing.T) { { Config: configAWSWithAutoscaling(projectID, clusterName, "true", "false", "true", "false", minSize, maxSize, instanceSize), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "auto_scaling_compute_enabled", "true"), @@ -1011,7 +1003,7 @@ func TestAccCluster_withAutoScalingAWS(t *testing.T) { { Config: configAWSWithAutoscaling(projectID, clusterName, "false", "true", "true", "true", minSizeUpdated, maxSizeUpdated, instanceSizeUpdated), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "auto_scaling_compute_enabled", "true"), @@ -1040,7 +1032,7 @@ func TestAccCluster_tenant(t *testing.T) { { Config: configTenant(orgID, projectName, clusterName, "M2", "2"), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "2"), @@ -1050,7 +1042,7 @@ func TestAccCluster_tenant(t *testing.T) { { Config: configTenantUpdated(orgID, projectName, clusterName), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "10"), @@ -1077,7 +1069,7 @@ func TestAccCluster_tenant_m5(t *testing.T) { { Config: configTenant(orgID, projectName, clusterName, "M5", "5"), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "5"), @@ -1270,7 +1262,7 @@ func TestAccCluster_basicAWS_UnpauseToPaused(t *testing.T) { { Config: configAWSPaused(projectID, clusterName, true, false), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "100"), @@ -1283,7 +1275,7 @@ func TestAccCluster_basicAWS_UnpauseToPaused(t *testing.T) { { Config: configAWSPaused(projectID, clusterName, false, true), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "100"), @@ -1293,13 +1285,7 @@ func TestAccCluster_basicAWS_UnpauseToPaused(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "paused", "true"), ), }, - { - ResourceName: resourceName, - ImportStateIdFunc: acc.ImportStateClusterIDFunc(resourceName), - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"cloud_backup", "backup_enabled"}, - }, + acc.TestStepImportCluster(resourceName, "cloud_backup", "backup_enabled"), }, }) } @@ -1318,7 +1304,7 @@ func TestAccCluster_basicAWS_PausedToUnpaused(t *testing.T) { { Config: configAWSPaused(projectID, clusterName, true, true), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "100"), @@ -1331,7 +1317,7 @@ func TestAccCluster_basicAWS_PausedToUnpaused(t *testing.T) { { Config: configAWSPaused(projectID, clusterName, false, false), Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), + acc.CheckExistsCluster(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "100"), @@ -1402,22 +1388,57 @@ func TestAccCluster_create_RedactClientLogData(t *testing.T) { }) } -func checkExists(resourceName string) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[resourceName] - if !ok { - return fmt.Errorf("not found: %s", resourceName) - } - if rs.Primary.ID == "" { - return fmt.Errorf("no ID is set") - } - ids := conversion.DecodeStateID(rs.Primary.ID) - log.Printf("[DEBUG] projectID: %s, name %s", ids["project_id"], ids["cluster_name"]) - if _, _, err := acc.Conn().Clusters.Get(context.Background(), ids["project_id"], ids["cluster_name"]); err == nil { - return nil - } - return fmt.Errorf("cluster(%s:%s) does not exist", rs.Primary.Attributes["project_id"], rs.Primary.ID) - } +func TestAccCluster_pinnedFCVWithVersionUpgradeAndDowngrade(t *testing.T) { + var ( + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acc.RandomProjectName() // Using single project to assert plural data source + clusterName = acc.RandomClusterName() + ) + + now := time.Now() + // Time 7 days from now, truncated to the beginning of the day + sevenDaysFromNow := now.AddDate(0, 0, 7).Truncate(24 * time.Hour) + firstExpirationDate := conversion.TimeToString(sevenDaysFromNow) + // Time 8 days from now + eightDaysFromNow := sevenDaysFromNow.AddDate(0, 0, 1) + updatedExpirationDate := conversion.TimeToString(eightDaysFromNow) + invalidDateFormat := "invalid" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acc.PreCheckBasic(t) }, + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configFCVPinning(orgID, projectName, clusterName, nil, "7.0"), + Check: acc.CheckFCVPinningConfig(resourceName, dataSourceName, dataSourcePluralName, 7, nil, nil), + }, + { // pins fcv + Config: configFCVPinning(orgID, projectName, clusterName, &firstExpirationDate, "7.0"), + Check: acc.CheckFCVPinningConfig(resourceName, dataSourceName, dataSourcePluralName, 7, conversion.Pointer(firstExpirationDate), conversion.Pointer(7)), + }, + { // using incorrect format + Config: configFCVPinning(orgID, projectName, clusterName, &invalidDateFormat, "7.0"), + ExpectError: regexp.MustCompile("expiration_date format is incorrect: " + invalidDateFormat), + }, + { // updates expiration date of fcv + Config: configFCVPinning(orgID, projectName, clusterName, &updatedExpirationDate, "7.0"), + Check: acc.CheckFCVPinningConfig(resourceName, dataSourceName, dataSourcePluralName, 7, conversion.Pointer(updatedExpirationDate), conversion.Pointer(7)), + }, + { // upgrade mongodb version with fcv pinned + Config: configFCVPinning(orgID, projectName, clusterName, &updatedExpirationDate, "8.0"), + Check: acc.CheckFCVPinningConfig(resourceName, dataSourceName, dataSourcePluralName, 8, conversion.Pointer(updatedExpirationDate), conversion.Pointer(7)), + }, + { // downgrade mongodb version with fcv pinned + Config: configFCVPinning(orgID, projectName, clusterName, &updatedExpirationDate, "7.0"), + Check: acc.CheckFCVPinningConfig(resourceName, dataSourceName, dataSourcePluralName, 7, conversion.Pointer(updatedExpirationDate), conversion.Pointer(7)), + }, + { // unpins fcv + Config: configFCVPinning(orgID, projectName, clusterName, nil, "7.0"), + Check: acc.CheckFCVPinningConfig(resourceName, dataSourceName, dataSourcePluralName, 7, nil, nil), + }, + }, + }) } func configAWS(projectID, name string, backupEnabled, autoDiskGBEnabled bool) string { @@ -2416,6 +2437,54 @@ func configClusterGlobal(orgID, projectName, clusterName string) string { `, orgID, projectName, clusterName) } +func configFCVPinning(orgID, projectName, clusterName string, pinningExpirationDate *string, mongoDBMajorVersion string) string { + var pinnedFCVAttr string + if pinningExpirationDate != nil { + pinnedFCVAttr = fmt.Sprintf(` + pinned_fcv { + expiration_date = %q + } + `, *pinningExpirationDate) + } + + return fmt.Sprintf(` + resource "mongodbatlas_project" "test" { + org_id = %[1]q + name = %[2]q + } + + resource "mongodbatlas_cluster" "test" { + project_id = mongodbatlas_project.test.id + name = %[3]q + cluster_type = "REPLICASET" + provider_name = "AWS" + provider_instance_size_name = "M10" + + mongo_db_major_version = %[4]q + + %[5]s + + replication_specs { + num_shards = 1 + regions_config { + region_name = "US_WEST_2" + electable_nodes = 3 + priority = 7 + } + } + } + + data "mongodbatlas_cluster" "test" { + project_id = mongodbatlas_cluster.test.project_id + name = mongodbatlas_cluster.test.name + } + + data "mongodbatlas_clusters" "test" { + project_id = mongodbatlas_cluster.test.project_id + } + `, orgID, projectName, clusterName, mongoDBMajorVersion, pinnedFCVAttr) +} + func TestIsMultiRegionCluster(t *testing.T) { tests := []struct { name string diff --git a/internal/service/clusteroutagesimulation/resource_cluster_outage_simulation.go b/internal/service/clusteroutagesimulation/resource_cluster_outage_simulation.go index aac5d3a622..0686462905 100644 --- a/internal/service/clusteroutagesimulation/resource_cluster_outage_simulation.go +++ b/internal/service/clusteroutagesimulation/resource_cluster_outage_simulation.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/controlplaneipaddresses/data_source.go b/internal/service/controlplaneipaddresses/data_source.go index 188fb907e4..9af538c01e 100644 --- a/internal/service/controlplaneipaddresses/data_source.go +++ b/internal/service/controlplaneipaddresses/data_source.go @@ -32,7 +32,7 @@ func (d *controlPlaneIPAddressesDS) Schema(ctx context.Context, req datasource.S func (d *controlPlaneIPAddressesDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { connV2 := d.Client.AtlasV2 - apiResp, _, err := connV2.RootApi.ReturnAllControlPlaneIPAddresses(ctx).Execute() + apiResp, _, err := connV2.RootApi.ReturnAllControlPlaneIpAddresses(ctx).Execute() if err != nil { resp.Diagnostics.AddError("error fetching control plane ip addresses", err.Error()) return diff --git a/internal/service/controlplaneipaddresses/model.go b/internal/service/controlplaneipaddresses/model.go index 3b2c8cd6ba..879c43ae4d 100644 --- a/internal/service/controlplaneipaddresses/model.go +++ b/internal/service/controlplaneipaddresses/model.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func NewTFControlPlaneIPAddresses(ctx context.Context, apiResp *admin.ControlPlaneIPAddresses) (*TFControlPlaneIpAddressesModel, diag.Diagnostics) { diff --git a/internal/service/controlplaneipaddresses/model_test.go b/internal/service/controlplaneipaddresses/model_test.go index 1e299c22a3..cd4df4aa1e 100644 --- a/internal/service/controlplaneipaddresses/model_test.go +++ b/internal/service/controlplaneipaddresses/model_test.go @@ -9,7 +9,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/controlplaneipaddresses" "github.com/stretchr/testify/assert" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) type sdkToTFModelTestCase struct { diff --git a/internal/service/customdbrole/data_source_custom_db_roles.go b/internal/service/customdbrole/data_source_custom_db_roles.go index fa98a13ade..b99952688d 100644 --- a/internal/service/customdbrole/data_source_custom_db_roles.go +++ b/internal/service/customdbrole/data_source_custom_db_roles.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { diff --git a/internal/service/customdbrole/resource_custom_db_role.go b/internal/service/customdbrole/resource_custom_db_role.go index 95fca23d8a..ed2d8a46f3 100644 --- a/internal/service/customdbrole/resource_custom_db_role.go +++ b/internal/service/customdbrole/resource_custom_db_role.go @@ -17,7 +17,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/spf13/cast" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func Resource() *schema.Resource { diff --git a/internal/service/customdbrole/resource_custom_db_role_test.go b/internal/service/customdbrole/resource_custom_db_role_test.go index 2faee46be0..583ebac62f 100644 --- a/internal/service/customdbrole/resource_custom_db_role_test.go +++ b/internal/service/customdbrole/resource_custom_db_role_test.go @@ -11,7 +11,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" "github.com/spf13/cast" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const resourceName = "mongodbatlas_custom_db_role.test" diff --git a/internal/service/customdnsconfigurationclusteraws/data_source_custom_dns_configuration_cluster_aws.go b/internal/service/customdnsconfigurationclusteraws/data_source_custom_dns_configuration_cluster_aws.go index fe18c3ade2..d974c659a5 100644 --- a/internal/service/customdnsconfigurationclusteraws/data_source_custom_dns_configuration_cluster_aws.go +++ b/internal/service/customdnsconfigurationclusteraws/data_source_custom_dns_configuration_cluster_aws.go @@ -28,7 +28,7 @@ func DataSource() *schema.Resource { func dataSourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { connV2 := meta.(*config.MongoDBClient).AtlasV2 projectID := d.Get("project_id").(string) - dnsResp, _, err := connV2.AWSClustersDNSApi.GetAWSCustomDNS(ctx, projectID).Execute() + dnsResp, _, err := connV2.AWSClustersDNSApi.GetAwsCustomDns(ctx, projectID).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorRead, err)) } diff --git a/internal/service/customdnsconfigurationclusteraws/resource_custom_dns_configuration_cluster_aws.go b/internal/service/customdnsconfigurationclusteraws/resource_custom_dns_configuration_cluster_aws.go index 3d1c8f77dc..115de67c68 100644 --- a/internal/service/customdnsconfigurationclusteraws/resource_custom_dns_configuration_cluster_aws.go +++ b/internal/service/customdnsconfigurationclusteraws/resource_custom_dns_configuration_cluster_aws.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( @@ -49,7 +49,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. params := &admin.AWSCustomDNSEnabled{ Enabled: d.Get("enabled").(bool), } - _, _, err := connV2.AWSClustersDNSApi.ToggleAWSCustomDNS(ctx, projectID, params).Execute() + _, _, err := connV2.AWSClustersDNSApi.ToggleAwsCustomDns(ctx, projectID, params).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorCreate, err)) } @@ -60,7 +60,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. func resourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { connV2 := meta.(*config.MongoDBClient).AtlasV2 projectID := d.Id() - dnsResp, resp, err := connV2.AWSClustersDNSApi.GetAWSCustomDNS(context.Background(), projectID).Execute() + dnsResp, resp, err := connV2.AWSClustersDNSApi.GetAwsCustomDns(context.Background(), projectID).Execute() if err != nil { if resp != nil && resp.StatusCode == http.StatusNotFound { d.SetId("") @@ -85,7 +85,7 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. params := &admin.AWSCustomDNSEnabled{ Enabled: d.Get("enabled").(bool), } - _, _, err := connV2.AWSClustersDNSApi.ToggleAWSCustomDNS(ctx, projectID, params).Execute() + _, _, err := connV2.AWSClustersDNSApi.ToggleAwsCustomDns(ctx, projectID, params).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorUpdate, err)) } @@ -100,7 +100,7 @@ func resourceDelete(ctx context.Context, d *schema.ResourceData, meta any) diag. params := &admin.AWSCustomDNSEnabled{ Enabled: false, } - _, _, err := connV2.AWSClustersDNSApi.ToggleAWSCustomDNS(ctx, projectID, params).Execute() + _, _, err := connV2.AWSClustersDNSApi.ToggleAwsCustomDns(ctx, projectID, params).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorDelete, projectID, err)) } diff --git a/internal/service/customdnsconfigurationclusteraws/resource_custom_dns_configuration_cluster_aws_test.go b/internal/service/customdnsconfigurationclusteraws/resource_custom_dns_configuration_cluster_aws_test.go index 68a2ed2985..cdc1342225 100644 --- a/internal/service/customdnsconfigurationclusteraws/resource_custom_dns_configuration_cluster_aws_test.go +++ b/internal/service/customdnsconfigurationclusteraws/resource_custom_dns_configuration_cluster_aws_test.go @@ -67,7 +67,7 @@ func checkExists(resourceName string) resource.TestCheckFunc { if rs.Primary.ID == "" { return fmt.Errorf("no ID is set") } - _, _, err := acc.ConnV2().AWSClustersDNSApi.GetAWSCustomDNS(context.Background(), rs.Primary.ID).Execute() + _, _, err := acc.ConnV2().AWSClustersDNSApi.GetAwsCustomDns(context.Background(), rs.Primary.ID).Execute() if err == nil { return nil } @@ -81,7 +81,7 @@ func checkDestroy(s *terraform.State) error { continue } - resp, _, err := acc.ConnV2().AWSClustersDNSApi.GetAWSCustomDNS(context.Background(), rs.Primary.ID).Execute() + resp, _, err := acc.ConnV2().AWSClustersDNSApi.GetAwsCustomDns(context.Background(), rs.Primary.ID).Execute() if err != nil && resp != nil && resp.Enabled { return fmt.Errorf("custom dns configuration cluster aws (%s) still enabled", rs.Primary.ID) } diff --git a/internal/service/databaseuser/model_database_user.go b/internal/service/databaseuser/model_database_user.go index 5bb4d61c63..a7de40f89e 100644 --- a/internal/service/databaseuser/model_database_user.go +++ b/internal/service/databaseuser/model_database_user.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func NewMongoDBDatabaseUser(ctx context.Context, statePasswordValue types.String, dbUserModel *TfDatabaseUserModel) (*admin.CloudDatabaseUser, diag.Diagnostics) { diff --git a/internal/service/databaseuser/model_database_user_test.go b/internal/service/databaseuser/model_database_user_test.go index 94ad686bb1..0a9647e973 100644 --- a/internal/service/databaseuser/model_database_user_test.go +++ b/internal/service/databaseuser/model_database_user_test.go @@ -9,7 +9,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/databaseuser" "github.com/stretchr/testify/assert" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) var ( diff --git a/internal/service/databaseuser/resource_database_user_migration_test.go b/internal/service/databaseuser/resource_database_user_migration_test.go index a3b6dfdc87..d7c634bdab 100644 --- a/internal/service/databaseuser/resource_database_user_migration_test.go +++ b/internal/service/databaseuser/resource_database_user_migration_test.go @@ -3,7 +3,7 @@ package databaseuser_test import ( "testing" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" diff --git a/internal/service/databaseuser/resource_database_user_test.go b/internal/service/databaseuser/resource_database_user_test.go index f39d5379ec..812fbf8296 100644 --- a/internal/service/databaseuser/resource_database_user_test.go +++ b/internal/service/databaseuser/resource_database_user_test.go @@ -11,7 +11,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/databaseuser" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/datalakepipeline/data_source_data_lake_pipeline_run.go b/internal/service/datalakepipeline/data_source_data_lake_pipeline_run.go index cc9fd66940..41e2c5164b 100644 --- a/internal/service/datalakepipeline/data_source_data_lake_pipeline_run.go +++ b/internal/service/datalakepipeline/data_source_data_lake_pipeline_run.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const errorDataLakePipelineRunRead = "error reading MongoDB Atlas DataLake Run (%s): %s" diff --git a/internal/service/datalakepipeline/data_source_data_lake_pipeline_runs.go b/internal/service/datalakepipeline/data_source_data_lake_pipeline_runs.go index 31cc64406d..1a3769e7c6 100644 --- a/internal/service/datalakepipeline/data_source_data_lake_pipeline_runs.go +++ b/internal/service/datalakepipeline/data_source_data_lake_pipeline_runs.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const errorDataLakePipelineRunList = "error reading MongoDB Atlas DataLake Runs (%s): %s" diff --git a/internal/service/datalakepipeline/data_source_data_lake_pipelines.go b/internal/service/datalakepipeline/data_source_data_lake_pipelines.go index 89c8615295..96f29e6c02 100644 --- a/internal/service/datalakepipeline/data_source_data_lake_pipelines.go +++ b/internal/service/datalakepipeline/data_source_data_lake_pipelines.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const errorDataLakePipelineList = "error creating MongoDB Atlas DataLake Pipelines: %s" diff --git a/internal/service/datalakepipeline/resource_data_lake_pipeline.go b/internal/service/datalakepipeline/resource_data_lake_pipeline.go index 0dcb35033b..bd7a2fa2d8 100644 --- a/internal/service/datalakepipeline/resource_data_lake_pipeline.go +++ b/internal/service/datalakepipeline/resource_data_lake_pipeline.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/encryptionatrest/data_source_schema.go b/internal/service/encryptionatrest/data_source_schema.go index 32842daf61..3bc251fe44 100644 --- a/internal/service/encryptionatrest/data_source_schema.go +++ b/internal/service/encryptionatrest/data_source_schema.go @@ -3,7 +3,7 @@ package encryptionatrest import ( "context" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" diff --git a/internal/service/encryptionatrest/model.go b/internal/service/encryptionatrest/model.go index 4c709b9a42..c7b0a5ae5b 100644 --- a/internal/service/encryptionatrest/model.go +++ b/internal/service/encryptionatrest/model.go @@ -3,7 +3,7 @@ package encryptionatrest import ( "context" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-framework/types" diff --git a/internal/service/encryptionatrest/model_test.go b/internal/service/encryptionatrest/model_test.go index 2993981d04..40027c4111 100644 --- a/internal/service/encryptionatrest/model_test.go +++ b/internal/service/encryptionatrest/model_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stretchr/testify/assert" diff --git a/internal/service/encryptionatrest/resource.go b/internal/service/encryptionatrest/resource.go index 907db6af5c..14b4d30e01 100644 --- a/internal/service/encryptionatrest/resource.go +++ b/internal/service/encryptionatrest/resource.go @@ -9,7 +9,7 @@ import ( "reflect" "time" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" "github.com/hashicorp/terraform-plugin-framework/path" diff --git a/internal/service/encryptionatrest/resource_migration_test.go b/internal/service/encryptionatrest/resource_migration_test.go index 66a74f3a65..9723495b7a 100644 --- a/internal/service/encryptionatrest/resource_migration_test.go +++ b/internal/service/encryptionatrest/resource_migration_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/plancheck" diff --git a/internal/service/encryptionatrest/resource_test.go b/internal/service/encryptionatrest/resource_test.go index bd0b84a610..f011e19ab7 100644 --- a/internal/service/encryptionatrest/resource_test.go +++ b/internal/service/encryptionatrest/resource_test.go @@ -7,8 +7,8 @@ import ( "os" "testing" - "go.mongodb.org/atlas-sdk/v20241023002/admin" - "go.mongodb.org/atlas-sdk/v20241023002/mockadmin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" + "go.mongodb.org/atlas-sdk/v20241113003/mockadmin" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/internal/service/encryptionatrestprivateendpoint/data_source.go b/internal/service/encryptionatrestprivateendpoint/data_source.go index 602fec357c..3093e9a508 100644 --- a/internal/service/encryptionatrestprivateendpoint/data_source.go +++ b/internal/service/encryptionatrestprivateendpoint/data_source.go @@ -26,8 +26,9 @@ type encryptionAtRestPrivateEndpointDS struct { } func (d *encryptionAtRestPrivateEndpointDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = DataSourceSchema(ctx) - conversion.UpdateSchemaDescription(&resp.Schema) + resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.DataSourceSchemaRequest{ + RequiredFields: []string{"id", "project_id", "cloud_provider"}, + }) } func (d *encryptionAtRestPrivateEndpointDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/service/encryptionatrestprivateendpoint/data_source_schema.go b/internal/service/encryptionatrestprivateendpoint/data_source_schema.go index 0018519ac3..841373c896 100644 --- a/internal/service/encryptionatrestprivateendpoint/data_source_schema.go +++ b/internal/service/encryptionatrestprivateendpoint/data_source_schema.go @@ -1,23 +1,16 @@ package encryptionatrestprivateendpoint import ( - "context" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" ) -func DataSourceSchema(ctx context.Context) schema.Schema { - return schema.Schema{ - Attributes: DSAttributes(true), - } -} - func DSAttributes(withArguments bool) map[string]schema.Attribute { return map[string]schema.Attribute{ "cloud_provider": schema.StringAttribute{ Required: withArguments, Computed: !withArguments, - MarkdownDescription: "Label that identifies the cloud provider of the private endpoint.", + MarkdownDescription: "Label that identifies the cloud provider for the Encryption At Rest private endpoint.", }, "error_message": schema.StringAttribute{ Computed: true, @@ -47,3 +40,9 @@ func DSAttributes(withArguments bool) map[string]schema.Attribute { }, } } + +type TFEncryptionAtRestPrivateEndpointsDSModel struct { + CloudProvider types.String `tfsdk:"cloud_provider"` + ProjectID types.String `tfsdk:"project_id"` + Results []TFEarPrivateEndpointModel `tfsdk:"results"` +} diff --git a/internal/service/encryptionatrestprivateendpoint/model.go b/internal/service/encryptionatrestprivateendpoint/model.go index 07cc5e830a..afe17a0a9d 100644 --- a/internal/service/encryptionatrestprivateendpoint/model.go +++ b/internal/service/encryptionatrestprivateendpoint/model.go @@ -3,7 +3,7 @@ package encryptionatrestprivateendpoint import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func NewTFEarPrivateEndpoint(apiResp admin.EARPrivateEndpoint, projectID string) TFEarPrivateEndpointModel { diff --git a/internal/service/encryptionatrestprivateendpoint/model_test.go b/internal/service/encryptionatrestprivateendpoint/model_test.go index a6e3c67248..9d8d54cc53 100644 --- a/internal/service/encryptionatrestprivateendpoint/model_test.go +++ b/internal/service/encryptionatrestprivateendpoint/model_test.go @@ -3,7 +3,7 @@ package encryptionatrestprivateendpoint_test import ( "testing" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stretchr/testify/assert" diff --git a/internal/service/encryptionatrestprivateendpoint/plural_data_source.go b/internal/service/encryptionatrestprivateendpoint/plural_data_source.go index 3f2d5b5031..3bea6d7aca 100644 --- a/internal/service/encryptionatrestprivateendpoint/plural_data_source.go +++ b/internal/service/encryptionatrestprivateendpoint/plural_data_source.go @@ -10,7 +10,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/dsschema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) var _ datasource.DataSource = &encryptionAtRestPrivateEndpointsDS{} @@ -29,8 +29,9 @@ type encryptionAtRestPrivateEndpointsDS struct { } func (d *encryptionAtRestPrivateEndpointsDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = PluralDataSourceSchema(ctx) - conversion.UpdateSchemaDescription(&resp.Schema) + resp.Schema = conversion.PluralDataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.PluralDataSourceSchemaRequest{ + RequiredFields: []string{"project_id", "cloud_provider"}, + }) } func (d *encryptionAtRestPrivateEndpointsDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/service/encryptionatrestprivateendpoint/plural_data_source_schema.go b/internal/service/encryptionatrestprivateendpoint/plural_data_source_schema.go deleted file mode 100644 index 940c94e3f5..0000000000 --- a/internal/service/encryptionatrestprivateendpoint/plural_data_source_schema.go +++ /dev/null @@ -1,36 +0,0 @@ -package encryptionatrestprivateendpoint - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func PluralDataSourceSchema(ctx context.Context) schema.Schema { - return schema.Schema{ - Attributes: map[string]schema.Attribute{ - "cloud_provider": schema.StringAttribute{ - Required: true, - MarkdownDescription: "Label that identifies the cloud provider of the private endpoint.", - }, - "project_id": schema.StringAttribute{ - Required: true, - MarkdownDescription: "Unique 24-hexadecimal digit string that identifies your project.", - }, - "results": schema.ListNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: DSAttributes(false), - }, - Computed: true, - MarkdownDescription: "List of returned documents that MongoDB Cloud providers when completing this request.", - }, - }, - } -} - -type TFEncryptionAtRestPrivateEndpointsDSModel struct { - CloudProvider types.String `tfsdk:"cloud_provider"` - ProjectID types.String `tfsdk:"project_id"` - Results []TFEarPrivateEndpointModel `tfsdk:"results"` -} diff --git a/internal/service/encryptionatrestprivateendpoint/resource.go b/internal/service/encryptionatrestprivateendpoint/resource.go index f1115f6976..e3209184a3 100644 --- a/internal/service/encryptionatrestprivateendpoint/resource.go +++ b/internal/service/encryptionatrestprivateendpoint/resource.go @@ -6,7 +6,7 @@ import ( "net/http" "regexp" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" diff --git a/internal/service/encryptionatrestprivateendpoint/resource_test.go b/internal/service/encryptionatrestprivateendpoint/resource_test.go index 7d498b2339..36ba486936 100644 --- a/internal/service/encryptionatrestprivateendpoint/resource_test.go +++ b/internal/service/encryptionatrestprivateendpoint/resource_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/internal/service/encryptionatrestprivateendpoint/state_transition.go b/internal/service/encryptionatrestprivateendpoint/state_transition.go index 3e6cd32e30..d4233dfbe9 100644 --- a/internal/service/encryptionatrestprivateendpoint/state_transition.go +++ b/internal/service/encryptionatrestprivateendpoint/state_transition.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/retrystrategy" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/encryptionatrestprivateendpoint/state_transition_test.go b/internal/service/encryptionatrestprivateendpoint/state_transition_test.go index fa7929fff6..3455eb72c9 100644 --- a/internal/service/encryptionatrestprivateendpoint/state_transition_test.go +++ b/internal/service/encryptionatrestprivateendpoint/state_transition_test.go @@ -13,8 +13,8 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/encryptionatrestprivateendpoint" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "go.mongodb.org/atlas-sdk/v20241023002/admin" - "go.mongodb.org/atlas-sdk/v20241023002/mockadmin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" + "go.mongodb.org/atlas-sdk/v20241113003/mockadmin" ) type testCase struct { diff --git a/internal/service/eventtrigger/resource_event_trigger.go b/internal/service/eventtrigger/resource_event_trigger.go index ee02d7f1f3..b1e99aee41 100644 --- a/internal/service/eventtrigger/resource_event_trigger.go +++ b/internal/service/eventtrigger/resource_event_trigger.go @@ -108,13 +108,13 @@ func Resource() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + DiffSuppressFunc: func(k, oldAttr, newAttr string, d *schema.ResourceData) bool { var j, j2 any - if err := json.Unmarshal([]byte(old), &j); err != nil { + if err := json.Unmarshal([]byte(oldAttr), &j); err != nil { log.Printf("[ERROR] json.Unmarshal %v", err) return false } - if err := json.Unmarshal([]byte(new), &j2); err != nil { + if err := json.Unmarshal([]byte(newAttr), &j2); err != nil { log.Printf("[ERROR] json.Unmarshal %v", err) return false } @@ -129,13 +129,13 @@ func Resource() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + DiffSuppressFunc: func(k, oldAttr, newAttr string, d *schema.ResourceData) bool { var j, j2 any - if err := json.Unmarshal([]byte(old), &j); err != nil { + if err := json.Unmarshal([]byte(oldAttr), &j); err != nil { log.Printf("[ERROR] json.Unmarshal %v", err) return false } - if err := json.Unmarshal([]byte(new), &j2); err != nil { + if err := json.Unmarshal([]byte(newAttr), &j2); err != nil { log.Printf("[ERROR] json.Unmarshal %v", err) return false } diff --git a/internal/service/federateddatabaseinstance/data_source_federated_database_instance_test.go b/internal/service/federateddatabaseinstance/data_source_federated_database_instance_test.go index c9c6d7ea88..e0da600575 100644 --- a/internal/service/federateddatabaseinstance/data_source_federated_database_instance_test.go +++ b/internal/service/federateddatabaseinstance/data_source_federated_database_instance_test.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func TestAccFederatedDatabaseInstanceDS_s3Bucket(t *testing.T) { diff --git a/internal/service/federateddatabaseinstance/data_source_federated_database_instances.go b/internal/service/federateddatabaseinstance/data_source_federated_database_instances.go index be8aeec79e..07fcadea80 100644 --- a/internal/service/federateddatabaseinstance/data_source_federated_database_instances.go +++ b/internal/service/federateddatabaseinstance/data_source_federated_database_instances.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" diff --git a/internal/service/federateddatabaseinstance/resource_federated_database_instance.go b/internal/service/federateddatabaseinstance/resource_federated_database_instance.go index ecae729e9c..7726d33700 100644 --- a/internal/service/federateddatabaseinstance/resource_federated_database_instance.go +++ b/internal/service/federateddatabaseinstance/resource_federated_database_instance.go @@ -7,7 +7,7 @@ import ( "net/http" "strings" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/internal/service/federatedquerylimit/data_source_federated_query_limits.go b/internal/service/federatedquerylimit/data_source_federated_query_limits.go index f949f6e59d..f5c224c46e 100644 --- a/internal/service/federatedquerylimit/data_source_federated_query_limits.go +++ b/internal/service/federatedquerylimit/data_source_federated_query_limits.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { diff --git a/internal/service/federatedquerylimit/resource_federated_query_limit.go b/internal/service/federatedquerylimit/resource_federated_query_limit.go index 0b15b0e76f..e0a8264221 100644 --- a/internal/service/federatedquerylimit/resource_federated_query_limit.go +++ b/internal/service/federatedquerylimit/resource_federated_query_limit.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/federatedsettingsidentityprovider/data_source_federated_settings_identity_providers.go b/internal/service/federatedsettingsidentityprovider/data_source_federated_settings_identity_providers.go index 8772f6863c..5e543df9d5 100644 --- a/internal/service/federatedsettingsidentityprovider/data_source_federated_settings_identity_providers.go +++ b/internal/service/federatedsettingsidentityprovider/data_source_federated_settings_identity_providers.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider.go b/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider.go index 75183fd705..7e63534689 100644 --- a/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider.go +++ b/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider.go @@ -4,7 +4,7 @@ import ( "sort" "strings" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" diff --git a/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider_test.go b/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider_test.go index 9b64804b43..bb6191441d 100644 --- a/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider_test.go +++ b/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/stretchr/testify/assert" diff --git a/internal/service/federatedsettingsorgconfig/data_source_federated_settings.go b/internal/service/federatedsettingsorgconfig/data_source_federated_settings.go index 8c44c02e00..8312ff3a09 100644 --- a/internal/service/federatedsettingsorgconfig/data_source_federated_settings.go +++ b/internal/service/federatedsettingsorgconfig/data_source_federated_settings.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func DataSourceSettings() *schema.Resource { diff --git a/internal/service/federatedsettingsorgconfig/data_source_federated_settings_connected_orgs.go b/internal/service/federatedsettingsorgconfig/data_source_federated_settings_connected_orgs.go index 4e53bf4cb4..a9ef90fbbd 100644 --- a/internal/service/federatedsettingsorgconfig/data_source_federated_settings_connected_orgs.go +++ b/internal/service/federatedsettingsorgconfig/data_source_federated_settings_connected_orgs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { diff --git a/internal/service/federatedsettingsorgconfig/model_federated_settings_connected_orgs.go b/internal/service/federatedsettingsorgconfig/model_federated_settings_connected_orgs.go index 7c4b32bf53..8486a13cc8 100644 --- a/internal/service/federatedsettingsorgconfig/model_federated_settings_connected_orgs.go +++ b/internal/service/federatedsettingsorgconfig/model_federated_settings_connected_orgs.go @@ -4,7 +4,7 @@ import ( "sort" "strings" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) type roleMappingsByGroupName []admin.AuthFederationRoleMapping diff --git a/internal/service/federatedsettingsorgrolemapping/data_source_federated_settings_org_role_mappings.go b/internal/service/federatedsettingsorgrolemapping/data_source_federated_settings_org_role_mappings.go index c012c37ad1..32a6c52390 100644 --- a/internal/service/federatedsettingsorgrolemapping/data_source_federated_settings_org_role_mappings.go +++ b/internal/service/federatedsettingsorgrolemapping/data_source_federated_settings_org_role_mappings.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { diff --git a/internal/service/federatedsettingsorgrolemapping/model_federated_settings_org_role_mapping.go b/internal/service/federatedsettingsorgrolemapping/model_federated_settings_org_role_mapping.go index 05d84a2802..8fb880281b 100644 --- a/internal/service/federatedsettingsorgrolemapping/model_federated_settings_org_role_mapping.go +++ b/internal/service/federatedsettingsorgrolemapping/model_federated_settings_org_role_mapping.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) type mRoleAssignment []admin.RoleAssignment diff --git a/internal/service/federatedsettingsorgrolemapping/resource_federated_settings_org_role_mapping.go b/internal/service/federatedsettingsorgrolemapping/resource_federated_settings_org_role_mapping.go index dffb7379fd..c9555edddd 100644 --- a/internal/service/federatedsettingsorgrolemapping/resource_federated_settings_org_role_mapping.go +++ b/internal/service/federatedsettingsorgrolemapping/resource_federated_settings_org_role_mapping.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func Resource() *schema.Resource { diff --git a/internal/service/flexcluster/data_source.go b/internal/service/flexcluster/data_source.go new file mode 100644 index 0000000000..b8d75e5e9f --- /dev/null +++ b/internal/service/flexcluster/data_source.go @@ -0,0 +1,52 @@ +package flexcluster + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" +) + +var _ datasource.DataSource = &ds{} +var _ datasource.DataSourceWithConfigure = &ds{} + +func DataSource() datasource.DataSource { + return &ds{ + DSCommon: config.DSCommon{ + DataSourceName: resourceName, + }, + } +} + +type ds struct { + config.DSCommon +} + +func (d *ds) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.DataSourceSchemaRequest{ + RequiredFields: []string{"project_id", "name"}, + }) +} + +func (d *ds) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var tfModel TFModel + resp.Diagnostics.Append(req.Config.Get(ctx, &tfModel)...) + if resp.Diagnostics.HasError() { + return + } + + connV2 := d.Client.AtlasV2 + apiResp, _, err := connV2.FlexClustersApi.GetFlexCluster(ctx, tfModel.ProjectId.ValueString(), tfModel.Name.ValueString()).Execute() + if err != nil { + resp.Diagnostics.AddError("error reading data source", err.Error()) + return + } + + newFlexClusterModel, diags := NewTFModel(ctx, apiResp) + if diags.HasError() { + resp.Diagnostics.Append(diags...) + return + } + resp.Diagnostics.Append(resp.State.Set(ctx, newFlexClusterModel)...) +} diff --git a/internal/service/flexcluster/main_test.go b/internal/service/flexcluster/main_test.go new file mode 100644 index 0000000000..ca4213b1d7 --- /dev/null +++ b/internal/service/flexcluster/main_test.go @@ -0,0 +1,15 @@ +package flexcluster_test + +import ( + "os" + "testing" + + "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" +) + +func TestMain(m *testing.M) { + cleanup := acc.SetupSharedResources() + exitCode := m.Run() + cleanup() + os.Exit(exitCode) +} diff --git a/internal/service/flexcluster/model.go b/internal/service/flexcluster/model.go new file mode 100644 index 0000000000..61c60ed767 --- /dev/null +++ b/internal/service/flexcluster/model.go @@ -0,0 +1,133 @@ +package flexcluster + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" + "go.mongodb.org/atlas-sdk/v20241113003/admin" +) + +func NewTFModel(ctx context.Context, apiResp *admin.FlexClusterDescription20241113) (*TFModel, diag.Diagnostics) { + connectionStrings, diags := ConvertConnectionStringsToTF(ctx, apiResp.ConnectionStrings) + if diags.HasError() { + return nil, diags + } + backupSettings, diags := ConvertBackupSettingsToTF(ctx, apiResp.BackupSettings) + if diags.HasError() { + return nil, diags + } + providerSettings, diags := ConvertProviderSettingsToTF(ctx, apiResp.ProviderSettings) + if diags.HasError() { + return nil, diags + } + return &TFModel{ + ProviderSettings: *providerSettings, + ConnectionStrings: *connectionStrings, + Tags: conversion.NewTFTags(apiResp.GetTags()), + CreateDate: types.StringPointerValue(conversion.TimePtrToStringPtr(apiResp.CreateDate)), + ProjectId: types.StringPointerValue(apiResp.GroupId), + Id: types.StringPointerValue(apiResp.Id), + MongoDbversion: types.StringPointerValue(apiResp.MongoDBVersion), + Name: types.StringPointerValue(apiResp.Name), + ClusterType: types.StringPointerValue(apiResp.ClusterType), + StateName: types.StringPointerValue(apiResp.StateName), + VersionReleaseSystem: types.StringPointerValue(apiResp.VersionReleaseSystem), + BackupSettings: *backupSettings, + TerminationProtectionEnabled: types.BoolPointerValue(apiResp.TerminationProtectionEnabled), + }, nil +} + +func NewTFModelDSP(ctx context.Context, projectID string, input []admin.FlexClusterDescription20241113) (*TFModelDSP, diag.Diagnostics) { + diags := &diag.Diagnostics{} + tfModels := make([]TFModel, len(input)) + for i := range input { + item := &input[i] + tfModel, diagsLocal := NewTFModel(ctx, item) + diags.Append(diagsLocal...) + if tfModel != nil { + tfModels[i] = *tfModel + } + } + if diags.HasError() { + return nil, *diags + } + return &TFModelDSP{ + ProjectId: types.StringValue(projectID), + Results: tfModels, + }, *diags +} + +func NewAtlasCreateReq(ctx context.Context, plan *TFModel) (*admin.FlexClusterDescriptionCreate20241113, diag.Diagnostics) { + providerSettings := &TFProviderSettings{} + if diags := plan.ProviderSettings.As(ctx, providerSettings, basetypes.ObjectAsOptions{}); diags.HasError() { + return nil, diags + } + return &admin.FlexClusterDescriptionCreate20241113{ + Name: plan.Name.ValueString(), + ProviderSettings: admin.FlexProviderSettingsCreate20241113{ + BackingProviderName: providerSettings.BackingProviderName.ValueString(), + RegionName: providerSettings.RegionName.ValueString(), + }, + TerminationProtectionEnabled: plan.TerminationProtectionEnabled.ValueBoolPointer(), + Tags: conversion.NewResourceTags(ctx, plan.Tags), + }, nil +} + +func NewAtlasUpdateReq(ctx context.Context, plan *TFModel) (*admin.FlexClusterDescriptionUpdate20241113, diag.Diagnostics) { + updateRequest := &admin.FlexClusterDescriptionUpdate20241113{ + TerminationProtectionEnabled: plan.TerminationProtectionEnabled.ValueBoolPointer(), + Tags: conversion.NewResourceTags(ctx, plan.Tags), + } + + return updateRequest, nil +} + +func ConvertBackupSettingsToTF(ctx context.Context, backupSettings *admin.FlexBackupSettings20241113) (*types.Object, diag.Diagnostics) { + if backupSettings == nil { + backupSettingsTF := types.ObjectNull(BackupSettingsType.AttributeTypes()) + return &backupSettingsTF, nil + } + + backupSettingsTF := &TFBackupSettings{ + Enabled: types.BoolPointerValue(backupSettings.Enabled), + } + backupSettingsObject, diags := types.ObjectValueFrom(ctx, BackupSettingsType.AttributeTypes(), backupSettingsTF) + if diags.HasError() { + return nil, diags + } + return &backupSettingsObject, nil +} + +func ConvertConnectionStringsToTF(ctx context.Context, connectionStrings *admin.FlexConnectionStrings20241113) (*types.Object, diag.Diagnostics) { + if connectionStrings == nil { + connectionStringsTF := types.ObjectNull(ConnectionStringsType.AttributeTypes()) + return &connectionStringsTF, nil + } + + connectionStringsTF := &TFConnectionStrings{ + Standard: types.StringPointerValue(connectionStrings.Standard), + StandardSrv: types.StringPointerValue(connectionStrings.StandardSrv), + } + connectionStringsObject, diags := types.ObjectValueFrom(ctx, ConnectionStringsType.AttributeTypes(), connectionStringsTF) + if diags.HasError() { + return nil, diags + } + return &connectionStringsObject, nil +} + +func ConvertProviderSettingsToTF(ctx context.Context, providerSettings admin.FlexProviderSettings20241113) (*types.Object, diag.Diagnostics) { + providerSettingsTF := &TFProviderSettings{ + ProviderName: types.StringPointerValue(providerSettings.ProviderName), + RegionName: types.StringPointerValue(providerSettings.RegionName), + BackingProviderName: types.StringPointerValue(providerSettings.BackingProviderName), + DiskSizeGb: types.Float64PointerValue(providerSettings.DiskSizeGB), + } + providerSettingsObject, diags := types.ObjectValueFrom(ctx, ProviderSettingsType.AttributeTypes(), providerSettingsTF) + if diags.HasError() { + return nil, diags + } + return &providerSettingsObject, nil +} diff --git a/internal/service/flexcluster/model_test.go b/internal/service/flexcluster/model_test.go new file mode 100644 index 0000000000..8f9bd0849b --- /dev/null +++ b/internal/service/flexcluster/model_test.go @@ -0,0 +1,385 @@ +package flexcluster_test + +import ( + "context" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/flexcluster" + "github.com/stretchr/testify/assert" + "go.mongodb.org/atlas-sdk/v20241113003/admin" +) + +var ( + projectID = "projectId" + id = "id" + createDate = "2021-08-17T17:00:00Z" + mongoDBVersion = "8.0" + name = "myCluster" + clusterType = "REPLICASET" + stateName = "IDLE" + versionReleaseSystem = "LTS" + terminationProtectionEnabled = true + createDateTime, _ = conversion.StringToTime(createDate) + providerName = "AWS" + regionName = "us-east-1" + backingProviderName = "AWS" + diskSizeGb = 100.0 + standardConnectionString = "mongodb://localhost:27017" + standardSrvConnectionString = "mongodb+srv://localhost:27017" + key1 = "key1" + value1 = "value1" + connectionStringsObject, _ = flexcluster.ConvertConnectionStringsToTF(context.Background(), &admin.FlexConnectionStrings20241113{ + Standard: &standardConnectionString, + StandardSrv: &standardSrvConnectionString, + }) + backupSettingsObject, _ = flexcluster.ConvertBackupSettingsToTF(context.Background(), &admin.FlexBackupSettings20241113{ + Enabled: conversion.Pointer(true), + }) + providerSettingsObject, _ = flexcluster.ConvertProviderSettingsToTF(context.Background(), admin.FlexProviderSettings20241113{ + ProviderName: &providerName, + RegionName: ®ionName, + BackingProviderName: &backingProviderName, + DiskSizeGB: &diskSizeGb, + }) +) + +type NewTFModelTestCase struct { + expectedTFModel *flexcluster.TFModel + input *admin.FlexClusterDescription20241113 +} + +type NewTFModelDSPTestCase struct { + expectedTFModelDSP *flexcluster.TFModelDSP + input []admin.FlexClusterDescription20241113 +} + +type NewAtlasCreateReqTestCase struct { + input *flexcluster.TFModel + expectedSDKReq *admin.FlexClusterDescriptionCreate20241113 +} + +type NewAtlasUpdateReqTestCase struct { + input *flexcluster.TFModel + expectedSDKReq *admin.FlexClusterDescriptionUpdate20241113 +} + +func TestNewTFModel(t *testing.T) { + providerSettingsTF := &flexcluster.TFProviderSettings{ + ProviderName: types.StringNull(), + RegionName: types.StringNull(), + BackingProviderName: types.StringNull(), + DiskSizeGb: types.Float64Null(), + } + nilProviderSettingsObject, _ := types.ObjectValueFrom(context.Background(), flexcluster.ProviderSettingsType.AttributeTypes(), providerSettingsTF) + testCases := map[string]NewTFModelTestCase{ + "Complete TF state": { + expectedTFModel: &flexcluster.TFModel{ + ProjectId: types.StringValue(projectID), + Id: types.StringValue(id), + Tags: types.MapValueMust(types.StringType, map[string]attr.Value{ + key1: types.StringValue(value1), + }), + ProviderSettings: *providerSettingsObject, + ConnectionStrings: *connectionStringsObject, + CreateDate: types.StringValue(createDate), + MongoDbversion: types.StringValue(mongoDBVersion), + Name: types.StringValue(name), + ClusterType: types.StringValue(clusterType), + StateName: types.StringValue(stateName), + VersionReleaseSystem: types.StringValue(versionReleaseSystem), + BackupSettings: *backupSettingsObject, + TerminationProtectionEnabled: types.BoolValue(terminationProtectionEnabled), + }, + input: &admin.FlexClusterDescription20241113{ + GroupId: &projectID, + Id: &id, + Tags: &[]admin.ResourceTag{ + { + Key: key1, + Value: value1, + }, + }, + ProviderSettings: admin.FlexProviderSettings20241113{ + ProviderName: &providerName, + RegionName: ®ionName, + BackingProviderName: &backingProviderName, + DiskSizeGB: &diskSizeGb, + }, + ConnectionStrings: &admin.FlexConnectionStrings20241113{ + Standard: &standardConnectionString, + StandardSrv: &standardSrvConnectionString, + }, + CreateDate: &createDateTime, + MongoDBVersion: &mongoDBVersion, + Name: &name, + ClusterType: &clusterType, + StateName: &stateName, + VersionReleaseSystem: &versionReleaseSystem, + BackupSettings: &admin.FlexBackupSettings20241113{ + Enabled: conversion.Pointer(true), + }, + TerminationProtectionEnabled: &terminationProtectionEnabled, + }, + }, + "Nil values": { + expectedTFModel: &flexcluster.TFModel{ + ProjectId: types.StringNull(), + Id: types.StringNull(), + Tags: types.MapValueMust(types.StringType, map[string]attr.Value{}), + ProviderSettings: nilProviderSettingsObject, + ConnectionStrings: types.ObjectNull(flexcluster.ConnectionStringsType.AttrTypes), + CreateDate: types.StringNull(), + MongoDbversion: types.StringNull(), + Name: types.StringNull(), + ClusterType: types.StringNull(), + StateName: types.StringNull(), + VersionReleaseSystem: types.StringNull(), + BackupSettings: types.ObjectNull(flexcluster.BackupSettingsType.AttrTypes), + TerminationProtectionEnabled: types.BoolNull(), + }, + input: &admin.FlexClusterDescription20241113{ + GroupId: nil, + Id: nil, + Tags: &[]admin.ResourceTag{}, + ProviderSettings: admin.FlexProviderSettings20241113{}, + ConnectionStrings: nil, + CreateDate: nil, + MongoDBVersion: nil, + Name: nil, + ClusterType: nil, + StateName: nil, + VersionReleaseSystem: nil, + BackupSettings: nil, + TerminationProtectionEnabled: nil, + }, + }, + } + + for testName, tc := range testCases { + t.Run(testName, func(t *testing.T) { + tfModel, diags := flexcluster.NewTFModel(context.Background(), tc.input) + if diags.HasError() { + t.Errorf("unexpected errors found: %s", diags.Errors()[0].Summary()) + } + assert.Equal(t, tc.expectedTFModel, tfModel, "created TF model did not match expected output") + }) + } +} + +func TestNewTFModelDSP(t *testing.T) { + testCases := map[string]NewTFModelDSPTestCase{ + "Complete TF state": { + expectedTFModelDSP: &flexcluster.TFModelDSP{ + ProjectId: types.StringValue(projectID), + Results: []flexcluster.TFModel{ + { + ProjectId: types.StringValue(projectID), + Id: types.StringValue(id), + Tags: types.MapValueMust(types.StringType, map[string]attr.Value{ + key1: types.StringValue(value1), + }), + ProviderSettings: *providerSettingsObject, + ConnectionStrings: *connectionStringsObject, + CreateDate: types.StringValue(createDate), + MongoDbversion: types.StringValue(mongoDBVersion), + Name: types.StringValue(name), + ClusterType: types.StringValue(clusterType), + StateName: types.StringValue(stateName), + VersionReleaseSystem: types.StringValue(versionReleaseSystem), + BackupSettings: *backupSettingsObject, + TerminationProtectionEnabled: types.BoolValue(terminationProtectionEnabled), + }, + { + ProjectId: types.StringValue(projectID), + Id: types.StringValue("id-2"), + Tags: types.MapValueMust(types.StringType, map[string]attr.Value{ + key1: types.StringValue(value1), + }), + ProviderSettings: *providerSettingsObject, + ConnectionStrings: *connectionStringsObject, + CreateDate: types.StringValue(createDate), + MongoDbversion: types.StringValue(mongoDBVersion), + Name: types.StringValue(name), + ClusterType: types.StringValue(clusterType), + StateName: types.StringValue(stateName), + VersionReleaseSystem: types.StringValue(versionReleaseSystem), + BackupSettings: *backupSettingsObject, + TerminationProtectionEnabled: types.BoolValue(terminationProtectionEnabled), + }, + }, + }, + input: []admin.FlexClusterDescription20241113{ + { + GroupId: &projectID, + Id: &id, + Tags: &[]admin.ResourceTag{ + { + Key: key1, + Value: value1, + }, + }, + ProviderSettings: admin.FlexProviderSettings20241113{ + ProviderName: &providerName, + RegionName: ®ionName, + BackingProviderName: &backingProviderName, + DiskSizeGB: &diskSizeGb, + }, + ConnectionStrings: &admin.FlexConnectionStrings20241113{ + Standard: &standardConnectionString, + StandardSrv: &standardSrvConnectionString, + }, + CreateDate: &createDateTime, + MongoDBVersion: &mongoDBVersion, + Name: &name, + ClusterType: &clusterType, + StateName: &stateName, + VersionReleaseSystem: &versionReleaseSystem, + BackupSettings: &admin.FlexBackupSettings20241113{ + Enabled: conversion.Pointer(true), + }, + TerminationProtectionEnabled: &terminationProtectionEnabled, + }, + { + GroupId: &projectID, + Id: conversion.StringPtr("id-2"), + Tags: &[]admin.ResourceTag{ + { + Key: key1, + Value: value1, + }, + }, + ProviderSettings: admin.FlexProviderSettings20241113{ + ProviderName: &providerName, + RegionName: ®ionName, + BackingProviderName: &backingProviderName, + DiskSizeGB: &diskSizeGb, + }, + ConnectionStrings: &admin.FlexConnectionStrings20241113{ + Standard: &standardConnectionString, + StandardSrv: &standardSrvConnectionString, + }, + CreateDate: &createDateTime, + MongoDBVersion: &mongoDBVersion, + Name: &name, + ClusterType: &clusterType, + StateName: &stateName, + VersionReleaseSystem: &versionReleaseSystem, + BackupSettings: &admin.FlexBackupSettings20241113{ + Enabled: conversion.Pointer(true), + }, + TerminationProtectionEnabled: &terminationProtectionEnabled, + }, + }, + }, + "No Flex Clusters": { + expectedTFModelDSP: &flexcluster.TFModelDSP{ + ProjectId: types.StringValue(projectID), + Results: []flexcluster.TFModel{}, + }, + input: []admin.FlexClusterDescription20241113{}, + }, + } + for testName, tc := range testCases { + t.Run(testName, func(t *testing.T) { + tfModelDSP, diags := flexcluster.NewTFModelDSP(context.Background(), projectID, tc.input) + if diags.HasError() { + t.Errorf("unexpected errors found: %s", diags.Errors()[0].Summary()) + } + assert.Equal(t, tc.expectedTFModelDSP, tfModelDSP, "created TF model DSP did not match expected output") + }) + } +} + +func TestNewAtlasCreateReq(t *testing.T) { + testCases := map[string]NewAtlasCreateReqTestCase{ + "Complete TF state": { + input: &flexcluster.TFModel{ + ProjectId: types.StringValue(projectID), + Id: types.StringValue(id), + Tags: types.MapValueMust(types.StringType, map[string]attr.Value{ + key1: types.StringValue(value1), + }), + ProviderSettings: *providerSettingsObject, + ConnectionStrings: *connectionStringsObject, + CreateDate: types.StringValue(createDate), + MongoDbversion: types.StringValue(mongoDBVersion), + Name: types.StringValue(name), + ClusterType: types.StringValue(clusterType), + StateName: types.StringValue(stateName), + VersionReleaseSystem: types.StringValue(versionReleaseSystem), + BackupSettings: *backupSettingsObject, + TerminationProtectionEnabled: types.BoolValue(terminationProtectionEnabled), + }, + expectedSDKReq: &admin.FlexClusterDescriptionCreate20241113{ + Name: name, + Tags: &[]admin.ResourceTag{ + { + Key: key1, + Value: value1, + }, + }, + ProviderSettings: admin.FlexProviderSettingsCreate20241113{ + RegionName: regionName, + BackingProviderName: backingProviderName, + }, + TerminationProtectionEnabled: &terminationProtectionEnabled, + }, + }, + } + + for testName, tc := range testCases { + t.Run(testName, func(t *testing.T) { + apiReqResult, diags := flexcluster.NewAtlasCreateReq(context.Background(), tc.input) + if diags.HasError() { + t.Errorf("unexpected errors found: %s", diags.Errors()[0].Summary()) + } + assert.Equal(t, tc.expectedSDKReq, apiReqResult, "created sdk model did not match expected output") + }) + } +} + +func TestNewAtlasUpdateReq(t *testing.T) { + testCases := map[string]NewAtlasUpdateReqTestCase{ + "Complete TF state": { + input: &flexcluster.TFModel{ + ProjectId: types.StringValue(projectID), + Id: types.StringValue(id), + Tags: types.MapValueMust(types.StringType, map[string]attr.Value{ + key1: types.StringValue(value1), + }), + ProviderSettings: *providerSettingsObject, + ConnectionStrings: *connectionStringsObject, + CreateDate: types.StringValue(createDate), + MongoDbversion: types.StringValue(mongoDBVersion), + Name: types.StringValue(name), + ClusterType: types.StringValue(clusterType), + StateName: types.StringValue(stateName), + VersionReleaseSystem: types.StringValue(versionReleaseSystem), + BackupSettings: *backupSettingsObject, + TerminationProtectionEnabled: types.BoolValue(terminationProtectionEnabled), + }, + expectedSDKReq: &admin.FlexClusterDescriptionUpdate20241113{ + Tags: &[]admin.ResourceTag{ + { + Key: key1, + Value: value1, + }, + }, + TerminationProtectionEnabled: &terminationProtectionEnabled, + }, + }, + } + + for testName, tc := range testCases { + t.Run(testName, func(t *testing.T) { + apiReqResult, diags := flexcluster.NewAtlasUpdateReq(context.Background(), tc.input) + if diags.HasError() { + t.Errorf("unexpected errors found: %s", diags.Errors()[0].Summary()) + } + assert.Equal(t, tc.expectedSDKReq, apiReqResult, "created sdk model did not match expected output") + }) + } +} diff --git a/internal/service/flexcluster/plural_data_source.go b/internal/service/flexcluster/plural_data_source.go new file mode 100644 index 0000000000..1abde0e2c7 --- /dev/null +++ b/internal/service/flexcluster/plural_data_source.go @@ -0,0 +1,66 @@ +package flexcluster + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/dsschema" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" + "go.mongodb.org/atlas-sdk/v20241113003/admin" +) + +var _ datasource.DataSource = &pluralDS{} +var _ datasource.DataSourceWithConfigure = &pluralDS{} + +func PluralDataSource() datasource.DataSource { + return &pluralDS{ + DSCommon: config.DSCommon{ + DataSourceName: fmt.Sprintf("%ss", resourceName), + }, + } +} + +type pluralDS struct { + config.DSCommon +} + +func (d *pluralDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = conversion.PluralDataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.PluralDataSourceSchemaRequest{ + RequiredFields: []string{"project_id"}, + }) +} + +func (d *pluralDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var tfModel TFModelDSP + resp.Diagnostics.Append(req.Config.Get(ctx, &tfModel)...) + if resp.Diagnostics.HasError() { + return + } + + connV2 := d.Client.AtlasV2 + + params := admin.ListFlexClustersApiParams{ + GroupId: tfModel.ProjectId.ValueString(), + } + + sdkProcessors, err := dsschema.AllPages(ctx, func(ctx context.Context, pageNum int) (dsschema.PaginateResponse[admin.FlexClusterDescription20241113], *http.Response, error) { + request := connV2.FlexClustersApi.ListFlexClustersWithParams(ctx, ¶ms) + request = request.PageNum(pageNum) + return request.Execute() + }) + + if err != nil { + resp.Diagnostics.AddError("error reading plural data source", err.Error()) + return + } + + newFlexClustersModel, diags := NewTFModelDSP(ctx, tfModel.ProjectId.ValueString(), sdkProcessors) + if diags.HasError() { + resp.Diagnostics.Append(diags...) + return + } + resp.Diagnostics.Append(resp.State.Set(ctx, newFlexClustersModel)...) +} diff --git a/internal/service/flexcluster/resource.go b/internal/service/flexcluster/resource.go new file mode 100644 index 0000000000..b0c7578852 --- /dev/null +++ b/internal/service/flexcluster/resource.go @@ -0,0 +1,215 @@ +package flexcluster + +import ( + "context" + "errors" + "net/http" + "regexp" + + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/types" + "go.mongodb.org/atlas-sdk/v20241113003/admin" + + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/retrystrategy" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" +) + +const resourceName = "flex_cluster" +const ErrorUpdateNotAllowed = "update not allowed" + +var _ resource.ResourceWithConfigure = &rs{} +var _ resource.ResourceWithImportState = &rs{} + +func Resource() resource.Resource { + return &rs{ + RSCommon: config.RSCommon{ + ResourceName: resourceName, + }, + } +} + +type rs struct { + config.RSCommon +} + +func (r *rs) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = ResourceSchema(ctx) + conversion.UpdateSchemaDescription(&resp.Schema) +} + +func (r *rs) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var tfModel TFModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &tfModel)...) + if resp.Diagnostics.HasError() { + return + } + + flexClusterReq, diags := NewAtlasCreateReq(ctx, &tfModel) + if diags.HasError() { + resp.Diagnostics.Append(diags...) + return + } + + projectID := tfModel.ProjectId.ValueString() + clusterName := tfModel.Name.ValueString() + + connV2 := r.Client.AtlasV2 + _, _, err := connV2.FlexClustersApi.CreateFlexCluster(ctx, projectID, flexClusterReq).Execute() + if err != nil { + resp.Diagnostics.AddError("error creating resource", err.Error()) + return + } + + flexClusterParams := &admin.GetFlexClusterApiParams{ + GroupId: projectID, + Name: clusterName, + } + + flexClusterResp, err := WaitStateTransition(ctx, flexClusterParams, connV2.FlexClustersApi, []string{retrystrategy.RetryStrategyCreatingState}, []string{retrystrategy.RetryStrategyIdleState}) + if err != nil { + resp.Diagnostics.AddError("error waiting for resource to be created", err.Error()) + return + } + + newFlexClusterModel, diags := NewTFModel(ctx, flexClusterResp) + if diags.HasError() { + resp.Diagnostics.Append(diags...) + return + } + + if conversion.UseNilForEmpty(tfModel.Tags, newFlexClusterModel.Tags) { + newFlexClusterModel.Tags = types.MapNull(types.StringType) + } + + resp.Diagnostics.Append(resp.State.Set(ctx, newFlexClusterModel)...) +} + +func (r *rs) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var flexClusterState TFModel + resp.Diagnostics.Append(req.State.Get(ctx, &flexClusterState)...) + if resp.Diagnostics.HasError() { + return + } + + connV2 := r.Client.AtlasV2 + flexCluster, apiResp, err := connV2.FlexClustersApi.GetFlexCluster(ctx, flexClusterState.ProjectId.ValueString(), flexClusterState.Name.ValueString()).Execute() + if err != nil { + if apiResp != nil && apiResp.StatusCode == http.StatusNotFound { + resp.State.RemoveResource(ctx) + return + } + resp.Diagnostics.AddError("error fetching resource", err.Error()) + return + } + + newFlexClusterModel, diags := NewTFModel(ctx, flexCluster) + if diags.HasError() { + resp.Diagnostics.Append(diags...) + return + } + + if conversion.UseNilForEmpty(flexClusterState.Tags, newFlexClusterModel.Tags) { + newFlexClusterModel.Tags = types.MapNull(types.StringType) + } + + resp.Diagnostics.Append(resp.State.Set(ctx, newFlexClusterModel)...) +} + +func (r *rs) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var plan TFModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + flexClusterReq, diags := NewAtlasUpdateReq(ctx, &plan) + if diags.HasError() { + resp.Diagnostics.Append(diags...) + return + } + + projectID := plan.ProjectId.ValueString() + clusterName := plan.Name.ValueString() + + connV2 := r.Client.AtlasV2 + _, _, err := connV2.FlexClustersApi.UpdateFlexCluster(ctx, projectID, plan.Name.ValueString(), flexClusterReq).Execute() + if err != nil { + resp.Diagnostics.AddError("error updating resource", err.Error()) + return + } + + flexClusterParams := &admin.GetFlexClusterApiParams{ + GroupId: projectID, + Name: clusterName, + } + + flexClusterResp, err := WaitStateTransition(ctx, flexClusterParams, connV2.FlexClustersApi, []string{retrystrategy.RetryStrategyUpdatingState}, []string{retrystrategy.RetryStrategyIdleState}) + if err != nil { + resp.Diagnostics.AddError("error waiting for resource to be updated", err.Error()) + return + } + + newFlexClusterModel, diags := NewTFModel(ctx, flexClusterResp) + if diags.HasError() { + resp.Diagnostics.Append(diags...) + return + } + + if conversion.UseNilForEmpty(plan.Tags, newFlexClusterModel.Tags) { + newFlexClusterModel.Tags = types.MapNull(types.StringType) + } + + resp.Diagnostics.Append(resp.State.Set(ctx, newFlexClusterModel)...) +} + +func (r *rs) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var flexClusterState *TFModel + resp.Diagnostics.Append(req.State.Get(ctx, &flexClusterState)...) + if resp.Diagnostics.HasError() { + return + } + + connV2 := r.Client.AtlasV2 + if _, _, err := connV2.FlexClustersApi.DeleteFlexCluster(ctx, flexClusterState.ProjectId.ValueString(), flexClusterState.Name.ValueString()).Execute(); err != nil { + resp.Diagnostics.AddError("error deleting resource", err.Error()) + return + } + + flexClusterParams := &admin.GetFlexClusterApiParams{ + GroupId: flexClusterState.ProjectId.ValueString(), + Name: flexClusterState.Name.ValueString(), + } + + if err := WaitStateTransitionDelete(ctx, flexClusterParams, connV2.FlexClustersApi); err != nil { + resp.Diagnostics.AddError("error waiting for resource to be deleted", err.Error()) + return + } +} + +func (r *rs) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + projectID, name, err := splitFlexClusterImportID(req.ID) + if err != nil { + resp.Diagnostics.AddError("error splitting import ID", err.Error()) + return + } + + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), projectID)...) + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("name"), name)...) +} + +func splitFlexClusterImportID(id string) (projectID, clusterName *string, err error) { + var re = regexp.MustCompile(`(?s)^([0-9a-fA-F]{24})-(.*)$`) + parts := re.FindStringSubmatch(id) + + if len(parts) != 3 { + err = errors.New("import format error: to import a flex cluster, use the format {project_id}-{cluster_name}") + return + } + + projectID = &parts[1] + clusterName = &parts[2] + + return +} diff --git a/internal/service/flexcluster/resource_schema.go b/internal/service/flexcluster/resource_schema.go new file mode 100644 index 0000000000..d703b24b30 --- /dev/null +++ b/internal/service/flexcluster/resource_schema.go @@ -0,0 +1,203 @@ +package flexcluster + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/customplanmodifier" + + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/float64planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" +) + +func ResourceSchema(ctx context.Context) schema.Schema { + return schema.Schema{ + Attributes: map[string]schema.Attribute{ + "project_id": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + customplanmodifier.NonUpdatableStringAttributePlanModifier(), + }, + MarkdownDescription: "Unique 24-hexadecimal character string that identifies the project.", + }, + "name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + customplanmodifier.NonUpdatableStringAttributePlanModifier(), + }, + MarkdownDescription: "Human-readable label that identifies the instance.", + }, + "provider_settings": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "backing_provider_name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + customplanmodifier.NonUpdatableStringAttributePlanModifier(), + }, + MarkdownDescription: "Cloud service provider on which MongoDB Cloud provisioned the flex cluster.", + }, + "disk_size_gb": schema.Float64Attribute{ + Computed: true, + PlanModifiers: []planmodifier.Float64{ + float64planmodifier.UseStateForUnknown(), + }, + MarkdownDescription: "Storage capacity available to the flex cluster expressed in gigabytes.", + }, + "provider_name": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: "Human-readable label that identifies the cloud service provider.", + }, + "region_name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + customplanmodifier.NonUpdatableStringAttributePlanModifier(), + }, + MarkdownDescription: "Human-readable label that identifies the geographic location of your MongoDB flex cluster. The region you choose can affect network latency for clients accessing your databases. For a complete list of region names, see [AWS](https://docs.atlas.mongodb.com/reference/amazon-aws/#std-label-amazon-aws), [GCP](https://docs.atlas.mongodb.com/reference/google-gcp/), and [Azure](https://docs.atlas.mongodb.com/reference/microsoft-azure/).", + }, + }, + Required: true, + MarkdownDescription: "Group of cloud provider settings that configure the provisioned MongoDB flex cluster.", + }, + "tags": schema.MapAttribute{ + ElementType: types.StringType, + Optional: true, + MarkdownDescription: "Map that contains key-value pairs between 1 to 255 characters in length for tagging and categorizing the instance.", + }, + "backup_settings": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "enabled": schema.BoolAttribute{ + Computed: true, + MarkdownDescription: "Flag that indicates whether backups are performed for this flex cluster. Backup uses [TODO](TODO) for flex clusters.", + }, + }, + Computed: true, + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: "Flex backup configuration", + }, + "cluster_type": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: "Flex cluster topology.", + }, + "connection_strings": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "standard": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "Public connection string that you can use to connect to this cluster. This connection string uses the mongodb:// protocol.", + }, + "standard_srv": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "Public connection string that you can use to connect to this flex cluster. This connection string uses the `mongodb+srv://` protocol.", + }, + }, + Computed: true, + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: "Collection of Uniform Resource Locators that point to the MongoDB database.", + }, + "create_date": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: "Date and time when MongoDB Cloud created this instance. This parameter expresses its value in ISO 8601 format in UTC.", + }, + "id": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: "Unique 24-hexadecimal digit string that identifies the instance.", + }, + "mongo_db_version": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "Version of MongoDB that the instance runs.", + }, + "state_name": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "Human-readable label that indicates the current operating condition of this instance.", + }, + "termination_protection_enabled": schema.BoolAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Bool{ + boolplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: "Flag that indicates whether termination protection is enabled on the cluster. If set to `true`, MongoDB Cloud won't delete the cluster. If set to `false`, MongoDB Cloud will delete the cluster.", + }, + "version_release_system": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: "Method by which the cluster maintains the MongoDB versions.", + }, + }, + } +} + +type TFModel struct { + ProviderSettings types.Object `tfsdk:"provider_settings"` + ConnectionStrings types.Object `tfsdk:"connection_strings"` + Tags types.Map `tfsdk:"tags"` + CreateDate types.String `tfsdk:"create_date"` + ProjectId types.String `tfsdk:"project_id"` + Id types.String `tfsdk:"id"` + MongoDbversion types.String `tfsdk:"mongo_db_version"` + Name types.String `tfsdk:"name"` + ClusterType types.String `tfsdk:"cluster_type"` + StateName types.String `tfsdk:"state_name"` + VersionReleaseSystem types.String `tfsdk:"version_release_system"` + BackupSettings types.Object `tfsdk:"backup_settings"` + TerminationProtectionEnabled types.Bool `tfsdk:"termination_protection_enabled"` +} + +type TFBackupSettings struct { + Enabled types.Bool `tfsdk:"enabled"` +} + +var BackupSettingsType = types.ObjectType{AttrTypes: map[string]attr.Type{ + "enabled": types.BoolType, +}} + +type TFConnectionStrings struct { + Standard types.String `tfsdk:"standard"` + StandardSrv types.String `tfsdk:"standard_srv"` +} + +var ConnectionStringsType = types.ObjectType{AttrTypes: map[string]attr.Type{ + "standard": types.StringType, + "standard_srv": types.StringType, +}} + +type TFProviderSettings struct { + BackingProviderName types.String `tfsdk:"backing_provider_name"` + DiskSizeGb types.Float64 `tfsdk:"disk_size_gb"` + ProviderName types.String `tfsdk:"provider_name"` + RegionName types.String `tfsdk:"region_name"` +} + +var ProviderSettingsType = types.ObjectType{AttrTypes: map[string]attr.Type{ + "backing_provider_name": types.StringType, + "disk_size_gb": types.Float64Type, + "provider_name": types.StringType, + "region_name": types.StringType, +}} + +type TFModelDSP struct { + ProjectId types.String `tfsdk:"project_id"` + Results []TFModel `tfsdk:"results"` +} diff --git a/internal/service/flexcluster/resource_test.go b/internal/service/flexcluster/resource_test.go new file mode 100644 index 0000000000..b93d9a07fb --- /dev/null +++ b/internal/service/flexcluster/resource_test.go @@ -0,0 +1,202 @@ +package flexcluster_test + +import ( + "context" + "fmt" + "os" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" +) + +var ( + resourceType = "mongodbatlas_flex_cluster" + resourceName = "mongodbatlas_flex_cluster.test" + dataSourceName = "data.mongodbatlas_flex_cluster.test" + dataSourcePluralName = "data.mongodbatlas_flex_clusters.test" +) + +func TestAccFlexClusterRS_basic(t *testing.T) { + tc := basicTestCase(t) + // Tests include testing of plural data source and so cannot be run in parallel + resource.Test(t, *tc) +} + +func TestAccFlexClusterRS_failedUpdate(t *testing.T) { + tc := failedUpdateTestCase(t) + resource.Test(t, *tc) +} + +func basicTestCase(t *testing.T) *resource.TestCase { + t.Helper() + var ( + projectID = os.Getenv("MONGODB_ATLAS_FLEX_PROJECT_ID") + clusterName = acc.RandomName() + provider = "AWS" + region = "US_EAST_1" + ) + return &resource.TestCase{ + PreCheck: func() { acc.PreCheckBasic(t) }, + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: checkDestroy, + Steps: []resource.TestStep{ + { + Config: configBasic(projectID, clusterName, provider, region, true, false), + Check: checksFlexCluster(projectID, clusterName, true, false), + }, + { + Config: configBasic(projectID, clusterName, provider, region, false, true), + Check: checksFlexCluster(projectID, clusterName, false, true), + }, + { + Config: configBasic(projectID, clusterName, provider, region, true, true), + ResourceName: resourceName, + ImportStateIdFunc: importStateIDFunc(resourceName), + ImportState: true, + ImportStateVerify: true, + }, + }, + } +} + +func failedUpdateTestCase(t *testing.T) *resource.TestCase { + t.Helper() + var ( + projectID = os.Getenv("MONGODB_ATLAS_FLEX_PROJECT_ID") + projectIDUpdated = os.Getenv("MONGODB_ATLAS_FLEX_PROJECT_ID") + "-updated" + clusterName = acc.RandomName() + clusterNameUpdated = clusterName + "-updated" + provider = "AWS" + providerUpdated = "GCP" + region = "US_EAST_1" + regionUpdated = "US_EAST_2" + ) + return &resource.TestCase{ + PreCheck: func() { acc.PreCheckBasic(t) }, + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: checkDestroy, + Steps: []resource.TestStep{ + { + Config: configBasic(projectID, clusterName, provider, region, false, false), + Check: checksFlexCluster(projectID, clusterName, false, false), + }, + { + Config: configBasic(projectID, clusterNameUpdated, provider, region, false, false), + ExpectError: regexp.MustCompile("name cannot be updated"), + }, + { + Config: configBasic(projectIDUpdated, clusterName, provider, region, false, false), + ExpectError: regexp.MustCompile("project_id cannot be updated"), + }, + { + Config: configBasic(projectID, clusterName, providerUpdated, region, false, false), + ExpectError: regexp.MustCompile("provider_settings.backing_provider_name cannot be updated"), + }, + { + Config: configBasic(projectID, clusterName, provider, regionUpdated, false, false), + ExpectError: regexp.MustCompile("provider_settings.region_name cannot be updated"), + }, + }, + } +} + +func configBasic(projectID, clusterName, provider, region string, terminationProtectionEnabled, tags bool) string { + tagsConfig := "" + if tags { + tagsConfig = ` + tags = { + testKey = "testValue" + }` + } + return fmt.Sprintf(` + resource "mongodbatlas_flex_cluster" "test" { + project_id = %[1]q + name = %[2]q + provider_settings = { + backing_provider_name = %[3]q + region_name = %[4]q + } + termination_protection_enabled = %[5]t + %[6]s + } + data "mongodbatlas_flex_cluster" "test" { + project_id = mongodbatlas_flex_cluster.test.project_id + name = mongodbatlas_flex_cluster.test.name + } + data "mongodbatlas_flex_clusters" "test" { + project_id = mongodbatlas_flex_cluster.test.project_id + }`, projectID, clusterName, provider, region, terminationProtectionEnabled, tagsConfig) +} + +func checksFlexCluster(projectID, clusterName string, terminationProtectionEnabled, tagsCheck bool) resource.TestCheckFunc { + checks := []resource.TestCheckFunc{checkExists()} + attrMap := map[string]string{ + "project_id": projectID, + "name": clusterName, + "termination_protection_enabled": fmt.Sprintf("%v", terminationProtectionEnabled), + } + if tagsCheck { + attrMap["tags.testKey"] = "testValue" + } + pluralMap := map[string]string{ + "project_id": projectID, + "results.#": "1", + } + attrSet := []string{ + "backup_settings.enabled", + "cluster_type", + "connection_strings.standard", + "create_date", + "id", + "mongo_db_version", + "state_name", + "version_release_system", + "provider_settings.provider_name", + } + checks = acc.AddAttrChecks(dataSourcePluralName, checks, pluralMap) + return acc.CheckRSAndDS(resourceName, &dataSourceName, &dataSourcePluralName, attrSet, attrMap, checks...) +} + +func checkExists() resource.TestCheckFunc { + return func(s *terraform.State) error { + for _, rs := range s.RootModule().Resources { + if rs.Type == resourceType { + projectID := rs.Primary.Attributes["project_id"] + name := rs.Primary.Attributes["name"] + _, _, err := acc.ConnV2().FlexClustersApi.GetFlexCluster(context.Background(), projectID, name).Execute() + if err != nil { + return fmt.Errorf("flex cluster (%s:%s) not found", projectID, name) + } + } + } + return nil + } +} + +func checkDestroy(state *terraform.State) error { + for _, rs := range state.RootModule().Resources { + if rs.Type == resourceType { + projectID := rs.Primary.Attributes["project_id"] + name := rs.Primary.Attributes["name"] + _, _, err := acc.ConnV2().FlexClustersApi.GetFlexCluster(context.Background(), projectID, name).Execute() + if err == nil { + return fmt.Errorf("flex cluster (%s:%s) still exists", projectID, name) + } + } + } + return nil +} + +func importStateIDFunc(resourceName string) resource.ImportStateIdFunc { + return func(s *terraform.State) (string, error) { + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return "", fmt.Errorf("not found: %s", resourceName) + } + + return fmt.Sprintf("%s-%s", rs.Primary.Attributes["project_id"], rs.Primary.Attributes["name"]), nil + } +} diff --git a/internal/service/flexcluster/state_transition.go b/internal/service/flexcluster/state_transition.go new file mode 100644 index 0000000000..72f65c90bf --- /dev/null +++ b/internal/service/flexcluster/state_transition.go @@ -0,0 +1,60 @@ +package flexcluster + +import ( + "context" + "errors" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/retrystrategy" + "go.mongodb.org/atlas-sdk/v20241113003/admin" +) + +func WaitStateTransition(ctx context.Context, requestParams *admin.GetFlexClusterApiParams, client admin.FlexClustersApi, pendingStates, desiredStates []string) (*admin.FlexClusterDescription20241113, error) { + stateConf := &retry.StateChangeConf{ + Pending: pendingStates, + Target: desiredStates, + Refresh: refreshFunc(ctx, requestParams, client), + Timeout: 3 * time.Hour, + MinTimeout: 3 * time.Second, + Delay: 0, + } + + flexClusterResp, err := stateConf.WaitForStateContext(ctx) + if err != nil { + return nil, err + } + + if flexCluster, ok := flexClusterResp.(*admin.FlexClusterDescription20241113); ok && flexCluster != nil { + return flexCluster, nil + } + + return nil, errors.New("did not obtain valid result when waiting for flex cluster state transition") +} + +func WaitStateTransitionDelete(ctx context.Context, requestParams *admin.GetFlexClusterApiParams, client admin.FlexClustersApi) error { + stateConf := &retry.StateChangeConf{ + Pending: []string{retrystrategy.RetryStrategyDeletingState}, + Target: []string{retrystrategy.RetryStrategyDeletedState}, + Refresh: refreshFunc(ctx, requestParams, client), + Timeout: 3 * time.Hour, + MinTimeout: 3 * time.Second, + Delay: 0, + } + _, err := stateConf.WaitForStateContext(ctx) + return err +} + +func refreshFunc(ctx context.Context, requestParams *admin.GetFlexClusterApiParams, client admin.FlexClustersApi) retry.StateRefreshFunc { + return func() (any, string, error) { + flexCluster, resp, err := client.GetFlexClusterWithParams(ctx, requestParams).Execute() + if err != nil { + if resp.StatusCode == 404 { + return "", retrystrategy.RetryStrategyDeletedState, nil + } + return nil, "", err + } + state := flexCluster.GetStateName() + return flexCluster, state, nil + } +} diff --git a/internal/service/flexcluster/state_transition_test.go b/internal/service/flexcluster/state_transition_test.go new file mode 100644 index 0000000000..ca0f751b6b --- /dev/null +++ b/internal/service/flexcluster/state_transition_test.go @@ -0,0 +1,163 @@ +package flexcluster_test + +import ( + "context" + "errors" + "net/http" + "testing" + + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/flexcluster" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "go.mongodb.org/atlas-sdk/v20241113003/admin" + "go.mongodb.org/atlas-sdk/v20241113003/mockadmin" +) + +var ( + IdleState = "IDLE" + CreatingState = "CREATING" + UpdatingState = "UPDATING" + DeletingState = "DELETING" + DeletedState = "DELETED" + UnknownState = "" + sc500 = conversion.IntPtr(500) + sc200 = conversion.IntPtr(200) + sc404 = conversion.IntPtr(404) + clusterName = "clusterName" + requestParams = &admin.GetFlexClusterApiParams{ + GroupId: "groupId", + Name: clusterName, + } +) + +type testCase struct { + expectedState *string + name string + mockResponses []response + desiredStates []string + pendingStates []string + expectedError bool +} + +func TestFlexClusterStateTransition(t *testing.T) { + testCases := []testCase{ + { + name: "Successful transition to IDLE", + mockResponses: []response{ + {state: &CreatingState, statusCode: sc200}, + {state: &IdleState, statusCode: sc200}, + }, + expectedState: &IdleState, + expectedError: false, + desiredStates: []string{IdleState}, + pendingStates: []string{CreatingState}, + }, + { + name: "Error when API returns 5XX", + mockResponses: []response{ + {statusCode: sc500, err: errors.New("Internal server error")}, + }, + expectedState: nil, + expectedError: true, + desiredStates: []string{IdleState}, + pendingStates: []string{CreatingState}, + }, + { + name: "Deleted state when API returns 404", + mockResponses: []response{ + {state: &DeletingState, statusCode: sc200}, + {statusCode: sc404, err: errors.New("Not found")}, + }, + expectedState: nil, + expectedError: true, + desiredStates: []string{IdleState}, + pendingStates: []string{DeletingState}, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + m := mockadmin.NewFlexClustersApi(t) + m.EXPECT().GetFlexClusterWithParams(mock.Anything, mock.Anything).Return(admin.GetFlexClusterApiRequest{ApiService: m}) + + for _, resp := range tc.mockResponses { + modelResp, httpResp, err := resp.get() + m.EXPECT().GetFlexClusterExecute(mock.Anything).Return(modelResp, httpResp, err).Once() + } + resp, err := flexcluster.WaitStateTransition(context.Background(), requestParams, m, tc.pendingStates, tc.desiredStates) + assert.Equal(t, tc.expectedError, err != nil) + if resp != nil { + assert.Equal(t, *tc.expectedState, *resp.StateName) + } + }) + } +} + +func TestFlexClusterStateTransitionForDelete(t *testing.T) { + testCases := []testCase{ + { + name: "Successful transition to DELETED", + mockResponses: []response{ + {state: &DeletingState, statusCode: sc200}, + {statusCode: sc404, err: errors.New("Not found")}, + }, + expectedError: false, + }, + { + name: "Error when API responds with error", + mockResponses: []response{ + {statusCode: sc500, err: errors.New("Internal server error")}, + }, + expectedError: true, + }, + { + name: "Failed delete when responding with unknown state", + mockResponses: []response{ + {state: &DeletingState}, + {state: &UnknownState}, + }, + expectedError: true, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + m := mockadmin.NewFlexClustersApi(t) + m.EXPECT().GetFlexClusterWithParams(mock.Anything, mock.Anything).Return(admin.GetFlexClusterApiRequest{ApiService: m}) + + for _, resp := range tc.mockResponses { + modelResp, httpResp, err := resp.get() + m.EXPECT().GetFlexClusterExecute(mock.Anything).Return(modelResp, httpResp, err).Once() + } + err := flexcluster.WaitStateTransitionDelete(context.Background(), requestParams, m) + assert.Equal(t, tc.expectedError, err != nil) + }) + } +} + +type response struct { + state *string + statusCode *int + err error +} + +func (r *response) get() (*admin.FlexClusterDescription20241113, *http.Response, error) { + var httpResp *http.Response + if r.statusCode != nil { + httpResp = &http.Response{ + StatusCode: *r.statusCode, + } + } + return responseWithState(r.state), httpResp, r.err +} + +func responseWithState(state *string) *admin.FlexClusterDescription20241113 { + if state == nil { + return nil + } + return &admin.FlexClusterDescription20241113{ + Name: &clusterName, + StateName: state, + } +} diff --git a/internal/service/flexcluster/tfplugingen/generator_config.yml b/internal/service/flexcluster/tfplugingen/generator_config.yml new file mode 100644 index 0000000000..d8ca4550d9 --- /dev/null +++ b/internal/service/flexcluster/tfplugingen/generator_config.yml @@ -0,0 +1,21 @@ +provider: + name: mongodbatlas + +resources: + flex_cluster: + read: + path: /api/atlas/v2/groups/{groupId}/flexClusters/{name} + method: GET + create: + path: /api/atlas/v2/groups/{groupId}/flexClusters + method: POST + +data_sources: + flex_cluster: + read: + path: /api/atlas/v2/groups/{groupId}/flexClusters/{name} + method: GET + flex_clusters: + read: + path: /api/atlas/v2/groups/{groupId}/flexClusters + method: GET diff --git a/internal/service/globalclusterconfig/resource_global_cluster_config.go b/internal/service/globalclusterconfig/resource_global_cluster_config.go index 0024876e49..ae56d8ab5d 100644 --- a/internal/service/globalclusterconfig/resource_global_cluster_config.go +++ b/internal/service/globalclusterconfig/resource_global_cluster_config.go @@ -14,7 +14,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/ldapconfiguration/data_source_ldap_configuration.go b/internal/service/ldapconfiguration/data_source_ldap_configuration.go index 9b4739b51b..f7a657c16c 100644 --- a/internal/service/ldapconfiguration/data_source_ldap_configuration.go +++ b/internal/service/ldapconfiguration/data_source_ldap_configuration.go @@ -77,7 +77,7 @@ func dataSourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag. connV2 := meta.(*config.MongoDBClient).AtlasV2 projectID := d.Get("project_id").(string) - resp, _, err := connV2.LDAPConfigurationApi.GetLDAPConfiguration(ctx, projectID).Execute() + resp, _, err := connV2.LDAPConfigurationApi.GetLdapConfiguration(ctx, projectID).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorRead, projectID, err)) } diff --git a/internal/service/ldapconfiguration/resource_ldap_configuration.go b/internal/service/ldapconfiguration/resource_ldap_configuration.go index 22a7346be1..736821d2ef 100644 --- a/internal/service/ldapconfiguration/resource_ldap_configuration.go +++ b/internal/service/ldapconfiguration/resource_ldap_configuration.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( @@ -144,7 +144,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. params := &admin.UserSecurity{ Ldap: ldap, } - _, _, err := connV2.LDAPConfigurationApi.SaveLDAPConfiguration(ctx, projectID, params).Execute() + _, _, err := connV2.LDAPConfigurationApi.SaveLdapConfiguration(ctx, projectID, params).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorCreate, projectID, err)) } @@ -154,7 +154,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. func resourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { connV2 := meta.(*config.MongoDBClient).AtlasV2 - resp, httpResp, err := connV2.LDAPConfigurationApi.GetLDAPConfiguration(context.Background(), d.Id()).Execute() + resp, httpResp, err := connV2.LDAPConfigurationApi.GetLdapConfiguration(context.Background(), d.Id()).Execute() if err != nil { if httpResp != nil && httpResp.StatusCode == http.StatusNotFound { d.SetId("") @@ -233,7 +233,7 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. params := &admin.UserSecurity{ Ldap: ldap, } - _, _, err := connV2.LDAPConfigurationApi.SaveLDAPConfiguration(ctx, d.Id(), params).Execute() + _, _, err := connV2.LDAPConfigurationApi.SaveLdapConfiguration(ctx, d.Id(), params).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorUpdate, d.Id(), err)) } @@ -248,7 +248,7 @@ func resourceDelete(ctx context.Context, d *schema.ResourceData, meta any) diag. AuthorizationEnabled: conversion.Pointer(false), }, } - _, _, err := connV2.LDAPConfigurationApi.SaveLDAPConfiguration(ctx, d.Id(), params).Execute() + _, _, err := connV2.LDAPConfigurationApi.SaveLdapConfiguration(ctx, d.Id(), params).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorDelete, d.Id(), err)) } diff --git a/internal/service/ldapconfiguration/resource_ldap_configuration_test.go b/internal/service/ldapconfiguration/resource_ldap_configuration_test.go index 8dd34facfe..cf770e4844 100644 --- a/internal/service/ldapconfiguration/resource_ldap_configuration_test.go +++ b/internal/service/ldapconfiguration/resource_ldap_configuration_test.go @@ -125,7 +125,7 @@ func checkExists(resourceName string) resource.TestCheckFunc { if rs.Primary.ID == "" { return fmt.Errorf("no ID is set") } - _, _, err := acc.ConnV2().LDAPConfigurationApi.GetLDAPConfiguration(context.Background(), rs.Primary.ID).Execute() + _, _, err := acc.ConnV2().LDAPConfigurationApi.GetLdapConfiguration(context.Background(), rs.Primary.ID).Execute() if err != nil { return fmt.Errorf("ldapConfiguration (%s) does not exist", rs.Primary.ID) } diff --git a/internal/service/ldapverify/data_source_ldap_verify.go b/internal/service/ldapverify/data_source_ldap_verify.go index 70eddfe720..f00e8b64f8 100644 --- a/internal/service/ldapverify/data_source_ldap_verify.go +++ b/internal/service/ldapverify/data_source_ldap_verify.go @@ -78,7 +78,7 @@ func dataSourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag. connV2 := meta.(*config.MongoDBClient).AtlasV2 projectID := d.Get("project_id").(string) requestID := d.Get("request_id").(string) - ldapResp, _, err := connV2.LDAPConfigurationApi.GetLDAPConfigurationStatus(ctx, projectID, requestID).Execute() + ldapResp, _, err := connV2.LDAPConfigurationApi.GetLdapConfigurationStatus(ctx, projectID, requestID).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorRead, projectID, err)) } diff --git a/internal/service/ldapverify/resource_ldap_verify.go b/internal/service/ldapverify/resource_ldap_verify.go index 607fa05e9d..a4ead00fd5 100644 --- a/internal/service/ldapverify/resource_ldap_verify.go +++ b/internal/service/ldapverify/resource_ldap_verify.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( @@ -136,7 +136,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. params.AuthzQueryTemplate = conversion.Pointer(v.(string)) } - ldap, _, err := connV2.LDAPConfigurationApi.VerifyLDAPConfiguration(ctx, projectID, params).Execute() + ldap, _, err := connV2.LDAPConfigurationApi.VerifyLdapConfiguration(ctx, projectID, params).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorCreate, projectID, err)) } @@ -168,7 +168,7 @@ func resourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Di ids := conversion.DecodeStateID(d.Id()) projectID := ids["project_id"] requestID := ids["request_id"] - ldapResp, resp, err := connV2.LDAPConfigurationApi.GetLDAPConfigurationStatus(context.Background(), projectID, requestID).Execute() + ldapResp, resp, err := connV2.LDAPConfigurationApi.GetLdapConfigurationStatus(context.Background(), projectID, requestID).Execute() if err != nil || ldapResp == nil { if resp != nil && resp.StatusCode == http.StatusNotFound { d.SetId("") @@ -228,7 +228,7 @@ func resourceImport(ctx context.Context, d *schema.ResourceData, meta any) ([]*s projectID := parts[0] requestID := parts[1] - _, _, err := connV2.LDAPConfigurationApi.GetLDAPConfigurationStatus(ctx, projectID, requestID).Execute() + _, _, err := connV2.LDAPConfigurationApi.GetLdapConfigurationStatus(ctx, projectID, requestID).Execute() if err != nil { return nil, fmt.Errorf(errorRead, requestID, err) } @@ -250,7 +250,7 @@ func resourceImport(ctx context.Context, d *schema.ResourceData, meta any) ([]*s func resourceRefreshFunc(ctx context.Context, projectID, requestID string, connV2 *admin.APIClient) retry.StateRefreshFunc { return func() (any, string, error) { - ldap, resp, err := connV2.LDAPConfigurationApi.GetLDAPConfigurationStatus(ctx, projectID, requestID).Execute() + ldap, resp, err := connV2.LDAPConfigurationApi.GetLdapConfigurationStatus(ctx, projectID, requestID).Execute() if err != nil { if resp.StatusCode == 404 { return "", "DELETED", nil diff --git a/internal/service/ldapverify/resource_ldap_verify_test.go b/internal/service/ldapverify/resource_ldap_verify_test.go index cc285978aa..c4e126a33f 100644 --- a/internal/service/ldapverify/resource_ldap_verify_test.go +++ b/internal/service/ldapverify/resource_ldap_verify_test.go @@ -110,7 +110,7 @@ func checkExists(resourceName string) resource.TestCheckFunc { if rs.Primary.ID == "" { return fmt.Errorf("no ID is set") } - _, _, err := acc.ConnV2().LDAPConfigurationApi.GetLDAPConfigurationStatus(context.Background(), rs.Primary.Attributes["project_id"], rs.Primary.Attributes["request_id"]).Execute() + _, _, err := acc.ConnV2().LDAPConfigurationApi.GetLdapConfigurationStatus(context.Background(), rs.Primary.Attributes["project_id"], rs.Primary.Attributes["request_id"]).Execute() if err != nil { return fmt.Errorf("ldapVerify (%s) does not exist", rs.Primary.ID) } diff --git a/internal/service/maintenancewindow/resource_maintenance_window.go b/internal/service/maintenancewindow/resource_maintenance_window.go index 44c5b27a25..2c14c7097f 100644 --- a/internal/service/maintenancewindow/resource_maintenance_window.go +++ b/internal/service/maintenancewindow/resource_maintenance_window.go @@ -10,7 +10,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/spf13/cast" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/mongodbemployeeaccessgrant/data_source.go b/internal/service/mongodbemployeeaccessgrant/data_source.go index 1125e3e875..303e59b6cf 100644 --- a/internal/service/mongodbemployeeaccessgrant/data_source.go +++ b/internal/service/mongodbemployeeaccessgrant/data_source.go @@ -24,7 +24,9 @@ type ds struct { } func (d *ds) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), "project_id", "cluster_name") + resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.DataSourceSchemaRequest{ + RequiredFields: []string{"project_id", "cluster_name"}, + }) } func (d *ds) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/service/mongodbemployeeaccessgrant/model.go b/internal/service/mongodbemployeeaccessgrant/model.go index 673078c215..9662975f40 100644 --- a/internal/service/mongodbemployeeaccessgrant/model.go +++ b/internal/service/mongodbemployeeaccessgrant/model.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func NewTFModel(projectID, clusterName string, apiResp *admin.EmployeeAccessGrant) *TFModel { diff --git a/internal/service/mongodbemployeeaccessgrant/model_test.go b/internal/service/mongodbemployeeaccessgrant/model_test.go index 24c2ff2213..7294674a7d 100644 --- a/internal/service/mongodbemployeeaccessgrant/model_test.go +++ b/internal/service/mongodbemployeeaccessgrant/model_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/mongodbemployeeaccessgrant" "github.com/stretchr/testify/assert" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func TestNewTFModel(t *testing.T) { diff --git a/internal/service/mongodbemployeeaccessgrant/resource.go b/internal/service/mongodbemployeeaccessgrant/resource.go index 95e3e3de18..37b90c1aad 100644 --- a/internal/service/mongodbemployeeaccessgrant/resource.go +++ b/internal/service/mongodbemployeeaccessgrant/resource.go @@ -83,7 +83,7 @@ func (r *rs) Delete(ctx context.Context, req resource.DeleteRequest, resp *resou connV2 := r.Client.AtlasV2 projectID := tfModel.ProjectID.ValueString() clusterName := tfModel.ClusterName.ValueString() - _, httpResp, err := connV2.ClustersApi.RevokeMongoDBEmployeeAccess(ctx, projectID, clusterName).Execute() + _, httpResp, err := connV2.ClustersApi.RevokeMongoDbEmployeeAccess(ctx, projectID, clusterName).Execute() if err != nil && httpResp.StatusCode != http.StatusNotFound { resp.Diagnostics.AddError(errorDelete, err.Error()) return @@ -108,7 +108,7 @@ func (r *rs) createOrUpdate(ctx context.Context, tfModelFunc func(context.Contex connV2 := r.Client.AtlasV2 projectID := tfModel.ProjectID.ValueString() clusterName := tfModel.ClusterName.ValueString() - if _, _, err := connV2.ClustersApi.GrantMongoDBEmployeeAccess(ctx, projectID, clusterName, atlasReq).Execute(); err != nil { + if _, _, err := connV2.ClustersApi.GrantMongoDbEmployeeAccess(ctx, projectID, clusterName, atlasReq).Execute(); err != nil { diagnostics.AddError(errorCreateUpdate, err.Error()) return } diff --git a/internal/service/networkcontainer/data_source_network_containers.go b/internal/service/networkcontainer/data_source_network_containers.go index f6b182e45b..887070ae3e 100644 --- a/internal/service/networkcontainer/data_source_network_containers.go +++ b/internal/service/networkcontainer/data_source_network_containers.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { diff --git a/internal/service/networkcontainer/resource_network_container.go b/internal/service/networkcontainer/resource_network_container.go index 79856a21b6..1ee5ab556d 100644 --- a/internal/service/networkcontainer/resource_network_container.go +++ b/internal/service/networkcontainer/resource_network_container.go @@ -17,7 +17,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/spf13/cast" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/networkpeering/data_source_network_peering.go b/internal/service/networkpeering/data_source_network_peering.go index af3ad55af0..93a8e05a9b 100644 --- a/internal/service/networkpeering/data_source_network_peering.go +++ b/internal/service/networkpeering/data_source_network_peering.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func DataSource() *schema.Resource { diff --git a/internal/service/networkpeering/data_source_network_peerings.go b/internal/service/networkpeering/data_source_network_peerings.go index 93e503476f..a9832afa41 100644 --- a/internal/service/networkpeering/data_source_network_peerings.go +++ b/internal/service/networkpeering/data_source_network_peerings.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { diff --git a/internal/service/networkpeering/resource_network_peering.go b/internal/service/networkpeering/resource_network_peering.go index ea8d2facc8..be2a954777 100644 --- a/internal/service/networkpeering/resource_network_peering.go +++ b/internal/service/networkpeering/resource_network_peering.go @@ -16,7 +16,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/networkcontainer" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/onlinearchive/resource_online_archive.go b/internal/service/onlinearchive/resource_online_archive.go index fef3bfe85c..cf61b9528e 100644 --- a/internal/service/onlinearchive/resource_online_archive.go +++ b/internal/service/onlinearchive/resource_online_archive.go @@ -15,7 +15,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/organization/data_source_organizations.go b/internal/service/organization/data_source_organizations.go index 95ccbd7c91..b975d91510 100644 --- a/internal/service/organization/data_source_organizations.go +++ b/internal/service/organization/data_source_organizations.go @@ -5,7 +5,7 @@ import ( "fmt" "log" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" diff --git a/internal/service/organization/resource_organization.go b/internal/service/organization/resource_organization.go index acdbb0e533..ab25f0e56e 100644 --- a/internal/service/organization/resource_organization.go +++ b/internal/service/organization/resource_organization.go @@ -7,7 +7,7 @@ import ( "net/http" "strings" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -215,7 +215,7 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. updateRequest := new(admin.AtlasOrganization) if d.HasChange("name") { updateRequest.Name = d.Get("name").(string) - _, _, err := conn.OrganizationsApi.RenameOrganization(ctx, orgID, updateRequest).Execute() + _, _, err := conn.OrganizationsApi.UpdateOrganization(ctx, orgID, updateRequest).Execute() if err != nil { return diag.FromErr(fmt.Errorf("error updating Organization name: %s", err)) } diff --git a/internal/service/organization/resource_organization_test.go b/internal/service/organization/resource_organization_test.go index b047d75029..c25506b1c8 100644 --- a/internal/service/organization/resource_organization_test.go +++ b/internal/service/organization/resource_organization_test.go @@ -7,7 +7,7 @@ import ( "regexp" "testing" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" diff --git a/internal/service/orginvitation/resource_org_invitation.go b/internal/service/orginvitation/resource_org_invitation.go index 5975b5ad30..77802b3de1 100644 --- a/internal/service/orginvitation/resource_org_invitation.go +++ b/internal/service/orginvitation/resource_org_invitation.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func Resource() *schema.Resource { diff --git a/internal/service/privateendpointregionalmode/resource_private_endpoint_regional_mode.go b/internal/service/privateendpointregionalmode/resource_private_endpoint_regional_mode.go index dae1142dc2..46f07b729c 100644 --- a/internal/service/privateendpointregionalmode/resource_private_endpoint_regional_mode.go +++ b/internal/service/privateendpointregionalmode/resource_private_endpoint_regional_mode.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) type permCtxKey string diff --git a/internal/service/privatelinkendpoint/resource_privatelink_endpoint.go b/internal/service/privatelinkendpoint/resource_privatelink_endpoint.go index 5a27bf935f..e3fc180033 100644 --- a/internal/service/privatelinkendpoint/resource_privatelink_endpoint.go +++ b/internal/service/privatelinkendpoint/resource_privatelink_endpoint.go @@ -15,7 +15,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/privatelinkendpointserverless/resource_privatelink_endpoint_serverless.go b/internal/service/privatelinkendpointserverless/resource_privatelink_endpoint_serverless.go index 7d21f100f2..828435ec5a 100644 --- a/internal/service/privatelinkendpointserverless/resource_privatelink_endpoint_serverless.go +++ b/internal/service/privatelinkendpointserverless/resource_privatelink_endpoint_serverless.go @@ -8,13 +8,14 @@ import ( "strings" "time" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/privatelinkendpoint" @@ -34,6 +35,7 @@ func Resource() *schema.Resource { Importer: &schema.ResourceImporter{ StateContext: resourceImport, }, + DeprecationMessage: fmt.Sprintf(constant.DeprecationResourceByDateWithExternalLink, "March 2025", "https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide"), Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, diff --git a/internal/service/privatelinkendpointservice/resource_privatelink_endpoint_service.go b/internal/service/privatelinkendpointservice/resource_privatelink_endpoint_service.go index 892f8f8310..973dd5ade0 100644 --- a/internal/service/privatelinkendpointservice/resource_privatelink_endpoint_service.go +++ b/internal/service/privatelinkendpointservice/resource_privatelink_endpoint_service.go @@ -16,7 +16,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/privatelinkendpointservicedatafederationonlinearchive/data_source_privatelink_endpoint_service_data_federation_online_archives.go b/internal/service/privatelinkendpointservicedatafederationonlinearchive/data_source_privatelink_endpoint_service_data_federation_online_archives.go index 9870929343..d55215f797 100644 --- a/internal/service/privatelinkendpointservicedatafederationonlinearchive/data_source_privatelink_endpoint_service_data_federation_online_archives.go +++ b/internal/service/privatelinkendpointservicedatafederationonlinearchive/data_source_privatelink_endpoint_service_data_federation_online_archives.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/datalakepipeline" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const errorPrivateEndpointServiceDataFederationOnlineArchiveList = "error reading Private Endpoings for projectId %s: %s" diff --git a/internal/service/privatelinkendpointservicedatafederationonlinearchive/resource_privatelink_endpoint_service_data_federation_online_archive.go b/internal/service/privatelinkendpointservicedatafederationonlinearchive/resource_privatelink_endpoint_service_data_federation_online_archive.go index 85a12bc810..c0fca7f763 100644 --- a/internal/service/privatelinkendpointservicedatafederationonlinearchive/resource_privatelink_endpoint_service_data_federation_online_archive.go +++ b/internal/service/privatelinkendpointservicedatafederationonlinearchive/resource_privatelink_endpoint_service_data_federation_online_archive.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/internal/service/privatelinkendpointserviceserverless/data_source_privatelink_endpoint_service_serverless.go b/internal/service/privatelinkendpointserviceserverless/data_source_privatelink_endpoint_service_serverless.go index 8a7331f7b3..e69fbe840b 100644 --- a/internal/service/privatelinkendpointserviceserverless/data_source_privatelink_endpoint_service_serverless.go +++ b/internal/service/privatelinkendpointserviceserverless/data_source_privatelink_endpoint_service_serverless.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/privatelinkendpointservice" @@ -13,7 +14,8 @@ import ( func DataSource() *schema.Resource { return &schema.Resource{ - ReadContext: dataSourceRead, + ReadContext: dataSourceRead, + DeprecationMessage: fmt.Sprintf(constant.DeprecationDataSourceByDateWithExternalLink, "March 2025", "https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide"), Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, diff --git a/internal/service/privatelinkendpointserviceserverless/data_source_privatelink_endpoints_service_serverless.go b/internal/service/privatelinkendpointserviceserverless/data_source_privatelink_endpoints_service_serverless.go index 6bef64c9b9..bfbe445206 100644 --- a/internal/service/privatelinkendpointserviceserverless/data_source_privatelink_endpoints_service_serverless.go +++ b/internal/service/privatelinkendpointserviceserverless/data_source_privatelink_endpoints_service_serverless.go @@ -2,17 +2,20 @@ package privatelinkendpointserviceserverless import ( "context" + "fmt" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { return &schema.Resource{ - ReadContext: dataSourcePluralRead, + ReadContext: dataSourcePluralRead, + DeprecationMessage: fmt.Sprintf(constant.DeprecationDataSourceByDateWithExternalLink, "March 2025", "https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide"), Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, diff --git a/internal/service/privatelinkendpointserviceserverless/resource_privatelink_endpoint_service_serverless.go b/internal/service/privatelinkendpointserviceserverless/resource_privatelink_endpoint_service_serverless.go index a41fdc7a90..dd6e42f02b 100644 --- a/internal/service/privatelinkendpointserviceserverless/resource_privatelink_endpoint_service_serverless.go +++ b/internal/service/privatelinkendpointserviceserverless/resource_privatelink_endpoint_service_serverless.go @@ -8,13 +8,14 @@ import ( "strings" "time" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) @@ -34,6 +35,7 @@ func Resource() *schema.Resource { Importer: &schema.ResourceImporter{ StateContext: resourceImport, }, + DeprecationMessage: fmt.Sprintf(constant.DeprecationResourceByDateWithExternalLink, "March 2025", "https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide"), Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, diff --git a/internal/service/project/data_source_project.go b/internal/service/project/data_source_project.go index 08d10b3d08..a31cb5b444 100644 --- a/internal/service/project/data_source_project.go +++ b/internal/service/project/data_source_project.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) @@ -180,6 +181,7 @@ func (d *projectDS) Schema(ctx context.Context, req datasource.SchemaRequest, re }, }, } + conversion.UpdateSchemaDescription(&resp.Schema) } func (d *projectDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/service/project/data_source_projects.go b/internal/service/project/data_source_projects.go index 9fa11dc3d1..1982c07853 100644 --- a/internal/service/project/data_source_projects.go +++ b/internal/service/project/data_source_projects.go @@ -12,7 +12,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const projectsDataSourceName = "projects" @@ -178,6 +178,7 @@ func (d *ProjectsDS) Schema(ctx context.Context, req datasource.SchemaRequest, r }, }, } + conversion.UpdateSchemaDescription(&resp.Schema) } func (d *ProjectsDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/service/project/model_project.go b/internal/service/project/model_project.go index 3fe7620eb3..89e6b6f9dd 100644 --- a/internal/service/project/model_project.go +++ b/internal/service/project/model_project.go @@ -3,9 +3,8 @@ package project import ( "context" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" - "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" @@ -35,7 +34,7 @@ func NewTFProjectDataSourceModel(ctx context.Context, project *admin.Group, proj Teams: NewTFTeamsDataSourceModel(ctx, projectProps.Teams), Limits: NewTFLimitsDataSourceModel(ctx, projectProps.Limits), IPAddresses: ipAddressesModel, - Tags: NewTFTags(project.GetTags()), + Tags: conversion.NewTFTags(project.GetTags()), IsSlowOperationThresholdingEnabled: types.BoolValue(projectProps.IsSlowOperationThresholdingEnabled), }, nil } @@ -111,7 +110,7 @@ func NewTFProjectResourceModel(ctx context.Context, projectRes *admin.Group, pro Teams: newTFTeamsResourceModel(ctx, projectProps.Teams), Limits: newTFLimitsResourceModel(ctx, projectProps.Limits), IPAddresses: ipAddressesModel, - Tags: NewTFTags(projectRes.GetTags()), + Tags: conversion.NewTFTags(projectRes.GetTags()), IsSlowOperationThresholdingEnabled: types.BoolValue(projectProps.IsSlowOperationThresholdingEnabled), } @@ -208,27 +207,3 @@ func UpdateProjectBool(plan, state types.Bool, setting **bool) bool { } return false } - -func NewTFTags(tags []admin.ResourceTag) types.Map { - typesTags := make(map[string]attr.Value, len(tags)) - for _, tag := range tags { - typesTags[tag.Key] = types.StringValue(tag.Value) - } - return types.MapValueMust(types.StringType, typesTags) -} - -func NewResourceTags(ctx context.Context, tags types.Map) []admin.ResourceTag { - if tags.IsNull() || len(tags.Elements()) == 0 { - return []admin.ResourceTag{} - } - elements := make(map[string]types.String, len(tags.Elements())) - _ = tags.ElementsAs(ctx, &elements, false) - var tagsAdmin []admin.ResourceTag - for key, tagValue := range elements { - tagsAdmin = append(tagsAdmin, admin.ResourceTag{ - Key: key, - Value: tagValue.ValueString(), - }) - } - return tagsAdmin -} diff --git a/internal/service/project/model_project_test.go b/internal/service/project/model_project_test.go index e3d9fb3a57..0060fcbe58 100644 --- a/internal/service/project/model_project_test.go +++ b/internal/service/project/model_project_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" @@ -236,7 +236,7 @@ func TestProjectDataSourceSDKToDataSourceTFModel(t *testing.T) { Limits: limitsTF, IPAddresses: ipAddressesTF, Created: types.StringValue("0001-01-01T00:00:00Z"), - Tags: emptyTfTags(), + Tags: types.MapValueMust(types.StringType, map[string]attr.Value{}), }, }, { @@ -271,7 +271,7 @@ func TestProjectDataSourceSDKToDataSourceTFModel(t *testing.T) { Limits: limitsTF, IPAddresses: ipAddressesTF, Created: types.StringValue("0001-01-01T00:00:00Z"), - Tags: emptyTfTags(), + Tags: types.MapValueMust(types.StringType, map[string]attr.Value{}), }, }, } @@ -323,7 +323,7 @@ func TestProjectDataSourceSDKToResourceTFModel(t *testing.T) { Limits: limitsTFSet, IPAddresses: ipAddressesTF, Created: types.StringValue("0001-01-01T00:00:00Z"), - Tags: emptyTfTags(), + Tags: types.MapValueMust(types.StringType, map[string]attr.Value{}), }, }, { @@ -356,7 +356,7 @@ func TestProjectDataSourceSDKToResourceTFModel(t *testing.T) { Limits: limitsTFSet, IPAddresses: ipAddressesTF, Created: types.StringValue("0001-01-01T00:00:00Z"), - Tags: emptyTfTags(), + Tags: types.MapValueMust(types.StringType, map[string]attr.Value{}), }, }, } @@ -550,48 +550,3 @@ func TestUpdateProjectBool(t *testing.T) { }) } } - -func TestNewResourceTags(t *testing.T) { - testCases := map[string]struct { - plan types.Map - expected []admin.ResourceTag - }{ - "tags null": {types.MapNull(types.StringType), []admin.ResourceTag{}}, - "tags unknown": {types.MapUnknown(types.StringType), []admin.ResourceTag{}}, - "tags convert normally": {types.MapValueMust(types.StringType, map[string]attr.Value{ - "key1": types.StringValue("value1"), - }), []admin.ResourceTag{ - *admin.NewResourceTag("key1", "value1"), - }}, - } - for name, tc := range testCases { - t.Run(name, func(t *testing.T) { - assert.Equal(t, tc.expected, project.NewResourceTags(context.Background(), tc.plan)) - }) - } -} - -func TestNewTFTags(t *testing.T) { - var ( - tfMapEmpty = emptyTfTags() - apiListEmpty = []admin.ResourceTag{} - apiSingleTag = []admin.ResourceTag{*admin.NewResourceTag("key1", "value1")} - tfMapSingleTag = types.MapValueMust(types.StringType, map[string]attr.Value{"key1": types.StringValue("value1")}) - ) - testCases := map[string]struct { - expected types.Map - adminTags []admin.ResourceTag - }{ - "api empty list tf null should give map null": {tfMapEmpty, apiListEmpty}, - "tags single value tf null should give map single": {tfMapSingleTag, apiSingleTag}, - } - for name, tc := range testCases { - t.Run(name, func(t *testing.T) { - assert.Equal(t, tc.expected, project.NewTFTags(tc.adminTags)) - }) - } -} - -func emptyTfTags() types.Map { - return types.MapValueMust(types.StringType, map[string]attr.Value{}) -} diff --git a/internal/service/project/resource_project.go b/internal/service/project/resource_project.go index 800f0fdd6b..9e21510dbd 100644 --- a/internal/service/project/resource_project.go +++ b/internal/service/project/resource_project.go @@ -10,25 +10,15 @@ import ( "sort" "time" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" - "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) @@ -59,258 +49,9 @@ type projectRS struct { config.RSCommon } -type TFProjectRSModel struct { - Limits types.Set `tfsdk:"limits"` - Teams types.Set `tfsdk:"teams"` - Tags types.Map `tfsdk:"tags"` - IPAddresses types.Object `tfsdk:"ip_addresses"` - RegionUsageRestrictions types.String `tfsdk:"region_usage_restrictions"` - Name types.String `tfsdk:"name"` - OrgID types.String `tfsdk:"org_id"` - Created types.String `tfsdk:"created"` - ProjectOwnerID types.String `tfsdk:"project_owner_id"` - ID types.String `tfsdk:"id"` - ClusterCount types.Int64 `tfsdk:"cluster_count"` - IsDataExplorerEnabled types.Bool `tfsdk:"is_data_explorer_enabled"` - IsPerformanceAdvisorEnabled types.Bool `tfsdk:"is_performance_advisor_enabled"` - IsRealtimePerformancePanelEnabled types.Bool `tfsdk:"is_realtime_performance_panel_enabled"` - IsSchemaAdvisorEnabled types.Bool `tfsdk:"is_schema_advisor_enabled"` - IsExtendedStorageSizesEnabled types.Bool `tfsdk:"is_extended_storage_sizes_enabled"` - IsCollectDatabaseSpecificsStatisticsEnabled types.Bool `tfsdk:"is_collect_database_specifics_statistics_enabled"` - WithDefaultAlertsSettings types.Bool `tfsdk:"with_default_alerts_settings"` - IsSlowOperationThresholdingEnabled types.Bool `tfsdk:"is_slow_operation_thresholding_enabled"` -} - -type TFTeamModel struct { - TeamID types.String `tfsdk:"team_id"` - RoleNames types.Set `tfsdk:"role_names"` -} - -type TFLimitModel struct { - Name types.String `tfsdk:"name"` - Value types.Int64 `tfsdk:"value"` - CurrentUsage types.Int64 `tfsdk:"current_usage"` - DefaultLimit types.Int64 `tfsdk:"default_limit"` - MaximumLimit types.Int64 `tfsdk:"maximum_limit"` -} - -type TFIPAddressesModel struct { - Services TFServicesModel `tfsdk:"services"` -} - -type TFServicesModel struct { - Clusters []TFClusterIPsModel `tfsdk:"clusters"` -} - -type TFClusterIPsModel struct { - ClusterName types.String `tfsdk:"cluster_name"` - Inbound types.List `tfsdk:"inbound"` - Outbound types.List `tfsdk:"outbound"` -} - -var IPAddressesObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ - "services": ServicesObjectType, -}} - -var ServicesObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ - "clusters": types.ListType{ElemType: ClusterIPsObjectType}, -}} - -var ClusterIPsObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ - "cluster_name": types.StringType, - "inbound": types.ListType{ElemType: types.StringType}, - "outbound": types.ListType{ElemType: types.StringType}, -}} - -var TfTeamObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ - "team_id": types.StringType, - "role_names": types.SetType{ElemType: types.StringType}, -}} -var TfLimitObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ - "name": types.StringType, - "value": types.Int64Type, - "current_usage": types.Int64Type, - "default_limit": types.Int64Type, - "maximum_limit": types.Int64Type, -}} - -// Resources that need to be cleaned up before a project can be deleted -type AtlasProjectDependants struct { - AdvancedClusters *admin.PaginatedClusterDescription20240805 -} - func (r *projectRS) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - "name": schema.StringAttribute{ - Required: true, - }, - "org_id": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "cluster_count": schema.Int64Attribute{ - Computed: true, - PlanModifiers: []planmodifier.Int64{ - int64planmodifier.UseStateForUnknown(), - }, - }, - "created": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - "project_owner_id": schema.StringAttribute{ - Optional: true, - }, - "with_default_alerts_settings": schema.BoolAttribute{ - // Default values also must be Computed otherwise Terraform throws error: - // Schema Using Attribute Default For Non-Computed Attribute - Optional: true, - Computed: true, - Default: booldefault.StaticBool(true), - }, - "is_collect_database_specifics_statistics_enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.UseStateForUnknown(), - }, - }, - "is_data_explorer_enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.UseStateForUnknown(), - }, - }, - "is_extended_storage_sizes_enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.UseStateForUnknown(), - }, - }, - "is_performance_advisor_enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.UseStateForUnknown(), - }, - }, - "is_realtime_performance_panel_enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.UseStateForUnknown(), - }, - }, - "is_schema_advisor_enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.UseStateForUnknown(), - }, - }, - "is_slow_operation_thresholding_enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - DeprecationMessage: fmt.Sprintf(constant.DeprecationParamByVersion, "1.24.0"), - PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.UseStateForUnknown(), - }, - }, - "region_usage_restrictions": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "ip_addresses": schema.SingleNestedAttribute{ - Computed: true, - DeprecationMessage: fmt.Sprintf(constant.DeprecationParamByVersionWithReplacement, "1.21.0", "mongodbatlas_project_ip_addresses data source"), - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.UseStateForUnknown(), - }, - Attributes: map[string]schema.Attribute{ - "services": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "clusters": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "cluster_name": schema.StringAttribute{ - Computed: true, - }, - "inbound": schema.ListAttribute{ - ElementType: types.StringType, - Computed: true, - }, - "outbound": schema.ListAttribute{ - ElementType: types.StringType, - Computed: true, - }, - }, - }, - }, - }, - }, - }, - }, - "tags": schema.MapAttribute{ - ElementType: types.StringType, - Optional: true, - }, - }, - Blocks: map[string]schema.Block{ - "teams": schema.SetNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "team_id": schema.StringAttribute{ - Required: true, - }, - "role_names": schema.SetAttribute{ - Required: true, - ElementType: types.StringType, - }, - }, - }, - }, - "limits": schema.SetNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "name": schema.StringAttribute{ - Required: true, - }, - "value": schema.Int64Attribute{ - Required: true, - }, - "current_usage": schema.Int64Attribute{ - Computed: true, - }, - "default_limit": schema.Int64Attribute{ - Computed: true, - }, - "maximum_limit": schema.Int64Attribute{ - Computed: true, - }, - }, - }, - // https://discuss.hashicorp.com/t/computed-attributes-and-plan-modifiers/45830/12 - PlanModifiers: []planmodifier.Set{ - setplanmodifier.UseStateForUnknown(), - }, - }, - }, - } + resp.Schema = ResourceSchema(ctx) + conversion.UpdateSchemaDescription(&resp.Schema) } func (r *projectRS) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { @@ -325,13 +66,12 @@ func (r *projectRS) Create(ctx context.Context, req resource.CreateRequest, resp if resp.Diagnostics.HasError() { return } - tags := NewResourceTags(ctx, projectPlan.Tags) projectGroup := &admin.Group{ OrgId: projectPlan.OrgID.ValueString(), Name: projectPlan.Name.ValueString(), WithDefaultAlertsSettings: projectPlan.WithDefaultAlertsSettings.ValueBoolPointer(), RegionUsageRestrictions: conversion.StringNullIfEmpty(projectPlan.RegionUsageRestrictions.ValueString()).ValueStringPointer(), - Tags: &tags, + Tags: conversion.NewResourceTags(ctx, projectPlan.Tags), } projectAPIParams := &admin.CreateProjectApiParams{ @@ -645,7 +385,7 @@ func GetProjectPropsFromAPI(ctx context.Context, projectsAPI admin.ProjectsApi, return nil, fmt.Errorf("error getting project's settings assigned (%s): %v", projectID, err.Error()) } - ipAddresses, _, err := projectsAPI.ReturnAllIPAddresses(ctx, projectID).Execute() + ipAddresses, _, err := projectsAPI.ReturnAllIpAddresses(ctx, projectID).Execute() if err != nil { return nil, fmt.Errorf("error getting project's IP addresses (%s): %v", projectID, err.Error()) } @@ -843,15 +583,15 @@ func hasLimitsChanged(planLimits, stateLimits []TFLimitModel) bool { } func UpdateProject(ctx context.Context, projectsAPI admin.ProjectsApi, projectState, projectPlan *TFProjectRSModel) error { - tagsBefore := NewResourceTags(ctx, projectState.Tags) - tagsAfter := NewResourceTags(ctx, projectPlan.Tags) + tagsBefore := conversion.NewResourceTags(ctx, projectState.Tags) + tagsAfter := conversion.NewResourceTags(ctx, projectPlan.Tags) if projectPlan.Name.Equal(projectState.Name) && reflect.DeepEqual(tagsBefore, tagsAfter) { return nil } projectID := projectState.ID.ValueString() - if _, _, err := projectsAPI.UpdateProject(ctx, projectID, NewGroupUpdate(projectPlan, &tagsAfter)).Execute(); err != nil { + if _, _, err := projectsAPI.UpdateProject(ctx, projectID, NewGroupUpdate(projectPlan, tagsAfter)).Execute(); err != nil { return fmt.Errorf("error updating the project(%s): %s", projectID, err) } diff --git a/internal/service/project/resource_project_migration_test.go b/internal/service/project/resource_project_migration_test.go index aa2d6881e3..1a68f1a2e8 100644 --- a/internal/service/project/resource_project_migration_test.go +++ b/internal/service/project/resource_project_migration_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" diff --git a/internal/service/project/resource_project_schema.go b/internal/service/project/resource_project_schema.go new file mode 100644 index 0000000000..3292b3e89a --- /dev/null +++ b/internal/service/project/resource_project_schema.go @@ -0,0 +1,273 @@ +package project + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" + "go.mongodb.org/atlas-sdk/v20241113003/admin" +) + +func ResourceSchema(ctx context.Context) schema.Schema { + return schema.Schema{ + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "name": schema.StringAttribute{ + Required: true, + }, + "org_id": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + "cluster_count": schema.Int64Attribute{ + Computed: true, + PlanModifiers: []planmodifier.Int64{ + int64planmodifier.UseStateForUnknown(), + }, + }, + "created": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "project_owner_id": schema.StringAttribute{ + Optional: true, + }, + "with_default_alerts_settings": schema.BoolAttribute{ + // Default values also must be Computed otherwise Terraform throws error: + // Schema Using Attribute Default For Non-Computed Attribute + Optional: true, + Computed: true, + Default: booldefault.StaticBool(true), + }, + "is_collect_database_specifics_statistics_enabled": schema.BoolAttribute{ + Computed: true, + Optional: true, + PlanModifiers: []planmodifier.Bool{ + boolplanmodifier.UseStateForUnknown(), + }, + }, + "is_data_explorer_enabled": schema.BoolAttribute{ + Computed: true, + Optional: true, + PlanModifiers: []planmodifier.Bool{ + boolplanmodifier.UseStateForUnknown(), + }, + }, + "is_extended_storage_sizes_enabled": schema.BoolAttribute{ + Computed: true, + Optional: true, + PlanModifiers: []planmodifier.Bool{ + boolplanmodifier.UseStateForUnknown(), + }, + }, + "is_performance_advisor_enabled": schema.BoolAttribute{ + Computed: true, + Optional: true, + PlanModifiers: []planmodifier.Bool{ + boolplanmodifier.UseStateForUnknown(), + }, + }, + "is_realtime_performance_panel_enabled": schema.BoolAttribute{ + Computed: true, + Optional: true, + PlanModifiers: []planmodifier.Bool{ + boolplanmodifier.UseStateForUnknown(), + }, + }, + "is_schema_advisor_enabled": schema.BoolAttribute{ + Computed: true, + Optional: true, + PlanModifiers: []planmodifier.Bool{ + boolplanmodifier.UseStateForUnknown(), + }, + }, + "is_slow_operation_thresholding_enabled": schema.BoolAttribute{ + Computed: true, + Optional: true, + DeprecationMessage: fmt.Sprintf(constant.DeprecationParamByVersion, "1.24.0"), + PlanModifiers: []planmodifier.Bool{ + boolplanmodifier.UseStateForUnknown(), + }, + }, + "region_usage_restrictions": schema.StringAttribute{ + Computed: true, + Optional: true, + }, + "ip_addresses": schema.SingleNestedAttribute{ + Computed: true, + DeprecationMessage: fmt.Sprintf(constant.DeprecationParamByVersionWithReplacement, "1.21.0", "mongodbatlas_project_ip_addresses data source"), + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.UseStateForUnknown(), + }, + Attributes: map[string]schema.Attribute{ + "services": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ + "clusters": schema.ListNestedAttribute{ + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "cluster_name": schema.StringAttribute{ + Computed: true, + }, + "inbound": schema.ListAttribute{ + ElementType: types.StringType, + Computed: true, + }, + "outbound": schema.ListAttribute{ + ElementType: types.StringType, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + }, + "tags": schema.MapAttribute{ + ElementType: types.StringType, + Optional: true, + }, + }, + Blocks: map[string]schema.Block{ + "teams": schema.SetNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "team_id": schema.StringAttribute{ + Required: true, + }, + "role_names": schema.SetAttribute{ + Required: true, + ElementType: types.StringType, + }, + }, + }, + }, + "limits": schema.SetNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{ + Required: true, + }, + "value": schema.Int64Attribute{ + Required: true, + }, + "current_usage": schema.Int64Attribute{ + Computed: true, + }, + "default_limit": schema.Int64Attribute{ + Computed: true, + }, + "maximum_limit": schema.Int64Attribute{ + Computed: true, + }, + }, + }, + // https://discuss.hashicorp.com/t/computed-attributes-and-plan-modifiers/45830/12 + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + }, + }, + } +} + +type TFProjectRSModel struct { + Limits types.Set `tfsdk:"limits"` + Teams types.Set `tfsdk:"teams"` + Tags types.Map `tfsdk:"tags"` + IPAddresses types.Object `tfsdk:"ip_addresses"` + RegionUsageRestrictions types.String `tfsdk:"region_usage_restrictions"` + Name types.String `tfsdk:"name"` + OrgID types.String `tfsdk:"org_id"` + Created types.String `tfsdk:"created"` + ProjectOwnerID types.String `tfsdk:"project_owner_id"` + ID types.String `tfsdk:"id"` + ClusterCount types.Int64 `tfsdk:"cluster_count"` + IsDataExplorerEnabled types.Bool `tfsdk:"is_data_explorer_enabled"` + IsPerformanceAdvisorEnabled types.Bool `tfsdk:"is_performance_advisor_enabled"` + IsRealtimePerformancePanelEnabled types.Bool `tfsdk:"is_realtime_performance_panel_enabled"` + IsSchemaAdvisorEnabled types.Bool `tfsdk:"is_schema_advisor_enabled"` + IsExtendedStorageSizesEnabled types.Bool `tfsdk:"is_extended_storage_sizes_enabled"` + IsCollectDatabaseSpecificsStatisticsEnabled types.Bool `tfsdk:"is_collect_database_specifics_statistics_enabled"` + WithDefaultAlertsSettings types.Bool `tfsdk:"with_default_alerts_settings"` + IsSlowOperationThresholdingEnabled types.Bool `tfsdk:"is_slow_operation_thresholding_enabled"` +} + +type TFTeamModel struct { + TeamID types.String `tfsdk:"team_id"` + RoleNames types.Set `tfsdk:"role_names"` +} + +type TFLimitModel struct { + Name types.String `tfsdk:"name"` + Value types.Int64 `tfsdk:"value"` + CurrentUsage types.Int64 `tfsdk:"current_usage"` + DefaultLimit types.Int64 `tfsdk:"default_limit"` + MaximumLimit types.Int64 `tfsdk:"maximum_limit"` +} + +type TFIPAddressesModel struct { + Services TFServicesModel `tfsdk:"services"` +} + +type TFServicesModel struct { + Clusters []TFClusterIPsModel `tfsdk:"clusters"` +} + +type TFClusterIPsModel struct { + ClusterName types.String `tfsdk:"cluster_name"` + Inbound types.List `tfsdk:"inbound"` + Outbound types.List `tfsdk:"outbound"` +} + +var IPAddressesObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ + "services": ServicesObjectType, +}} + +var ServicesObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ + "clusters": types.ListType{ElemType: ClusterIPsObjectType}, +}} + +var ClusterIPsObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ + "cluster_name": types.StringType, + "inbound": types.ListType{ElemType: types.StringType}, + "outbound": types.ListType{ElemType: types.StringType}, +}} + +var TfTeamObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ + "team_id": types.StringType, + "role_names": types.SetType{ElemType: types.StringType}, +}} +var TfLimitObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ + "name": types.StringType, + "value": types.Int64Type, + "current_usage": types.Int64Type, + "default_limit": types.Int64Type, + "maximum_limit": types.Int64Type, +}} + +// Resources that need to be cleaned up before a project can be deleted +type AtlasProjectDependants struct { + AdvancedClusters *admin.PaginatedClusterDescription20240805 +} diff --git a/internal/service/project/resource_project_test.go b/internal/service/project/resource_project_test.go index 2f4b788dc7..efe49c0a6c 100644 --- a/internal/service/project/resource_project_test.go +++ b/internal/service/project/resource_project_test.go @@ -12,8 +12,8 @@ import ( "strings" "testing" - "go.mongodb.org/atlas-sdk/v20241023002/admin" - "go.mongodb.org/atlas-sdk/v20241023002/mockadmin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" + "go.mongodb.org/atlas-sdk/v20241113003/mockadmin" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -133,8 +133,8 @@ func TestGetProjectPropsFromAPI(t *testing.T) { projectsMock.EXPECT().GetProjectSettings(mock.Anything, mock.Anything).Return(admin.GetProjectSettingsApiRequest{ApiService: projectsMock}).Maybe() projectsMock.EXPECT().GetProjectSettingsExecute(mock.Anything).Return(tc.groupResponse.GroupSettings, tc.groupResponse.HTTPResponse, tc.groupResponse.Err).Maybe() - projectsMock.EXPECT().ReturnAllIPAddresses(mock.Anything, mock.Anything).Return(admin.ReturnAllIPAddressesApiRequest{ApiService: projectsMock}).Maybe() - projectsMock.EXPECT().ReturnAllIPAddressesExecute(mock.Anything).Return(tc.ipAddressesResponse.IPAddresses, tc.ipAddressesResponse.HTTPResponse, tc.ipAddressesResponse.Err).Maybe() + projectsMock.EXPECT().ReturnAllIpAddresses(mock.Anything, mock.Anything).Return(admin.ReturnAllIpAddressesApiRequest{ApiService: projectsMock}).Maybe() + projectsMock.EXPECT().ReturnAllIpAddressesExecute(mock.Anything).Return(tc.ipAddressesResponse.IPAddresses, tc.ipAddressesResponse.HTTPResponse, tc.ipAddressesResponse.Err).Maybe() perfMock.EXPECT().GetManagedSlowMs(mock.Anything, mock.Anything).Return(admin.GetManagedSlowMsApiRequest{ApiService: perfMock}).Maybe() managedSlowMsJSON := tc.getManagedSlowMs diff --git a/internal/service/projectapikey/data_source_project_api_keys.go b/internal/service/projectapikey/data_source_project_api_keys.go index 13aff5160d..24d4e27895 100644 --- a/internal/service/projectapikey/data_source_project_api_keys.go +++ b/internal/service/projectapikey/data_source_project_api_keys.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { diff --git a/internal/service/projectapikey/model_project_api_key.go b/internal/service/projectapikey/model_project_api_key.go index a738949369..af72c523c2 100644 --- a/internal/service/projectapikey/model_project_api_key.go +++ b/internal/service/projectapikey/model_project_api_key.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func expandProjectAssignments(projectAssignments *schema.Set) map[string][]string { diff --git a/internal/service/projectapikey/resource_project_api_key.go b/internal/service/projectapikey/resource_project_api_key.go index 863a8268b6..0225cc9b8a 100644 --- a/internal/service/projectapikey/resource_project_api_key.go +++ b/internal/service/projectapikey/resource_project_api_key.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func Resource() *schema.Resource { diff --git a/internal/service/projectinvitation/resource_project_invitation.go b/internal/service/projectinvitation/resource_project_invitation.go index 2eab749f75..bf4edf21a0 100644 --- a/internal/service/projectinvitation/resource_project_invitation.go +++ b/internal/service/projectinvitation/resource_project_invitation.go @@ -11,7 +11,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func Resource() *schema.Resource { diff --git a/internal/service/projectipaccesslist/data_source_project_ip_access_list.go b/internal/service/projectipaccesslist/data_source_project_ip_access_list.go index 21fa8a71e0..33539a5b0e 100644 --- a/internal/service/projectipaccesslist/data_source_project_ip_access_list.go +++ b/internal/service/projectipaccesslist/data_source_project_ip_access_list.go @@ -45,14 +45,9 @@ type TfProjectIPAccessListDSModel struct { } func (d *projectIPAccessListDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "project_id": schema.StringAttribute{ - Required: true, - }, + resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.DataSourceSchemaRequest{ + RequiredFields: []string{"project_id"}, + OverridenFields: map[string]schema.Attribute{ "cidr_block": schema.StringAttribute{ Optional: true, Computed: true, @@ -85,12 +80,8 @@ func (d *projectIPAccessListDS) Schema(ctx context.Context, req datasource.Schem }...), }, }, - "comment": schema.StringAttribute{ - Computed: true, - }, }, - } - conversion.UpdateSchemaDescription(&resp.Schema) + }) } func (d *projectIPAccessListDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/service/projectipaccesslist/model_project_ip_access_list.go b/internal/service/projectipaccesslist/model_project_ip_access_list.go index 52d853333d..22eb3bee1a 100644 --- a/internal/service/projectipaccesslist/model_project_ip_access_list.go +++ b/internal/service/projectipaccesslist/model_project_ip_access_list.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func NewMongoDBProjectIPAccessList(projectIPAccessListModel *TfProjectIPAccessListModel) *[]admin.NetworkPermissionEntry { diff --git a/internal/service/projectipaccesslist/model_project_ip_access_list_test.go b/internal/service/projectipaccesslist/model_project_ip_access_list_test.go index 63d6445c9c..86a46b4f78 100644 --- a/internal/service/projectipaccesslist/model_project_ip_access_list_test.go +++ b/internal/service/projectipaccesslist/model_project_ip_access_list_test.go @@ -9,7 +9,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/projectipaccesslist" "github.com/stretchr/testify/assert" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) var ( diff --git a/internal/service/projectipaccesslist/resource_project_ip_access_list.go b/internal/service/projectipaccesslist/resource_project_ip_access_list.go index 4f4e95d6ea..2a7cf19d68 100644 --- a/internal/service/projectipaccesslist/resource_project_ip_access_list.go +++ b/internal/service/projectipaccesslist/resource_project_ip_access_list.go @@ -7,21 +7,13 @@ import ( "strings" "time" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" - "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/validate" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) @@ -36,16 +28,6 @@ const ( delayCreate = 10 * time.Second ) -type TfProjectIPAccessListModel struct { - ID types.String `tfsdk:"id"` - ProjectID types.String `tfsdk:"project_id"` - CIDRBlock types.String `tfsdk:"cidr_block"` - IPAddress types.String `tfsdk:"ip_address"` - AWSSecurityGroup types.String `tfsdk:"aws_security_group"` - Comment types.String `tfsdk:"comment"` - Timeouts timeouts.Value `tfsdk:"timeouts"` -} - type projectIPAccessListRS struct { config.RSCommon } @@ -62,73 +44,7 @@ var _ resource.ResourceWithConfigure = &projectIPAccessListRS{} var _ resource.ResourceWithImportState = &projectIPAccessListRS{} func (r *projectIPAccessListRS) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "project_id": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "cidr_block": schema.StringAttribute{ - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Validators: []validator.String{ - validate.ValidCIDR(), - stringvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("aws_security_group"), - path.MatchRelative().AtParent().AtName("ip_address"), - }...), - }, - }, - "ip_address": schema.StringAttribute{ - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Validators: []validator.String{ - validate.ValidIP(), - stringvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("aws_security_group"), - path.MatchRelative().AtParent().AtName("cidr_block"), - }...), - }, - }, - "aws_security_group": schema.StringAttribute{ - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Validators: []validator.String{ - stringvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("ip_address"), - path.MatchRelative().AtParent().AtName("cidr_block"), - }...), - }, - }, - "comment": schema.StringAttribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - }, - Blocks: map[string]schema.Block{ - "timeouts": timeouts.Block(ctx, timeouts.Opts{ - Delete: true, - Read: true, - }), - }, - } + resp.Schema = ResourceSchema(ctx) conversion.UpdateSchemaDescription(&resp.Schema) } diff --git a/internal/service/projectipaccesslist/resource_schema.go b/internal/service/projectipaccesslist/resource_schema.go new file mode 100644 index 0000000000..335486e48d --- /dev/null +++ b/internal/service/projectipaccesslist/resource_schema.go @@ -0,0 +1,93 @@ +package projectipaccesslist + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/validate" +) + +func ResourceSchema(ctx context.Context) schema.Schema { + return schema.Schema{ + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + }, + "project_id": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + "cidr_block": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + Validators: []validator.String{ + validate.ValidCIDR(), + stringvalidator.ConflictsWith(path.Expressions{ + path.MatchRelative().AtParent().AtName("aws_security_group"), + path.MatchRelative().AtParent().AtName("ip_address"), + }...), + }, + }, + "ip_address": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + Validators: []validator.String{ + validate.ValidIP(), + stringvalidator.ConflictsWith(path.Expressions{ + path.MatchRelative().AtParent().AtName("aws_security_group"), + path.MatchRelative().AtParent().AtName("cidr_block"), + }...), + }, + }, + "aws_security_group": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + Validators: []validator.String{ + stringvalidator.ConflictsWith(path.Expressions{ + path.MatchRelative().AtParent().AtName("ip_address"), + path.MatchRelative().AtParent().AtName("cidr_block"), + }...), + }, + }, + "comment": schema.StringAttribute{ + Computed: true, + Optional: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + "timeouts": timeouts.Attributes(ctx, timeouts.Opts{ + Read: true, + Delete: true, + }), + }, + } +} + +type TfProjectIPAccessListModel struct { + ID types.String `tfsdk:"id"` + ProjectID types.String `tfsdk:"project_id"` + CIDRBlock types.String `tfsdk:"cidr_block"` + IPAddress types.String `tfsdk:"ip_address"` + AWSSecurityGroup types.String `tfsdk:"aws_security_group"` + Comment types.String `tfsdk:"comment"` + Timeouts timeouts.Value `tfsdk:"timeouts"` +} diff --git a/internal/service/projectipaddresses/data_source.go b/internal/service/projectipaddresses/data_source.go index 429a56ff47..f54e5e4461 100644 --- a/internal/service/projectipaddresses/data_source.go +++ b/internal/service/projectipaddresses/data_source.go @@ -38,7 +38,7 @@ func (d *projectIPAddressesDS) Read(ctx context.Context, req datasource.ReadRequ return } - projectIPAddresses, _, err := connV2.ProjectsApi.ReturnAllIPAddresses(ctx, databaseDSUserConfig.ProjectId.ValueString()).Execute() + projectIPAddresses, _, err := connV2.ProjectsApi.ReturnAllIpAddresses(ctx, databaseDSUserConfig.ProjectId.ValueString()).Execute() if err != nil { resp.Diagnostics.AddError("error getting project's IP addresses", err.Error()) return diff --git a/internal/service/projectipaddresses/model.go b/internal/service/projectipaddresses/model.go index fbd0372987..ae167501c8 100644 --- a/internal/service/projectipaddresses/model.go +++ b/internal/service/projectipaddresses/model.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func NewTFProjectIPAddresses(ctx context.Context, ipAddresses *admin.GroupIPAddresses) (*TFProjectIpAddressesModel, diag.Diagnostics) { diff --git a/internal/service/projectipaddresses/model_test.go b/internal/service/projectipaddresses/model_test.go index e121d2ab0c..5401eb533f 100644 --- a/internal/service/projectipaddresses/model_test.go +++ b/internal/service/projectipaddresses/model_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/projectipaddresses" "github.com/stretchr/testify/assert" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/pushbasedlogexport/data_source.go b/internal/service/pushbasedlogexport/data_source.go index 78e0a05bb7..6c3d0cd723 100644 --- a/internal/service/pushbasedlogexport/data_source.go +++ b/internal/service/pushbasedlogexport/data_source.go @@ -25,7 +25,9 @@ type pushBasedLogExportDS struct { } func (d *pushBasedLogExportDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), "project_id") + resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.DataSourceSchemaRequest{ + RequiredFields: []string{"project_id"}, + }) } func (d *pushBasedLogExportDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/service/pushbasedlogexport/model.go b/internal/service/pushbasedlogexport/model.go index 3bd3143a2a..1324697cd8 100644 --- a/internal/service/pushbasedlogexport/model.go +++ b/internal/service/pushbasedlogexport/model.go @@ -3,7 +3,7 @@ package pushbasedlogexport import ( "context" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" "github.com/hashicorp/terraform-plugin-framework/diag" diff --git a/internal/service/pushbasedlogexport/model_test.go b/internal/service/pushbasedlogexport/model_test.go index 85fe64ed61..fdb7213540 100644 --- a/internal/service/pushbasedlogexport/model_test.go +++ b/internal/service/pushbasedlogexport/model_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" "github.com/hashicorp/terraform-plugin-framework/types" diff --git a/internal/service/pushbasedlogexport/resource.go b/internal/service/pushbasedlogexport/resource.go index ce8953c1f4..d53303074f 100644 --- a/internal/service/pushbasedlogexport/resource.go +++ b/internal/service/pushbasedlogexport/resource.go @@ -7,7 +7,7 @@ import ( "slices" "time" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" diff --git a/internal/service/pushbasedlogexport/state_transition.go b/internal/service/pushbasedlogexport/state_transition.go index afdc176af0..50d17c93c0 100644 --- a/internal/service/pushbasedlogexport/state_transition.go +++ b/internal/service/pushbasedlogexport/state_transition.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" diff --git a/internal/service/pushbasedlogexport/state_transition_test.go b/internal/service/pushbasedlogexport/state_transition_test.go index f7de95e547..8d4b205911 100644 --- a/internal/service/pushbasedlogexport/state_transition_test.go +++ b/internal/service/pushbasedlogexport/state_transition_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "go.mongodb.org/atlas-sdk/v20241023002/admin" - "go.mongodb.org/atlas-sdk/v20241023002/mockadmin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" + "go.mongodb.org/atlas-sdk/v20241113003/mockadmin" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/internal/service/resourcepolicy/data_source.go b/internal/service/resourcepolicy/data_source.go index c77a7f9bfa..d2dc079aa4 100644 --- a/internal/service/resourcepolicy/data_source.go +++ b/internal/service/resourcepolicy/data_source.go @@ -4,6 +4,7 @@ import ( "context" "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) @@ -27,7 +28,9 @@ type resourcePolicyDS struct { } func (d *resourcePolicyDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = DataSourceSchema(ctx) + resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.DataSourceSchemaRequest{ + RequiredFields: []string{"org_id", "id"}, + }) } func (d *resourcePolicyDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/service/resourcepolicy/data_source_schema.go b/internal/service/resourcepolicy/data_source_schema.go deleted file mode 100644 index 6c888e4f43..0000000000 --- a/internal/service/resourcepolicy/data_source_schema.go +++ /dev/null @@ -1,102 +0,0 @@ -package resourcepolicy - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" -) - -func DataSourceSchema(ctx context.Context) schema.Schema { - return schema.Schema{ - Attributes: dataSourceSchema(false), - } -} - -func dataSourceSchema(isPlural bool) map[string]schema.Attribute { - return map[string]schema.Attribute{ - "created_by_user": schema.SingleNestedAttribute{ - Description: "The user that last updated the Atlas resource policy.", - MarkdownDescription: "The user that last updated the Atlas resource policy.", - Computed: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "Unique 24-hexadecimal character string that identifies a user.", - MarkdownDescription: "Unique 24-hexadecimal character string that identifies a user.", - Computed: true, - }, - "name": schema.StringAttribute{ - Description: "Human-readable label that describes a user.", - MarkdownDescription: "Human-readable label that describes a user.", - Computed: true, - }, - }, - }, - "created_date": schema.StringAttribute{ - Description: "Date and time in UTC when the Atlas resource policy was created.", - MarkdownDescription: "Date and time in UTC when the Atlas resource policy was created.", - Computed: true, - }, - "id": schema.StringAttribute{ - Description: "Unique 24-hexadecimal digit string that identifies an Atlas resource policy.", - MarkdownDescription: "Unique 24-hexadecimal digit string that identifies an Atlas resource policy.", - Required: !isPlural, - Computed: isPlural, - }, - "last_updated_by_user": schema.SingleNestedAttribute{ - Description: "The user that last updated the Atlas resource policy.", - MarkdownDescription: "The user that last updated the Atlas resource policy.", - Computed: true, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "Unique 24-hexadecimal character string that identifies a user.", - MarkdownDescription: "Unique 24-hexadecimal character string that identifies a user.", - Computed: true, - }, - "name": schema.StringAttribute{ - Description: "Human-readable label that describes a user.", - MarkdownDescription: "Human-readable label that describes a user.", - Computed: true, - }, - }, - }, - "last_updated_date": schema.StringAttribute{ - Description: "Date and time in UTC when the Atlas resource policy was last updated.", - MarkdownDescription: "Date and time in UTC when the Atlas resource policy was last updated.", - Computed: true, - }, - "name": schema.StringAttribute{ - Description: "Human-readable label that describes the Atlas resource policy.", - MarkdownDescription: "Human-readable label that describes the Atlas resource policy.", - Computed: true, - }, - "org_id": schema.StringAttribute{ - Required: !isPlural, - Computed: isPlural, - Description: "Unique 24-hexadecimal digit string that identifies the organization that contains your projects. Use the [/orgs](#tag/Organizations/operation/listOrganizations) endpoint to retrieve all organizations to which the authenticated user has access.", - MarkdownDescription: "Unique 24-hexadecimal digit string that identifies the organization that contains your projects. Use the [/orgs](#tag/Organizations/operation/listOrganizations) endpoint to retrieve all organizations to which the authenticated user has access.", - }, - "policies": schema.ListNestedAttribute{ - Description: "List of policies that make up the Atlas resource policy.", - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "body": schema.StringAttribute{ - Description: "A string that defines the permissions for the policy. The syntax used is the Cedar Policy language.", - MarkdownDescription: "A string that defines the permissions for the policy. The syntax used is the Cedar Policy language.", - Computed: true, - }, - "id": schema.StringAttribute{ - Description: "Unique 24-hexadecimal character string that identifies the policy.", - MarkdownDescription: "Unique 24-hexadecimal character string that identifies the policy.", - Computed: true, - }, - }, - }, - }, - "version": schema.StringAttribute{ - Description: "A string that identifies the version of the Atlas resource policy.", - MarkdownDescription: "A string that identifies the version of the Atlas resource policy.", - Computed: true, - }, - } -} diff --git a/internal/service/resourcepolicy/model.go b/internal/service/resourcepolicy/model.go index f3b82c873a..55e83fb56c 100644 --- a/internal/service/resourcepolicy/model.go +++ b/internal/service/resourcepolicy/model.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func NewTFModel(ctx context.Context, input *admin.ApiAtlasResourcePolicy) (*TFModel, diag.Diagnostics) { diff --git a/internal/service/resourcepolicy/model_test.go b/internal/service/resourcepolicy/model_test.go index 3852a9f0b3..bdccf9eb1c 100644 --- a/internal/service/resourcepolicy/model_test.go +++ b/internal/service/resourcepolicy/model_test.go @@ -11,7 +11,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/resourcepolicy" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/unit" "github.com/stretchr/testify/assert" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) var ( diff --git a/internal/service/resourcepolicy/plural_data_source.go b/internal/service/resourcepolicy/plural_data_source.go index 1e65e34ec7..7414d1dd41 100644 --- a/internal/service/resourcepolicy/plural_data_source.go +++ b/internal/service/resourcepolicy/plural_data_source.go @@ -2,8 +2,12 @@ package resourcepolicy import ( "context" + "fmt" "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) @@ -29,7 +33,16 @@ type resourcePolicysDS struct { } func (d *resourcePolicysDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = DataSourcePluralSchema(ctx) + reqSchema := &conversion.PluralDataSourceSchemaRequest{ + RequiredFields: []string{"org_id"}, + } + resp.Schema = conversion.PluralDataSourceSchemaFromResource(ResourceSchema(ctx), reqSchema) + clone := conversion.PluralDataSourceSchemaFromResource(ResourceSchema(ctx), reqSchema) + resourcePolicies := clone.Attributes["results"].(schema.ListNestedAttribute) + resourcePolicies.DeprecationMessage = fmt.Sprintf(constant.DeprecationParamWithReplacement, "`results`") + resourcePolicies.Description = "" + resourcePolicies.MarkdownDescription = "" + resp.Schema.Attributes["resource_policies"] = resourcePolicies } func (d *resourcePolicysDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/service/resourcepolicy/plural_data_source_schema.go b/internal/service/resourcepolicy/plural_data_source_schema.go deleted file mode 100644 index bfe843386d..0000000000 --- a/internal/service/resourcepolicy/plural_data_source_schema.go +++ /dev/null @@ -1,43 +0,0 @@ -package resourcepolicy - -import ( - "context" - "fmt" - - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" - - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" -) - -func DataSourcePluralSchema(ctx context.Context) schema.Schema { - dsAttributes := dataSourceSchema(true) - return schema.Schema{ - Attributes: map[string]schema.Attribute{ - "org_id": schema.StringAttribute{ - Required: true, - Description: "Unique 24-hexadecimal digit string that identifies the organization that contains your projects. Use the [/orgs](#tag/Organizations/operation/listOrganizations) endpoint to retrieve all organizations to which the authenticated user has access.", - MarkdownDescription: "Unique 24-hexadecimal digit string that identifies the organization that contains your projects. Use the [/orgs](#tag/Organizations/operation/listOrganizations) endpoint to retrieve all organizations to which the authenticated user has access.", - }, - "resource_policies": schema.ListNestedAttribute{ - DeprecationMessage: fmt.Sprintf(constant.DeprecationParamWithReplacement, "`results`"), - NestedObject: schema.NestedAttributeObject{ - Attributes: dsAttributes, - }, - Computed: true, - }, - "results": schema.ListNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: dsAttributes, - }, - Computed: true, - }, - }, - } -} - -type TFModelDSP struct { - OrgID types.String `tfsdk:"org_id"` - ResourcePolicies []TFModel `tfsdk:"resource_policies"` - Results []TFModel `tfsdk:"results"` -} diff --git a/internal/service/resourcepolicy/resource.go b/internal/service/resourcepolicy/resource.go index 29e971e86d..d05f165f58 100644 --- a/internal/service/resourcepolicy/resource.go +++ b/internal/service/resourcepolicy/resource.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) var _ resource.ResourceWithConfigure = &resourcePolicyRS{} @@ -64,6 +64,7 @@ func (r *resourcePolicyRS) ModifyPlan(ctx context.Context, req resource.ModifyPl func (r *resourcePolicyRS) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = ResourceSchema(ctx) + conversion.UpdateSchemaDescription(&resp.Schema) } func (r *resourcePolicyRS) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { diff --git a/internal/service/resourcepolicy/resource_schema.go b/internal/service/resourcepolicy/resource_schema.go index 3aa68467d4..067fd0e6bf 100644 --- a/internal/service/resourcepolicy/resource_schema.go +++ b/internal/service/resourcepolicy/resource_schema.go @@ -14,29 +14,24 @@ func ResourceSchema(ctx context.Context) schema.Schema { return schema.Schema{ Attributes: map[string]schema.Attribute{ "created_by_user": schema.SingleNestedAttribute{ - Description: "The user that last updated the Atlas resource policy.", MarkdownDescription: "The user that last updated the Atlas resource policy.", Computed: true, Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - Description: "Unique 24-hexadecimal character string that identifies a user.", MarkdownDescription: "Unique 24-hexadecimal character string that identifies a user.", Computed: true, }, "name": schema.StringAttribute{ - Description: "Human-readable label that describes a user.", MarkdownDescription: "Human-readable label that describes a user.", Computed: true, }, }, }, "created_date": schema.StringAttribute{ - Description: "Date and time in UTC when the Atlas resource policy was created.", MarkdownDescription: "Date and time in UTC when the Atlas resource policy was created.", Computed: true, }, "id": schema.StringAttribute{ - Description: "Unique 24-hexadecimal digit string that identifies an Atlas resource policy.", MarkdownDescription: "Unique 24-hexadecimal digit string that identifies an Atlas resource policy.", Computed: true, PlanModifiers: []planmodifier.String{ @@ -44,50 +39,41 @@ func ResourceSchema(ctx context.Context) schema.Schema { }, }, "last_updated_by_user": schema.SingleNestedAttribute{ - Description: "The user that last updated the Atlas resource policy.", MarkdownDescription: "The user that last updated the Atlas resource policy.", Computed: true, Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - Description: "Unique 24-hexadecimal character string that identifies a user.", MarkdownDescription: "Unique 24-hexadecimal character string that identifies a user.", Computed: true, }, "name": schema.StringAttribute{ - Description: "Human-readable label that describes a user.", MarkdownDescription: "Human-readable label that describes a user.", Computed: true, }, }, }, "last_updated_date": schema.StringAttribute{ - Description: "Date and time in UTC when the Atlas resource policy was last updated.", MarkdownDescription: "Date and time in UTC when the Atlas resource policy was last updated.", Computed: true, }, "name": schema.StringAttribute{ - Description: "Human-readable label that describes the Atlas resource policy.", MarkdownDescription: "Human-readable label that describes the Atlas resource policy.", Required: true, }, "org_id": schema.StringAttribute{ - Description: "Unique 24-hexadecimal digit string that identifies the organization that contains your projects. Use the [/orgs](#tag/Organizations/operation/listOrganizations) endpoint to retrieve all organizations to which the authenticated user has access.", MarkdownDescription: "Unique 24-hexadecimal digit string that identifies the organization that contains your projects. Use the [/orgs](#tag/Organizations/operation/listOrganizations) endpoint to retrieve all organizations to which the authenticated user has access.", Required: true, }, "policies": schema.ListNestedAttribute{ - Description: "List of policies that make up the Atlas resource policy.", MarkdownDescription: "List of policies that make up the Atlas resource policy.", Required: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "body": schema.StringAttribute{ - Description: "A string that defines the permissions for the policy. The syntax used is the Cedar Policy language.", MarkdownDescription: "A string that defines the permissions for the policy. The syntax used is the Cedar Policy language.", Required: true, }, "id": schema.StringAttribute{ - Description: "Unique 24-hexadecimal character string that identifies the policy.", MarkdownDescription: "Unique 24-hexadecimal character string that identifies the policy.", Computed: true, }, @@ -95,7 +81,6 @@ func ResourceSchema(ctx context.Context) schema.Schema { }, }, "version": schema.StringAttribute{ - Description: "A string that identifies the version of the Atlas resource policy.", MarkdownDescription: "A string that identifies the version of the Atlas resource policy.", Computed: true, PlanModifiers: []planmodifier.String{ @@ -132,3 +117,9 @@ type TFPolicyModel struct { Body types.String `tfsdk:"body"` ID types.String `tfsdk:"id"` } + +type TFModelDSP struct { + OrgID types.String `tfsdk:"org_id"` + ResourcePolicies []TFModel `tfsdk:"resource_policies"` + Results []TFModel `tfsdk:"results"` +} diff --git a/internal/service/searchdeployment/data_source_search_deployment.go b/internal/service/searchdeployment/data_source_search_deployment.go index 1a413657b1..a454d98f97 100644 --- a/internal/service/searchdeployment/data_source_search_deployment.go +++ b/internal/service/searchdeployment/data_source_search_deployment.go @@ -24,7 +24,9 @@ type searchDeploymentDS struct { } func (d *searchDeploymentDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), "project_id", "cluster_name") + resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.DataSourceSchemaRequest{ + RequiredFields: []string{"project_id", "cluster_name"}, + }) } func (d *searchDeploymentDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/service/searchdeployment/model_search_deployment.go b/internal/service/searchdeployment/model_search_deployment.go index e7864b1dbb..55aeec3cc0 100644 --- a/internal/service/searchdeployment/model_search_deployment.go +++ b/internal/service/searchdeployment/model_search_deployment.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func NewSearchDeploymentReq(ctx context.Context, searchDeploymentPlan *TFSearchDeploymentRSModel) admin.ApiSearchDeploymentRequest { diff --git a/internal/service/searchdeployment/model_search_deployment_test.go b/internal/service/searchdeployment/model_search_deployment_test.go index ecd8696b5f..b3995b4eb7 100644 --- a/internal/service/searchdeployment/model_search_deployment_test.go +++ b/internal/service/searchdeployment/model_search_deployment_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/searchdeployment" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) type sdkToTFModelTestCase struct { diff --git a/internal/service/searchdeployment/state_transition_search_deployment.go b/internal/service/searchdeployment/state_transition_search_deployment.go index 5ad49c2c21..5bd581637e 100644 --- a/internal/service/searchdeployment/state_transition_search_deployment.go +++ b/internal/service/searchdeployment/state_transition_search_deployment.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/retrystrategy" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const SearchDeploymentDoesNotExistsError = "ATLAS_SEARCH_DEPLOYMENT_DOES_NOT_EXIST" diff --git a/internal/service/searchdeployment/state_transition_search_deployment_test.go b/internal/service/searchdeployment/state_transition_search_deployment_test.go index 81b10c2acf..669b39bb09 100644 --- a/internal/service/searchdeployment/state_transition_search_deployment_test.go +++ b/internal/service/searchdeployment/state_transition_search_deployment_test.go @@ -12,8 +12,8 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/searchdeployment" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "go.mongodb.org/atlas-sdk/v20241023002/admin" - "go.mongodb.org/atlas-sdk/v20241023002/mockadmin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" + "go.mongodb.org/atlas-sdk/v20241113003/mockadmin" ) var ( diff --git a/internal/service/searchindex/data_source_search_indexes.go b/internal/service/searchindex/data_source_search_indexes.go index 213a12dfd5..82ff23e703 100644 --- a/internal/service/searchindex/data_source_search_indexes.go +++ b/internal/service/searchindex/data_source_search_indexes.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { diff --git a/internal/service/searchindex/model_search_index.go b/internal/service/searchindex/model_search_index.go index bc3176c248..b5bfedc5e2 100644 --- a/internal/service/searchindex/model_search_index.go +++ b/internal/service/searchindex/model_search_index.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/schemafunc" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func flattenSearchIndexSynonyms(synonyms []admin.SearchSynonymMappingDefinition) []map[string]any { diff --git a/internal/service/searchindex/resource_search_index.go b/internal/service/searchindex/resource_search_index.go index 34114ff637..db54d1f9ef 100644 --- a/internal/service/searchindex/resource_search_index.go +++ b/internal/service/searchindex/resource_search_index.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/serverlessinstance/data_source_serverless_instance.go b/internal/service/serverlessinstance/data_source_serverless_instance.go index 9588e65b65..ca799d60cf 100644 --- a/internal/service/serverlessinstance/data_source_serverless_instance.go +++ b/internal/service/serverlessinstance/data_source_serverless_instance.go @@ -2,9 +2,11 @@ package serverlessinstance import ( "context" + "fmt" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster" @@ -88,14 +90,16 @@ func dataSourceSchema() map[string]*schema.Schema { Computed: true, }, "continuous_backup_enabled": { - Type: schema.TypeBool, - Optional: true, - Computed: true, + Deprecated: fmt.Sprintf(constant.DeprecatioParamByDateWithExternalLink, "March 2025", "https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide"), + Type: schema.TypeBool, + Optional: true, + Computed: true, }, "auto_indexing": { - Type: schema.TypeBool, - Optional: true, - Computed: true, + Deprecated: fmt.Sprintf(constant.DeprecatioParamByDateWithExternalLink, "March 2025", "https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide"), + Type: schema.TypeBool, + Optional: true, + Computed: true, }, "tags": &advancedcluster.DSTagsSchema, } diff --git a/internal/service/serverlessinstance/data_source_serverless_instances.go b/internal/service/serverlessinstance/data_source_serverless_instances.go index 5dcec67451..543507e827 100644 --- a/internal/service/serverlessinstance/data_source_serverless_instances.go +++ b/internal/service/serverlessinstance/data_source_serverless_instances.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { diff --git a/internal/service/serverlessinstance/resource_serverless_instance.go b/internal/service/serverlessinstance/resource_serverless_instance.go index 882642ef8f..bf45ac8918 100644 --- a/internal/service/serverlessinstance/resource_serverless_instance.go +++ b/internal/service/serverlessinstance/resource_serverless_instance.go @@ -12,10 +12,11 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( @@ -110,14 +111,16 @@ func resourceSchema() map[string]*schema.Schema { Computed: true, }, "continuous_backup_enabled": { - Type: schema.TypeBool, - Optional: true, - Computed: true, + Deprecated: fmt.Sprintf(constant.DeprecatioParamByDateWithExternalLink, "March 2025", "https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide"), + Type: schema.TypeBool, + Optional: true, + Computed: true, }, "auto_indexing": { - Type: schema.TypeBool, - Optional: true, - Computed: true, + Deprecated: fmt.Sprintf(constant.DeprecatioParamByDateWithExternalLink, "March 2025", "https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/serverless-shared-migration-guide"), + Type: schema.TypeBool, + Optional: true, + Computed: true, }, "tags": &advancedcluster.RSTagsSchema, } diff --git a/internal/service/serverlessinstance/resource_serverless_instance_test.go b/internal/service/serverlessinstance/resource_serverless_instance_test.go index 42257a4f85..fd2c8c6675 100644 --- a/internal/service/serverlessinstance/resource_serverless_instance_test.go +++ b/internal/service/serverlessinstance/resource_serverless_instance_test.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/sharedtier/data_source_cloud_shared_tier_restore_jobs.go b/internal/service/sharedtier/data_source_cloud_shared_tier_restore_jobs.go index 50ec28d5c1..bed6d2a1c1 100644 --- a/internal/service/sharedtier/data_source_cloud_shared_tier_restore_jobs.go +++ b/internal/service/sharedtier/data_source_cloud_shared_tier_restore_jobs.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" diff --git a/internal/service/sharedtier/data_source_shared_tier_snapshots.go b/internal/service/sharedtier/data_source_shared_tier_snapshots.go index e1c4c965f0..9c31dd78bb 100644 --- a/internal/service/sharedtier/data_source_shared_tier_snapshots.go +++ b/internal/service/sharedtier/data_source_shared_tier_snapshots.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" diff --git a/internal/service/streamconnection/data_source_stream_connection.go b/internal/service/streamconnection/data_source_stream_connection.go index 24687115a4..925cda7096 100644 --- a/internal/service/streamconnection/data_source_stream_connection.go +++ b/internal/service/streamconnection/data_source_stream_connection.go @@ -4,8 +4,7 @@ import ( "context" "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) @@ -25,85 +24,9 @@ type streamConnectionDS struct { } func (d *streamConnectionDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: DSAttributes(true), - } -} - -// DSAttributes returns the attribute definitions for a single stream connection. -// `withArguments` marks certain attributes as required (for singular data source) or as computed (for plural data source) -func DSAttributes(withArguments bool) map[string]schema.Attribute { - return map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "project_id": schema.StringAttribute{ - Required: withArguments, - Computed: !withArguments, - }, - "instance_name": schema.StringAttribute{ - Required: withArguments, - Computed: !withArguments, - }, - "connection_name": schema.StringAttribute{ - Required: withArguments, - Computed: !withArguments, - }, - "type": schema.StringAttribute{ - Computed: true, - }, - - // cluster type specific - "cluster_name": schema.StringAttribute{ - Computed: true, - }, - "db_role_to_execute": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "role": schema.StringAttribute{ - Computed: true, - }, - "type": schema.StringAttribute{ - Computed: true, - }, - }, - }, - - // kafka type specific - "authentication": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "mechanism": schema.StringAttribute{ - Computed: true, - }, - "password": schema.StringAttribute{ - Computed: true, - Sensitive: true, - }, - "username": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "bootstrap_servers": schema.StringAttribute{ - Computed: true, - }, - "config": schema.MapAttribute{ - ElementType: types.StringType, - Computed: true, - }, - "security": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "broker_public_certificate": schema.StringAttribute{ - Computed: true, - }, - "protocol": schema.StringAttribute{ - Computed: true, - }, - }, - }, - } + resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.DataSourceSchemaRequest{ + RequiredFields: []string{"project_id", "instance_name", "connection_name"}, + }) } func (d *streamConnectionDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/service/streamconnection/data_source_stream_connections.go b/internal/service/streamconnection/data_source_stream_connections.go index 220585e651..e7c1c1203b 100644 --- a/internal/service/streamconnection/data_source_stream_connections.go +++ b/internal/service/streamconnection/data_source_stream_connections.go @@ -5,12 +5,10 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/dsschema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) var _ datasource.DataSource = &streamConnectionsDS{} @@ -28,27 +26,11 @@ type streamConnectionsDS struct { config.DSCommon } -type TFStreamConnectionsDSModel struct { - ID types.String `tfsdk:"id"` - ProjectID types.String `tfsdk:"project_id"` - InstanceName types.String `tfsdk:"instance_name"` - Results []TFStreamConnectionModel `tfsdk:"results"` - PageNum types.Int64 `tfsdk:"page_num"` - ItemsPerPage types.Int64 `tfsdk:"items_per_page"` - TotalCount types.Int64 `tfsdk:"total_count"` -} - func (d *streamConnectionsDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = dsschema.PaginatedDSSchema( - map[string]schema.Attribute{ - "project_id": schema.StringAttribute{ - Required: true, - }, - "instance_name": schema.StringAttribute{ - Required: true, - }, - }, - DSAttributes(false)) + resp.Schema = conversion.PluralDataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.PluralDataSourceSchemaRequest{ + RequiredFields: []string{"project_id", "instance_name"}, + HasLegacyFields: true, + }) } func (d *streamConnectionsDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { @@ -83,3 +65,13 @@ func (d *streamConnectionsDS) Read(ctx context.Context, req datasource.ReadReque } resp.Diagnostics.Append(resp.State.Set(ctx, newStreamConnectionsModel)...) } + +type TFStreamConnectionsDSModel struct { + ID types.String `tfsdk:"id"` + ProjectID types.String `tfsdk:"project_id"` + InstanceName types.String `tfsdk:"instance_name"` + Results []TFStreamConnectionModel `tfsdk:"results"` + PageNum types.Int64 `tfsdk:"page_num"` + ItemsPerPage types.Int64 `tfsdk:"items_per_page"` + TotalCount types.Int64 `tfsdk:"total_count"` +} diff --git a/internal/service/streamconnection/data_source_stream_connections_test.go b/internal/service/streamconnection/data_source_stream_connections_test.go index 2b26c4a706..9603eb6b93 100644 --- a/internal/service/streamconnection/data_source_stream_connections_test.go +++ b/internal/service/streamconnection/data_source_stream_connections_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func TestAccStreamDSStreamConnections_basic(t *testing.T) { diff --git a/internal/service/streamconnection/model_stream_connection.go b/internal/service/streamconnection/model_stream_connection.go index 7abb8ccb8b..80fc6d5697 100644 --- a/internal/service/streamconnection/model_stream_connection.go +++ b/internal/service/streamconnection/model_stream_connection.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func NewStreamConnectionReq(ctx context.Context, plan *TFStreamConnectionModel) (*admin.StreamsConnection, diag.Diagnostics) { diff --git a/internal/service/streamconnection/model_stream_connection_test.go b/internal/service/streamconnection/model_stream_connection_test.go index bb3a0d3871..f206b5d47c 100644 --- a/internal/service/streamconnection/model_stream_connection_test.go +++ b/internal/service/streamconnection/model_stream_connection_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/streamconnection" "github.com/stretchr/testify/assert" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/streamconnection/resource_schema.go b/internal/service/streamconnection/resource_schema.go new file mode 100644 index 0000000000..be3ec15d42 --- /dev/null +++ b/internal/service/streamconnection/resource_schema.go @@ -0,0 +1,100 @@ +package streamconnection + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func ResourceSchema(ctx context.Context) schema.Schema { + return schema.Schema{ + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + }, + "project_id": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + "instance_name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + "connection_name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + "type": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + + // cluster type specific + "cluster_name": schema.StringAttribute{ + Optional: true, + }, + "db_role_to_execute": schema.SingleNestedAttribute{ + Optional: true, + Attributes: map[string]schema.Attribute{ + "role": schema.StringAttribute{ + Required: true, + }, + "type": schema.StringAttribute{ + Required: true, + Validators: []validator.String{ + stringvalidator.OneOf("BUILT_IN", "CUSTOM"), + }, + }, + }, + }, + + // kafka type specific + "authentication": schema.SingleNestedAttribute{ + Optional: true, + Attributes: map[string]schema.Attribute{ + "mechanism": schema.StringAttribute{ + Optional: true, + }, + "password": schema.StringAttribute{ + Optional: true, + Sensitive: true, + }, + "username": schema.StringAttribute{ + Optional: true, + }, + }, + }, + "bootstrap_servers": schema.StringAttribute{ + Optional: true, + }, + "config": schema.MapAttribute{ + ElementType: types.StringType, + Optional: true, + }, + "security": schema.SingleNestedAttribute{ + Optional: true, + Attributes: map[string]schema.Attribute{ + "broker_public_certificate": schema.StringAttribute{ + Optional: true, + }, + "protocol": schema.StringAttribute{ + Optional: true, + }, + }, + }, + }, + } +} diff --git a/internal/service/streamconnection/resource_stream_connection.go b/internal/service/streamconnection/resource_stream_connection.go index 530e855021..f4f571ce23 100644 --- a/internal/service/streamconnection/resource_stream_connection.go +++ b/internal/service/streamconnection/resource_stream_connection.go @@ -6,15 +6,11 @@ import ( "net/http" "regexp" - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) @@ -82,91 +78,8 @@ var DBRoleToExecuteObjectType = types.ObjectType{AttrTypes: map[string]attr.Type }} func (r *streamConnectionRS) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "project_id": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "instance_name": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "connection_name": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "type": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - // cluster type specific - "cluster_name": schema.StringAttribute{ - Optional: true, - }, - "db_role_to_execute": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "role": schema.StringAttribute{ - Required: true, - }, - "type": schema.StringAttribute{ - Required: true, - Validators: []validator.String{ - stringvalidator.OneOf("BUILT_IN", "CUSTOM"), - }, - }, - }, - }, - - // kafka type specific - "authentication": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "mechanism": schema.StringAttribute{ - Optional: true, - }, - "password": schema.StringAttribute{ - Optional: true, - Sensitive: true, - }, - "username": schema.StringAttribute{ - Optional: true, - }, - }, - }, - "bootstrap_servers": schema.StringAttribute{ - Optional: true, - }, - "config": schema.MapAttribute{ - ElementType: types.StringType, - Optional: true, - }, - "security": schema.SingleNestedAttribute{ - Optional: true, - Attributes: map[string]schema.Attribute{ - "broker_public_certificate": schema.StringAttribute{ - Optional: true, - }, - "protocol": schema.StringAttribute{ - Optional: true, - }, - }, - }, - }, - } + resp.Schema = ResourceSchema(ctx) + conversion.UpdateSchemaDescription(&resp.Schema) } func (r *streamConnectionRS) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { diff --git a/internal/service/streaminstance/data_source_stream_instance.go b/internal/service/streaminstance/data_source_stream_instance.go index a5ff091f15..7a365eb892 100644 --- a/internal/service/streaminstance/data_source_stream_instance.go +++ b/internal/service/streaminstance/data_source_stream_instance.go @@ -4,8 +4,7 @@ import ( "context" "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) @@ -25,50 +24,9 @@ type streamInstanceDS struct { } func (d *streamInstanceDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: DSAttributes(true), - } -} - -// DSAttributes returns the attribute definitions for a single stream instance. -// `withArguments` marks certain attributes as required (for singular data source) or as computed (for plural data source) -func DSAttributes(withArguments bool) map[string]schema.Attribute { - return map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "instance_name": schema.StringAttribute{ - Required: withArguments, - Computed: !withArguments, - }, - "project_id": schema.StringAttribute{ - Required: withArguments, - Computed: !withArguments, - }, - "data_process_region": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "cloud_provider": schema.StringAttribute{ - Computed: true, - }, - "region": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "hostnames": schema.ListAttribute{ - ElementType: types.StringType, - Computed: true, - }, - "stream_config": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "tier": schema.StringAttribute{ - Computed: true, - }, - }, - }, - } + resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.DataSourceSchemaRequest{ + RequiredFields: []string{"project_id", "instance_name"}, + }) } func (d *streamInstanceDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/service/streaminstance/data_source_stream_instances.go b/internal/service/streaminstance/data_source_stream_instances.go index 94f0ddd6b2..73be09748a 100644 --- a/internal/service/streaminstance/data_source_stream_instances.go +++ b/internal/service/streaminstance/data_source_stream_instances.go @@ -5,12 +5,10 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/dsschema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) var _ datasource.DataSource = &streamInstancesDS{} @@ -28,23 +26,11 @@ type streamInstancesDS struct { config.DSCommon } -type TFStreamInstancesModel struct { - ID types.String `tfsdk:"id"` - ProjectID types.String `tfsdk:"project_id"` - Results []TFStreamInstanceModel `tfsdk:"results"` - PageNum types.Int64 `tfsdk:"page_num"` - ItemsPerPage types.Int64 `tfsdk:"items_per_page"` - TotalCount types.Int64 `tfsdk:"total_count"` -} - func (d *streamInstancesDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = dsschema.PaginatedDSSchema( - map[string]schema.Attribute{ - "project_id": schema.StringAttribute{ - Required: true, - }, - }, - DSAttributes(false)) + resp.Schema = conversion.PluralDataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.PluralDataSourceSchemaRequest{ + RequiredFields: []string{"project_id"}, + HasLegacyFields: true, + }) } func (d *streamInstancesDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { @@ -75,3 +61,12 @@ func (d *streamInstancesDS) Read(ctx context.Context, req datasource.ReadRequest } resp.Diagnostics.Append(resp.State.Set(ctx, newStreamInstancesModel)...) } + +type TFStreamInstancesModel struct { + ID types.String `tfsdk:"id"` + ProjectID types.String `tfsdk:"project_id"` + Results []TFStreamInstanceModel `tfsdk:"results"` + PageNum types.Int64 `tfsdk:"page_num"` + ItemsPerPage types.Int64 `tfsdk:"items_per_page"` + TotalCount types.Int64 `tfsdk:"total_count"` +} diff --git a/internal/service/streaminstance/data_source_stream_instances_test.go b/internal/service/streaminstance/data_source_stream_instances_test.go index a0065773aa..64506f84e6 100644 --- a/internal/service/streaminstance/data_source_stream_instances_test.go +++ b/internal/service/streaminstance/data_source_stream_instances_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func TestAccStreamDSStreamInstances_basic(t *testing.T) { diff --git a/internal/service/streaminstance/model_stream_instance.go b/internal/service/streaminstance/model_stream_instance.go index 342cb54203..dc2a292e3b 100644 --- a/internal/service/streaminstance/model_stream_instance.go +++ b/internal/service/streaminstance/model_stream_instance.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func NewStreamInstanceCreateReq(ctx context.Context, plan *TFStreamInstanceModel) (*admin.StreamsTenant, diag.Diagnostics) { diff --git a/internal/service/streaminstance/model_stream_instance_test.go b/internal/service/streaminstance/model_stream_instance_test.go index bc289c0779..d702301aee 100644 --- a/internal/service/streaminstance/model_stream_instance_test.go +++ b/internal/service/streaminstance/model_stream_instance_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/streaminstance" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/streaminstance/resource_schema.go b/internal/service/streaminstance/resource_schema.go new file mode 100644 index 0000000000..974ca06364 --- /dev/null +++ b/internal/service/streaminstance/resource_schema.go @@ -0,0 +1,85 @@ +package streaminstance + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +func ResourceSchema(ctx context.Context) schema.Schema { + return schema.Schema{ + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + }, + "instance_name": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + "project_id": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + "data_process_region": schema.SingleNestedAttribute{ + Required: true, + Attributes: map[string]schema.Attribute{ + "cloud_provider": schema.StringAttribute{ + Required: true, + }, + "region": schema.StringAttribute{ + Required: true, + }, + }, + }, + "hostnames": schema.ListAttribute{ + ElementType: types.StringType, + Computed: true, + }, + "stream_config": schema.SingleNestedAttribute{ + Optional: true, + Computed: true, + Attributes: map[string]schema.Attribute{ + "tier": schema.StringAttribute{ + Optional: true, + Computed: true, + }, + }, + }, + }, + } +} + +type TFStreamInstanceModel struct { + ID types.String `tfsdk:"id"` + InstanceName types.String `tfsdk:"instance_name"` + ProjectID types.String `tfsdk:"project_id"` + DataProcessRegion types.Object `tfsdk:"data_process_region"` + StreamConfig types.Object `tfsdk:"stream_config"` + Hostnames types.List `tfsdk:"hostnames"` +} + +type TFInstanceProcessRegionSpecModel struct { + CloudProvider types.String `tfsdk:"cloud_provider"` + Region types.String `tfsdk:"region"` +} + +type TFInstanceStreamConfigSpecModel struct { + Tier types.String `tfsdk:"tier"` +} + +var ProcessRegionObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ + "cloud_provider": types.StringType, + "region": types.StringType, +}} + +var StreamConfigObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ + "tier": types.StringType, +}} diff --git a/internal/service/streaminstance/resource_stream_instance.go b/internal/service/streaminstance/resource_stream_instance.go index bfc30c7bf2..d9f35ff7b2 100644 --- a/internal/service/streaminstance/resource_stream_instance.go +++ b/internal/service/streaminstance/resource_stream_instance.go @@ -6,13 +6,9 @@ import ( "net/http" "regexp" - "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) @@ -33,78 +29,9 @@ type streamInstanceRS struct { config.RSCommon } -type TFStreamInstanceModel struct { - ID types.String `tfsdk:"id"` - InstanceName types.String `tfsdk:"instance_name"` - ProjectID types.String `tfsdk:"project_id"` - DataProcessRegion types.Object `tfsdk:"data_process_region"` - StreamConfig types.Object `tfsdk:"stream_config"` - Hostnames types.List `tfsdk:"hostnames"` -} - -type TFInstanceProcessRegionSpecModel struct { - CloudProvider types.String `tfsdk:"cloud_provider"` - Region types.String `tfsdk:"region"` -} - -type TFInstanceStreamConfigSpecModel struct { - Tier types.String `tfsdk:"tier"` -} - -var ProcessRegionObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ - "cloud_provider": types.StringType, - "region": types.StringType, -}} - -var StreamConfigObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ - "tier": types.StringType, -}} - func (r *streamInstanceRS) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - }, - "instance_name": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "project_id": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "data_process_region": schema.SingleNestedAttribute{ - Required: true, - Attributes: map[string]schema.Attribute{ - "cloud_provider": schema.StringAttribute{ - Required: true, - }, - "region": schema.StringAttribute{ - Required: true, - }, - }, - }, - "hostnames": schema.ListAttribute{ - ElementType: types.StringType, - Computed: true, - }, - "stream_config": schema.SingleNestedAttribute{ - Optional: true, - Computed: true, - Attributes: map[string]schema.Attribute{ - "tier": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - }, - }, - }, - } + resp.Schema = ResourceSchema(ctx) + conversion.UpdateSchemaDescription(&resp.Schema) } func (r *streamInstanceRS) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { diff --git a/internal/service/streamprocessor/data_source.go b/internal/service/streamprocessor/data_source.go index 025c6f7c76..b252034587 100644 --- a/internal/service/streamprocessor/data_source.go +++ b/internal/service/streamprocessor/data_source.go @@ -24,9 +24,9 @@ type StreamProccesorDS struct { } func (d *StreamProccesorDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - // TODO: Schema and model must be defined in data_source_schema.go. Details on scaffolding this file found in contributing/development-best-practices.md under "Scaffolding Schema and Model Definitions" - resp.Schema = DataSourceSchema(ctx) - conversion.UpdateSchemaDescription(&resp.Schema) + resp.Schema = conversion.DataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.DataSourceSchemaRequest{ + RequiredFields: []string{"project_id", "instance_name", "processor_name"}, + }) } func (d *StreamProccesorDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/service/streamprocessor/data_source_schema.go b/internal/service/streamprocessor/data_source_schema.go deleted file mode 100644 index dba98fe299..0000000000 --- a/internal/service/streamprocessor/data_source_schema.go +++ /dev/null @@ -1,63 +0,0 @@ -package streamprocessor - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-framework/types" - - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" -) - -func DataSourceSchema(ctx context.Context) schema.Schema { - return schema.Schema{ - Attributes: DSAttributes(true), - } -} - -func DSAttributes(withArguments bool) map[string]schema.Attribute { - return map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - MarkdownDescription: "Unique 24-hexadecimal character string that identifies the stream processor.", - }, - "instance_name": schema.StringAttribute{ - Required: withArguments, - Computed: !withArguments, - MarkdownDescription: "Human-readable label that identifies the stream instance.", - }, - "pipeline": schema.StringAttribute{ - Computed: true, - MarkdownDescription: "Stream aggregation pipeline you want to apply to your streaming data.", - }, - "processor_name": schema.StringAttribute{ - Required: withArguments, - Computed: !withArguments, - MarkdownDescription: "Human-readable label that identifies the stream processor.", - }, - "project_id": schema.StringAttribute{ - Required: withArguments, - Computed: !withArguments, - MarkdownDescription: "Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.\n\n**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups.", - }, - "state": schema.StringAttribute{ - Computed: true, - MarkdownDescription: "The state of the stream processor.", - }, - "stats": schema.StringAttribute{ - Computed: true, - MarkdownDescription: "The stats associated with the stream processor.", - }, - "options": optionsSchema(true), - } -} - -type TFStreamProcessorDSModel struct { - ID types.String `tfsdk:"id"` - InstanceName types.String `tfsdk:"instance_name"` - Options types.Object `tfsdk:"options"` - Pipeline types.String `tfsdk:"pipeline"` - ProcessorName types.String `tfsdk:"processor_name"` - ProjectID types.String `tfsdk:"project_id"` - State types.String `tfsdk:"state"` - Stats types.String `tfsdk:"stats"` -} diff --git a/internal/service/streamprocessor/model.go b/internal/service/streamprocessor/model.go index 0d770c9ac4..8787699062 100644 --- a/internal/service/streamprocessor/model.go +++ b/internal/service/streamprocessor/model.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/fwtypes" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func NewStreamProcessorReq(ctx context.Context, plan *TFStreamProcessorRSModel) (*admin.StreamsProcessor, diag.Diagnostics) { diff --git a/internal/service/streamprocessor/model_test.go b/internal/service/streamprocessor/model_test.go index b3cb808b43..db05ec1766 100644 --- a/internal/service/streamprocessor/model_test.go +++ b/internal/service/streamprocessor/model_test.go @@ -11,7 +11,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/schemafunc" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/streamprocessor" "github.com/stretchr/testify/assert" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) var ( diff --git a/internal/service/streamprocessor/plural_data_source.go b/internal/service/streamprocessor/plural_data_source.go index fff8dac97b..918d7910cd 100644 --- a/internal/service/streamprocessor/plural_data_source.go +++ b/internal/service/streamprocessor/plural_data_source.go @@ -2,13 +2,38 @@ package streamprocessor import ( "context" + "fmt" "net/http" "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/dsschema" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) +var _ datasource.DataSource = &StreamProccesorDS{} +var _ datasource.DataSourceWithConfigure = &StreamProccesorDS{} + +func PluralDataSource() datasource.DataSource { + return &streamProcessorsDS{ + DSCommon: config.DSCommon{ + DataSourceName: fmt.Sprintf("%ss", StreamProcessorName), + }, + } +} + +type streamProcessorsDS struct { + config.DSCommon +} + +func (d *streamProcessorsDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = conversion.PluralDataSourceSchemaFromResource(ResourceSchema(ctx), &conversion.PluralDataSourceSchemaRequest{ + RequiredFields: []string{"project_id", "instance_name"}, + OverrideResultsDoc: "Returns all Stream Processors within the specified stream instance.\n\nTo use this resource, the requesting API Key must have the Project Owner\n\nrole or Project Stream Processing Owner role.", + }) +} + func (d *streamProcessorsDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { var streamConnectionsConfig TFStreamProcessorsDSModel resp.Diagnostics.Append(req.Config.Get(ctx, &streamConnectionsConfig)...) diff --git a/internal/service/streamprocessor/plural_data_source_schema.go b/internal/service/streamprocessor/plural_data_source_schema.go deleted file mode 100644 index 4d6a94391b..0000000000 --- a/internal/service/streamprocessor/plural_data_source_schema.go +++ /dev/null @@ -1,56 +0,0 @@ -package streamprocessor - -import ( - "context" - "fmt" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" -) - -var _ datasource.DataSource = &StreamProccesorDS{} -var _ datasource.DataSourceWithConfigure = &StreamProccesorDS{} - -func PluralDataSource() datasource.DataSource { - return &streamProcessorsDS{ - DSCommon: config.DSCommon{ - DataSourceName: fmt.Sprintf("%ss", StreamProcessorName), - }, - } -} - -type streamProcessorsDS struct { - config.DSCommon -} - -func (d *streamProcessorsDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "project_id": schema.StringAttribute{ - Required: true, - MarkdownDescription: "Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.\n\n**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups.", - }, - "instance_name": schema.StringAttribute{ - Required: true, - MarkdownDescription: "Human-readable label that identifies the stream instance.", - }, - "results": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: DSAttributes(false), - }, - MarkdownDescription: "Returns all Stream Processors within the specified stream instance.\n\nTo use this resource, the requesting API Key must have the Project Owner\n\nrole or Project Stream Processing Owner role.", - }, - }, - } - conversion.UpdateSchemaDescription(&resp.Schema) -} - -type TFStreamProcessorsDSModel struct { - ProjectID types.String `tfsdk:"project_id"` - InstanceName types.String `tfsdk:"instance_name"` - Results []TFStreamProcessorDSModel `tfsdk:"results"` -} diff --git a/internal/service/streamprocessor/resource.go b/internal/service/streamprocessor/resource.go index 3e58998ce2..bc7bff0e83 100644 --- a/internal/service/streamprocessor/resource.go +++ b/internal/service/streamprocessor/resource.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const StreamProcessorName = "stream_processor" diff --git a/internal/service/streamprocessor/resource_schema.go b/internal/service/streamprocessor/resource_schema.go index daeab850a1..030aa6635e 100644 --- a/internal/service/streamprocessor/resource_schema.go +++ b/internal/service/streamprocessor/resource_schema.go @@ -11,38 +11,6 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/fwtypes" ) -func optionsSchema(isDatasource bool) schema.SingleNestedAttribute { - return schema.SingleNestedAttribute{ - Attributes: map[string]schema.Attribute{ - "dlq": schema.SingleNestedAttribute{ - Attributes: map[string]schema.Attribute{ - "coll": schema.StringAttribute{ - Required: !isDatasource, - Computed: isDatasource, - MarkdownDescription: "Name of the collection to use for the DLQ.", - }, - "connection_name": schema.StringAttribute{ - Required: !isDatasource, - Computed: isDatasource, - MarkdownDescription: "Name of the connection to write DLQ messages to. Must be an Atlas connection.", - }, - "db": schema.StringAttribute{ - Required: !isDatasource, - Computed: isDatasource, - MarkdownDescription: "Name of the database to use for the DLQ.", - }, - }, - Required: !isDatasource, - Computed: isDatasource, - MarkdownDescription: "Dead letter queue for the stream processor. Refer to the [MongoDB Atlas Docs](https://www.mongodb.com/docs/atlas/reference/glossary/#std-term-dead-letter-queue) for more information.", - }, - }, - Optional: !isDatasource, - Computed: isDatasource, - MarkdownDescription: "Optional configuration for the stream processor.", - } -} - func ResourceSchema(ctx context.Context) schema.Schema { return schema.Schema{ Attributes: map[string]schema.Attribute{ @@ -61,7 +29,7 @@ func ResourceSchema(ctx context.Context) schema.Schema { CustomType: fwtypes.JSONStringType, Required: true, MarkdownDescription: "Stream aggregation pipeline you want to apply to your streaming data. [MongoDB Atlas Docs](https://www.mongodb.com/docs/atlas/atlas-stream-processing/stream-aggregation/#std-label-stream-aggregation)" + - " contain more information. Using [jsonencode](https://developer.hashicorp.com/terraform/language/functions/jsonencode) is recommended when settig this attribute. For more details see [Aggregation Pipelines Documentation](https://www.mongodb.com/docs/atlas/atlas-stream-processing/stream-aggregation/)", + " contain more information. Using [jsonencode](https://developer.hashicorp.com/terraform/language/functions/jsonencode) is recommended when setting this attribute. For more details see the [Aggregation Pipelines Documentation](https://www.mongodb.com/docs/atlas/atlas-stream-processing/stream-aggregation/)", }, "processor_name": schema.StringAttribute{ Required: true, @@ -75,9 +43,32 @@ func ResourceSchema(ctx context.Context) schema.Schema { Optional: true, Computed: true, MarkdownDescription: "The state of the stream processor. Commonly occurring states are 'CREATED', 'STARTED', 'STOPPED' and 'FAILED'. Used to start or stop the Stream Processor. Valid values are `CREATED`, `STARTED` or `STOPPED`." + - " When a Stream Processor is created without specifying the state, it will default to `CREATED` state.\n\n**NOTE** When a stream processor is created, the only valid states are CREATED or STARTED. A stream processor can be automatically started when creating it if the state is set to STARTED.", + " When a Stream Processor is created without specifying the state, it will default to `CREATED` state.\n\n**NOTE** When creating a stream processor, setting the state to STARTED can automatically start the stream processor.", + }, + "options": schema.SingleNestedAttribute{ + Optional: true, + MarkdownDescription: "Optional configuration for the stream processor.", + Attributes: map[string]schema.Attribute{ + "dlq": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "coll": schema.StringAttribute{ + Required: true, + MarkdownDescription: "Name of the collection to use for the DLQ.", + }, + "connection_name": schema.StringAttribute{ + Required: true, + MarkdownDescription: "Name of the connection to write DLQ messages to. Must be an Atlas connection.", + }, + "db": schema.StringAttribute{ + Required: true, + MarkdownDescription: "Name of the database to use for the DLQ.", + }, + }, + Required: true, + MarkdownDescription: "Dead letter queue for the stream processor. Refer to the [MongoDB Atlas Docs](https://www.mongodb.com/docs/atlas/reference/glossary/#std-term-dead-letter-queue) for more information.", + }, + }, }, - "options": optionsSchema(false), "stats": schema.StringAttribute{ Computed: true, MarkdownDescription: "The stats associated with the stream processor. Refer to the [MongoDB Atlas Docs](https://www.mongodb.com/docs/atlas/atlas-stream-processing/manage-stream-processor/#view-statistics-of-a-stream-processor) for more information.", @@ -117,3 +108,20 @@ var DlqObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ "db": types.StringType, }, } + +type TFStreamProcessorDSModel struct { + ID types.String `tfsdk:"id"` + InstanceName types.String `tfsdk:"instance_name"` + Options types.Object `tfsdk:"options"` + Pipeline types.String `tfsdk:"pipeline"` + ProcessorName types.String `tfsdk:"processor_name"` + ProjectID types.String `tfsdk:"project_id"` + State types.String `tfsdk:"state"` + Stats types.String `tfsdk:"stats"` +} + +type TFStreamProcessorsDSModel struct { + ProjectID types.String `tfsdk:"project_id"` + InstanceName types.String `tfsdk:"instance_name"` + Results []TFStreamProcessorDSModel `tfsdk:"results"` +} diff --git a/internal/service/streamprocessor/state_transition.go b/internal/service/streamprocessor/state_transition.go index 077bac4db6..4613ff1213 100644 --- a/internal/service/streamprocessor/state_transition.go +++ b/internal/service/streamprocessor/state_transition.go @@ -8,7 +8,7 @@ import ( "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/service/streamprocessor/state_transition_test.go b/internal/service/streamprocessor/state_transition_test.go index 5e5bbf77cd..17687612c2 100644 --- a/internal/service/streamprocessor/state_transition_test.go +++ b/internal/service/streamprocessor/state_transition_test.go @@ -6,8 +6,8 @@ import ( "net/http" "testing" - "go.mongodb.org/atlas-sdk/v20241023002/admin" - "go.mongodb.org/atlas-sdk/v20241023002/mockadmin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" + "go.mongodb.org/atlas-sdk/v20241113003/mockadmin" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/internal/service/team/data_source_team.go b/internal/service/team/data_source_team.go index 985d943277..194db4e002 100644 --- a/internal/service/team/data_source_team.go +++ b/internal/service/team/data_source_team.go @@ -11,7 +11,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func DataSource() *schema.Resource { diff --git a/internal/service/team/resource_team.go b/internal/service/team/resource_team.go index 4726efe600..609f5d5a06 100644 --- a/internal/service/team/resource_team.go +++ b/internal/service/team/resource_team.go @@ -15,7 +15,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( @@ -75,7 +75,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. teamsResp, _, err := connV2.TeamsApi.CreateTeam(ctx, orgID, &admin.Team{ Name: d.Get("name").(string), - Usernames: &usernames, + Usernames: usernames, }).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorTeamCreate, err)) diff --git a/internal/service/team/update_user.go b/internal/service/team/update_user.go index 886d7df22e..9b9716ed4a 100644 --- a/internal/service/team/update_user.go +++ b/internal/service/team/update_user.go @@ -3,10 +3,10 @@ package team import ( "context" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) -func UpdateTeamUsers(teamsAPI admin.TeamsApi, usersAPI admin.MongoDBCloudUsersApi, existingTeamUsers *admin.PaginatedApiAppUser, newUsernames []string, orgID, teamID string) error { +func UpdateTeamUsers(teamsAPI admin.TeamsApi, usersAPI admin.MongoDBCloudUsersApi, existingTeamUsers *admin.PaginatedAppUser, newUsernames []string, orgID, teamID string) error { validNewUsers, err := ValidateUsernames(usersAPI, newUsernames) if err != nil { return err diff --git a/internal/service/team/update_user_test.go b/internal/service/team/update_user_test.go index b4cd9fc18b..eac04d0b4b 100644 --- a/internal/service/team/update_user_test.go +++ b/internal/service/team/update_user_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "go.mongodb.org/atlas-sdk/v20241023002/admin" - "go.mongodb.org/atlas-sdk/v20241023002/mockadmin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" + "go.mongodb.org/atlas-sdk/v20241113003/mockadmin" ) func TestGetChangesForTeamUsers(t *testing.T) { @@ -73,7 +73,7 @@ func TestUpdateTeamUsers(t *testing.T) { testCases := map[string]struct { mockFuncExpectations func(*mockadmin.TeamsApi, *mockadmin.MongoDBCloudUsersApi) - existingTeamUsers *admin.PaginatedApiAppUser + existingTeamUsers *admin.PaginatedAppUser expectError require.ErrorAssertionFunc testName string usernames []string @@ -87,7 +87,7 @@ func TestUpdateTeamUsers(t *testing.T) { mockValidUser1.EXPECT().GetUserByUsernameExecute(mock.Anything).Return(&admin.CloudAppUser{Id: &validuser1}, nil, nil) mockValidUser2.EXPECT().GetUserByUsernameExecute(mock.Anything).Return(&admin.CloudAppUser{Id: &validuser2}, nil, nil) }, - existingTeamUsers: &admin.PaginatedApiAppUser{Results: &[]admin.CloudAppUser{{Id: &validuser1}, {Id: &validuser2}}}, + existingTeamUsers: &admin.PaginatedAppUser{Results: &[]admin.CloudAppUser{{Id: &validuser1}, {Id: &validuser2}}}, usernames: []string{validuser1, validuser2}, expectError: require.NoError, }, @@ -112,7 +112,7 @@ func TestUpdateTeamUsers(t *testing.T) { mockTeamsApi.EXPECT().AddTeamUser(mock.Anything, mock.Anything, mock.Anything, &[]admin.AddUserToTeam{{Id: validuser2}}).Return(admin.AddTeamUserApiRequest{ApiService: mockTeamsApi}) mockTeamsApi.EXPECT().AddTeamUserExecute(mock.Anything).Return(nil, nil, nil) }, - existingTeamUsers: &admin.PaginatedApiAppUser{Results: &[]admin.CloudAppUser{{Id: &validuser1}}}, + existingTeamUsers: &admin.PaginatedAppUser{Results: &[]admin.CloudAppUser{{Id: &validuser1}}}, usernames: []string{validuser1, validuser2}, expectError: require.NoError, }, @@ -125,7 +125,7 @@ func TestUpdateTeamUsers(t *testing.T) { mockTeamsApi.EXPECT().RemoveTeamUser(mock.Anything, mock.Anything, mock.Anything, validuser1).Return(admin.RemoveTeamUserApiRequest{ApiService: mockTeamsApi}) mockTeamsApi.EXPECT().RemoveTeamUserExecute(mock.Anything).Return(nil, nil) }, - existingTeamUsers: &admin.PaginatedApiAppUser{Results: &[]admin.CloudAppUser{{Id: &validuser1}, {Id: &validuser2}}}, + existingTeamUsers: &admin.PaginatedAppUser{Results: &[]admin.CloudAppUser{{Id: &validuser1}, {Id: &validuser2}}}, usernames: []string{validuser2}, expectError: require.NoError, }, @@ -142,7 +142,7 @@ func TestUpdateTeamUsers(t *testing.T) { removeCall.NotBefore(addCall.Call) // Ensures new additions are made before removing mockTeamsApi.EXPECT().RemoveTeamUserExecute(mock.Anything).Return(nil, nil) }, - existingTeamUsers: &admin.PaginatedApiAppUser{Results: &[]admin.CloudAppUser{{Id: &validuser2}}}, + existingTeamUsers: &admin.PaginatedAppUser{Results: &[]admin.CloudAppUser{{Id: &validuser2}}}, usernames: []string{validuser1}, expectError: require.NoError, }, diff --git a/internal/service/thirdpartyintegration/data_source_third_party_integrations.go b/internal/service/thirdpartyintegration/data_source_third_party_integrations.go index ca3c6d5b57..e50e718312 100644 --- a/internal/service/thirdpartyintegration/data_source_third_party_integrations.go +++ b/internal/service/thirdpartyintegration/data_source_third_party_integrations.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func PluralDataSource() *schema.Resource { diff --git a/internal/service/x509authenticationdatabaseuser/data_source_x509_authentication_database_user.go b/internal/service/x509authenticationdatabaseuser/data_source_x509_authentication_database_user.go index aab73547fd..52a296147a 100644 --- a/internal/service/x509authenticationdatabaseuser/data_source_x509_authentication_database_user.go +++ b/internal/service/x509authenticationdatabaseuser/data_source_x509_authentication_database_user.go @@ -78,7 +78,7 @@ func dataSourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag. } } - resp, _, err := connV2.LDAPConfigurationApi.GetLDAPConfiguration(ctx, projectID).Execute() + resp, _, err := connV2.LDAPConfigurationApi.GetLdapConfiguration(ctx, projectID).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorCustomerX509AuthDBUsersRead, projectID, err)) } diff --git a/internal/service/x509authenticationdatabaseuser/resource_x509_authentication_database_user.go b/internal/service/x509authenticationdatabaseuser/resource_x509_authentication_database_user.go index a040da323e..ce358340bb 100644 --- a/internal/service/x509authenticationdatabaseuser/resource_x509_authentication_database_user.go +++ b/internal/service/x509authenticationdatabaseuser/resource_x509_authentication_database_user.go @@ -11,7 +11,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/spf13/cast" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( @@ -120,7 +120,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. userReq := &admin.UserSecurity{ CustomerX509: &admin.DBUserTLSX509Settings{Cas: &customerX509Cas}, } - _, _, err := connV2.LDAPConfigurationApi.SaveLDAPConfiguration(ctx, projectID, userReq).Execute() + _, _, err := connV2.LDAPConfigurationApi.SaveLdapConfiguration(ctx, projectID, userReq).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorCustomerX509AuthDBUsersCreate, projectID, err)) } @@ -206,7 +206,7 @@ func resourceImport(ctx context.Context, d *schema.ResourceData, meta any) ([]*s } } - resp, _, err := connV2.LDAPConfigurationApi.GetLDAPConfiguration(ctx, projectID).Execute() + resp, _, err := connV2.LDAPConfigurationApi.GetLdapConfiguration(ctx, projectID).Execute() if err != nil { return nil, fmt.Errorf(errorCustomerX509AuthDBUsersRead, projectID, err) } diff --git a/internal/service/x509authenticationdatabaseuser/resource_x509_authentication_database_user_test.go b/internal/service/x509authenticationdatabaseuser/resource_x509_authentication_database_user_test.go index 18bf930f0c..47476f0c47 100644 --- a/internal/service/x509authenticationdatabaseuser/resource_x509_authentication_database_user_test.go +++ b/internal/service/x509authenticationdatabaseuser/resource_x509_authentication_database_user_test.go @@ -136,7 +136,7 @@ func checkExists(resourceName string) resource.TestCheckFunc { } return fmt.Errorf("the X509 Authentication Database User(%s) does not exist in the project(%s)", ids["username"], ids["project_id"]) } - if _, _, err := acc.ConnV2().LDAPConfigurationApi.GetLDAPConfiguration(context.Background(), ids["project_id"]).Execute(); err == nil { + if _, _, err := acc.ConnV2().LDAPConfigurationApi.GetLdapConfiguration(context.Background(), ids["project_id"]).Execute(); err == nil { return nil } return fmt.Errorf("the Customer X509 Authentication does not exist in the project(%s)", ids["project_id"]) diff --git a/internal/testutil/acc/advanced_cluster.go b/internal/testutil/acc/advanced_cluster.go index d83b64b75b..7511c0b46a 100644 --- a/internal/testutil/acc/advanced_cluster.go +++ b/internal/testutil/acc/advanced_cluster.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) var ( @@ -26,15 +26,43 @@ var ( "key": "key 3", "value": "value 3", } + ClusterLabelsMap1 = map[string]string{ + "key": "label key 1", + "value": "label value 1", + } + + ClusterLabelsMap2 = map[string]string{ + "key": "label key 2", + "value": "label value 2", + } + + ClusterLabelsMap3 = map[string]string{ + "key": "label key 3", + "value": "label value 3", + } ) +func TestStepImportCluster(resourceName string, ignoredFields ...string) resource.TestStep { + return resource.TestStep{ + ResourceName: resourceName, + ImportStateIdFunc: ImportStateIDFuncProjectIDClusterName(resourceName, "project_id", "name"), + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIdentifierAttribute: "name", + ImportStateVerifyIgnore: ignoredFields, + } +} + func CheckDestroyCluster(s *terraform.State) error { for _, rs := range s.RootModule().Resources { if rs.Type != "mongodbatlas_cluster" && rs.Type != "mongodbatlas_advanced_cluster" { continue } projectID := rs.Primary.Attributes["project_id"] - clusterName := rs.Primary.Attributes["cluster_name"] + clusterName := rs.Primary.Attributes["name"] + if projectID == "" || clusterName == "" { + return fmt.Errorf("projectID or clusterName is empty: %s, %s", projectID, clusterName) + } resp, _, _ := ConnV2().ClustersApi.GetCluster(context.Background(), projectID, clusterName).Execute() if resp.GetId() != "" { return fmt.Errorf("cluster (%s:%s) still exists", clusterName, rs.Primary.ID) @@ -43,22 +71,28 @@ func CheckDestroyCluster(s *terraform.State) error { return nil } -func ImportStateClusterIDFunc(resourceName string) resource.ImportStateIdFunc { - return func(s *terraform.State) (string, error) { +func CheckExistsCluster(resourceName string) resource.TestCheckFunc { + return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[resourceName] if !ok { - return "", fmt.Errorf("not found: %s", resourceName) + return fmt.Errorf("not found: %s", resourceName) } - - return fmt.Sprintf("%s-%s", rs.Primary.Attributes["project_id"], rs.Primary.Attributes["name"]), nil + projectID := rs.Primary.Attributes["project_id"] + clusterName := rs.Primary.Attributes["name"] + if projectID == "" || clusterName == "" { + return fmt.Errorf("projectID or clusterName is empty: %s, %s", projectID, clusterName) + } + if err := CheckExistsClusterHandlingRetry(projectID, clusterName); err != nil { + return fmt.Errorf("cluster(%s:%s) does not exist: %w", projectID, clusterName, err) + } + return nil } } -func CheckClusterExistsHandlingRetry(projectID, clusterName string) error { +func CheckExistsClusterHandlingRetry(projectID, clusterName string) error { return retry.RetryContext(context.Background(), 3*time.Minute, func() *retry.RetryError { - _, _, err := ConnV2().ClustersApi.GetCluster(context.Background(), projectID, clusterName).Execute() - if apiError, ok := admin.AsError(err); ok { - if apiError.GetErrorCode() == "SERVICE_UNAVAILABLE" { + if _, _, err := ConnV2().ClustersApi.GetCluster(context.Background(), projectID, clusterName).Execute(); err != nil { + if admin.IsErrorCode(err, "SERVICE_UNAVAILABLE") { // retrying get operation because for migration test it can be the first time new API is called for a cluster so API responds with temporary error as it transition to enabling ISS FF return retry.RetryableError(err) } @@ -67,3 +101,23 @@ func CheckClusterExistsHandlingRetry(projectID, clusterName string) error { return nil }) } + +func CheckFCVPinningConfig(resourceName, dataSourceName, pluralDataSourceName string, mongoDBMajorVersion int, pinningExpirationDate *string, fcvVersion *int) resource.TestCheckFunc { + mapChecks := map[string]string{ + "mongo_db_major_version": fmt.Sprintf("%d.0", mongoDBMajorVersion), + } + + if pinningExpirationDate != nil { + mapChecks["pinned_fcv.0.expiration_date"] = *pinningExpirationDate + } else { + mapChecks["pinned_fcv.#"] = "0" + } + + if fcvVersion != nil { + mapChecks["pinned_fcv.0.version"] = fmt.Sprintf("%d.0", *fcvVersion) + } + + additionalCheck := resource.TestCheckResourceAttrWith(resourceName, "mongo_db_version", MatchesExpression(fmt.Sprintf("%d..*", mongoDBMajorVersion))) + + return CheckRSAndDS(resourceName, admin.PtrString(dataSourceName), admin.PtrString(pluralDataSourceName), []string{}, mapChecks, additionalCheck) +} diff --git a/internal/testutil/acc/advanced_cluster_schema_v2.go b/internal/testutil/acc/advanced_cluster_schema_v2.go new file mode 100644 index 0000000000..59d8a2047c --- /dev/null +++ b/internal/testutil/acc/advanced_cluster_schema_v2.go @@ -0,0 +1,218 @@ +package acc + +import ( + "strings" + "testing" + + "github.com/hashicorp/hcl/v2" + "github.com/hashicorp/hcl/v2/hclparse" + "github.com/hashicorp/hcl/v2/hclsyntax" + "github.com/hashicorp/hcl/v2/hclwrite" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" + "github.com/zclconf/go-cty/cty" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestCheckResourceAttrSchemaV2(isAcc bool, name, key, value string) resource.TestCheckFunc { + if skipChecks(isAcc, name) { + return testCheckFuncAlwaysPass + } + return resource.TestCheckResourceAttr(name, AttrNameToSchemaV2(isAcc, key), value) +} + +func TestCheckResourceAttrSetSchemaV2(isAcc bool, name, key string) resource.TestCheckFunc { + if skipChecks(isAcc, name) { + return testCheckFuncAlwaysPass + } + return resource.TestCheckResourceAttrSet(name, AttrNameToSchemaV2(isAcc, key)) +} + +func TestCheckResourceAttrWithSchemaV2(isAcc bool, name, key string, checkValueFunc resource.CheckResourceAttrWithFunc) resource.TestCheckFunc { + if skipChecks(isAcc, name) { + return testCheckFuncAlwaysPass + } + return resource.TestCheckResourceAttrWith(name, AttrNameToSchemaV2(isAcc, key), checkValueFunc) +} + +func TestCheckTypeSetElemNestedAttrsSchemaV2(isAcc bool, name, key string, values map[string]string) resource.TestCheckFunc { + if skipChecks(isAcc, name) { + return testCheckFuncAlwaysPass + } + return resource.TestCheckTypeSetElemNestedAttrs(name, AttrNameToSchemaV2(isAcc, key), values) +} + +func testCheckFuncAlwaysPass(*terraform.State) error { + return nil +} + +func AddAttrChecksSchemaV2(isAcc bool, name string, checks []resource.TestCheckFunc, mapChecks map[string]string) []resource.TestCheckFunc { + if skipChecks(isAcc, name) { + return []resource.TestCheckFunc{} + } + return AddAttrChecks(name, checks, ConvertToSchemaV2AttrsMap(isAcc, mapChecks)) +} + +func AddAttrSetChecksSchemaV2(isAcc bool, name string, checks []resource.TestCheckFunc, attrNames ...string) []resource.TestCheckFunc { + if skipChecks(isAcc, name) { + return []resource.TestCheckFunc{} + } + return AddAttrSetChecks(name, checks, ConvertToSchemaV2AttrsSet(isAcc, attrNames)...) +} + +func AddAttrChecksPrefixSchemaV2(isAcc bool, name string, checks []resource.TestCheckFunc, mapChecks map[string]string, prefix string, skipNames ...string) []resource.TestCheckFunc { + if skipChecks(isAcc, name) { + return []resource.TestCheckFunc{} + } + return AddAttrChecksPrefix(name, checks, ConvertToSchemaV2AttrsMap(isAcc, mapChecks), prefix, skipNames...) +} + +func skipChecks(isAcc bool, name string) bool { + if !config.AdvancedClusterV2Schema() || !isAcc { + return false + } + return strings.HasPrefix(name, "data.mongodbatlas_advanced_cluster") +} + +func ConvertToSchemaV2AttrsMap(isAcc bool, attrsMap map[string]string) map[string]string { + if !config.AdvancedClusterV2Schema() || !isAcc { + return attrsMap + } + ret := make(map[string]string, len(attrsMap)) + for name, value := range attrsMap { + ret[AttrNameToSchemaV2(isAcc, name)] = value + } + return ret +} + +func ConvertToSchemaV2AttrsSet(isAcc bool, attrsSet []string) []string { + if !config.AdvancedClusterV2Schema() || !isAcc { + return attrsSet + } + ret := make([]string, 0, len(attrsSet)) + for _, name := range attrsSet { + ret = append(ret, AttrNameToSchemaV2(isAcc, name)) + } + return ret +} + +var tpfSingleNestedAttrs = []string{ + "analytics_specs", + "electable_specs", + "read_only_specs", + "auto_scaling", // includes analytics_auto_scaling + "advanced_configuration", + "bi_connector_config", +} + +func AttrNameToSchemaV2(isAcc bool, name string) string { + if !config.AdvancedClusterV2Schema() || !isAcc { + return name + } + for _, singleAttrName := range tpfSingleNestedAttrs { + name = strings.ReplaceAll(name, singleAttrName+".0", singleAttrName) + } + return name +} + +func ConvertAdvancedClusterToSchemaV2(t *testing.T, isAcc bool, def string) string { + t.Helper() + if !config.AdvancedClusterV2Schema() || !isAcc { + return def + } + parse := getDefParser(t, def) + for _, resource := range parse.Body().Blocks() { + isResource := resource.Type() == "resource" + resourceName := resource.Labels()[0] + if !isResource || resourceName != "mongodbatlas_advanced_cluster" { + continue + } + writeBody := resource.Body() + convertAttrs(t, "labels", writeBody, true, getAttrVal) + convertAttrs(t, "tags", writeBody, true, getAttrVal) + convertAttrs(t, "replication_specs", writeBody, true, getReplicationSpecs) + convertAttrs(t, "advanced_configuration", writeBody, false, getAttrVal) + convertAttrs(t, "bi_connector_config", writeBody, false, getAttrVal) + } + content := parse.Bytes() + return string(content) +} + +func AssertEqualHCL(t *testing.T, expected, actual string, msgAndArgs ...interface{}) { + t.Helper() + assert.Equal(t, canonicalHCL(t, expected), canonicalHCL(t, actual), msgAndArgs...) +} + +func convertAttrs(t *testing.T, name string, writeBody *hclwrite.Body, isList bool, getOneAttr func(*testing.T, *hclsyntax.Body) cty.Value) { + t.Helper() + var vals []cty.Value + for { + match := writeBody.FirstMatchingBlock(name, nil) + if match == nil { + break + } + vals = append(vals, getOneAttr(t, getBlockBody(t, match))) + writeBody.RemoveBlock(match) // TODO: RemoveBlock doesn't remove newline just after the block so an extra line is added + } + if len(vals) == 0 { + return + } + if isList { + writeBody.SetAttributeValue(name, cty.TupleVal(vals)) + } else { + assert.Len(t, vals, 1, "can be only one of %s", name) + writeBody.SetAttributeValue(name, vals[0]) + } +} + +func getReplicationSpecs(t *testing.T, body *hclsyntax.Body) cty.Value { + t.Helper() + const name = "region_configs" + var vals []cty.Value + for _, block := range body.Blocks { + assert.Equal(t, name, block.Type, "unexpected block type: %s", block.Type) + vals = append(vals, getAttrVal(t, block.Body)) + } + return cty.ObjectVal(map[string]cty.Value{ + name: cty.TupleVal(vals), + }) +} + +func getAttrVal(t *testing.T, body *hclsyntax.Body) cty.Value { + t.Helper() + ret := make(map[string]cty.Value) + for name, attr := range body.Attributes { + val, diags := attr.Expr.Value(nil) + require.False(t, diags.HasErrors(), "failed to parse attribute %s: %s", name, diags.Error()) + ret[name] = val + } + for _, block := range body.Blocks { + ret[block.Type] = getAttrVal(t, block.Body) + } + return cty.ObjectVal(ret) +} + +func canonicalHCL(t *testing.T, def string) string { + t.Helper() + return string(getDefParser(t, def).Bytes()) +} + +func getDefParser(t *testing.T, def string) *hclwrite.File { + t.Helper() + parser, diags := hclwrite.ParseConfig([]byte(def), "", hcl.Pos{Line: 1, Column: 1}) + require.False(t, diags.HasErrors(), "failed to parse def: %s", diags.Error()) + return parser +} + +func getBlockBody(t *testing.T, block *hclwrite.Block) *hclsyntax.Body { + t.Helper() + parser, diags := hclparse.NewParser().ParseHCL(block.Body().BuildTokens(nil).Bytes(), "") + require.False(t, diags.HasErrors(), "failed to parse block: %s", diags.Error()) + + body, ok := parser.Body.(*hclsyntax.Body) + require.True(t, ok, "unexpected *hclsyntax.Body type: %T", parser.Body) + return body +} diff --git a/internal/testutil/acc/advanced_cluster_schema_v2_test.go b/internal/testutil/acc/advanced_cluster_schema_v2_test.go new file mode 100644 index 0000000000..98848f2925 --- /dev/null +++ b/internal/testutil/acc/advanced_cluster_schema_v2_test.go @@ -0,0 +1,261 @@ +package acc_test + +import ( + "sort" + "testing" + + "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" + "github.com/stretchr/testify/assert" +) + +func TestConvertToSchemaV2AttrsMapAndAttrsSet(t *testing.T) { + if !config.AdvancedClusterV2Schema() { + t.Skip("Skipping test as not in AdvancedClusterV2Schema") + } + attrsMap := map[string]string{ + "attr": "val1", + "electable_specs.0": "val2", + "prefixbi_connector_config.0": "val3", + "advanced_configuration.0postfix": "val4", + "electable_specs.0advanced_configuration.0bi_connector_config.0": "val5", + } + expectedMap := map[string]string{ + "attr": "val1", + "electable_specs": "val2", + "prefixbi_connector_config": "val3", + "advanced_configurationpostfix": "val4", + "electable_specsadvanced_configurationbi_connector_config": "val5", + } + actualMap := acc.ConvertToSchemaV2AttrsMap(true, attrsMap) + assert.Equal(t, expectedMap, actualMap) + + attrsSet := make([]string, 0, len(attrsMap)) + for name := range attrsMap { + attrsSet = append(attrsSet, name) + } + expectedSet := make([]string, 0, len(attrsMap)) + for name := range expectedMap { + expectedSet = append(expectedSet, name) + } + actualSet := acc.ConvertToSchemaV2AttrsSet(true, attrsSet) + sort.Strings(expectedSet) + sort.Strings(actualSet) + assert.Equal(t, expectedSet, actualSet) +} + +func TestConvertAdvancedClusterToSchemaV2(t *testing.T) { + if !config.AdvancedClusterV2Schema() { + t.Skip("Skipping test as not in AdvancedClusterV2Schema") + } + var ( + input = ` + resource "mongodbatlas_advanced_cluster" "cluster2" { + project_id = "MY-PROJECT-ID" + name = "cluster2" + cluster_type = "SHARDED" + + replication_specs { + region_configs { + electable_specs { + disk_size_gb = 10 + instance_size = "M10" + node_count = 3 + } + analytics_specs { + disk_size_gb = 10 + instance_size = "M10" + node_count = 1 + } + priority = 7 + provider_name = "AWS" + region_name = "EU_WEST_1" + } + region_configs { + electable_specs { + instance_size = "M30" + node_count = 2 + } + provider_name = "AZURE" + priority = 6 + region_name = "US_EAST_2" + } + } + + replication_specs { + region_configs { + electable_specs { + disk_size_gb = 10 + instance_size = "M10" + node_count = 3 + } + analytics_specs { + disk_size_gb = 10 + instance_size = "M10" + node_count = 1 + } + priority = 7 + provider_name = "AWS" + region_name = "EU_WEST_1" + } + } + + tags { + key = "Key Tag 2" + value = "Value Tag 2" + } + + labels { + key = "Key Label 1" + value = "Value Label 1" + } + + tags { + key = "Key Tag 1" + value = "Value Tag 1" + } + + labels { + key = "Key Label 2" + value = "Value Label 2" + } + + labels { + key = "Key Label 3" + value = "Value Label 3" + } + + advanced_configuration { + fail_index_key_too_long = false + javascript_enabled = true + minimum_enabled_tls_protocol = "TLS1_1" + no_table_scan = false + oplog_size_mb = 1000 + sample_size_bi_connector = 110 + sample_refresh_interval_bi_connector = 310 + transaction_lifetime_limit_seconds = 300 + change_stream_options_pre_and_post_images_expire_after_seconds = 100 + } + + bi_connector_config { + enabled = true + read_preference = "secondary" + } + } + ` + // expected has the attributes sorted alphabetically to match the output of ConvertAdvancedClusterToSchemaV2 + expected = ` + resource "mongodbatlas_advanced_cluster" "cluster2" { + project_id = "MY-PROJECT-ID" + name = "cluster2" + cluster_type = "SHARDED" + + + + + + + + + + labels = [{ + key = "Key Label 1" + value = "Value Label 1" + }, { + key = "Key Label 2" + value = "Value Label 2" + }, { + key = "Key Label 3" + value = "Value Label 3" + }] + tags = [{ + key = "Key Tag 2" + value = "Value Tag 2" + }, { + key = "Key Tag 1" + value = "Value Tag 1" + }] + replication_specs = [{ + region_configs = [{ + analytics_specs = { + disk_size_gb = 10 + instance_size = "M10" + node_count = 1 + } + electable_specs = { + disk_size_gb = 10 + instance_size = "M10" + node_count = 3 + } + priority = 7 + provider_name = "AWS" + region_name = "EU_WEST_1" + }, { + electable_specs = { + instance_size = "M30" + node_count = 2 + } + priority = 6 + provider_name = "AZURE" + region_name = "US_EAST_2" + }] + }, { + region_configs = [{ + analytics_specs = { + disk_size_gb = 10 + instance_size = "M10" + node_count = 1 + } + electable_specs = { + disk_size_gb = 10 + instance_size = "M10" + node_count = 3 + } + priority = 7 + provider_name = "AWS" + region_name = "EU_WEST_1" + }] + }] + advanced_configuration = { + change_stream_options_pre_and_post_images_expire_after_seconds = 100 + fail_index_key_too_long = false + javascript_enabled = true + minimum_enabled_tls_protocol = "TLS1_1" + no_table_scan = false + oplog_size_mb = 1000 + sample_refresh_interval_bi_connector = 310 + sample_size_bi_connector = 110 + transaction_lifetime_limit_seconds = 300 + } + bi_connector_config = { + enabled = true + read_preference = "secondary" + } + } + ` + ) + actual := acc.ConvertAdvancedClusterToSchemaV2(t, true, input) + acc.AssertEqualHCL(t, expected, actual) +} + +func TestAssertEqualHCL(t *testing.T) { + var ( + val1 = ` + resource "type1" "name1" { + attr1 = "val1" + block1 { + attr2 = "val2" + } + } + ` + val2 = ` + resource "type1" "name1" { + attr1 = "val1" + block1 { + attr2="val2" + } + } + ` + ) + acc.AssertEqualHCL(t, val1, val2) +} diff --git a/internal/testutil/acc/atlas.go b/internal/testutil/acc/atlas.go index 4c698be660..4ae0de5c24 100644 --- a/internal/testutil/acc/atlas.go +++ b/internal/testutil/acc/atlas.go @@ -10,7 +10,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster" "github.com/stretchr/testify/require" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func createProject(tb testing.TB, name string) string { diff --git a/internal/testutil/acc/cluster.go b/internal/testutil/acc/cluster.go index a7422ac8d4..fde87d7fb4 100644 --- a/internal/testutil/acc/cluster.go +++ b/internal/testutil/acc/cluster.go @@ -7,7 +7,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) // ClusterRequest contains configuration for a cluster where all fields are optional and AddDefaults is used for required fields. diff --git a/internal/testutil/acc/config_cluster.go b/internal/testutil/acc/config_cluster.go index 06e7fa90d3..8dc723bb65 100644 --- a/internal/testutil/acc/config_cluster.go +++ b/internal/testutil/acc/config_cluster.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/hcl/v2/hclwrite" "github.com/zclconf/go-cty/cty" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func ClusterDatasourceHcl(req *ClusterRequest) (configStr, clusterName, resourceName string, err error) { @@ -98,7 +98,7 @@ func ClusterResourceHcl(req *ClusterRequest) (configStr, clusterName, resourceNa } } if len(req.Tags) > 0 { - for _, key := range sortStringMapKeys(req.Tags) { + for _, key := range SortStringMapKeys(req.Tags) { value := req.Tags[key] tagBlock := cluster.AppendNewBlock("tags", nil).Body() tagBlock.SetAttributeValue("key", cty.StringVal(key)) diff --git a/internal/testutil/acc/config_formatter.go b/internal/testutil/acc/config_formatter.go index 6ee705c87f..2add315c27 100644 --- a/internal/testutil/acc/config_formatter.go +++ b/internal/testutil/acc/config_formatter.go @@ -22,7 +22,7 @@ func FormatToHCLMap(m map[string]string, indent, varName string) string { } indentKeyValues := indent + "\t" - for _, k := range sortStringMapKeys(m) { + for _, k := range SortStringMapKeys(m) { v := m[k] lines = append(lines, fmt.Sprintf("%s%s = %[3]q", indentKeyValues, k, v)) } @@ -48,14 +48,6 @@ func FormatToHCLLifecycleIgnore(keys ...string) string { return strings.Join(lines, "\n") } -func sortStringMapKeys(m map[string]string) []string { - keys := make([]string, 0, len(m)) - for k := range m { - keys = append(keys, k) - } - sort.Strings(keys) - return keys -} func sortStringMapKeysAny(m map[string]any) []string { keys := make([]string, 0, len(m)) for k := range m { diff --git a/internal/testutil/acc/database_user.go b/internal/testutil/acc/database_user.go index 7e75381d9c..368bc787fa 100644 --- a/internal/testutil/acc/database_user.go +++ b/internal/testutil/acc/database_user.go @@ -3,7 +3,7 @@ package acc import ( "fmt" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func ConfigDatabaseUserBasic(projectID, username, roleName, keyLabel, valueLabel string) string { diff --git a/internal/testutil/acc/encryption_at_rest.go b/internal/testutil/acc/encryption_at_rest.go index fc615dc3d2..4453cb4963 100644 --- a/internal/testutil/acc/encryption_at_rest.go +++ b/internal/testutil/acc/encryption_at_rest.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" diff --git a/internal/testutil/acc/factory.go b/internal/testutil/acc/factory.go index 92721251e8..dc0fa4571c 100644 --- a/internal/testutil/acc/factory.go +++ b/internal/testutil/acc/factory.go @@ -10,7 +10,7 @@ import ( adminpreview "github.com/mongodb/atlas-sdk-go/admin" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/mongodb/terraform-provider-mongodbatlas/internal/provider" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) const ( diff --git a/internal/testutil/acc/pre_check.go b/internal/testutil/acc/pre_check.go index d6f15746e1..1c8e0d68df 100644 --- a/internal/testutil/acc/pre_check.go +++ b/internal/testutil/acc/pre_check.go @@ -7,6 +7,7 @@ import ( "time" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) func PreCheckBasic(tb testing.TB) { @@ -18,10 +19,10 @@ func PreCheckBasic(tb testing.TB) { } } -func SkipIfTPFAdvancedCluster(tb testing.TB) { +func SkipIfAdvancedClusterV2Schema(tb testing.TB) { tb.Helper() - if os.Getenv("MONGODB_ATLAS_TPF_ADV_CLUSTER_TESTS") == "true" { - tb.Skip("Skipping tests as resource is TPF Advanced Cluster and implementation is pending") + if config.AdvancedClusterV2Schema() { + tb.Skip("Skipping test in AdvancedClusterV2Schema as implementation is pending or test is not applicable") } } diff --git a/internal/testutil/acc/project.go b/internal/testutil/acc/project.go index 666ea91c37..8027b927b8 100644 --- a/internal/testutil/acc/project.go +++ b/internal/testutil/acc/project.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func CheckDestroyProject(s *terraform.State) error { diff --git a/internal/testutil/acc/serverless.go b/internal/testutil/acc/serverless.go index cfb50ecc6a..f22617f9b7 100644 --- a/internal/testutil/acc/serverless.go +++ b/internal/testutil/acc/serverless.go @@ -3,7 +3,7 @@ package acc import ( "fmt" - "go.mongodb.org/atlas-sdk/v20241023002/admin" + "go.mongodb.org/atlas-sdk/v20241113003/admin" ) func ConfigServerlessInstance(projectID, name string, ignoreConnectionStrings bool, autoIndexing *bool, tags []admin.ResourceTag) string { diff --git a/internal/testutil/acc/shared_resource.go b/internal/testutil/acc/shared_resource.go index 5a23ae0efd..d6e7756c0b 100644 --- a/internal/testutil/acc/shared_resource.go +++ b/internal/testutil/acc/shared_resource.go @@ -85,7 +85,7 @@ func ClusterNameExecution(tb testing.TB) (projectID, clusterName string) { return sharedInfo.projectID, sharedInfo.clusterName } -// SerialSleep waits a few seconds the first time so the first cluster in a project is not created concurrently, see HELP-65223. +// SerialSleep waits a few seconds so clusters in a project are not created concurrently, see HELP-65223. // This must be called once the test is marked as parallel, e.g. in PreCheck inside Terraform tests. func SerialSleep(tb testing.TB) { tb.Helper() @@ -95,11 +95,7 @@ func SerialSleep(tb testing.TB) { sharedInfo.muSleep.Lock() defer sharedInfo.muSleep.Unlock() - sharedInfo.testCount++ - // SerialSleep is called in tests before they create the cluster, so wait in the second test after the first cluster is being created before creating the second cluster - if sharedInfo.testCount == 2 { - time.Sleep(5 * time.Second) - } + time.Sleep(5 * time.Second) } var sharedInfo = struct { @@ -108,6 +104,5 @@ var sharedInfo = struct { clusterName string mu sync.Mutex muSleep sync.Mutex - testCount int init bool }{} diff --git a/internal/testutil/acc/sort.go b/internal/testutil/acc/sort.go new file mode 100644 index 0000000000..dc8ef71832 --- /dev/null +++ b/internal/testutil/acc/sort.go @@ -0,0 +1,12 @@ +package acc + +import "sort" + +func SortStringMapKeys(m map[string]string) []string { + keys := make([]string, 0, len(m)) + for k := range m { + keys = append(keys, k) + } + sort.Strings(keys) + return keys +} diff --git a/internal/testutil/mig/test_case.go b/internal/testutil/mig/test_case.go index 171887c22c..b55954e72c 100644 --- a/internal/testutil/mig/test_case.go +++ b/internal/testutil/mig/test_case.go @@ -42,7 +42,7 @@ func CreateTest(t *testing.T, test *resource.TestCase) resource.TestCase { firstStep := test.Steps[0] steps := []resource.TestStep{ useExternalProvider(&firstStep, ExternalProviders()), - TestStepCheckEmptyPlan(firstStep.Config), + TestStepCheckEmptyPlan(acc.ConvertAdvancedClusterToSchemaV2(t, true, firstStep.Config)), } newTest := reuseCase(test, steps) return newTest @@ -57,7 +57,7 @@ func CreateTestUseExternalProvider(t *testing.T, test *resource.TestCase, extern validateReusableCase(t, test) firstStep := test.Steps[0] require.NotContains(t, additionalProviders, "mongodbatlas", "Will use the local provider, cannot specify mongodbatlas provider") - emptyPlanStep := TestStepCheckEmptyPlan(firstStep.Config) + emptyPlanStep := TestStepCheckEmptyPlan(acc.ConvertAdvancedClusterToSchemaV2(t, true, firstStep.Config)) steps := []resource.TestStep{ useExternalProvider(&firstStep, externalProviders), useExternalProvider(&emptyPlanStep, additionalProviders), diff --git a/internal/testutil/tc/advanced_cluster.go b/internal/testutil/tc/advanced_cluster.go new file mode 100644 index 0000000000..78e40f6fec --- /dev/null +++ b/internal/testutil/tc/advanced_cluster.go @@ -0,0 +1,322 @@ +package tc + +import ( + "fmt" + "strconv" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" +) + +const ( + resourceName = "mongodbatlas_advanced_cluster.test" + dataSourceName = "data.mongodbatlas_advanced_cluster.test" + dataSourcePluralName = "data.mongodbatlas_advanced_clusters.test" +) + +var ( + configServerManagementModeFixedToDedicated = "FIXED_TO_DEDICATED" + configServerManagementModeAtlasManaged = "ATLAS_MANAGED" +) + +func SymmetricShardedOldSchemaDiskSizeGBAtElectableLevel(t *testing.T, orgID, projectName, clusterName string) *resource.TestCase { + t.Helper() + return &resource.TestCase{ + PreCheck: func() { acc.PreCheckBasic(t) }, + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configShardedOldSchemaDiskSizeGBElectableLevel(orgID, projectName, clusterName, 50), + Check: checkShardedOldSchemaDiskSizeGBElectableLevel(50), + }, + { + Config: configShardedOldSchemaDiskSizeGBElectableLevel(orgID, projectName, clusterName, 55), + Check: checkShardedOldSchemaDiskSizeGBElectableLevel(55), + }, + }, + } +} + +func configShardedOldSchemaDiskSizeGBElectableLevel(orgID, projectName, name string, diskSizeGB int) string { + return fmt.Sprintf(` + resource "mongodbatlas_project" "cluster_project" { + org_id = %[1]q + name = %[2]q + } + + resource "mongodbatlas_advanced_cluster" "test" { + project_id = mongodbatlas_project.cluster_project.id + name = %[3]q + backup_enabled = false + mongo_db_major_version = "7.0" + cluster_type = "SHARDED" + + replication_specs = [{ + num_shards = 2 + + region_configs = [{ + electable_specs = { + instance_size = "M10" + node_count = 3 + disk_size_gb = %[4]d + } + analytics_specs = { + instance_size = "M10" + node_count = 0 + disk_size_gb = %[4]d + } + provider_name = "AWS" + priority = 7 + region_name = "US_EAST_1" + }, + ] + }] + } + `, orgID, projectName, name, diskSizeGB) +} + +func checkShardedOldSchemaDiskSizeGBElectableLevel(diskSizeGB int) resource.TestCheckFunc { + return checkAggr( + []string{}, + map[string]string{ + "replication_specs.0.num_shards": "2", + "disk_size_gb": fmt.Sprintf("%d", diskSizeGB), + "replication_specs.0.region_configs.0.electable_specs.disk_size_gb": fmt.Sprintf("%d", diskSizeGB), + "replication_specs.0.region_configs.0.analytics_specs.disk_size_gb": fmt.Sprintf("%d", diskSizeGB), + }) +} + +func checkAggr(attrsSet []string, attrsMap map[string]string, extra ...resource.TestCheckFunc) resource.TestCheckFunc { + checks := []resource.TestCheckFunc{} + checks = acc.AddAttrChecks(resourceName, checks, attrsMap) + checks = acc.AddAttrSetChecks(resourceName, checks, attrsSet...) + checks = append(checks, extra...) + return resource.ComposeAggregateTestCheckFunc(checks...) +} + +func SymmetricShardedOldSchema(t *testing.T, orgID, projectName, clusterName string) *resource.TestCase { + t.Helper() + return &resource.TestCase{ + PreCheck: func() { acc.PreCheckBasic(t) }, + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configShardedOldSchemaMultiCloud(orgID, projectName, clusterName, 2, "M10", &configServerManagementModeFixedToDedicated), + Check: checkShardedOldSchemaMultiCloud(clusterName, 2, "M10", false, &configServerManagementModeFixedToDedicated), + }, + { + Config: configShardedOldSchemaMultiCloud(orgID, projectName, clusterName, 2, "M20", &configServerManagementModeAtlasManaged), + Check: checkShardedOldSchemaMultiCloud(clusterName, 2, "M20", false, &configServerManagementModeAtlasManaged), + }, + }, + } +} + +func configShardedOldSchemaMultiCloud(orgID, projectName, name string, numShards int, analyticsSize string, configServerManagementMode *string) string { + var rootConfig string + if configServerManagementMode != nil { + // valid values: FIXED_TO_DEDICATED or ATLAS_MANAGED (default) + // only valid for Major version 8 and later + // cluster must be SHARDED + rootConfig = fmt.Sprintf(` + mongo_db_major_version = "8" + config_server_management_mode = %[1]q + `, *configServerManagementMode) + } + return fmt.Sprintf(` + resource "mongodbatlas_project" "cluster_project" { + org_id = %[1]q + name = %[2]q + } + + resource "mongodbatlas_advanced_cluster" "test" { + project_id = mongodbatlas_project.cluster_project.id + name = %[3]q + cluster_type = "SHARDED" + %[6]s + + replication_specs = [{ + num_shards = %[4]d + region_configs = [{ + electable_specs = { + instance_size = "M10" + node_count = 3 + } + analytics_specs = { + instance_size = %[5]q + node_count = 1 + } + provider_name = "AWS" + priority = 7 + region_name = "EU_WEST_1" + }, { + electable_specs = { + instance_size = "M10" + node_count = 2 + } + provider_name = "AZURE" + priority = 6 + region_name = "US_EAST_2" + },] + },] + } + `, orgID, projectName, name, numShards, analyticsSize, rootConfig) +} + +func checkShardedOldSchemaMultiCloud(name string, numShards int, analyticsSize string, verifyExternalID bool, configServerManagementMode *string) resource.TestCheckFunc { + additionalChecks := []resource.TestCheckFunc{ + resource.TestCheckResourceAttrWith(resourceName, "replication_specs.0.region_configs.0.electable_specs.disk_iops", acc.IntGreatThan(0)), + resource.TestCheckResourceAttrWith(resourceName, "replication_specs.0.region_configs.0.analytics_specs.disk_iops", acc.IntGreatThan(0)), + resource.TestCheckResourceAttrWith(resourceName, "replication_specs.0.region_configs.1.electable_specs.disk_iops", acc.IntGreatThan(0)), + } + + if verifyExternalID { + additionalChecks = append( + additionalChecks, + resource.TestCheckResourceAttrSet(resourceName, "replication_specs.0.external_id")) + } + if configServerManagementMode != nil { + additionalChecks = append( + additionalChecks, + resource.TestCheckResourceAttr(resourceName, "config_server_management_mode", *configServerManagementMode), + resource.TestCheckResourceAttrSet(resourceName, "config_server_type"), + ) + } + + return checkAggr( + []string{"project_id", "replication_specs.#", "replication_specs.0.id", "replication_specs.0.region_configs.#"}, + map[string]string{ + "name": name, + "replication_specs.0.num_shards": strconv.Itoa(numShards), + "replication_specs.0.region_configs.0.analytics_specs.instance_size": analyticsSize, + }, + additionalChecks...) +} + +func BasicTenantTestCase(t *testing.T, projectID, clusterName, clusterNameUpdated string) *resource.TestCase { + t.Helper() + return &resource.TestCase{ + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName), + Steps: []resource.TestStep{ + { + Config: configTenant(t, true, projectID, clusterName), + Check: checkTenant(projectID, clusterName), + }, + { + Config: configTenant(t, true, projectID, clusterNameUpdated), + Check: checkTenant(projectID, clusterNameUpdated), + }, + acc.TestStepImportCluster(resourceName), + }, + } +} + +func configTenant(t *testing.T, isAcc bool, projectID, name string) string { + t.Helper() + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` + resource "mongodbatlas_advanced_cluster" "test" { + project_id = %[1]q + name = %[2]q + cluster_type = "REPLICASET" + + replication_specs = [{ + region_configs = [{ + electable_specs = { + instance_size = "M5" + } + provider_name = "TENANT" + backing_provider_name = "AWS" + region_name = "US_EAST_1" + priority = 7 + }] + }] + } + `, projectID, name)) +} + +func checkTenant(projectID, name string) resource.TestCheckFunc { + attrsSet := []string{"replication_specs.#", "replication_specs.0.id", "replication_specs.0.region_configs.#"} + attrsMap := map[string]string{ + "project_id": projectID, + "name": name, + "termination_protection_enabled": "false", + "global_cluster_self_managed_sharding": "false", + "labels.#": "0", + } + checks := acc.AddAttrSetChecks(resourceName, nil, attrsSet...) + checks = acc.AddAttrChecks(resourceName, checks, attrsMap) + return resource.ComposeAggregateTestCheckFunc(checks...) +} + +func TenantUpgrade(t *testing.T, projectID, clusterName string) *resource.TestCase { + t.Helper() + return &resource.TestCase{ + PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName), + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configTenant(t, true, projectID, clusterName), + Check: checkTenant(projectID, clusterName), + }, + { + Config: configTenantUpgraded(t, true, projectID, clusterName), + Check: checksTenantUpgraded(projectID, clusterName), + }, + }, + } +} + +func configTenantUpgraded(t *testing.T, isAcc bool, projectID, name string) string { + t.Helper() + return acc.ConvertAdvancedClusterToSchemaV2(t, isAcc, fmt.Sprintf(` + resource "mongodbatlas_advanced_cluster" "test" { + project_id = %[1]q + name = %[2]q + cluster_type = "REPLICASET" + + replication_specs { + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "US_EAST_1" + electable_specs { + node_count = 3 + instance_size = "M10" + } + } + } + } + `, projectID, name)) +} + +func enableChecksLatestTpf(checkMap map[string]string) map[string]string { + newMap := map[string]string{} + for k, v := range checkMap { + modifiedKey := strings.ReplaceAll(k, "electable_specs.0", "electable_specs") + newMap[modifiedKey] = v + } + return newMap +} + +func checksTenantUpgraded(projectID, name string) resource.TestCheckFunc { + originalChecks := checkTenant(projectID, name) + checks := []resource.TestCheckFunc{originalChecks} + checkMap := map[string]string{ + "replication_specs.0.region_configs.0.electable_specs.0.node_count": "3", + "replication_specs.0.region_configs.0.electable_specs.0.instance_size": "M10", + "replication_specs.0.region_configs.0.provider_name": "AWS", + } + if config.AdvancedClusterV2Schema() { + checkMap = enableChecksLatestTpf(checkMap) + } + checks = acc.AddAttrChecks(resourceName, checks, checkMap) + return resource.ComposeAggregateTestCheckFunc(originalChecks, resource.ComposeAggregateTestCheckFunc(checks...)) +} diff --git a/internal/testutil/unit/http_mocker.go b/internal/testutil/unit/http_mocker.go new file mode 100644 index 0000000000..749e65aba0 --- /dev/null +++ b/internal/testutil/unit/http_mocker.go @@ -0,0 +1,354 @@ +package unit + +import ( + "encoding/json" + "fmt" + "io" + "net/http" + "os" + "path" + "regexp" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/jarcoal/httpmock" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" + "github.com/sebdah/goldie/v2" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v3" +) + +func replaceVars(text string, vars map[string]string) string { + for key, value := range vars { + text = strings.ReplaceAll(text, fmt.Sprintf("{%s}", key), value) + } + return text +} + +type statusText struct { + Text string `yaml:"text"` + Status int `yaml:"status"` + ResponseIndex int `yaml:"response_index"` +} + +type RequestInfo struct { + Version string `yaml:"version"` + Method string `yaml:"method"` + Path string `yaml:"path"` + Text string `yaml:"text"` + Responses []statusText `yaml:"responses"` +} + +func (i *RequestInfo) id() string { + return fmt.Sprintf("%s_%s_%s_%s", i.Method, i.Path, i.Version, i.Text) +} + +func (i *RequestInfo) idShort() string { + return fmt.Sprintf("%s_%s_%s", i.Method, i.Path, i.Version) +} + +func (i *RequestInfo) Match(method, urlPath, version string, vars map[string]string) bool { + if i.Method != method { + return false + } + selfPath := replaceVars(i.Path, vars) + return selfPath == urlPath && i.Version == version +} + +type stepRequests struct { + DiffRequests []RequestInfo `yaml:"diff_requests"` + RequestResponses []RequestInfo `yaml:"request_responses"` +} + +type mockHTTPData struct { + Variables map[string]string `yaml:"variables"` + Steps []stepRequests `yaml:"steps"` + StepCount int `yaml:"step_count"` +} + +type MockHTTPDataConfig struct { + AllowMissingRequests bool + AllowReReadGet bool +} + +func parseTestDataConfigYAML(filePath string) (*mockHTTPData, error) { + data, err := os.ReadFile(filePath) + if err != nil { + return nil, err + } + var testData mockHTTPData + err = yaml.Unmarshal(data, &testData) + if err != nil { + return nil, err + } + return &testData, nil +} + +func MockTestCaseAndRun(t *testing.T, vars map[string]string, config *MockHTTPDataConfig, testCase *resource.TestCase) { + t.Helper() + roundTripper, checkFunc := MockRoundTripper(t, vars, config) + testCase.ProtoV6ProviderFactories = TestAccProviderV6FactoriesWithMock(t, roundTripper) + testCase.PreCheck = nil + stepCount := len(testCase.Steps) + for i := range stepCount - 1 { + step := &testCase.Steps[i] + if oldCheck := step.Check; oldCheck != nil { + step.Check = resource.ComposeAggregateTestCheckFunc(oldCheck, checkFunc) + } + } + // Using CheckDestroy for the final step assertions to allow mocked responses in cleanup + oldCheckDestroy := testCase.CheckDestroy + newCheckDestroy := func(s *terraform.State) error { + if oldCheckDestroy != nil { + if err := oldCheckDestroy(s); err != nil { + return err + } + } + return checkFunc(s) + } + testCase.CheckDestroy = newCheckDestroy + resource.ParallelTest(t, *testCase) +} + +func MockRoundTripper(t *testing.T, vars map[string]string, config *MockHTTPDataConfig) (http.RoundTripper, resource.TestCheckFunc) { + t.Helper() + testDir := "testdata" + httpDataPath := path.Join(testDir, t.Name()+".yaml") + data, err := parseTestDataConfigYAML(httpDataPath) + require.NoError(t, err) + myTransport := httpmock.NewMockTransport() + var mockTransport http.RoundTripper = myTransport + g := goldie.New(t, goldie.WithTestNameForDir(true), goldie.WithNameSuffix(".json")) + tracker := requestTracker{data: data, g: g, vars: vars, t: t} + if config != nil { + tracker.allowMissingRequests = config.AllowMissingRequests + tracker.allowReReadGet = config.AllowReReadGet + } + err = tracker.initStep() + require.NoError(t, err) + for _, method := range []string{"GET", "POST", "PUT", "DELETE", "PATCH"} { + myTransport.RegisterRegexpResponder(method, regexp.MustCompile(".*"), tracker.receiveRequest(method)) + } + return mockTransport, tracker.checkStepRequests +} + +var versionDatePattern = regexp.MustCompile(`(\d{4}-\d{2}-\d{2})`) + +func ExtractVersion(contentType string) (string, error) { + match := versionDatePattern.FindStringSubmatch(contentType) + if len(match) > 1 { + return match[1], nil + } + return "", fmt.Errorf("could not extract version from %s header", contentType) +} + +type requestTracker struct { + t *testing.T + g *goldie.Goldie + data *mockHTTPData + vars map[string]string + usedResponses map[string]int + foundsDiffs map[int]string + currentStepIndex int + diffResponseIndex int + allowMissingRequests bool + allowReReadGet bool +} + +func (r *requestTracker) allowReUse(method string) bool { + return r.allowReReadGet && method == "GET" +} + +func (r *requestTracker) requestFilename(requestID string, index int) string { + return strings.ReplaceAll(fmt.Sprintf("%02d_%02d_%s", r.currentStepIndex+1, index+1, requestID), "/", "_") +} + +func (r *requestTracker) manualFilenameIfExist(requestID string, index int) string { + defaultFilestem := strings.ReplaceAll(fmt.Sprintf("%02d_%02d_%s", r.currentStepIndex+1, index+1, requestID), "/", "_") + manualFilestem := defaultFilestem + "_manual" + if _, err := os.Stat("testdata" + "/" + r.t.Name() + "/" + manualFilestem + ".json"); err == nil { + return manualFilestem + } + return defaultFilestem +} + +func (r *requestTracker) initStep() error { + require.Len(r.t, r.data.Steps, r.data.StepCount, "step count didn't match steps") + usedKeys := strings.Join(acc.SortStringMapKeys(r.vars), ", ") + expectedKeys := strings.Join(acc.SortStringMapKeys(r.data.Variables), ", ") + require.Equal(r.t, expectedKeys, usedKeys, "mock variables didn't match mock data variables") + r.usedResponses = map[string]int{} + r.foundsDiffs = map[int]string{} + step := r.currentStep() + if step == nil { + return nil + } + for index, req := range step.DiffRequests { + err := r.g.Update(r.t, r.requestFilename(req.idShort(), index), []byte(replaceVars(req.Text, r.vars))) + if err != nil { + return err + } + } + r.nextDiffResponseIndex() + return nil +} + +func (r *requestTracker) nextDiffResponseIndex() { + step := r.currentStep() + if step == nil { + r.t.Fatal("no more steps, in testCase") + } + for index, req := range step.DiffRequests { + if _, ok := r.foundsDiffs[index]; !ok { + r.diffResponseIndex = req.Responses[0].ResponseIndex + return + } + } + // no more diffs in current step, any response index will do, assuming never more than 100k responses + r.diffResponseIndex = 99999 +} + +func (r *requestTracker) currentStep() *stepRequests { + if r.currentStepIndex >= r.data.StepCount { + return nil + } + return &r.data.Steps[r.currentStepIndex] +} + +func (r *requestTracker) checkStepRequests(_ *terraform.State) error { + missingRequests := []string{} + step := r.currentStep() + for _, req := range step.RequestResponses { + missingRequestsCount := len(req.Responses) - r.usedResponses[req.id()] + if missingRequestsCount > 0 { + missingIndexes := []string{} + for i := 0; i < missingRequestsCount; i++ { + missingResponse := (len(req.Responses) - missingRequestsCount) + i + missingIndexes = append(missingIndexes, fmt.Sprintf("%d", req.Responses[missingResponse].ResponseIndex)) + } + missingIndexesStr := strings.Join(missingIndexes, ", ") + missingRequests = append(missingRequests, fmt.Sprintf("missing %d requests of %s (%s)", missingRequestsCount, req.idShort(), missingIndexesStr)) + } + } + if r.allowMissingRequests { + if len(missingRequests) > 0 { + r.t.Logf("missing requests:\n%s", strings.Join(missingRequests, "\n")) + } + } else { + assert.Empty(r.t, missingRequests) + } + missingDiffs := []string{} + for i, req := range step.DiffRequests { + if _, ok := r.foundsDiffs[i]; !ok { + missingDiffs = append(missingDiffs, fmt.Sprintf("missing diff request %s", req.idShort())) + } + } + assert.Empty(r.t, missingDiffs) + for index, payload := range r.foundsDiffs { + diff := step.DiffRequests[index] + filename := r.manualFilenameIfExist(diff.idShort(), index) + r.t.Logf("checking diff %s", filename) + r.g.Assert(r.t, filename, []byte(payload)) + } + r.currentStepIndex++ + return r.initStep() +} + +func (r *requestTracker) receiveRequest(method string) func(req *http.Request) (*http.Response, error) { + return func(req *http.Request) (*http.Response, error) { + acceptHeader := req.Header.Get("Accept") + version, err := ExtractVersion(acceptHeader) + if err != nil { + return nil, err + } + var payload string + if req.Body != nil { + payloadBytes, err := io.ReadAll(req.Body) + if err != nil { + return nil, err + } + payload = string(payloadBytes) + } + text, status, err := r.matchRequest(method, req.URL.Path, version, payload) + if err != nil { + return nil, err + } + response := httpmock.NewStringResponse(status, text) + response.Header.Set("Content-Type", fmt.Sprintf("application/vnd.atlas.%s+json;charset=utf-8", version)) + return response, nil + } +} + +func normalizePayload(payload string) (string, error) { + if payload == "" { + return "", nil + } + var tempHolder any + err := json.Unmarshal([]byte(payload), &tempHolder) + if err != nil { + return "", err + } + sb := strings.Builder{} + encoder := json.NewEncoder(&sb) + encoder.SetIndent("", " ") + err = encoder.Encode(tempHolder) + if err != nil { + return "", err + } + return strings.TrimSuffix(sb.String(), "\n"), nil +} + +func (r *requestTracker) matchRequest(method, urlPath, version, payload string) (response string, statusCode int, err error) { + step := r.currentStep() + if step == nil { + return "", 0, fmt.Errorf("no more steps in mock data") + } + for index, request := range step.DiffRequests { + if !request.Match(method, urlPath, version, r.vars) { + continue + } + if _, ok := r.foundsDiffs[index]; ok { + continue + } + normalizedPayload, err := normalizePayload(payload) + if err != nil { + return "", 0, err + } + r.foundsDiffs[index] = normalizedPayload + r.nextDiffResponseIndex() + break + } + nextDiffResponse := r.diffResponseIndex + + for _, request := range step.RequestResponses { + if !request.Match(method, urlPath, version, r.vars) { + continue + } + requestID := request.id() + nextIndex := r.usedResponses[requestID] + if nextIndex >= len(request.Responses) { + if r.allowReReadGet && method == "GET" { + nextIndex = len(request.Responses) - 1 + } else { + continue + } + } + response := request.Responses[nextIndex] + // cannot return a response that is sent after a diff response + if response.ResponseIndex > nextDiffResponse { + prevIndex := nextIndex - 1 + if prevIndex >= 0 && r.allowReUse(method) { + response = request.Responses[prevIndex] + r.t.Logf("re-reading GET request with response_index=%d as diff hasn't been returned yet (%d)", response.ResponseIndex, nextDiffResponse) + return replaceVars(response.Text, r.vars), response.Status, nil + } + continue + } + r.usedResponses[requestID]++ + return replaceVars(response.Text, r.vars), response.Status, nil + } + return "", 0, fmt.Errorf("no matching request found %s %s %s", method, urlPath, version) +} diff --git a/internal/testutil/unit/http_mocker_test.go b/internal/testutil/unit/http_mocker_test.go new file mode 100644 index 0000000000..03f8fe7079 --- /dev/null +++ b/internal/testutil/unit/http_mocker_test.go @@ -0,0 +1,161 @@ +package unit_test + +import ( + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "strings" + "testing" + + "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/unit" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "go.mongodb.org/atlas-sdk/v20241113003/admin" +) + +func TestExtractVersion(t *testing.T) { + version, err := unit.ExtractVersion("application/json; version=2022-06-01") + require.NoError(t, err) + require.Equal(t, "2022-06-01", version) +} +func TestRequestInfo_Match(t *testing.T) { + req := unit.RequestInfo{ + Version: "2022-06-01", + Method: "GET", + Path: "/v1/cluster/{cluster_id}", + } + assert.True(t, req.Match("GET", "/v1/cluster/123", "2022-06-01", map[string]string{"cluster_id": "123"})) + assert.False(t, req.Match("GET", "/v1/cluster/123", "2022-06-01", map[string]string{"cluster_id": "456"})) +} + +func request(method, path string) *http.Request { + return &http.Request{ + Method: method, + URL: &url.URL{Path: path}, + Header: http.Header{ + "Accept": []string{"application/json; version=2024-08-05"}, + }, + } +} + +const reqPoliciesCreateBody = `{ + "name": "test-policy", + "policies": [ + { + "body": "\t\t\t\n\tforbid (\n\tprincipal,\n\taction == cloud::Action::\"cluster.createEdit\",\n\tresource\n\t) when {\n\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\"aws\"])\n\t};\n" + } + ] +}` +const reqPoliciesUpdateBody = `{ + "name": "updated-policy", + "policies": [ + { + "body": "\t\t\t\n\tforbid (\n\tprincipal,\n\taction == cloud::Action::\"cluster.createEdit\",\n\tresource\n\t) when {\n\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\"aws\"])\n\t};\n" + } + ] +}` + +const reqPoliciesManualValidateDelete = `{}` + +func TestMockRoundTripper(t *testing.T) { + orgID := "123" + resourcePolicyID := "456" + vars := map[string]string{ + "orgId": orgID, + "resourcePolicyId": resourcePolicyID, + } + mockTransport, checkFunc := unit.MockRoundTripper(t, vars, &unit.MockHTTPDataConfig{AllowMissingRequests: true}) + client := &http.Client{ + Transport: mockTransport, + } + // Error check + unknownRequest := request("GET", "/v1/cluster/123") + resp, err := client.Do(unknownRequest) + require.ErrorContains(t, err, "no matching request found") + assert.Nil(t, resp) + + // Step 1 + createRequest := request("POST", fmt.Sprintf("/api/atlas/v2/orgs/%s/resourcePolicies", orgID)) + createRequest.Body = io.NopCloser(strings.NewReader(reqPoliciesCreateBody)) + resp, err = client.Do(createRequest) + + require.NoError(t, err) + require.Equal(t, 201, resp.StatusCode) + err = checkFunc(nil) + require.NoError(t, err) + // Step 2 + patchRequest := request("PATCH", fmt.Sprintf("/api/atlas/v2/orgs/%s/resourcePolicies/%s", orgID, resourcePolicyID)) + patchRequest.Body = io.NopCloser(strings.NewReader(reqPoliciesUpdateBody)) + resp, err = client.Do(patchRequest) + require.NoError(t, err) + err = checkFunc(nil) + require.NoError(t, err) + var policyResp admin.ApiAtlasResourcePolicy + err = json.NewDecoder(resp.Body).Decode(&policyResp) + require.NoError(t, err) + assert.Equal(t, resourcePolicyID, policyResp.GetId()) + + // Step 3 + // First GET request OK + // Second GET request OK + getRequest := request("GET", fmt.Sprintf("/api/atlas/v2/orgs/%s/resourcePolicies/%s", orgID, resourcePolicyID)) + _, err = client.Do(getRequest) + require.NoError(t, err) + _, err = client.Do(getRequest) + require.NoError(t, err) + // Third GET request FAIL with no match as there are no more responses until after DELETE + _, err = client.Do(getRequest) + require.ErrorContains(t, err, "no matching request found") + + // Test _manual diff file (set to {} instead of '') + validateRequest := request("DELETE", fmt.Sprintf("/api/atlas/v2/orgs/%s/resourcePolicies/%s", orgID, resourcePolicyID)) + validateRequest.Body = io.NopCloser(strings.NewReader(reqPoliciesManualValidateDelete)) + _, err = client.Do(validateRequest) + require.NoError(t, err) + // Fourth GET request OK, since we have gotten the diff + notFoundResp, err := client.Do(getRequest) + require.NoError(t, err) + notFoundMap := parseMapStringAny(t, notFoundResp) + assert.Equal(t, "RESOURCE_POLICY_NOT_FOUND", notFoundMap["errorCode"]) + + err = checkFunc(nil) + require.NoError(t, err) +} + +func parseMapStringAny(t *testing.T, resp *http.Response) map[string]any { + t.Helper() + stringMap := map[string]any{} + err := json.NewDecoder(resp.Body).Decode(&stringMap) + require.NoError(t, err) + return stringMap +} + +func TestMockRoundTripperAllowReRead(t *testing.T) { + orgID := "123" + resourcePolicyID := "456" + vars := map[string]string{ + "orgId": orgID, + "resourcePolicyId": resourcePolicyID, + } + mockTransport, checkFunc := unit.MockRoundTripper(t, vars, &unit.MockHTTPDataConfig{AllowReReadGet: true, AllowMissingRequests: true}) + client := &http.Client{ + Transport: mockTransport, + } + for range []int{0, 1, 2} { + getRequest := request("GET", fmt.Sprintf("/api/atlas/v2/orgs/%s/resourcePolicies", orgID)) + resp, err := client.Do(getRequest) + require.NoError(t, err) + assert.Equal(t, "returned again", parseMapStringAny(t, resp)["expect"]) + } + createRequest := request("POST", fmt.Sprintf("/api/atlas/v2/orgs/%s/resourcePolicies", orgID)) + createRequest.Body = io.NopCloser(strings.NewReader(reqPoliciesCreateBody)) + resp, err := client.Do(createRequest) + + require.NoError(t, err) + require.Equal(t, 201, resp.StatusCode) + err = checkFunc(nil) + require.NoError(t, err) +} diff --git a/internal/testutil/unit/provider_mock.go b/internal/testutil/unit/provider_mock.go new file mode 100644 index 0000000000..7afadd8640 --- /dev/null +++ b/internal/testutil/unit/provider_mock.go @@ -0,0 +1,91 @@ +package unit + +import ( + "context" + "log" + "net/http" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-mux/tf5to6server" + "github.com/hashicorp/terraform-plugin-mux/tf6muxserver" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/provider" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" + + fwProvider "github.com/hashicorp/terraform-plugin-framework/provider" +) + +type ProviderMocked struct { + OriginalProvider *provider.MongodbtlasProvider + MockRoundTripper http.RoundTripper + t *testing.T +} + +func (p *ProviderMocked) Metadata(ctx context.Context, req fwProvider.MetadataRequest, resp *fwProvider.MetadataResponse) { + p.OriginalProvider.Metadata(ctx, req, resp) +} +func (p *ProviderMocked) Schema(ctx context.Context, req fwProvider.SchemaRequest, resp *fwProvider.SchemaResponse) { + p.OriginalProvider.Schema(ctx, req, resp) +} +func (p *ProviderMocked) Configure(ctx context.Context, req fwProvider.ConfigureRequest, resp *fwProvider.ConfigureResponse) { + p.OriginalProvider.Configure(ctx, req, resp) + rd := resp.ResourceData + client, ok := rd.(*config.MongoDBClient) + if !ok { + p.t.Fatal("Failed to cast ResourceData to MongoDBClient") + } + httpClient := client.AtlasV2.GetConfig().HTTPClient + if httpClient == nil { + p.t.Fatal("HTTPClient is nil, mocking will fail") + } + httpClient.Transport = p.MockRoundTripper +} + +func (p *ProviderMocked) DataSources(ctx context.Context) []func() datasource.DataSource { + return p.OriginalProvider.DataSources(ctx) +} +func (p *ProviderMocked) Resources(ctx context.Context) []func() resource.Resource { + return p.OriginalProvider.Resources(ctx) +} + +// Similar to provider.go#muxProviderFactory +func muxProviderFactory(t *testing.T, mockRoundTripper http.RoundTripper) func() tfprotov6.ProviderServer { + t.Helper() + v2Provider := provider.NewSdkV2Provider(nil) + fwProviderInstance := provider.NewFrameworkProvider(nil) + fwProviderInstanceTyped, ok := fwProviderInstance.(*provider.MongodbtlasProvider) + if !ok { + log.Fatal("Failed to cast provider to MongodbtlasProvider") + } + mockedProvider := &ProviderMocked{ + OriginalProvider: fwProviderInstanceTyped, + MockRoundTripper: mockRoundTripper, + t: t, + } + ctx := context.Background() + upgradedSdkProvider, err := tf5to6server.UpgradeServer(ctx, v2Provider.GRPCProvider) + if err != nil { + log.Fatal(err) + } + muxServer, err := tf6muxserver.NewMuxServer(ctx, + func() tfprotov6.ProviderServer { return upgradedSdkProvider }, + providerserver.NewProtocol6(mockedProvider), + ) + if err != nil { + log.Fatal(err) + } + return muxServer.ProviderServer +} + +func TestAccProviderV6FactoriesWithMock(t *testing.T, mockRoundTripper http.RoundTripper) map[string]func() (tfprotov6.ProviderServer, error) { + t.Helper() + return map[string]func() (tfprotov6.ProviderServer, error){ + acc.ProviderNameMongoDBAtlas: func() (tfprotov6.ProviderServer, error) { + return muxProviderFactory(t, mockRoundTripper)(), nil + }, + } +} diff --git a/internal/testutil/unit/testdata/TestMockRoundTripper.yaml b/internal/testutil/unit/testdata/TestMockRoundTripper.yaml new file mode 100644 index 0000000000..e0b41b24a6 --- /dev/null +++ b/internal/testutil/unit/testdata/TestMockRoundTripper.yaml @@ -0,0 +1,169 @@ +step_count: 3 +steps: +- diff_requests: + - path: /api/atlas/v2/orgs/{orgId}/resourcePolicies + method: POST + version: '2024-08-05' + text: "{\n \"name\": \"test-policy\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\"\n }\n ]\n}" + responses: + - response_index: 2 + status: 201 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"673d8c796b13675d681aaf86\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:05Z\",\n \"name\": \"test-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c796b13675d681aaf85\"\n }\n ],\n \"version\": \"v1\"\n}" + request_responses: + - path: /api/atlas/v2/orgs/{orgId}/resourcePolicies:validate + method: POST + version: '2024-08-05' + text: "{\n \"name\": \"test-policy\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\"\n }\n ]\n}" + responses: + - response_index: 0 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:03Z\",\n \"id\": \"673d8c776b13675d681aaf84\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:03Z\",\n \"name\": \"test-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c776b13675d681aaf83\"\n }\n ],\n \"version\": \"v1\"\n}" + - response_index: 1 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"673d8c79b6145f2e523c71f7\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:05Z\",\n \"name\": \"test-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c79b6145f2e523c71f6\"\n }\n ],\n \"version\": \"v1\"\n}" + - response_index: 7 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:08Z\",\n \"id\": \"673d8c7cb6145f2e523c71fa\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:08Z\",\n \"name\": \"test-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c7cb6145f2e523c71f9\"\n }\n ],\n \"version\": \"v1\"\n}" + - response_index: 11 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:10Z\",\n \"id\": \"673d8c7e6b13675d681aaf8a\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:10Z\",\n \"name\": \"test-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c7e6b13675d681aaf89\"\n }\n ],\n \"version\": \"v1\"\n}" + - path: /api/atlas/v2/orgs/{orgId}/resourcePolicies + method: POST + version: '2024-08-05' + text: "{\n \"name\": \"test-policy\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\"\n }\n ]\n}" + responses: + - response_index: 2 + status: 201 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"673d8c796b13675d681aaf86\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:05Z\",\n \"name\": \"test-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c796b13675d681aaf85\"\n }\n ],\n \"version\": \"v1\"\n}" + - path: /api/atlas/v2/orgs/{orgId}/resourcePolicies + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 3 + status: 200 + text: "[\n {\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"673d8c796b13675d681aaf86\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:05Z\",\n \"name\": \"test-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c796b13675d681aaf85\"\n }\n ],\n \"version\": \"v1\"\n }\n]" + duplicate_responses: 1 + - response_index: 8 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"673d8c796b13675d681aaf86\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:05Z\",\n \"name\": \"test-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c796b13675d681aaf85\"\n }\n ],\n \"version\": \"v1\"\n}" + - path: /api/atlas/v2/orgs/{orgId}/resourcePolicies/{resourcePolicyId} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 4 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"{resourcePolicyId}\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:05Z\",\n \"name\": \"test-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c796b13675d681aaf85\"\n }\n ],\n \"version\": \"v1\"\n}" + duplicate_responses: 4 + - response_index: 9 + status: 200 + text: "[\n {\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"{resourcePolicyId}\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:05Z\",\n \"name\": \"test-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c796b13675d681aaf85\"\n }\n ],\n \"version\": \"v1\"\n }\n]" +- diff_requests: + - path: /api/atlas/v2/orgs/{orgId}/resourcePolicies/{resourcePolicyId} + method: PATCH + version: '2024-08-05' + text: "{\n \"name\": \"updated-policy\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\"\n }\n ]\n}" + responses: + - response_index: 17 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"{resourcePolicyId}\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:14Z\",\n \"name\": \"updated-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c82b6145f2e523c71fd\"\n }\n ],\n \"version\": \"v1\"\n}" + request_responses: + - path: /api/atlas/v2/orgs/{orgId}/resourcePolicies/{resourcePolicyId} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 14 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"{resourcePolicyId}\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:05Z\",\n \"name\": \"test-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c796b13675d681aaf85\"\n }\n ],\n \"version\": \"v1\"\n}" + - response_index: 19 + status: 200 + text: "[\n {\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"{resourcePolicyId}\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:14Z\",\n \"name\": \"updated-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c82b6145f2e523c71fd\"\n }\n ],\n \"version\": \"v1\"\n }\n]" + duplicate_responses: 1 + - response_index: 20 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"{resourcePolicyId}\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:14Z\",\n \"name\": \"updated-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c82b6145f2e523c71fd\"\n }\n ],\n \"version\": \"v1\"\n}" + duplicate_responses: 3 + - path: /api/atlas/v2/orgs/{orgId}/resourcePolicies:validate + method: POST + version: '2024-08-05' + text: "{\n \"name\": \"updated-policy\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\"\n }\n ]\n}" + responses: + - response_index: 15 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:13Z\",\n \"id\": \"673d8c816b13675d681aaf8c\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:13Z\",\n \"name\": \"updated-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c816b13675d681aaf8b\"\n }\n ],\n \"version\": \"v1\"\n}" + - response_index: 16 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:14Z\",\n \"id\": \"673d8c82b6145f2e523c71fc\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:14Z\",\n \"name\": \"updated-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c82b6145f2e523c71fb\"\n }\n ],\n \"version\": \"v1\"\n}" + - response_index: 22 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:17Z\",\n \"id\": \"673d8c85b6145f2e523c7200\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:17Z\",\n \"name\": \"updated-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c85b6145f2e523c71ff\"\n }\n ],\n \"version\": \"v1\"\n}" + - response_index: 26 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:19Z\",\n \"id\": \"673d8c876b13675d681aaf8f\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:19Z\",\n \"name\": \"updated-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c876b13675d681aaf8e\"\n }\n ],\n \"version\": \"v1\"\n}" + - path: /api/atlas/v2/orgs/{orgId}/resourcePolicies/{resourcePolicyId} + method: PATCH + version: '2024-08-05' + text: "{\n \"name\": \"updated-policy\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\"\n }\n ]\n}" + responses: + - response_index: 17 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"{resourcePolicyId}\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:14Z\",\n \"name\": \"updated-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c82b6145f2e523c71fd\"\n }\n ],\n \"version\": \"v1\"\n}" + - path: /api/atlas/v2/orgs/{orgId}/resourcePolicies + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 18 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"673d8c796b13675d681aaf86\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:14Z\",\n \"name\": \"updated-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c82b6145f2e523c71fd\"\n }\n ],\n \"version\": \"v1\"\n}" + duplicate_responses: 1 + - response_index: 27 + status: 200 + text: "[\n {\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"673d8c796b13675d681aaf86\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:14Z\",\n \"name\": \"updated-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c82b6145f2e523c71fd\"\n }\n ],\n \"version\": \"v1\"\n }\n]" +- diff_requests: + - version: '2024-08-05' + method: DELETE + path: /api/atlas/v2/orgs/{orgId}/resourcePolicies/{resourcePolicyId} + text: '' + responses: + - status: 200 + text: '{}' + response_index: 32 + request_responses: + - path: /api/atlas/v2/orgs/{orgId}/resourcePolicies/{resourcePolicyId} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 29 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"{resourcePolicyId}\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:14Z\",\n \"name\": \"updated-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c82b6145f2e523c71fd\"\n }\n ],\n \"version\": \"v1\"\n}" + - response_index: 30 + status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"{resourcePolicyId}\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:14Z\",\n \"name\": \"updated-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c82b6145f2e523c71fd\"\n }\n ],\n \"version\": \"v1\"\n}" + duplicate_responses: 1 + - response_index: 33 + status: 404 + text: "{\n \"errorCode\": \"RESOURCE_POLICY_NOT_FOUND\",\n \"message\": \"Resource Policy with id \\\"{resourcePolicyId}\\\" not found\",\n \"status\": \"ERROR\",\n \"version\": \"1\"\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/orgs/{orgId}/resourcePolicies + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 30 + status: 200 + text: "[\n {\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"673d8c796b13675d681aaf86\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:14Z\",\n \"name\": \"updated-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c82b6145f2e523c71fd\"\n }\n ],\n \"version\": \"v1\"\n }\n]" + - path: /api/atlas/v2/orgs/{orgId}/resourcePolicies/{resourcePolicyId} + method: DELETE + version: '2024-08-05' + text: '' + responses: + - response_index: 32 + status: 200 + text: '{}' +variables: + orgId: 65def6ce0f722a1507105aa5 + resourcePolicyId: 673d8c796b13675d681aaf86 diff --git a/internal/testutil/unit/testdata/TestMockRoundTripper/01_01_POST__api_atlas_v2_orgs_{orgId}_resourcePolicies_2024-08-05.json b/internal/testutil/unit/testdata/TestMockRoundTripper/01_01_POST__api_atlas_v2_orgs_{orgId}_resourcePolicies_2024-08-05.json new file mode 100644 index 0000000000..6603aada2a --- /dev/null +++ b/internal/testutil/unit/testdata/TestMockRoundTripper/01_01_POST__api_atlas_v2_orgs_{orgId}_resourcePolicies_2024-08-05.json @@ -0,0 +1,8 @@ +{ + "name": "test-policy", + "policies": [ + { + "body": "\t\t\t\n\tforbid (\n\tprincipal,\n\taction == cloud::Action::\"cluster.createEdit\",\n\tresource\n\t) when {\n\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\"aws\"])\n\t};\n" + } + ] +} \ No newline at end of file diff --git a/internal/testutil/unit/testdata/TestMockRoundTripper/02_01_PATCH__api_atlas_v2_orgs_{orgId}_resourcePolicies_{resourcePolicyId}_2024-08-05.json b/internal/testutil/unit/testdata/TestMockRoundTripper/02_01_PATCH__api_atlas_v2_orgs_{orgId}_resourcePolicies_{resourcePolicyId}_2024-08-05.json new file mode 100644 index 0000000000..f767be935b --- /dev/null +++ b/internal/testutil/unit/testdata/TestMockRoundTripper/02_01_PATCH__api_atlas_v2_orgs_{orgId}_resourcePolicies_{resourcePolicyId}_2024-08-05.json @@ -0,0 +1,8 @@ +{ + "name": "updated-policy", + "policies": [ + { + "body": "\t\t\t\n\tforbid (\n\tprincipal,\n\taction == cloud::Action::\"cluster.createEdit\",\n\tresource\n\t) when {\n\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\"aws\"])\n\t};\n" + } + ] +} \ No newline at end of file diff --git a/internal/testutil/unit/testdata/TestMockRoundTripper/03_01_DELETE__api_atlas_v2_orgs_{orgId}_resourcePolicies_{resourcePolicyId}_2024-08-05.json b/internal/testutil/unit/testdata/TestMockRoundTripper/03_01_DELETE__api_atlas_v2_orgs_{orgId}_resourcePolicies_{resourcePolicyId}_2024-08-05.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/internal/testutil/unit/testdata/TestMockRoundTripper/03_01_DELETE__api_atlas_v2_orgs_{orgId}_resourcePolicies_{resourcePolicyId}_2024-08-05_manual.json b/internal/testutil/unit/testdata/TestMockRoundTripper/03_01_DELETE__api_atlas_v2_orgs_{orgId}_resourcePolicies_{resourcePolicyId}_2024-08-05_manual.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/internal/testutil/unit/testdata/TestMockRoundTripper/03_01_DELETE__api_atlas_v2_orgs_{orgId}_resourcePolicies_{resourcePolicyId}_2024-08-05_manual.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/internal/testutil/unit/testdata/TestMockRoundTripperAllowReRead.yaml b/internal/testutil/unit/testdata/TestMockRoundTripperAllowReRead.yaml new file mode 100644 index 0000000000..a24f4b8c3a --- /dev/null +++ b/internal/testutil/unit/testdata/TestMockRoundTripperAllowReRead.yaml @@ -0,0 +1,37 @@ +step_count: 1 +steps: +- diff_requests: + - version: '2024-08-05' + method: POST + path: /api/atlas/v2/orgs/{orgId}/resourcePolicies + text: "{\n \"name\": \"test-policy\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\"\n }\n ]\n}" + responses: + - status: 201 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"673d8c796b13675d681aaf86\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:05Z\",\n \"name\": \"test-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c796b13675d681aaf85\"\n }\n ],\n \"version\": \"v1\"\n}" + response_index: 2 + request_responses: + - version: '2024-08-05' + method: POST + path: /api/atlas/v2/orgs/{orgId}/resourcePolicies + text: "{\n \"name\": \"test-policy\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\"\n }\n ]\n}" + responses: + - status: 201 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"673d8c796b13675d681aaf86\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:05Z\",\n \"name\": \"test-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c796b13675d681aaf85\"\n }\n ],\n \"version\": \"v1\"\n}" + response_index: 2 + - version: '2024-08-05' + method: GET + path: /api/atlas/v2/orgs/{orgId}/resourcePolicies + text: '' + responses: + - status: 200 + text: "{\"expect\": \"returned again\"}" + response_index: 0 + - status: 200 + text: "{\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"673d8c796b13675d681aaf86\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:05Z\",\n \"name\": \"test-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c796b13675d681aaf85\"\n }\n ],\n \"version\": \"v1\"\n}" + response_index: 8 + - status: 200 + text: "[\n {\n \"createdByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"createdDate\": \"2024-11-20T07:15:05Z\",\n \"id\": \"673d8c796b13675d681aaf86\",\n \"lastUpdatedByUser\": {\n \"id\": \"65def6f00f722a1507105ad8\",\n \"name\": \"mvccpeou\"\n },\n \"lastUpdatedDate\": \"2024-11-20T07:15:05Z\",\n \"name\": \"test-policy\",\n \"orgId\": \"{orgId}\",\n \"policies\": [\n {\n \"body\": \"\\t\\t\\t\\n\\tforbid (\\n\\tprincipal,\\n\\taction == cloud::Action::\\\"cluster.createEdit\\\",\\n\\tresource\\n\\t) when {\\n\\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\\\"aws\\\"])\\n\\t};\\n\",\n \"id\": \"673d8c796b13675d681aaf85\"\n }\n ],\n \"version\": \"v1\"\n }\n]" + response_index: 12 +variables: + orgId: 65def6ce0f722a1507105aa5 + resourcePolicyId: 673d8c796b13675d681aaf86 diff --git a/internal/testutil/unit/testdata/TestMockRoundTripperAllowReRead/01_01_POST__api_atlas_v2_orgs_{orgId}_resourcePolicies_2024-08-05.json b/internal/testutil/unit/testdata/TestMockRoundTripperAllowReRead/01_01_POST__api_atlas_v2_orgs_{orgId}_resourcePolicies_2024-08-05.json new file mode 100644 index 0000000000..6603aada2a --- /dev/null +++ b/internal/testutil/unit/testdata/TestMockRoundTripperAllowReRead/01_01_POST__api_atlas_v2_orgs_{orgId}_resourcePolicies_2024-08-05.json @@ -0,0 +1,8 @@ +{ + "name": "test-policy", + "policies": [ + { + "body": "\t\t\t\n\tforbid (\n\tprincipal,\n\taction == cloud::Action::\"cluster.createEdit\",\n\tresource\n\t) when {\n\tcontext.cluster.cloudProviders.containsAny([cloud::cloudProvider::\"aws\"])\n\t};\n" + } + ] +} \ No newline at end of file diff --git a/scripts/generate-doc.sh b/scripts/generate-doc.sh index 710b4b204a..cfc7c05d20 100755 --- a/scripts/generate-doc.sh +++ b/scripts/generate-doc.sh @@ -32,7 +32,7 @@ set -euo pipefail -TF_VERSION="${TF_VERSION:-"1.9.8"}" # TF version to use when running tfplugindocs. Default: 1.9.8 +TF_VERSION="${TF_VERSION:-"1.10.2"}" # TF version to use when running tfplugindocs. Default: 1.10.2 TEMPLATE_FOLDER_PATH="${TEMPLATE_FOLDER_PATH:-"templates"}" # PATH to the templates folder. Default: templates diff --git a/scripts/generate-docs-all.sh b/scripts/generate-docs-all.sh index 2a2d7e017c..99f52f8604 100755 --- a/scripts/generate-docs-all.sh +++ b/scripts/generate-docs-all.sh @@ -26,7 +26,7 @@ set -euo pipefail -TF_VERSION="${TF_VERSION:-"1.9.8"}" # TF version to use when running tfplugindocs. Default: 1.9.8 +TF_VERSION="${TF_VERSION:-"1.10.2"}" # TF version to use when running tfplugindocs. Default: 1.10.2 TEMPLATE_FOLDER_PATH="${TEMPLATE_FOLDER_PATH:-"templates"}" # PATH to the templates folder. Default: templates # ensure preview resource and data sources are also included during generation diff --git a/templates/data-source.md.tmpl b/templates/data-source.md.tmpl index 45b3c38584..b649202982 100644 --- a/templates/data-source.md.tmpl +++ b/templates/data-source.md.tmpl @@ -9,9 +9,7 @@ {{ else if eq .Name "mongodbatlas_privatelink_endpoint" }} {{ tffile (printf "examples/%s/aws/cluster/main.tf" .Name )}} {{ else if eq .Name "mongodbatlas_privatelink_endpoint_service_serverless" }} - {{ tffile (printf "examples/%s/aws/main.tf" .Name )}} {{ else if eq .Name "mongodbatlas_privatelink_endpoint_serverless" }} - {{ tffile "examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/main.tf" }} {{ else if eq .Name "mongodbatlas_cluster" }} {{ tffile (printf "examples/%s/tenant-upgrade/main.tf" .Name )}} {{ else if eq .Name "mongodbatlas_cluster" }} diff --git a/templates/data-sources/flex_cluster.md.tmpl b/templates/data-sources/flex_cluster.md.tmpl new file mode 100644 index 0000000000..33b57dc2c6 --- /dev/null +++ b/templates/data-sources/flex_cluster.md.tmpl @@ -0,0 +1,12 @@ +# {{.Type}}: {{.Name}} + +`{{.Name}}` describes a flex cluster. + +**NOTE:** Flex Cluster is in Public Preview. In order to use the resource and data sources you need to set the environment variable MONGODB_ATLAS_ENABLE_PREVIEW to true. + +## Example Usages +{{ tffile (printf "examples/%s/main.tf" .Name )}} + +{{ .SchemaMarkdown | trimspace }} + +For more information see: [MongoDB Atlas API - Flex Cluster](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Flex-Clusters/operation/getFlexCluster) Documentation. diff --git a/templates/data-sources/flex_clusters.md.tmpl b/templates/data-sources/flex_clusters.md.tmpl new file mode 100644 index 0000000000..ec8f1ee830 --- /dev/null +++ b/templates/data-sources/flex_clusters.md.tmpl @@ -0,0 +1,12 @@ +# {{.Type}}: {{.Name}} + +`{{.Name}}` returns all flex clusters in a project. + +**NOTE:** Flex Cluster is in Public Preview. In order to use the resource and data sources you need to set the environment variable MONGODB_ATLAS_ENABLE_PREVIEW to true. + +## Example Usages +{{ tffile (printf "examples/mongodbatlas_flex_cluster/main.tf" )}} + +{{ .SchemaMarkdown | trimspace }} + +For more information see: [MongoDB Atlas API - Flex Clusters](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Streams/operation/listFlexClusters) Documentation. diff --git a/templates/resources.md.tmpl b/templates/resources.md.tmpl index b2f176cdf3..855f829e7a 100644 --- a/templates/resources.md.tmpl +++ b/templates/resources.md.tmpl @@ -9,9 +9,7 @@ {{ else if eq .Name "mongodbatlas_privatelink_endpoint" }} {{ tffile (printf "examples/%s/aws/cluster/main.tf" .Name )}} {{ else if eq .Name "mongodbatlas_privatelink_endpoint_service_serverless" }} - {{ tffile (printf "examples/%s/aws/main.tf" .Name )}} {{ else if eq .Name "mongodbatlas_privatelink_endpoint_serverless" }} - {{ tffile "examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/main.tf" }} {{ else if eq .Name "mongodbatlas_cluster" }} {{ tffile (printf "examples/%s/tenant-upgrade/main.tf" .Name )}} {{ else if eq .Name "mongodbatlas_cluster" }} @@ -56,7 +54,6 @@ {{ else if eq .Name "mongodbatlas_ldap_verify" }} {{ else if eq .Name "mongodbatlas_third_party_integration" }} {{ else if eq .Name "mongodbatlas_x509_authentication_database_user" }} - {{ else if eq .Name "mongodbatlas_stream_processor" }} {{ else if eq .Name "mongodbatlas_privatelink_endpoint_service_data_federation_online_archive" }} {{ else }} {{ tffile (printf "examples/%s/main.tf" .Name )}} diff --git a/templates/resources/flex_cluster.md.tmpl b/templates/resources/flex_cluster.md.tmpl new file mode 100644 index 0000000000..0d13e265f0 --- /dev/null +++ b/templates/resources/flex_cluster.md.tmpl @@ -0,0 +1,19 @@ +# {{.Type}}: {{.Name}} + +`{{.Name}}` provides a Flex Cluster resource. The resource lets you create, update, delete and import a flex cluster. + +**NOTE:** Flex Cluster is in Public Preview. In order to use the resource and data sources you need to set the environment variable MONGODB_ATLAS_ENABLE_PREVIEW to true. + +## Example Usages + +{{ tffile (printf "examples/%s/main.tf" .Name )}} + +{{ .SchemaMarkdown | trimspace }} + +# Import +You can import the Flex Cluster resource by using the Project ID and Flex Cluster name, in the format `PROJECT_ID-FLEX_CLUSTER_NAME`. For example: +``` +$ terraform import mongodbatlas_flex_cluster.test 6117ac2fe2a3d04ed27a987v-yourFlexClusterName +``` + +For more information see: [MongoDB Atlas API - Flex Cluster](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Flex-Clusters/operation/createFlexcluster) Documentation. diff --git a/tools/codegen/config.yml b/tools/codegen/config.yml index 29cc04509c..3a2e017d77 100644 --- a/tools/codegen/config.yml +++ b/tools/codegen/config.yml @@ -11,7 +11,6 @@ resources: group_id: project_id ignores: ["links"] timeouts: ["create", "update", "delete"] - # overrides: # project_id: # plan_modifiers: [{ @@ -25,12 +24,10 @@ resources: # ], # definition: "stringvalidator.ConflictsWith(path.MatchRoot(\"name\"))" # }] - # prefix_path: # computability: # optional: true # computed: true - search_deployment: read: path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/deployment diff --git a/tools/scaffold/template/datasource.tmpl b/tools/scaffold/template/datasource.tmpl index b191d3bb92..3ad46a6dd1 100644 --- a/tools/scaffold/template/datasource.tmpl +++ b/tools/scaffold/template/datasource.tmpl @@ -30,6 +30,7 @@ type ds struct { func (d *ds) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { // TODO: Schema and model must be defined in data_source_schema.go. Details on scaffolding this file found in contributing/development-best-practices.md under "Scaffolding Schema and Model Definitions" resp.Schema = DataSourceSchema(ctx) + conversion.UpdateSchemaDescription(&resp.Schema) } func (d *ds) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/tools/scaffold/template/pluraldatasource.tmpl b/tools/scaffold/template/pluraldatasource.tmpl index 98e7efbbba..e164e19e2e 100644 --- a/tools/scaffold/template/pluraldatasource.tmpl +++ b/tools/scaffold/template/pluraldatasource.tmpl @@ -29,6 +29,7 @@ type pluralDS struct { func (d *pluralDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { // TODO: Schema and model must be defined in plural_data_source_schema.go. Details on scaffolding this file found in contributing/development-best-practices.md under "Scaffolding Schema and Model Definitions" resp.Schema = PluralDataSourceSchema(ctx) + conversion.UpdateSchemaDescription(&resp.Schema) } func (d *pluralDS) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/tools/scaffold/template/resource.tmpl b/tools/scaffold/template/resource.tmpl index 75304c3be2..2a73237ffa 100644 --- a/tools/scaffold/template/resource.tmpl +++ b/tools/scaffold/template/resource.tmpl @@ -29,6 +29,7 @@ type rs struct { func (r *rs) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { // TODO: Schema and model must be defined in resource_schema.go. Details on scaffolding this file found in contributing/development-best-practices.md under "Scaffolding Schema and Model Definitions" resp.Schema = ResourceSchema(ctx) + conversion.UpdateSchemaDescription(&resp.Schema) } func (r *rs) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { From d743227ea19eec5523d8d3d9549a3e75ca121c59 Mon Sep 17 00:00:00 2001 From: Agustin Bettati Date: Mon, 16 Dec 2024 10:51:06 +0100 Subject: [PATCH 10/12] include clarifying comments for when older API versions are used --- .../service/advancedcluster/resource_advanced_cluster.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/service/advancedcluster/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index 1222628afc..305cbd9a2b 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -509,6 +509,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. var clusterName string var clusterID string var err error + // With old sharding config we call older API (2024-08-05) to avoid cluster having asymmetric autoscaling mode. Old sharding config can only represent symmetric clusters. if isUsingOldShardingConfiguration(d) { var cluster20240805 *admin20240805.ClusterDescription20240805 cluster20240805, _, err = connV220240805.ClustersApi.CreateCluster(ctx, projectID, ConvertClusterDescription20241023to20240805(params)).Execute() @@ -619,6 +620,7 @@ func resourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Di return diag.FromErr(fmt.Errorf(errorRead, clusterName, err)) } } + // if config uses old sharding configuration we call latest API but group replications specs from the same zone and define num_shards attribute if isUsingOldShardingConfiguration(d) { replicationSpecs, err = FlattenAdvancedReplicationSpecsOldShardingConfig(ctx, cluster.GetReplicationSpecs(), zoneNameToOldReplicationSpecMeta, d.Get("replication_specs").([]any), d, connV2) if err != nil { @@ -658,7 +660,7 @@ func resourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Di } // GetReplicationSpecAttributesFromOldAPI returns the id and num shard values of replication specs coming from old API. This is used to populate replication_specs.*.id and replication_specs.*.num_shard attributes for old sharding confirgurations. -// In the old API, each replications spec has a 1:1 relation with each zone, so ids and num shards are stored in a struct oldShardConfigMeta and are returned in a map from zoneName to oldShardConfigMeta. +// In the old API (2023-02-01), each replications spec has a 1:1 relation with each zone, so ids and num shards are stored in a struct oldShardConfigMeta and are returned in a map from zoneName to oldShardConfigMeta. func GetReplicationSpecAttributesFromOldAPI(ctx context.Context, projectID, clusterName string, client20240530 admin20240530.ClustersApi) (map[string]OldShardConfigMeta, error) { clusterOldAPI, _, err := client20240530.GetCluster(ctx, projectID, clusterName).Execute() if err != nil { @@ -812,7 +814,7 @@ func WarningIfFCVExpiredOrUnpinnedExternally(d *schema.ResourceData, cluster *ad return nil } -// For both read and update operations if old sharding schema structure is used (at least one replication spec with numShards > 1) we continue to invoke the old API +// isUsingOldShardingConfiguration is identified if at least one replication spec defines num_shards > 1. This legacy form is from 2023-02-01 API and can only represent symmetric sharded clusters. func isUsingOldShardingConfiguration(d *schema.ResourceData) bool { tfList := d.Get("replication_specs").([]any) for _, tfMapRaw := range tfList { @@ -874,6 +876,7 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. return diags } + // With old sharding config we call older API (2023-02-01) to avoid cluster having asymmetric autoscaling mode. Old sharding config can only represent symmetric clusters. if isUsingOldShardingConfiguration(d) { req, diags := updateRequestOldAPI(d, clusterName) if diags != nil { @@ -901,7 +904,7 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. if d.HasChange("config_server_management_mode") { request.ConfigServerManagementMode = conversion.StringPtr(d.Get("config_server_management_mode").(string)) } - // can call latest API (2024-10-23 or newer) as replications specs with autoscaling property is not specified + // can call latest API (2024-10-23 or newer) as replications specs (with nested autoscaling property) is not specified if _, _, err := connV2.ClustersApi.UpdateCluster(ctx, projectID, clusterName, request).Execute(); err != nil { return diag.FromErr(fmt.Errorf(errorUpdate, clusterName, err)) } From ea275c310b0be9f0e6b7986cf42ebd61181274b0 Mon Sep 17 00:00:00 2001 From: Agustin Bettati Date: Mon, 16 Dec 2024 10:59:29 +0100 Subject: [PATCH 11/12] remove redundant new line --- internal/service/advancedcluster/resource_advanced_cluster.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/service/advancedcluster/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index 305cbd9a2b..d8f2012472 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -1433,6 +1433,5 @@ func waitForUpdateToFinish(ctx context.Context, connV2 *admin.APIClient, project } _, err := stateConf.WaitForStateContext(ctx) - return err } From bbac1e1b8bbd4bd7d5a59c93e54489cd567bdd04 Mon Sep 17 00:00:00 2001 From: Agustin Bettati Date: Mon, 16 Dec 2024 11:03:36 +0100 Subject: [PATCH 12/12] revert ordering changes in tpf schema model --- internal/service/advancedclustertpf/schema.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/advancedclustertpf/schema.go b/internal/service/advancedclustertpf/schema.go index abb1d67330..547390cd18 100644 --- a/internal/service/advancedclustertpf/schema.go +++ b/internal/service/advancedclustertpf/schema.go @@ -544,8 +544,8 @@ type TFModel struct { Labels types.Set `tfsdk:"labels"` ReplicationSpecs types.List `tfsdk:"replication_specs"` Tags types.Set `tfsdk:"tags"` - MongoDBVersion types.String `tfsdk:"mongo_db_version"` - BiConnectorConfig types.Object `tfsdk:"bi_connector_config"` + StateName types.String `tfsdk:"state_name"` + ConnectionStrings types.Object `tfsdk:"connection_strings"` CreateDate types.String `tfsdk:"create_date"` AcceptDataRisksAndForceReplicaSetReconfig types.String `tfsdk:"accept_data_risks_and_force_replica_set_reconfig"` EncryptionAtRestProvider types.String `tfsdk:"encryption_at_rest_provider"` @@ -554,10 +554,10 @@ type TFModel struct { ClusterID types.String `tfsdk:"cluster_id"` ConfigServerManagementMode types.String `tfsdk:"config_server_management_mode"` MongoDBMajorVersion types.String `tfsdk:"mongo_db_major_version"` - StateName types.String `tfsdk:"state_name"` + MongoDBVersion types.String `tfsdk:"mongo_db_version"` Name types.String `tfsdk:"name"` VersionReleaseSystem types.String `tfsdk:"version_release_system"` - ConnectionStrings types.Object `tfsdk:"connection_strings"` + BiConnectorConfig types.Object `tfsdk:"bi_connector_config"` ConfigServerType types.String `tfsdk:"config_server_type"` ReplicaSetScalingStrategy types.String `tfsdk:"replica_set_scaling_strategy"` ClusterType types.String `tfsdk:"cluster_type"`