From ecb0a1c0173f25808c14fc2863236557090b018d Mon Sep 17 00:00:00 2001 From: maastha <122359335+maastha@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:27:09 +0100 Subject: [PATCH 01/15] doc: Updates `troubleshooting.md` to include `mongodbatlas_alert_configuration` issue causing non-empty plans due to `integration_id` (#2627) --- docs/troubleshooting.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 565f40b754..b9605ce37e 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -70,3 +70,11 @@ variable "region_configs_list" { ``` +## Issue: `mongodbatlas_alert_configuration` resource attribute `notification.#.integration_id` causes drift detection (non-empty plan) as shown below if no value is set: +``` +~ notification { + - integration_id = "xxxxxxxxxxxxxxxxxxxxxxxx" -> null +``` + +### Cause: +Due to recent updates in the Atlas API [Alert Configuration](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Alert-Configurations/operation/getAlertConfiguration), a computed value for `integration_id` might be returned. This affects MongoDB Atlas Provider versions **1.16.0 to 1.19.0**. Please review the Breaking Changes section in our [1.20.0 upgrade guide](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/1.20.0-upgrade-guide) to learn more. From ee78a92505cbd42cbe5e6350bed109c727272c14 Mon Sep 17 00:00:00 2001 From: Leo Antoli <430982+lantoli@users.noreply.github.com> Date: Wed, 25 Sep 2024 17:57:19 +0200 Subject: [PATCH 02/15] chore: Creates test group `mongodbatlas_global_cluster_config` and updates tests (#2636) * test group for global_cluster_config * unify ds tests with resource * update test checks * add data source in tests * join similar tests --- .github/workflows/acceptance-tests-runner.yml | 33 +++- .../data_source_global_cluster_config_test.go | 29 --- ...ce_global_cluster_config_migration_test.go | 32 +--- .../resource_global_cluster_config_test.go | 171 ++++++++---------- 4 files changed, 109 insertions(+), 156 deletions(-) delete mode 100644 internal/service/globalclusterconfig/data_source_global_cluster_config_test.go diff --git a/.github/workflows/acceptance-tests-runner.yml b/.github/workflows/acceptance-tests-runner.yml index 453f9a62e6..b2c7bf5ce0 100644 --- a/.github/workflows/acceptance-tests-runner.yml +++ b/.github/workflows/acceptance-tests-runner.yml @@ -209,6 +209,7 @@ jobs: event_trigger: ${{ steps.filter.outputs.event_trigger == 'true' || env.mustTrigger == 'true' }} federated: ${{ steps.filter.outputs.federated == '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' }} mongodb_employee_access_grant: ${{ steps.filter.outputs.mongodb_employee_access_grant == 'true' || env.mustTrigger == 'true' }} network: ${{ steps.filter.outputs.network == 'true' || env.mustTrigger == 'true' }} @@ -240,7 +241,6 @@ jobs: - 'internal/service/controlplaneipaddresses/*.go' cluster: - 'internal/service/cluster/*.go' - - 'internal/service/globalclusterconfig/*.go' cluster_outage_simulation: - 'internal/service/clusteroutagesimulation/*.go' config: @@ -273,6 +273,8 @@ jobs: - 'internal/service/auditing/*.go' - 'internal/service/backupcompliancepolicy/*.go' - 'internal/service/x509authenticationdatabaseuser/*.go' + global_cluster_config: + - 'internal/service/globalclusterconfig/*.go' ldap: - 'internal/service/ldapconfiguration/*.go' - 'internal/service/ldapverify/*.go' @@ -425,8 +427,7 @@ jobs: - name: Acceptance Tests env: MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }} - ACCTEST_PACKAGES: | - ./internal/service/controlplaneipaddresses + ACCTEST_PACKAGES: ./internal/service/controlplaneipaddresses run: make testacc cluster: @@ -448,9 +449,7 @@ jobs: - name: Acceptance Tests env: MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }} - ACCTEST_PACKAGES: | - ./internal/service/cluster - ./internal/service/globalclusterconfig + ACCTEST_PACKAGES: ./internal/service/cluster run: make testacc cluster_outage_simulation: @@ -643,6 +642,28 @@ jobs: ./internal/service/x509authenticationdatabaseuser run: make testacc + global_cluster_config: + needs: [ change-detection, get-provider-version ] + if: ${{ needs.change-detection.outputs.global_cluster_config == 'true' || inputs.test_group == 'global_cluster_config' }} + runs-on: ubuntu-latest + permissions: {} + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + with: + ref: ${{ inputs.ref || github.ref }} + - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 + 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 }} + ACCTEST_PACKAGES: ./internal/service/globalclusterconfig + run: make testacc + ldap: needs: [ change-detection, get-provider-version ] if: ${{ needs.change-detection.outputs.ldap == 'true' || inputs.test_group == 'ldap' }} diff --git a/internal/service/globalclusterconfig/data_source_global_cluster_config_test.go b/internal/service/globalclusterconfig/data_source_global_cluster_config_test.go deleted file mode 100644 index fb50184c0f..0000000000 --- a/internal/service/globalclusterconfig/data_source_global_cluster_config_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package globalclusterconfig_test - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" -) - -func TestAccClusterRSGlobalClusterDS_basic(t *testing.T) { - var ( - clusterInfo = acc.GetClusterInfo(t, &acc.ClusterRequest{Geosharded: true}) - ) - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acc.PreCheckBasic(t) }, - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: checkDestroy, - Steps: []resource.TestStep{ - { - Config: configBasic(&clusterInfo, false, false), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrSet(dataSourceName, "project_id"), - resource.TestCheckResourceAttrSet(dataSourceName, "cluster_name"), - ), - }, - }, - }) -} diff --git a/internal/service/globalclusterconfig/resource_global_cluster_config_migration_test.go b/internal/service/globalclusterconfig/resource_global_cluster_config_migration_test.go index 7353bc22cd..d19f1258f0 100644 --- a/internal/service/globalclusterconfig/resource_global_cluster_config_migration_test.go +++ b/internal/service/globalclusterconfig/resource_global_cluster_config_migration_test.go @@ -3,37 +3,9 @@ package globalclusterconfig_test import ( "testing" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/mig" ) -func TestMigClusterRSGlobalCluster_basic(t *testing.T) { - var ( - clusterInfo = acc.GetClusterInfo(t, &acc.ClusterRequest{Geosharded: true}) - config = configBasic(&clusterInfo, false, false) - ) - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { mig.PreCheckBasic(t) }, - CheckDestroy: checkDestroy, - Steps: []resource.TestStep{ - { - ExternalProviders: mig.ExternalProviders(), - Config: config, - Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), - resource.TestCheckResourceAttrSet(resourceName, "custom_zone_mappings.#"), - resource.TestCheckResourceAttrSet(resourceName, "custom_zone_mapping.%"), - resource.TestCheckResourceAttrSet(resourceName, "custom_zone_mapping.CA"), - resource.TestCheckResourceAttrSet(resourceName, "project_id"), - resource.TestCheckResourceAttr(resourceName, "cluster_name", clusterInfo.Name), - resource.TestCheckResourceAttr(resourceName, "managed_namespaces.#", "1"), - resource.TestCheckResourceAttr(resourceName, "managed_namespaces.0.is_custom_shard_key_hashed", "false"), - resource.TestCheckResourceAttr(resourceName, "managed_namespaces.0.is_shard_key_unique", "false"), - ), - }, - mig.TestStepCheckEmptyPlan(config), - }, - }) +func TestMigGlobalClusterConfig_basic(t *testing.T) { + mig.CreateAndRunTest(t, basicTestCase(t, false)) } diff --git a/internal/service/globalclusterconfig/resource_global_cluster_config_test.go b/internal/service/globalclusterconfig/resource_global_cluster_config_test.go index 522305f543..52d3a45013 100644 --- a/internal/service/globalclusterconfig/resource_global_cluster_config_test.go +++ b/internal/service/globalclusterconfig/resource_global_cluster_config_test.go @@ -13,45 +13,25 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" ) -func TestAccClusterRSGlobalCluster_basic(t *testing.T) { - var ( - clusterInfo = acc.GetClusterInfo(t, &acc.ClusterRequest{Geosharded: true}) - ) +const ( + resourceName = "mongodbatlas_global_cluster_config.config" + dataSourceName = "data.mongodbatlas_global_cluster_config.config" +) - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acc.PreCheckBasic(t) }, - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: checkDestroy, - Steps: []resource.TestStep{ - { - Config: configBasic(&clusterInfo, false, false), - Check: resource.ComposeAggregateTestCheckFunc( - checkExists(resourceName), - resource.TestCheckResourceAttrSet(resourceName, "custom_zone_mappings.#"), - resource.TestCheckResourceAttrSet(resourceName, "custom_zone_mapping.%"), - resource.TestCheckResourceAttrSet(resourceName, "custom_zone_mapping.CA"), - resource.TestCheckResourceAttrSet(resourceName, "project_id"), - resource.TestCheckResourceAttr(resourceName, "cluster_name", clusterInfo.Name), - resource.TestCheckResourceAttr(resourceName, "managed_namespaces.#", "1"), - resource.TestCheckResourceAttr(resourceName, "managed_namespaces.0.is_custom_shard_key_hashed", "false"), - resource.TestCheckResourceAttr(resourceName, "managed_namespaces.0.is_shard_key_unique", "false"), - ), - }, - { - Config: configBasic(&clusterInfo, true, false), - ExpectError: regexp.MustCompile("Updating a global cluster configuration resource is not allowed"), - }, - }, - }) +func TestAccGlobalClusterConfig_basic(t *testing.T) { + resource.ParallelTest(t, *basicTestCase(t, false)) } -func TestAccClusterRSGlobalCluster_withAWSAndBackup(t *testing.T) { - var ( - clusterInfo = acc.GetClusterInfo(t, &acc.ClusterRequest{Geosharded: true, CloudBackup: true}) - ) +func TestAccGlobalClusterConfig_withBackup(t *testing.T) { + resource.ParallelTest(t, *basicTestCase(t, true)) +} - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acc.PreCheckBasic(t) }, +func basicTestCase(tb testing.TB, withBackup bool) *resource.TestCase { + tb.Helper() + clusterInfo := acc.GetClusterInfo(tb, &acc.ClusterRequest{Geosharded: true, CloudBackup: withBackup}) + + return &resource.TestCase{ + PreCheck: func() { acc.PreCheckBasic(tb) }, ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, CheckDestroy: checkDestroy, Steps: []resource.TestStep{ @@ -59,12 +39,14 @@ func TestAccClusterRSGlobalCluster_withAWSAndBackup(t *testing.T) { Config: configBasic(&clusterInfo, false, false), Check: resource.ComposeAggregateTestCheckFunc( checkExists(resourceName), - resource.TestCheckResourceAttr(resourceName, "managed_namespaces.#", "1"), - resource.TestCheckResourceAttrSet(resourceName, "custom_zone_mappings.#"), - resource.TestCheckResourceAttrSet(resourceName, "custom_zone_mapping.%"), - resource.TestCheckResourceAttrSet(resourceName, "custom_zone_mapping.CA"), - resource.TestCheckResourceAttrSet(resourceName, "project_id"), - resource.TestCheckResourceAttr(resourceName, "cluster_name", clusterInfo.Name), + acc.CheckRSAndDS(resourceName, nil, nil, + []string{"custom_zone_mappings.#", "custom_zone_mapping.%", "custom_zone_mapping.CA", "project_id"}, + map[string]string{ + "cluster_name": clusterInfo.Name, + "managed_namespaces.#": "1", + "managed_namespaces.0.is_custom_shard_key_hashed": "false", + "managed_namespaces.0.is_shard_key_unique": "false", + }), ), }, { @@ -74,11 +56,51 @@ func TestAccClusterRSGlobalCluster_withAWSAndBackup(t *testing.T) { ImportStateVerify: true, ImportStateVerifyIgnore: []string{"custom_zone_mappings"}, }, + { + Config: configBasic(&clusterInfo, true, false), + ExpectError: regexp.MustCompile("Updating a global cluster configuration resource is not allowed"), + }, }, - }) + } } -func TestAccClusterRSGlobalCluster_database(t *testing.T) { +func TestAccGlobalClusterConfig_database(t *testing.T) { + const ( + customZone = ` + custom_zone_mappings { + location = "US" + zone = "US" + } + custom_zone_mappings { + location = "IE" + zone = "EU" + } + custom_zone_mappings { + location = "DE" + zone = "DE" + } + ` + + customZoneUpdated = ` + custom_zone_mappings { + location = "US" + zone = "US" + } + custom_zone_mappings { + location = "IE" + zone = "EU" + } + custom_zone_mappings { + location = "DE" + zone = "DE" + } + custom_zone_mappings { + location = "JP" + zone = "JP" + } + ` + ) + var ( specUS = acc.ReplicationSpecRequest{ZoneName: "US", Region: "US_EAST_1"} specEU = acc.ReplicationSpecRequest{ZoneName: "EU", Region: "EU_WEST_1"} @@ -96,14 +118,12 @@ func TestAccClusterRSGlobalCluster_database(t *testing.T) { Config: configWithDBConfig(&clusterInfo, customZone), Check: resource.ComposeAggregateTestCheckFunc( checkExists(resourceName), - resource.TestCheckResourceAttr(resourceName, "managed_namespaces.#", "5"), - resource.TestCheckResourceAttrSet(resourceName, "custom_zone_mappings.#"), - resource.TestCheckResourceAttrSet(resourceName, "custom_zone_mapping.%"), - resource.TestCheckResourceAttrSet(resourceName, "custom_zone_mapping.US"), - resource.TestCheckResourceAttrSet(resourceName, "custom_zone_mapping.IE"), - resource.TestCheckResourceAttrSet(resourceName, "custom_zone_mapping.DE"), - resource.TestCheckResourceAttrSet(resourceName, "project_id"), - resource.TestCheckResourceAttr(resourceName, "cluster_name", clusterInfo.Name), + acc.CheckRSAndDS(resourceName, nil, nil, + []string{"custom_zone_mappings.#", "custom_zone_mapping.%", "custom_zone_mapping.US", "custom_zone_mapping.IE", "custom_zone_mapping.DE", "project_id"}, + map[string]string{ + "cluster_name": clusterInfo.Name, + "managed_namespaces.#": "5", + }), ), }, { @@ -194,8 +214,9 @@ func configBasic(info *acc.ClusterInfo, isCustomShard, isShardKeyUnique bool) st } data "mongodbatlas_global_cluster_config" "config" { - cluster_name = %[1]s - project_id = %[2]q + project_id = mongodbatlas_global_cluster_config.config.project_id + cluster_name = mongodbatlas_global_cluster_config.config.cluster_name + depends_on = [mongodbatlas_global_cluster_config.config] } `, info.TerraformNameRef, info.ProjectID, isCustomShard, isShardKeyUnique) } @@ -233,43 +254,11 @@ func configWithDBConfig(info *acc.ClusterInfo, zones string) string { } %[3]s } + + data "mongodbatlas_global_cluster_config" "config" { + project_id = mongodbatlas_global_cluster_config.config.project_id + cluster_name = mongodbatlas_global_cluster_config.config.cluster_name + depends_on = [mongodbatlas_global_cluster_config.config] + } `, info.TerraformNameRef, info.ProjectID, zones) } - -const ( - resourceName = "mongodbatlas_global_cluster_config.config" - dataSourceName = "data.mongodbatlas_global_cluster_config.config" - - customZone = ` - custom_zone_mappings { - location = "US" - zone = "US" - } - custom_zone_mappings { - location = "IE" - zone = "EU" - } - custom_zone_mappings { - location = "DE" - zone = "DE" - } - ` - customZoneUpdated = ` - custom_zone_mappings { - location = "US" - zone = "US" - } - custom_zone_mappings { - location = "IE" - zone = "EU" - } - custom_zone_mappings { - location = "DE" - zone = "DE" - } - custom_zone_mappings { - location = "JP" - zone = "JP" - } - ` -) From 99493b89da393c95c967d40e7bbca34cb1fc60ec Mon Sep 17 00:00:00 2001 From: Leo Antoli <430982+lantoli@users.noreply.github.com> Date: Thu, 26 Sep 2024 17:09:09 +0200 Subject: [PATCH 03/15] feat: Adds `custom_zone_mapping_zone_id` to `mongodbatlas_global_cluster_config` and deprecates `custom_zone_mapping` (#2637) * change region for backup test * changelog * Revert "change region for backup test" This reverts commit afe2487356ee1e14b8202327c40a32778a5473ee. * add attribute * ds changelog * doc * unclosed quote * deprecated message in attributes * test custom_zone_mapping_zone_id * add custom_zone_mapping_zone_id to database test * depends on cluster * use old API only for custom_zone_mapping * fix mig test * use DeprecationParamByVersionWithReplacement --- .changelog/2637.txt | 15 ++++ docs/data-sources/global_cluster_config.md | 5 +- docs/resources/global_cluster_config.md | 3 +- internal/common/constant/deprecation.go | 4 +- .../data_source_global_cluster_config.go | 30 +++++-- .../resource_global_cluster_config.go | 78 +++++++++++-------- ...ce_global_cluster_config_migration_test.go | 3 +- .../resource_global_cluster_config_test.go | 64 +++++++++++---- .../service/project/data_source_project.go | 2 +- .../service/project/data_source_projects.go | 2 +- internal/service/project/resource_project.go | 2 +- 11 files changed, 144 insertions(+), 64 deletions(-) create mode 100644 .changelog/2637.txt diff --git a/.changelog/2637.txt b/.changelog/2637.txt new file mode 100644 index 0000000000..a627ff780c --- /dev/null +++ b/.changelog/2637.txt @@ -0,0 +1,15 @@ +```release-note:enhancement +resource/mongodbatlas_global_cluster_config: Adds `custom_zone_mapping_zone_id` attribute +``` + +```release-note:enhancement +data-source/mongodbatlas_global_cluster_config: Adds `custom_zone_mapping_zone_id` attribute +``` + +```release-note:note +resource/mongodbatlas_global_cluster_config: Deprecates `custom_zone_mapping` in favor of `custom_zone_mapping_zone_id` +``` + +```release-note:note +data-source/mongodbatlas_global_cluster_config: Deprecates `custom_zone_mapping` in favor of `custom_zone_mapping_zone_id` +``` diff --git a/docs/data-sources/global_cluster_config.md b/docs/data-sources/global_cluster_config.md index 42fd408e27..23c8d47e62 100644 --- a/docs/data-sources/global_cluster_config.md +++ b/docs/data-sources/global_cluster_config.md @@ -97,14 +97,15 @@ resource "mongodbatlas_global_cluster_config" "config" { ## Argument Reference * `project_id` - (Required) The unique ID for the project to create the database user. -* `cluster_name - (Required) The name of the Global Cluster. +* `cluster_name` - (Required) The name of the Global Cluster. ## Attributes Reference In addition to all arguments above, the following attributes are exported: * `id` - The Terraform's unique identifier used internally for state management. -* `custom_zone_mapping` - A map of all custom zone mappings defined for the Global Cluster. Atlas automatically maps each location code to the closest geographical zone. Custom zone mappings allow administrators to override these automatic mappings. If your Global Cluster does not have any custom zone mappings, this document is empty. +* `custom_zone_mapping_zone_id` - A map of all custom zone mappings defined for the Global Cluster to `replication_specs.*.zone_id`. Atlas automatically maps each location code to the closest geographical zone. Custom zone mappings allow administrators to override these automatic mappings. If your Global Cluster does not have any custom zone mappings, this document is empty. +* `custom_zone_mapping` - (Deprecated) A map of all custom zone mappings defined for the Global Cluster to `replication_specs.*.id`. This attribute is deprecated, use `custom_zone_mapping_zone_id` instead. * `managed_namespaces` - Add a managed namespaces to a Global Cluster. For more information about managed namespaces, see [Global Clusters](https://docs.atlas.mongodb.com/reference/api/global-clusters/). See [Managed Namespace](#managed-namespace) below for more details. ### Managed Namespace diff --git a/docs/resources/global_cluster_config.md b/docs/resources/global_cluster_config.md index f672120dcf..184535ad23 100644 --- a/docs/resources/global_cluster_config.md +++ b/docs/resources/global_cluster_config.md @@ -92,7 +92,8 @@ resource "mongodbatlas_global_cluster_config" "config" { In addition to all arguments above, the following attributes are exported: * `id` - The Terraform's unique identifier used internally for state management. -* `custom_zone_mapping` - A map of all custom zone mappings defined for the Global Cluster. Atlas automatically maps each location code to the closest geographical zone. Custom zone mappings allow administrators to override these automatic mappings. If your Global Cluster does not have any custom zone mappings, this document is empty. +* `custom_zone_mapping_zone_id` - A map of all custom zone mappings defined for the Global Cluster to `replication_specs.*.zone_id`. Atlas automatically maps each location code to the closest geographical zone. Custom zone mappings allow administrators to override these automatic mappings. If your Global Cluster does not have any custom zone mappings, this document is empty. +* `custom_zone_mapping` - (Deprecated) A map of all custom zone mappings defined for the Global Cluster to `replication_specs.*.id`. This attribute is deprecated, use `custom_zone_mapping_zone_id` instead. ## Import diff --git a/internal/common/constant/deprecation.go b/internal/common/constant/deprecation.go index 72211322d2..88fc9c40e6 100644 --- a/internal/common/constant/deprecation.go +++ b/internal/common/constant/deprecation.go @@ -3,10 +3,8 @@ package constant const ( DeprecationParam = "This parameter is deprecated." DeprecationParamWithReplacement = "This parameter is deprecated. Please transition to %s." - DeprecationParamByDate = "This parameter is deprecated and will be removed by %s." - DeprecationParamByDateWithReplacement = "This parameter is deprecated and will be removed by %s. Please transition to %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" - DeprecationParamByVersion = "This parameter is deprecated and will be removed in version %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." ) diff --git a/internal/service/globalclusterconfig/data_source_global_cluster_config.go b/internal/service/globalclusterconfig/data_source_global_cluster_config.go index 099c4af659..c7c2a226f0 100644 --- a/internal/service/globalclusterconfig/data_source_global_cluster_config.go +++ b/internal/service/globalclusterconfig/data_source_global_cluster_config.go @@ -7,6 +7,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/config" ) @@ -54,6 +55,11 @@ func DataSource() *schema.Resource { }, }, "custom_zone_mapping": { + Deprecated: fmt.Sprintf(constant.DeprecationParamByVersionWithReplacement, "1.23.0", "custom_zone_mapping_zone_id"), + Type: schema.TypeMap, + Computed: true, + }, + "custom_zone_mapping_zone_id": { Type: schema.TypeMap, Computed: true, }, @@ -62,28 +68,38 @@ func DataSource() *schema.Resource { } func dataSourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + connV2 := meta.(*config.MongoDBClient).AtlasV2 connV220240530 := meta.(*config.MongoDBClient).AtlasV220240530 projectID := d.Get("project_id").(string) clusterName := d.Get("cluster_name").(string) - globalCluster, resp, err := connV220240530.GlobalClustersApi.GetManagedNamespace(ctx, projectID, clusterName).Execute() + resp, httpResp, err := connV2.GlobalClustersApi.GetManagedNamespace(ctx, projectID, clusterName).Execute() if err != nil { - if resp != nil && resp.StatusCode == http.StatusNotFound { + if httpResp.StatusCode == http.StatusNotFound { + d.SetId("") return nil } - return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) } - - if err := d.Set("managed_namespaces", flattenManagedNamespaces(globalCluster.GetManagedNamespaces())); err != nil { + oldResp, httpResp, err := connV220240530.GlobalClustersApi.GetManagedNamespace(ctx, projectID, clusterName).Execute() + if err != nil { + if httpResp.StatusCode == http.StatusNotFound { + d.SetId("") + return nil + } return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) } - if err := d.Set("custom_zone_mapping", globalCluster.GetCustomZoneMapping()); err != nil { + if err := d.Set("managed_namespaces", flattenManagedNamespaces(resp.GetManagedNamespaces())); err != nil { + return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) + } + if err := d.Set("custom_zone_mapping_zone_id", resp.GetCustomZoneMapping()); err != nil { + return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) + } + if err := d.Set("custom_zone_mapping", oldResp.GetCustomZoneMapping()); err != nil { return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) } d.SetId(clusterName) - return nil } diff --git a/internal/service/globalclusterconfig/resource_global_cluster_config.go b/internal/service/globalclusterconfig/resource_global_cluster_config.go index ff1286d8e5..16b7f0197e 100644 --- a/internal/service/globalclusterconfig/resource_global_cluster_config.go +++ b/internal/service/globalclusterconfig/resource_global_cluster_config.go @@ -11,9 +11,10 @@ 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" - admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" // fixed to old API due to CLOUDP-263795 + "go.mongodb.org/atlas-sdk/v20240805004/admin" ) const ( @@ -93,6 +94,11 @@ func Resource() *schema.Resource { }, }, "custom_zone_mapping": { + Deprecated: fmt.Sprintf(constant.DeprecationParamByVersionWithReplacement, "1.23.0", "custom_zone_mapping_zone_id"), + Type: schema.TypeMap, + Computed: true, + }, + "custom_zone_mapping_zone_id": { Type: schema.TypeMap, Computed: true, }, @@ -101,7 +107,7 @@ func Resource() *schema.Resource { } func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { - connV220240530 := meta.(*config.MongoDBClient).AtlasV220240530 + connV2 := meta.(*config.MongoDBClient).AtlasV2 projectID := d.Get("project_id").(string) clusterName := d.Get("cluster_name").(string) @@ -109,25 +115,25 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. for _, m := range v.(*schema.Set).List() { mn := m.(map[string]any) - addManagedNamespace := &admin20240530.ManagedNamespace{ - Collection: conversion.StringPtr(mn["collection"].(string)), - Db: conversion.StringPtr(mn["db"].(string)), - CustomShardKey: conversion.StringPtr(mn["custom_shard_key"].(string)), + req := &admin.ManagedNamespaces{ + Collection: mn["collection"].(string), + Db: mn["db"].(string), + CustomShardKey: mn["custom_shard_key"].(string), } if isCustomShardKeyHashed, okCustomShard := mn["is_custom_shard_key_hashed"]; okCustomShard { - addManagedNamespace.IsCustomShardKeyHashed = conversion.Pointer[bool](isCustomShardKeyHashed.(bool)) + req.IsCustomShardKeyHashed = conversion.Pointer[bool](isCustomShardKeyHashed.(bool)) } if isShardKeyUnique, okShard := mn["is_shard_key_unique"]; okShard { - addManagedNamespace.IsShardKeyUnique = conversion.Pointer[bool](isShardKeyUnique.(bool)) + req.IsShardKeyUnique = conversion.Pointer[bool](isShardKeyUnique.(bool)) } err := retry.RetryContext(ctx, 2*time.Minute, func() *retry.RetryError { - _, _, err := connV220240530.GlobalClustersApi.CreateManagedNamespace(ctx, projectID, clusterName, addManagedNamespace).Execute() + _, _, err := connV2.GlobalClustersApi.CreateManagedNamespace(ctx, projectID, clusterName, req).Execute() if err != nil { - if admin20240530.IsErrorCode(err, "DUPLICATE_MANAGED_NAMESPACE") { - if err := removeManagedNamespaces(ctx, connV220240530, v.(*schema.Set).List(), projectID, clusterName); err != nil { + if admin.IsErrorCode(err, "DUPLICATE_MANAGED_NAMESPACE") { + if err := removeManagedNamespaces(ctx, connV2, v.(*schema.Set).List(), projectID, clusterName); err != nil { return retry.NonRetryableError(fmt.Errorf(errorGlobalClusterCreate, err)) } return retry.RetryableError(err) @@ -143,13 +149,13 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. } if v, ok := d.GetOk("custom_zone_mappings"); ok { - _, _, err := connV220240530.GlobalClustersApi.CreateCustomZoneMapping(ctx, projectID, clusterName, &admin20240530.CustomZoneMappings{ + _, _, err := connV2.GlobalClustersApi.CreateCustomZoneMapping(ctx, projectID, clusterName, &admin.CustomZoneMappings{ CustomZoneMappings: newCustomZoneMappings(v.(*schema.Set).List()), }).Execute() if err != nil { if v2, ok2 := d.GetOk("managed_namespaces"); ok2 { - if err := removeManagedNamespaces(ctx, connV220240530, v2.(*schema.Set).List(), projectID, clusterName); err != nil { + if err := removeManagedNamespaces(ctx, connV2, v2.(*schema.Set).List(), projectID, clusterName); err != nil { return diag.FromErr(fmt.Errorf(errorGlobalClusterCreate, err)) } } @@ -166,26 +172,36 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. } func resourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { - connV220240530 := meta.(*config.MongoDBClient).AtlasV220240530 // fixed to old API due to CLOUDP-263795 + connV2 := meta.(*config.MongoDBClient).AtlasV2 + connV220240530 := meta.(*config.MongoDBClient).AtlasV220240530 ids := conversion.DecodeStateID(d.Id()) projectID := ids["project_id"] clusterName := ids["cluster_name"] - globalCluster, resp, err := connV220240530.GlobalClustersApi.GetManagedNamespace(ctx, projectID, clusterName).Execute() + resp, httpResp, err := connV2.GlobalClustersApi.GetManagedNamespace(ctx, projectID, clusterName).Execute() if err != nil { - if resp != nil && resp.StatusCode == http.StatusNotFound { + if httpResp.StatusCode == http.StatusNotFound { d.SetId("") return nil } - return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) } - - if err := d.Set("managed_namespaces", flattenManagedNamespaces(globalCluster.GetManagedNamespaces())); err != nil { + oldResp, httpResp, err := connV220240530.GlobalClustersApi.GetManagedNamespace(ctx, projectID, clusterName).Execute() + if err != nil { + if httpResp.StatusCode == http.StatusNotFound { + d.SetId("") + return nil + } return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) } - if err := d.Set("custom_zone_mapping", globalCluster.GetCustomZoneMapping()); err != nil { + if err := d.Set("managed_namespaces", flattenManagedNamespaces(resp.GetManagedNamespaces())); err != nil { + return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) + } + if err := d.Set("custom_zone_mapping_zone_id", resp.GetCustomZoneMapping()); err != nil { + return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) + } + if err := d.Set("custom_zone_mapping", oldResp.GetCustomZoneMapping()); err != nil { return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) } @@ -199,20 +215,20 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. } func resourceDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { - connV220240530 := meta.(*config.MongoDBClient).AtlasV220240530 + connV2 := meta.(*config.MongoDBClient).AtlasV2 ids := conversion.DecodeStateID(d.Id()) projectID := ids["project_id"] clusterName := ids["cluster_name"] if v, ok := d.GetOk("managed_namespaces"); ok { - if err := removeManagedNamespaces(ctx, connV220240530, v.(*schema.Set).List(), projectID, clusterName); err != nil { + if err := removeManagedNamespaces(ctx, connV2, v.(*schema.Set).List(), projectID, clusterName); err != nil { return diag.FromErr(fmt.Errorf(errorGlobalClusterDelete, clusterName, err)) } } if v, ok := d.GetOk("custom_zone_mappings"); ok { if v.(*schema.Set).Len() > 0 { - if _, _, err := connV220240530.GlobalClustersApi.DeleteAllCustomZoneMappings(ctx, projectID, clusterName).Execute(); err != nil { + if _, _, err := connV2.GlobalClustersApi.DeleteAllCustomZoneMappings(ctx, projectID, clusterName).Execute(); err != nil { return diag.FromErr(fmt.Errorf(errorGlobalClusterDelete, clusterName, err)) } } @@ -221,7 +237,7 @@ func resourceDelete(ctx context.Context, d *schema.ResourceData, meta any) diag. return nil } -func flattenManagedNamespaces(managedNamespaces []admin20240530.ManagedNamespaces) []map[string]any { +func flattenManagedNamespaces(managedNamespaces []admin.ManagedNamespaces) []map[string]any { var results []map[string]any if len(managedNamespaces) > 0 { @@ -265,17 +281,17 @@ func resourceImport(ctx context.Context, d *schema.ResourceData, meta any) ([]*s return []*schema.ResourceData{d}, nil } -func removeManagedNamespaces(ctx context.Context, connV220240530 *admin20240530.APIClient, remove []any, projectID, clusterName string) error { +func removeManagedNamespaces(ctx context.Context, connV2 *admin.APIClient, remove []any, projectID, clusterName string) error { for _, m := range remove { mn := m.(map[string]any) - managedNamespace := &admin20240530.DeleteManagedNamespaceApiParams{ + managedNamespace := &admin.DeleteManagedNamespaceApiParams{ Collection: conversion.StringPtr(mn["collection"].(string)), Db: conversion.StringPtr(mn["db"].(string)), ClusterName: clusterName, GroupId: projectID, } - _, _, err := connV220240530.GlobalClustersApi.DeleteManagedNamespaceWithParams(ctx, managedNamespace).Execute() + _, _, err := connV2.GlobalClustersApi.DeleteManagedNamespaceWithParams(ctx, managedNamespace).Execute() if err != nil { return err @@ -284,12 +300,12 @@ func removeManagedNamespaces(ctx context.Context, connV220240530 *admin20240530. return nil } -func newCustomZoneMapping(tfMap map[string]any) *admin20240530.ZoneMapping { +func newCustomZoneMapping(tfMap map[string]any) *admin.ZoneMapping { if tfMap == nil { return nil } - apiObject := &admin20240530.ZoneMapping{ + apiObject := &admin.ZoneMapping{ Location: tfMap["location"].(string), Zone: tfMap["zone"].(string), } @@ -297,12 +313,12 @@ func newCustomZoneMapping(tfMap map[string]any) *admin20240530.ZoneMapping { return apiObject } -func newCustomZoneMappings(tfList []any) *[]admin20240530.ZoneMapping { +func newCustomZoneMappings(tfList []any) *[]admin.ZoneMapping { if len(tfList) == 0 { return nil } - apiObjects := make([]admin20240530.ZoneMapping, len(tfList)) + apiObjects := make([]admin.ZoneMapping, len(tfList)) if len(tfList) > 0 { for i, tfMapRaw := range tfList { if tfMap, ok := tfMapRaw.(map[string]any); ok { diff --git a/internal/service/globalclusterconfig/resource_global_cluster_config_migration_test.go b/internal/service/globalclusterconfig/resource_global_cluster_config_migration_test.go index d19f1258f0..8ad7fbf039 100644 --- a/internal/service/globalclusterconfig/resource_global_cluster_config_migration_test.go +++ b/internal/service/globalclusterconfig/resource_global_cluster_config_migration_test.go @@ -7,5 +7,6 @@ import ( ) func TestMigGlobalClusterConfig_basic(t *testing.T) { - mig.CreateAndRunTest(t, basicTestCase(t, false)) + checkZoneID := mig.IsProviderVersionAtLeast("1.21.0") + mig.CreateAndRunTest(t, basicTestCase(t, checkZoneID, false)) } diff --git a/internal/service/globalclusterconfig/resource_global_cluster_config_test.go b/internal/service/globalclusterconfig/resource_global_cluster_config_test.go index 52d3a45013..e2760e5a81 100644 --- a/internal/service/globalclusterconfig/resource_global_cluster_config_test.go +++ b/internal/service/globalclusterconfig/resource_global_cluster_config_test.go @@ -19,16 +19,26 @@ const ( ) func TestAccGlobalClusterConfig_basic(t *testing.T) { - resource.ParallelTest(t, *basicTestCase(t, false)) + resource.ParallelTest(t, *basicTestCase(t, true, false)) } func TestAccGlobalClusterConfig_withBackup(t *testing.T) { - resource.ParallelTest(t, *basicTestCase(t, true)) + resource.ParallelTest(t, *basicTestCase(t, true, true)) } -func basicTestCase(tb testing.TB, withBackup bool) *resource.TestCase { +func basicTestCase(tb testing.TB, checkZoneID, withBackup bool) *resource.TestCase { tb.Helper() clusterInfo := acc.GetClusterInfo(tb, &acc.ClusterRequest{Geosharded: true, CloudBackup: withBackup}) + attrsMap := map[string]string{ + "cluster_name": clusterInfo.Name, + "managed_namespaces.#": "1", + "managed_namespaces.0.is_custom_shard_key_hashed": "false", + "managed_namespaces.0.is_shard_key_unique": "false", + "custom_zone_mapping.%": "1", + } + if checkZoneID { + attrsMap["custom_zone_mapping_zone_id.%"] = "1" + } return &resource.TestCase{ PreCheck: func() { acc.PreCheckBasic(tb) }, @@ -39,15 +49,8 @@ func basicTestCase(tb testing.TB, withBackup bool) *resource.TestCase { Config: configBasic(&clusterInfo, false, false), Check: resource.ComposeAggregateTestCheckFunc( checkExists(resourceName), - acc.CheckRSAndDS(resourceName, nil, nil, - []string{"custom_zone_mappings.#", "custom_zone_mapping.%", "custom_zone_mapping.CA", "project_id"}, - map[string]string{ - "cluster_name": clusterInfo.Name, - "managed_namespaces.#": "1", - "managed_namespaces.0.is_custom_shard_key_hashed": "false", - "managed_namespaces.0.is_shard_key_unique": "false", - }), - ), + checkZone(0, "CA", clusterInfo.ResourceName, checkZoneID), + acc.CheckRSAndDS(resourceName, conversion.Pointer(dataSourceName), nil, []string{"project_id"}, attrsMap)), }, { ResourceName: resourceName, @@ -118,11 +121,18 @@ func TestAccGlobalClusterConfig_database(t *testing.T) { Config: configWithDBConfig(&clusterInfo, customZone), Check: resource.ComposeAggregateTestCheckFunc( checkExists(resourceName), - acc.CheckRSAndDS(resourceName, nil, nil, - []string{"custom_zone_mappings.#", "custom_zone_mapping.%", "custom_zone_mapping.US", "custom_zone_mapping.IE", "custom_zone_mapping.DE", "project_id"}, + checkZone(0, "US", clusterInfo.ResourceName, true), + checkZone(1, "IE", clusterInfo.ResourceName, true), + checkZone(2, "DE", clusterInfo.ResourceName, true), + acc.CheckRSAndDS(resourceName, conversion.Pointer(dataSourceName), nil, + []string{"project_id"}, map[string]string{ "cluster_name": clusterInfo.Name, "managed_namespaces.#": "5", + "managed_namespaces.0.is_custom_shard_key_hashed": "false", + "managed_namespaces.0.is_shard_key_unique": "false", + "custom_zone_mapping_zone_id.%": "3", + "custom_zone_mapping.%": "3", }), ), }, @@ -141,6 +151,24 @@ func TestAccGlobalClusterConfig_database(t *testing.T) { }) } +func checkZone(pos int, zone, clusterName string, checkZoneID bool) resource.TestCheckFunc { + firstID := fmt.Sprintf("custom_zone_mapping.%s", zone) + secondID := fmt.Sprintf("replication_specs.%d.id", pos) + checks := []resource.TestCheckFunc{ + resource.TestCheckResourceAttrPair(resourceName, firstID, clusterName, secondID), + resource.TestCheckResourceAttrPair(dataSourceName, firstID, clusterName, secondID), + } + if checkZoneID { + firstZoneID := fmt.Sprintf("custom_zone_mapping_zone_id.%s", zone) + secondZoneID := fmt.Sprintf("replication_specs.%d.zone_id", pos) + checks = append(checks, + resource.TestCheckResourceAttrPair(resourceName, firstZoneID, clusterName, secondZoneID), + resource.TestCheckResourceAttrPair(dataSourceName, firstZoneID, clusterName, secondZoneID), + ) + } + return resource.ComposeAggregateTestCheckFunc(checks...) +} + func checkExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[resourceName] @@ -211,6 +239,8 @@ func configBasic(info *acc.ClusterInfo, isCustomShard, isShardKeyUnique bool) st location = "CA" zone = "Zone 1" } + + depends_on = [%[5]s] } data "mongodbatlas_global_cluster_config" "config" { @@ -218,7 +248,7 @@ func configBasic(info *acc.ClusterInfo, isCustomShard, isShardKeyUnique bool) st cluster_name = mongodbatlas_global_cluster_config.config.cluster_name depends_on = [mongodbatlas_global_cluster_config.config] } - `, info.TerraformNameRef, info.ProjectID, isCustomShard, isShardKeyUnique) + `, info.TerraformNameRef, info.ProjectID, isCustomShard, isShardKeyUnique, info.ResourceName) } func configWithDBConfig(info *acc.ClusterInfo, zones string) string { @@ -253,6 +283,8 @@ func configWithDBConfig(info *acc.ClusterInfo, zones string) string { custom_shard_key = "orgId" } %[3]s + + depends_on = [%[4]s] } data "mongodbatlas_global_cluster_config" "config" { @@ -260,5 +292,5 @@ func configWithDBConfig(info *acc.ClusterInfo, zones string) string { cluster_name = mongodbatlas_global_cluster_config.config.cluster_name depends_on = [mongodbatlas_global_cluster_config.config] } - `, info.TerraformNameRef, info.ProjectID, zones) + `, info.TerraformNameRef, info.ProjectID, zones, info.ResourceName) } diff --git a/internal/service/project/data_source_project.go b/internal/service/project/data_source_project.go index 4c2f0ef842..20e01f3859 100644 --- a/internal/service/project/data_source_project.go +++ b/internal/service/project/data_source_project.go @@ -142,7 +142,7 @@ func (d *projectDS) Schema(ctx context.Context, req datasource.SchemaRequest, re }, "ip_addresses": schema.SingleNestedAttribute{ Computed: true, - DeprecationMessage: fmt.Sprintf(constant.DeprecationParamByDateWithReplacement, "1.21.0", "mongodbatlas_project_ip_addresses data source"), + DeprecationMessage: fmt.Sprintf(constant.DeprecationParamByVersionWithReplacement, "1.21.0", "mongodbatlas_project_ip_addresses data source"), Attributes: map[string]schema.Attribute{ "services": schema.SingleNestedAttribute{ Computed: true, diff --git a/internal/service/project/data_source_projects.go b/internal/service/project/data_source_projects.go index 3ca709ef06..206861fc14 100644 --- a/internal/service/project/data_source_projects.go +++ b/internal/service/project/data_source_projects.go @@ -138,7 +138,7 @@ func (d *ProjectsDS) Schema(ctx context.Context, req datasource.SchemaRequest, r }, "ip_addresses": schema.SingleNestedAttribute{ Computed: true, - DeprecationMessage: fmt.Sprintf(constant.DeprecationParamByDateWithReplacement, "1.21.0", "mongodbatlas_project_ip_addresses data source"), + DeprecationMessage: fmt.Sprintf(constant.DeprecationParamByVersionWithReplacement, "1.21.0", "mongodbatlas_project_ip_addresses data source"), Attributes: map[string]schema.Attribute{ "services": schema.SingleNestedAttribute{ Computed: true, diff --git a/internal/service/project/resource_project.go b/internal/service/project/resource_project.go index 6b996dfff7..3d0b9d83b2 100644 --- a/internal/service/project/resource_project.go +++ b/internal/service/project/resource_project.go @@ -223,7 +223,7 @@ func (r *projectRS) Schema(ctx context.Context, req resource.SchemaRequest, resp }, "ip_addresses": schema.SingleNestedAttribute{ Computed: true, - DeprecationMessage: fmt.Sprintf(constant.DeprecationParamByDateWithReplacement, "1.21.0", "mongodbatlas_project_ip_addresses data source"), + DeprecationMessage: fmt.Sprintf(constant.DeprecationParamByVersionWithReplacement, "1.21.0", "mongodbatlas_project_ip_addresses data source"), PlanModifiers: []planmodifier.Object{ objectplanmodifier.UseStateForUnknown(), }, From 33a7afbc5d3af74017d59ef4bfc41c19900abc2f Mon Sep 17 00:00:00 2001 From: svc-apix-bot Date: Thu, 26 Sep 2024 15:11:04 +0000 Subject: [PATCH 04/15] chore: Updates CHANGELOG.md for #2637 --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a478ea5a9b..2cda6f0892 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ ## (Unreleased) +NOTES: + +* data-source/mongodbatlas_global_cluster_config: Deprecates `custom_zone_mapping` in favor of `custom_zone_mapping_zone_id` ([#2637](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2637)) +* resource/mongodbatlas_global_cluster_config: Deprecates `custom_zone_mapping` in favor of `custom_zone_mapping_zone_id` ([#2637](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2637)) + +ENHANCEMENTS: + +* data-source/mongodbatlas_global_cluster_config: Adds `custom_zone_mapping_zone_id` attribute ([#2637](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2637)) +* resource/mongodbatlas_global_cluster_config: Adds `custom_zone_mapping_zone_id` attribute ([#2637](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2637)) + ## 1.20.0 (September 20, 2024) BREAKING CHANGES: From 5fed862977639f88b96522d96d7136a15331228d Mon Sep 17 00:00:00 2001 From: Oriol Date: Fri, 27 Sep 2024 09:33:42 +0200 Subject: [PATCH 05/15] doc: Improves documentation for supported MongoDB versions in cluster and advanced_cluster (#2635) * improvee supported version docs * don't specify version --- docs/resources/advanced_cluster.md | 2 +- docs/resources/cluster.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/advanced_cluster.md b/docs/resources/advanced_cluster.md index 74775f039e..e73bf9ae72 100644 --- a/docs/resources/advanced_cluster.md +++ b/docs/resources/advanced_cluster.md @@ -382,7 +382,7 @@ This parameter defaults to false. * `encryption_at_rest_provider` - (Optional) Possible values are AWS, GCP, AZURE or NONE. Only needed if you desire to manage the keys, see [Encryption at Rest using Customer Key Management](https://docs.atlas.mongodb.com/security-kms-encryption/) for complete documentation. You must configure encryption at rest for the Atlas project before enabling it on any cluster in the project. For Documentation, see [AWS](https://docs.atlas.mongodb.com/security-aws-kms/), [GCP](https://docs.atlas.mongodb.com/security-kms-encryption/) and [Azure](https://docs.atlas.mongodb.com/security-azure-kms/#std-label-security-azure-kms). Requirements are if `replication_specs.#.region_configs.#.Specs.instance_size` is M10 or greater and `backup_enabled` is false or omitted. * `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 the following MongoDB versions for M10+ clusters: `4.4`, `5.0`, `6.0` or `7.0`. If omitted, Atlas deploys a cluster that runs MongoDB 7.0. If `replication_specs#.region_configs#.Specs.instance_size`: `M0`, `M2` or `M5`, Atlas deploys MongoDB 4.4. 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`. +* `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. * `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). diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index 31b6cc60cb..b9b48bc4bf 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -340,7 +340,7 @@ But in order to explicitly change `provider_instance_size_name` comment the `lif * `encryption_at_rest_provider` - (Optional) Possible values are AWS, GCP, AZURE or NONE. Only needed if you desire to manage the keys, see [Encryption at Rest using Customer Key Management](https://docs.atlas.mongodb.com/security-aws-kms/) for complete documentation. You must configure encryption at rest for the Atlas project before enabling it on any cluster in the project. For complete documentation on configuring Encryption at Rest, see Encryption at Rest using Customer Key Management. Requires M10 or greater. and for legacy backups, backup_enabled, to be false or omitted. **Note: Atlas encrypts all cluster storage and snapshot volumes, securing all cluster data on disk: a concept known as encryption at rest, by default**. * `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 the following MongoDB versions for M10+ clusters: `4.4`, `5.0`, `6.0` or `7.0`. If omitted, Atlas deploys a cluster that runs MongoDB 7.0. If `provider_instance_size_name`: `M0`, `M2` or `M5`, Atlas deploys MongoDB 5.0. 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. +* `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. * `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. From 2be98482ef5dc8c99e7b81b65614de618a309adc Mon Sep 17 00:00:00 2001 From: Leo Antoli <430982+lantoli@users.noreply.github.com> Date: Fri, 27 Sep 2024 10:39:04 +0200 Subject: [PATCH 06/15] fix: Enforces `priority` descending order in `region_configs` in `mongodbatlas_advanced_cluster` (#2640) * create * update * changelog * unit tests * test updates in old and new schema * apply feedback --- .changelog/2640.txt | 3 + .../advancedcluster/model_advanced_cluster.go | 27 +++++ .../model_advanced_cluster_test.go | 46 ++++++++ .../resource_advanced_cluster.go | 9 ++ .../resource_advanced_cluster_test.go | 105 ++++++++++++++++++ 5 files changed, 190 insertions(+) create mode 100644 .changelog/2640.txt diff --git a/.changelog/2640.txt b/.changelog/2640.txt new file mode 100644 index 0000000000..b64cd57a3f --- /dev/null +++ b/.changelog/2640.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/mongodbatlas_advanced_cluster: Enforces `priority` descending order in `region_configs` avoiding potential non-empty plans after apply +``` diff --git a/internal/service/advancedcluster/model_advanced_cluster.go b/internal/service/advancedcluster/model_advanced_cluster.go index 5523c35b89..e1c073d5a7 100644 --- a/internal/service/advancedcluster/model_advanced_cluster.go +++ b/internal/service/advancedcluster/model_advanced_cluster.go @@ -3,6 +3,7 @@ package advancedcluster import ( "bytes" "context" + "errors" "fmt" "hash/crc32" "log" @@ -398,6 +399,32 @@ func flattenTags(tags *[]admin.ResourceTag) []map[string]string { return ret } +// CheckRegionConfigsPriorityOrder will be deleted in CLOUDP-275825 +func CheckRegionConfigsPriorityOrder(regionConfigs []admin.ReplicationSpec20240805) error { + for _, spec := range regionConfigs { + configs := spec.GetRegionConfigs() + for i := 0; i < len(configs)-1; i++ { + if configs[i].GetPriority() < configs[i+1].GetPriority() { + return errors.New("priority values in region_configs must be in descending order") + } + } + } + return nil +} + +// CheckRegionConfigsPriorityOrderOld will be deleted in CLOUDP-275825 +func CheckRegionConfigsPriorityOrderOld(regionConfigs []admin20240530.ReplicationSpec) error { + for _, spec := range regionConfigs { + configs := spec.GetRegionConfigs() + for i := 0; i < len(configs)-1; i++ { + if configs[i].GetPriority() < configs[i+1].GetPriority() { + return errors.New("priority values in region_configs must be in descending order") + } + } + } + return nil +} + func flattenConnectionStrings(str admin.ClusterConnectionStrings) []map[string]any { return []map[string]any{ { diff --git a/internal/service/advancedcluster/model_advanced_cluster_test.go b/internal/service/advancedcluster/model_advanced_cluster_test.go index a311749cbe..f967de3b48 100644 --- a/internal/service/advancedcluster/model_advanced_cluster_test.go +++ b/internal/service/advancedcluster/model_advanced_cluster_test.go @@ -417,3 +417,49 @@ func TestIsChangeStreamOptionsMinRequiredMajorVersion(t *testing.T) { }) } } + +func TestCheckRegionConfigsPriorityOrder(t *testing.T) { + testCases := map[string]struct { + priorities []int + errorExpected bool + }{ + "Priority order 3 entries": { + priorities: []int{7, 6, 5}, + }, + "Priority order 2 entries": { + priorities: []int{7, 6}, + }, + "Only 1 entry": { + priorities: []int{7}, + }, + "Same order 3 entries": { + priorities: []int{7, 0, 0}, + }, + "Same order 2 entries": { + priorities: []int{0, 0}, + }, + "Invalid priority order 2 entries": { + priorities: []int{6, 7}, + errorExpected: true, + }, + "Invalid priority order 3 entries": { + priorities: []int{7, 5, 6}, + errorExpected: true, + }, + } + + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + 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([]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/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index 652c53b441..6196cea243 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -458,6 +458,9 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. } } + if err := CheckRegionConfigsPriorityOrder(params.GetReplicationSpecs()); err != nil { + return diag.FromErr(err) + } cluster, _, err := connV2.ClustersApi.CreateCluster(ctx, projectID, params).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorCreate, err)) @@ -799,6 +802,9 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. } clusterChangeDetect := new(admin20240530.AdvancedClusterDescription) if !reflect.DeepEqual(req, clusterChangeDetect) { + if err := CheckRegionConfigsPriorityOrderOld(req.GetReplicationSpecs()); err != nil { + return diag.FromErr(err) + } if _, _, err := connV220240530.ClustersApi.UpdateCluster(ctx, projectID, clusterName, req).Execute(); err != nil { return diag.FromErr(fmt.Errorf(errorUpdate, clusterName, err)) } @@ -823,6 +829,9 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. } clusterChangeDetect := new(admin.ClusterDescription20240805) if !reflect.DeepEqual(req, clusterChangeDetect) { + if err := CheckRegionConfigsPriorityOrder(req.GetReplicationSpecs()); err != nil { + return diag.FromErr(err) + } if _, _, err := connV2.ClustersApi.UpdateCluster(ctx, projectID, clusterName, req).Execute(); err != nil { return diag.FromErr(fmt.Errorf(errorUpdate, clusterName, err)) } diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index 935a34e5d2..92181c1685 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -804,6 +804,62 @@ func TestAccAdvancedCluster_replicaSetScalingStrategyOldSchema(t *testing.T) { }) } +// TestAccClusterAdvancedCluster_priorityOldSchema will be able to be simplied or deleted in CLOUDP-275825 +func TestAccClusterAdvancedCluster_priorityOldSchema(t *testing.T) { + var ( + projectID = acc.ProjectIDExecution(t) + clusterName = acc.RandomClusterName() + ) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acc.PreCheckBasic(t) }, + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configPriority(projectID, clusterName, true, true), + ExpectError: regexp.MustCompile("priority values in region_configs must be in descending order"), + }, + { + Config: configPriority(projectID, clusterName, true, false), + Check: resource.TestCheckResourceAttr(resourceName, "replication_specs.0.region_configs.#", "2"), + }, + { + Config: configPriority(projectID, clusterName, true, true), + ExpectError: regexp.MustCompile("priority values in region_configs must be in descending order"), + }, + }, + }) +} + +// TestAccClusterAdvancedCluster_priorityNewSchema will be able to be simplied or deleted in CLOUDP-275825 +func TestAccClusterAdvancedCluster_priorityNewSchema(t *testing.T) { + var ( + projectID = acc.ProjectIDExecution(t) + clusterName = acc.RandomClusterName() + ) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acc.PreCheckBasic(t) }, + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configPriority(projectID, clusterName, false, true), + ExpectError: regexp.MustCompile("priority values in region_configs must be in descending order"), + }, + { + Config: configPriority(projectID, clusterName, false, false), + Check: resource.TestCheckResourceAttr(resourceName, "replication_specs.0.region_configs.#", "2"), + }, + { + Config: configPriority(projectID, clusterName, false, true), + ExpectError: regexp.MustCompile("priority values in region_configs must be in descending order"), + }, + }, + }) +} + func checkAggr(attrsSet []string, attrsMap map[string]string, extra ...resource.TestCheckFunc) resource.TestCheckFunc { checks := []resource.TestCheckFunc{checkExists(resourceName)} checks = acc.AddAttrChecks(resourceName, checks, attrsMap) @@ -2124,3 +2180,52 @@ func checkReplicaSetScalingStrategy(replicaSetScalingStrategy string) resource.T additionalChecks..., ) } + +func configPriority(projectID, name string, oldSchema, swapPriorities bool) string { + const ( + config7 = ` + region_configs { + provider_name = "AWS" + priority = 7 + region_name = "US_EAST_1" + electable_specs { + node_count = 2 + instance_size = "M10" + } + } + ` + config6 = ` + region_configs { + provider_name = "AWS" + priority = 6 + region_name = "US_WEST_2" + electable_specs { + node_count = 1 + instance_size = "M10" + } + } + ` + ) + strType, strNumShards, strConfigs := "REPLICASET", "", config7+config6 + if oldSchema { + strType = "SHARDED" + strNumShards = "num_shards = 2" + } + if swapPriorities { + strConfigs = config6 + config7 + } + + return fmt.Sprintf(` + resource "mongodbatlas_advanced_cluster" "test" { + project_id = %[1]q + name = %[2]q + cluster_type = %[3]q + backup_enabled = false + + replication_specs { + %[4]s + %[5]s + } + } + `, projectID, name, strType, strNumShards, strConfigs) +} From 7373f6229f89f7a09623257574c536ea0060eb24 Mon Sep 17 00:00:00 2001 From: svc-apix-bot Date: Fri, 27 Sep 2024 08:40:58 +0000 Subject: [PATCH 07/15] chore: Updates CHANGELOG.md for #2640 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cda6f0892..d3ffb74e27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ ENHANCEMENTS: * data-source/mongodbatlas_global_cluster_config: Adds `custom_zone_mapping_zone_id` attribute ([#2637](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2637)) * resource/mongodbatlas_global_cluster_config: Adds `custom_zone_mapping_zone_id` attribute ([#2637](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2637)) +BUG FIXES: + +* resource/mongodbatlas_advanced_cluster: Enforces `priority` descending order in `region_configs` avoiding potential non-empty plans after apply ([#2640](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2640)) + ## 1.20.0 (September 20, 2024) BREAKING CHANGES: From 988a1d783ff6ceaa9ecad09f6d3044d1be8e396b Mon Sep 17 00:00:00 2001 From: Leo Antoli <430982+lantoli@users.noreply.github.com> Date: Fri, 27 Sep 2024 16:26:59 +0200 Subject: [PATCH 08/15] use new projects in tests (#2643) --- .../resource_advanced_cluster_test.go | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index 92181c1685..cf3ea6c584 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -807,7 +807,8 @@ func TestAccAdvancedCluster_replicaSetScalingStrategyOldSchema(t *testing.T) { // TestAccClusterAdvancedCluster_priorityOldSchema will be able to be simplied or deleted in CLOUDP-275825 func TestAccClusterAdvancedCluster_priorityOldSchema(t *testing.T) { var ( - projectID = acc.ProjectIDExecution(t) + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region clusterName = acc.RandomClusterName() ) @@ -817,15 +818,15 @@ func TestAccClusterAdvancedCluster_priorityOldSchema(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configPriority(projectID, clusterName, true, true), + Config: configPriority(orgID, projectName, clusterName, true, true), ExpectError: regexp.MustCompile("priority values in region_configs must be in descending order"), }, { - Config: configPriority(projectID, clusterName, true, false), + Config: configPriority(orgID, projectName, clusterName, true, false), Check: resource.TestCheckResourceAttr(resourceName, "replication_specs.0.region_configs.#", "2"), }, { - Config: configPriority(projectID, clusterName, true, true), + Config: configPriority(orgID, projectName, clusterName, true, true), ExpectError: regexp.MustCompile("priority values in region_configs must be in descending order"), }, }, @@ -835,7 +836,8 @@ 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) { var ( - projectID = acc.ProjectIDExecution(t) + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region clusterName = acc.RandomClusterName() ) @@ -845,15 +847,15 @@ func TestAccClusterAdvancedCluster_priorityNewSchema(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configPriority(projectID, clusterName, false, true), + Config: configPriority(orgID, projectName, clusterName, false, true), ExpectError: regexp.MustCompile("priority values in region_configs must be in descending order"), }, { - Config: configPriority(projectID, clusterName, false, false), + Config: configPriority(orgID, projectName, clusterName, false, false), Check: resource.TestCheckResourceAttr(resourceName, "replication_specs.0.region_configs.#", "2"), }, { - Config: configPriority(projectID, clusterName, false, true), + Config: configPriority(orgID, projectName, clusterName, false, true), ExpectError: regexp.MustCompile("priority values in region_configs must be in descending order"), }, }, @@ -2181,7 +2183,7 @@ func checkReplicaSetScalingStrategy(replicaSetScalingStrategy string) resource.T ) } -func configPriority(projectID, name string, oldSchema, swapPriorities bool) string { +func configPriority(orgID, projectName, clusterName string, oldSchema, swapPriorities bool) string { const ( config7 = ` region_configs { @@ -2216,16 +2218,21 @@ func configPriority(projectID, name string, oldSchema, swapPriorities bool) stri } return fmt.Sprintf(` + resource "mongodbatlas_project" "test" { + org_id = %[1]q + name = %[2]q + } + resource "mongodbatlas_advanced_cluster" "test" { - project_id = %[1]q - name = %[2]q - cluster_type = %[3]q + project_id = mongodbatlas_project.test.id + name = %[3]q + cluster_type = %[4]q backup_enabled = false replication_specs { - %[4]s %[5]s + %[6]s } } - `, projectID, name, strType, strNumShards, strConfigs) + `, orgID, projectName, clusterName, strType, strNumShards, strConfigs) } From 33906a9019491317d11f0edd095c79bc2f41862c Mon Sep 17 00:00:00 2001 From: Leo Antoli <430982+lantoli@users.noreply.github.com> Date: Tue, 1 Oct 2024 11:14:43 +0100 Subject: [PATCH 09/15] chore: Updates TF to 1.9.6, Go to 1.23.1 and Go linter to 1.61.0 (#2647) * update TF to 1.9.6 * update Go to 1.23.1 * update Go linter to v1.61.0 --- .github/workflows/code-health.yml | 2 +- .tool-versions | 4 ++-- GNUmakefile | 2 +- scripts/generate-doc.sh | 2 +- scripts/generate-docs-all.sh | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/code-health.yml b/.github/workflows/code-health.yml index 13a78afa54..c76f8f4ffd 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@aaa42aa0628b4ae2578232a66b541047968fac86 with: - version: v1.60.3 # Also update GOLANGCI_VERSION variable in GNUmakefile when updating this version + version: v1.61.0 # Also update GOLANGCI_VERSION variable in GNUmakefile when updating this version - name: actionlint run: | make tools diff --git a/.tool-versions b/.tool-versions index 46456547b9..0dfc294abc 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -golang 1.23.0 -terraform 1.9.5 +golang 1.23.1 +terraform 1.9.6 diff --git a/GNUmakefile b/GNUmakefile index 5b523e1965..afdda4f647 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.60.3 # Also update golangci-lint GH action in code-health.yml when updating this version +GOLANGCI_VERSION=v1.61.0 # 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 diff --git a/scripts/generate-doc.sh b/scripts/generate-doc.sh index ed9f8926c4..82eb51f9b3 100755 --- a/scripts/generate-doc.sh +++ b/scripts/generate-doc.sh @@ -32,7 +32,7 @@ set -euo pipefail -TF_VERSION="${TF_VERSION:-"1.9.2"}" # TF version to use when running tfplugindocs. Default: 1.9.2 +TF_VERSION="${TF_VERSION:-"1.9.6"}" # TF version to use when running tfplugindocs. Default: 1.9.6 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 15251d6099..6133d62a64 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.2"}" # TF version to use when running tfplugindocs. Default: 1.9.2 +TF_VERSION="${TF_VERSION:-"1.9.6"}" # TF version to use when running tfplugindocs. Default: 1.9.6 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 From 673db4603803a62a63a8c0b51bd72ae472214a3f Mon Sep 17 00:00:00 2001 From: Leo Antoli <430982+lantoli@users.noreply.github.com> Date: Tue, 1 Oct 2024 16:27:26 +0100 Subject: [PATCH 10/15] go1.23.1 (#2648) --- .tool-versions | 1 - go.mod | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.tool-versions b/.tool-versions index 0dfc294abc..649bc5eb3f 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1 @@ -golang 1.23.1 terraform 1.9.6 diff --git a/go.mod b/go.mod index 514876e7a4..26fe76562f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/mongodb/terraform-provider-mongodbatlas -go 1.23 +go 1.23.1 require ( github.com/andygrunwald/go-jira/v2 v2.0.0-20240116150243-50d59fe116d6 From ab4b9ed209e4ba37b6c5c93c6c4cb9d755ec6596 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:33:41 +0100 Subject: [PATCH 11/15] chore: Bump tj-actions/verify-changed-files (#2650) Bumps [tj-actions/verify-changed-files](https://github.com/tj-actions/verify-changed-files) from c55299aaf3f1f7bf2a782f00ba79897f92432d8b to bbd436f8e34e14fee2a0f7bc5b14bcc6b40927cf. - [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/c55299aaf3f1f7bf2a782f00ba79897f92432d8b...bbd436f8e34e14fee2a0f7bc5b14bcc6b40927cf) --- 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> --- .github/workflows/update-sdk.yml | 2 +- .github/workflows/update_tf_compatibility_matrix.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-sdk.yml b/.github/workflows/update-sdk.yml index a56f2e13d3..6d2ef38e89 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@c55299aaf3f1f7bf2a782f00ba79897f92432d8b + uses: tj-actions/verify-changed-files@bbd436f8e34e14fee2a0f7bc5b14bcc6b40927cf id: verify-changed-files - name: Create PR uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f diff --git a/.github/workflows/update_tf_compatibility_matrix.yml b/.github/workflows/update_tf_compatibility_matrix.yml index f1030d6377..8b5c2fe547 100644 --- a/.github/workflows/update_tf_compatibility_matrix.yml +++ b/.github/workflows/update_tf_compatibility_matrix.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@c55299aaf3f1f7bf2a782f00ba79897f92432d8b + uses: tj-actions/verify-changed-files@bbd436f8e34e14fee2a0f7bc5b14bcc6b40927cf id: verify-changed-files - name: Create PR uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f From 97781fa604f379b7819e1336d1797de7062df1ab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:34:03 +0100 Subject: [PATCH 12/15] chore: Bump actions/checkout from 4.1.7 to 4.2.0 (#2649) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.0. - [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/692973e3d937129bcbf40652eb9f2f61becf3332...d632683dd7b4114ad314bca15554477dd762a938) --- updated-dependencies: - dependency-name: actions/checkout 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> --- .github/workflows/acceptance-tests-runner.yml | 46 +++++++++---------- .../workflows/check-changelog-entry-file.yml | 2 +- .github/workflows/check-migration-guide.yml | 2 +- .github/workflows/cleanup-test-env.yml | 4 +- .github/workflows/code-health.yml | 10 ++-- .github/workflows/examples.yml | 4 +- .github/workflows/jira-release-version.yml | 2 +- .github/workflows/notify-docs-team.yml | 2 +- .github/workflows/release.yml | 6 +-- .github/workflows/run-script-and-commit.yml | 2 +- .../terraform-compatibility-matrix.yml | 4 +- .github/workflows/update-sdk.yml | 2 +- .../update_tf_compatibility_matrix.yml | 2 +- 13 files changed, 44 insertions(+), 44 deletions(-) diff --git a/.github/workflows/acceptance-tests-runner.yml b/.github/workflows/acceptance-tests-runner.yml index b2c7bf5ce0..bd58a88ada 100644 --- a/.github/workflows/acceptance-tests-runner.yml +++ b/.github/workflows/acceptance-tests-runner.yml @@ -183,7 +183,7 @@ jobs: provider_version: ${{ inputs.provider_version || steps.get_last_release.outputs.last_provider_version }} steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - name: Get Last Release id: get_last_release shell: bash @@ -220,7 +220,7 @@ jobs: serverless: ${{ steps.filter.outputs.serverless == 'true' || env.mustTrigger == 'true' }} stream: ${{ steps.filter.outputs.stream == 'true' || env.mustTrigger == 'true' }} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 id: filter if: ${{ inputs.test_group == '' && env.mustTrigger == 'false' }} @@ -314,7 +314,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -336,7 +336,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -376,7 +376,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -414,7 +414,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -436,7 +436,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -458,7 +458,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -480,7 +480,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -525,7 +525,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -561,7 +561,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -583,7 +583,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -621,7 +621,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -648,7 +648,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -670,7 +670,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -699,7 +699,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -721,7 +721,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -766,7 +766,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -804,7 +804,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -829,7 +829,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -851,7 +851,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -873,7 +873,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 @@ -900,7 +900,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.ref || github.ref }} - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 diff --git a/.github/workflows/check-changelog-entry-file.yml b/.github/workflows/check-changelog-entry-file.yml index 3f8f275793..9b180ac18c 100644 --- a/.github/workflows/check-changelog-entry-file.yml +++ b/.github/workflows/check-changelog-entry-file.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 with: go-version-file: 'go.mod' diff --git a/.github/workflows/check-migration-guide.yml b/.github/workflows/check-migration-guide.yml index 6a50e14c31..b06a80321d 100644 --- a/.github/workflows/check-migration-guide.yml +++ b/.github/workflows/check-migration-guide.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 id: changes with: diff --git a/.github/workflows/cleanup-test-env.yml b/.github/workflows/cleanup-test-env.yml index 5bce1f3c33..a5c46ca206 100644 --- a/.github/workflows/cleanup-test-env.yml +++ b/.github/workflows/cleanup-test-env.yml @@ -11,7 +11,7 @@ jobs: permissions: {} steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: sparse-checkout: | scripts @@ -29,7 +29,7 @@ jobs: permissions: {} steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: sparse-checkout: | scripts diff --git a/.github/workflows/code-health.yml b/.github/workflows/code-health.yml index c76f8f4ffd..cfe41883c8 100644 --- a/.github/workflows/code-health.yml +++ b/.github/workflows/code-health.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 with: go-version-file: 'go.mod' @@ -29,7 +29,7 @@ jobs: permissions: pull-requests: write # Needed by sticky-pull-request-comment steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 with: go-version-file: 'go.mod' @@ -40,7 +40,7 @@ jobs: permissions: {} steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - name: Install Go uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 with: @@ -60,14 +60,14 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - name: Run ShellCheck uses: bewuethr/shellcheck-action@d01912909579c4b1a335828b8fca197fbb8e0aa4 generate-doc-check: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - run: make tools generate-docs-all - name: Find mutations id: self_mutation diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index a0667e5f6e..b3b5edebe7 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 with: go-version-file: 'go.mod' @@ -31,7 +31,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 with: go-version-file: 'go.mod' diff --git a/.github/workflows/jira-release-version.yml b/.github/workflows/jira-release-version.yml index bc0c881d00..d3005bcfc5 100644 --- a/.github/workflows/jira-release-version.yml +++ b/.github/workflows/jira-release-version.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - name: Validation of version format, no pre-releases run: | echo "${{ inputs.version_number }}" | grep -P '^v\d+\.\d+\.\d+$' diff --git a/.github/workflows/notify-docs-team.yml b/.github/workflows/notify-docs-team.yml index 2eac3ba993..18bdc8019b 100644 --- a/.github/workflows/notify-docs-team.yml +++ b/.github/workflows/notify-docs-team.yml @@ -13,7 +13,7 @@ jobs: permissions: pull-requests: read steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 id: changes with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 589edb3967..843a557d47 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,7 +41,7 @@ jobs: run: | echo "${{ inputs.version_number }}" | grep -P '^v\d+\.\d+\.\d+(-pre[A-Za-z0-9-]*)?$' - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.use_existing_tag == 'true' && inputs.version_number || 'master' }} - name: Check for Upgrade Guide @@ -94,7 +94,7 @@ jobs: && needs.release-config.outputs.creates_new_tag == 'true' steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: 'master' - name: Get the latest commit SHA @@ -131,7 +131,7 @@ jobs: && !contains(needs.*.result, 'failure') steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: ref: ${{ inputs.version_number }} - name: Set up Go diff --git a/.github/workflows/run-script-and-commit.yml b/.github/workflows/run-script-and-commit.yml index e80f5b0af4..2357e6d2be 100644 --- a/.github/workflows/run-script-and-commit.yml +++ b/.github/workflows/run-script-and-commit.yml @@ -29,7 +29,7 @@ jobs: permissions: {} steps: - name: Checkout repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 with: fetch-depth: 0 token: ${{ secrets.apix_bot_pat }} diff --git a/.github/workflows/terraform-compatibility-matrix.yml b/.github/workflows/terraform-compatibility-matrix.yml index 7e6799f8f6..a0c02f0b20 100644 --- a/.github/workflows/terraform-compatibility-matrix.yml +++ b/.github/workflows/terraform-compatibility-matrix.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - name: Get HashiCorp Terraform supported versions shell: bash id: get-terraform-supported-versions @@ -56,7 +56,7 @@ jobs: runs-on: ubuntu-latest permissions: {} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - name: Get content of slack message id: slack-payload run: | diff --git a/.github/workflows/update-sdk.yml b/.github/workflows/update-sdk.yml index 6d2ef38e89..200b087992 100644 --- a/.github/workflows/update-sdk.yml +++ b/.github/workflows/update-sdk.yml @@ -13,7 +13,7 @@ jobs: pull-requests: write steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 with: go-version-file: 'go.mod' diff --git a/.github/workflows/update_tf_compatibility_matrix.yml b/.github/workflows/update_tf_compatibility_matrix.yml index 8b5c2fe547..8c4e582612 100644 --- a/.github/workflows/update_tf_compatibility_matrix.yml +++ b/.github/workflows/update_tf_compatibility_matrix.yml @@ -13,7 +13,7 @@ jobs: pull-requests: write steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - name: Update files env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 9b3d0e34cf937815077fa7545bd76bb19d1f82d4 Mon Sep 17 00:00:00 2001 From: Leo Antoli <430982+lantoli@users.noreply.github.com> Date: Wed, 2 Oct 2024 09:58:02 +0100 Subject: [PATCH 13/15] change only latest version (#2652) --- scripts/update-sdk.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/update-sdk.sh b/scripts/update-sdk.sh index b31a10caf4..c3f1c6baad 100755 --- a/scripts/update-sdk.sh +++ b/scripts/update-sdk.sh @@ -16,10 +16,20 @@ set -euo pipefail +CURRENT_SDK_RELEASE=$(grep 'go.mongodb.org/atlas-sdk/v' go.mod | + awk '{print $1}' | + sed 's/go.mongodb.org\/atlas-sdk\///' | + sort -V | + tail -n 1) +echo "CURRENT_SDK_RELEASE: $CURRENT_SDK_RELEASE" + LATEST_SDK_TAG=$(curl -sSfL -X GET https://api.github.com/repos/mongodb/atlas-sdk-go/releases/latest | jq -r '.tag_name') +echo "LATEST_SDK_TAG: $LATEST_SDK_TAG" LATEST_SDK_RELEASE=$(echo "${LATEST_SDK_TAG}" | cut -d '.' -f 1) -echo "==> Updating SDK to latest major version ${LATEST_SDK_TAG}" -gomajor get "go.mongodb.org/atlas-sdk/${LATEST_SDK_RELEASE}@${LATEST_SDK_TAG}" +echo "LATEST_SDK_RELEASE: $LATEST_SDK_RELEASE" +echo "==> Updating SDK ${CURRENT_SDK_RELEASE} to latest major version ${LATEST_SDK_TAG}" + +gomajor get --rewrite "go.mongodb.org/atlas-sdk/${CURRENT_SDK_RELEASE}" "go.mongodb.org/atlas-sdk/${LATEST_SDK_RELEASE}@${LATEST_SDK_TAG}" go mod tidy echo "Done" From 3c54841a1b03864c5b69a6ef4b6a76a51bf310eb Mon Sep 17 00:00:00 2001 From: svc-apix-Bot <142542575+svc-apix-Bot@users.noreply.github.com> Date: Wed, 2 Oct 2024 11:11:43 +0200 Subject: [PATCH 14/15] build(deps): bump go.mongodb.org/atlas-sdk (#2654) Co-authored-by: lantoli <430982+lantoli@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 26fe76562f..75fa9561e9 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/zclconf/go-cty v1.15.0 go.mongodb.org/atlas v0.37.0 go.mongodb.org/atlas-sdk/v20240530005 v20240530005.0.0 - go.mongodb.org/atlas-sdk/v20240805004 v20240805004.2.0 + go.mongodb.org/atlas-sdk/v20240805004 v20240805004.4.0 go.mongodb.org/realm v0.1.0 ) diff --git a/go.sum b/go.sum index 09ba56ee59..1763934705 100644 --- a/go.sum +++ b/go.sum @@ -780,8 +780,8 @@ go.mongodb.org/atlas v0.37.0 h1:zQnO1o5+bVP9IotpAYpres4UjMD2F4nwNEFTZhNL4ck= go.mongodb.org/atlas v0.37.0/go.mod h1:DJYtM+vsEpPEMSkQzJnFHrT0sP7ev6cseZc/GGjJYG8= go.mongodb.org/atlas-sdk/v20240530005 v20240530005.0.0 h1:d/gbYJ+obR0EM/3DZf7+ZMi2QWISegm3mid7Or708cc= go.mongodb.org/atlas-sdk/v20240530005 v20240530005.0.0/go.mod h1:O47ZrMMfcWb31wznNIq2PQkkdoFoK0ea2GlmRqGJC2s= -go.mongodb.org/atlas-sdk/v20240805004 v20240805004.2.0 h1:f40gW44GYiaF29nSJd0kU+SzRfrLlgU/8PmMIQdO+zc= -go.mongodb.org/atlas-sdk/v20240805004 v20240805004.2.0/go.mod h1:64cvOvwsE0TTi9nAl16XlVkHzT0gFLGcZeG7HnnXxtE= +go.mongodb.org/atlas-sdk/v20240805004 v20240805004.4.0 h1:ZqkuIH2X0jSxmJsbkNt2KyK9X6umtXKnXyC2s1aMJdM= +go.mongodb.org/atlas-sdk/v20240805004 v20240805004.4.0/go.mod h1:7KSDRNJm1Dxc+ggk2MOggp2/4zUpM4aRcP12evvsrQ4= 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= From bc70a61a78ec2717efa1df877bd2b2c116063abf Mon Sep 17 00:00:00 2001 From: svc-apix-Bot <142542575+svc-apix-Bot@users.noreply.github.com> Date: Fri, 4 Oct 2024 09:16:47 +0200 Subject: [PATCH 15/15] chore: Updates Atlas Go SDK (#2659) * build(deps): bump go.mongodb.org/atlas-sdk * fix build errors --------- Co-authored-by: lantoli <430982+lantoli@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- .../resource_cloud_provider_access_authorization.go | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 75fa9561e9..e46269ce74 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/zclconf/go-cty v1.15.0 go.mongodb.org/atlas v0.37.0 go.mongodb.org/atlas-sdk/v20240530005 v20240530005.0.0 - go.mongodb.org/atlas-sdk/v20240805004 v20240805004.4.0 + go.mongodb.org/atlas-sdk/v20240805004 v20240805004.5.0 go.mongodb.org/realm v0.1.0 ) diff --git a/go.sum b/go.sum index 1763934705..071a530b12 100644 --- a/go.sum +++ b/go.sum @@ -780,8 +780,8 @@ go.mongodb.org/atlas v0.37.0 h1:zQnO1o5+bVP9IotpAYpres4UjMD2F4nwNEFTZhNL4ck= go.mongodb.org/atlas v0.37.0/go.mod h1:DJYtM+vsEpPEMSkQzJnFHrT0sP7ev6cseZc/GGjJYG8= go.mongodb.org/atlas-sdk/v20240530005 v20240530005.0.0 h1:d/gbYJ+obR0EM/3DZf7+ZMi2QWISegm3mid7Or708cc= go.mongodb.org/atlas-sdk/v20240530005 v20240530005.0.0/go.mod h1:O47ZrMMfcWb31wznNIq2PQkkdoFoK0ea2GlmRqGJC2s= -go.mongodb.org/atlas-sdk/v20240805004 v20240805004.4.0 h1:ZqkuIH2X0jSxmJsbkNt2KyK9X6umtXKnXyC2s1aMJdM= -go.mongodb.org/atlas-sdk/v20240805004 v20240805004.4.0/go.mod h1:7KSDRNJm1Dxc+ggk2MOggp2/4zUpM4aRcP12evvsrQ4= +go.mongodb.org/atlas-sdk/v20240805004 v20240805004.5.0 h1:m14HgMj470RF+QvAgqSQdk+T+M9Ah8x9GL0RwNxdE90= +go.mongodb.org/atlas-sdk/v20240805004 v20240805004.5.0/go.mod h1:7KSDRNJm1Dxc+ggk2MOggp2/4zUpM4aRcP12evvsrQ4= 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= diff --git a/internal/service/cloudprovideraccess/resource_cloud_provider_access_authorization.go b/internal/service/cloudprovideraccess/resource_cloud_provider_access_authorization.go index ae8eb415cd..2e2f7323db 100644 --- a/internal/service/cloudprovideraccess/resource_cloud_provider_access_authorization.go +++ b/internal/service/cloudprovideraccess/resource_cloud_provider_access_authorization.go @@ -338,9 +338,10 @@ func featureUsagesSchema() *schema.Resource { } func featureToSchema(feature admin.CloudProviderAccessFeatureUsage) map[string]any { - featureID, _ := feature.GetFeatureId().ToMap() + featureID := feature.GetFeatureId() + featureIDMap, _ := featureID.ToMap() return map[string]any{ "feature_type": feature.GetFeatureType(), - "feature_id": featureID, + "feature_id": featureIDMap, } }