Skip to content

Commit 014d5f4

Browse files
authored
chore: Deprecates tenant_id for mongodbatlas_cloud_backup_snapshot_export_bucket (#2932)
* chore: Mark tenant_id as deprecated with updated usage instructions * refactor: Update tenant_id to computed to avoid plan after apply, and remove from test case * make tenant_id deprecation consistent in docs and examples * chore: use field as before until it is deprecated * docs: update tenant_id deprecation message for clarity
1 parent 047bc7d commit 014d5f4

File tree

6 files changed

+14
-19
lines changed

6 files changed

+14
-19
lines changed

docs/data-sources/cloud_backup_snapshot_export_bucket.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ In addition to all arguments above, the following attributes are exported:
3535
* `cloud_provider` - Name of the provider of the cloud service where Atlas can access the S3 bucket.
3636
* `role_id` - Unique identifier of the Azure Service Principal that Atlas can use to access the Azure Blob Storage Container.
3737
* `service_url` - URL that identifies the blob Endpoint of the Azure Blob Storage Account.
38-
* `tenant_id` - UUID that identifies the Azure Active Directory Tenant ID.
38+
* `tenant_id` - (Deprecated) This field is ignored; the `mongodbatlas_cloud_provider_access_authorization.azure.tenant_id` is used instead. UUID that identifies the Azure Active Directory Tenant ID.
3939

4040

4141

docs/data-sources/cloud_backup_snapshot_export_buckets.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ data "mongodbatlas_cloud_backup_snapshot_export_buckets" "test" {
2323
## Argument Reference
2424

2525
* `project_id` - (Required) The unique identifier of the project for the Atlas cluster.
26-
* `page_num` - (Optional) The page to return. Defaults to `1`.
26+
* `page_num` - (Optional) The page to return. Defaults to `1`.
2727
* `items_per_page` - (Optional) Number of items to return per page, up to a maximum of 500. Defaults to `100`.
2828

2929

@@ -38,13 +38,13 @@ In addition to all arguments above, the following attributes are exported:
3838

3939
### CloudProviderSnapshotExportBucket
4040
* `project_id` - The unique identifier of the project for the Atlas cluster.
41-
* `export_bucket_id` - Unique identifier of the snapshot bucket id.
41+
* `export_bucket_id` - Unique identifier of the snapshot bucket id.
4242
* `iam_role_id` - Unique identifier of the role that Atlas can use to access the bucket.
4343
* `bucket_name` - Name of the bucket that the provided role ID is authorized to access.
4444
* `cloud_provider` - Name of the provider of the cloud service where Atlas can access the S3 bucket.
4545
* `role_id` - Unique identifier of the Azure Service Principal that Atlas can use to access the Azure Blob Storage Container.
4646
* `service_url` - URL that identifies the blob Endpoint of the Azure Blob Storage Account.
47-
* `tenant_id` - UUID that identifies the Azure Active Directory Tenant ID.
47+
* `tenant_id` - (Deprecated) This field is ignored; the `mongodbatlas_cloud_provider_access_authorization.azure.tenant_id` is used instead. UUID that identifies the Azure Active Directory Tenant ID.
4848

4949

5050
For more information see: [MongoDB Atlas API Reference.](https://docs.atlas.mongodb.com/reference/api/cloud-backup/export/create-one-export-bucket/)

docs/resources/cloud_backup_snapshot_export_bucket.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Resource: mongodbatlas_cloud_backup_snapshot_export_bucket
22

3-
`mongodbatlas_cloud_backup_snapshot_export_bucket` allows you to create an export snapshot bucket for the specified project.
3+
`mongodbatlas_cloud_backup_snapshot_export_bucket` allows you to create an export snapshot bucket for the specified project.
44

55

66
-> **NOTE:** Groups and projects are synonymous terms. You may find `groupId` in the official documentation.
@@ -26,7 +26,6 @@ resource "mongodbatlas_cloud_backup_snapshot_export_bucket" "test" {
2626
project_id = "{PROJECT_ID}"
2727
role_id = "{ROLE_ID}"
2828
service_url = "{SERVICE_URL}"
29-
tenant_id = "{TENANT_ID}"
3029
bucket_name = "example-bucket"
3130
cloud_provider = "AZURE"
3231
}
@@ -40,20 +39,20 @@ resource "mongodbatlas_cloud_backup_snapshot_export_bucket" "test" {
4039
* `iam_role_id` - Unique identifier of the role that Atlas can use to access the bucket. Required if `cloud_provider` is set to `AWS`.
4140
* `role_id` - Unique identifier of the Azure Service Principal that Atlas can use to access the Azure Blob Storage Container. Required if `cloud_provider` is set to `AZURE`.
4241
* `service_url` - URL that identifies the blob Endpoint of the Azure Blob Storage Account. Required if `cloud_provider` is set to `AZURE`.
43-
* `tenant_id` - UUID that identifies the Azure Active Directory Tenant ID. Required if `cloud_provider` is set to `AZURE`.
42+
* `tenant_id` - (Deprecated) This field is ignored; the `mongodbatlas_cloud_provider_access_authorization.azure.tenant_id` is used instead. UUID that identifies the Azure Active Directory Tenant ID.
4443

4544
## Attributes Reference
4645

4746
In addition to all arguments above, the following attributes are exported:
4847

49-
* `export_bucket_id` - Unique identifier of the snapshot export bucket.
48+
* `export_bucket_id` - Unique identifier of the snapshot export bucket.
5049

5150
## Import
5251

5352
Cloud Backup Snapshot Export Backup entries can be imported using project project_id, and bucket_id (Unique identifier of the snapshot export bucket), in the format `PROJECTID-BUCKETID`, e.g.
5453

5554
```
56-
$ terraform import mongodbatlas_cloud_backup_snapshot_export_bucket.test 5d0f1f73cf09a29120e173cf-5d116d82014b764445b2f9b5
55+
terraform import mongodbatlas_cloud_backup_snapshot_export_bucket.test 5d0f1f73cf09a29120e173cf-5d116d82014b764445b2f9b5
5756
```
5857

5958
For more information see: [MongoDB Atlas API Reference.](https://docs.atlas.mongodb.com/reference/api/cloud-backup/export/create-one-export-bucket/)

examples/mongodbatlas_cloud_backup_snapshot_export_bucket/azure/main.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ resource "mongodbatlas_cloud_provider_access_authorization" "auth_role" {
2121

2222

2323
resource "mongodbatlas_cloud_backup_snapshot_export_bucket" "test" {
24-
project_id = var.tenant_id
24+
project_id = var.project_id
2525
bucket_name = azurerm_storage_container.test_storage_container.name
2626
cloud_provider = "AZURE"
2727
service_url = azurerm_storage_account.test_storage_account.primary_blob_endpoint
2828
role_id = mongodbatlas_cloud_provider_access_authorization.auth_role.role_id
29-
tenant_id = var.tenant_id
3029
}

internal/service/cloudbackupsnapshotexportbucket/resource_cloud_backup_snapshot_export_bucket.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
1616
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1717

18+
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant"
1819
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
1920
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
2021
)
@@ -72,9 +73,10 @@ func Schema() map[string]*schema.Schema {
7273
ForceNew: true,
7374
},
7475
"tenant_id": {
75-
Type: schema.TypeString,
76-
Optional: true,
77-
ForceNew: true,
76+
Deprecated: fmt.Sprintf(constant.DeprecationParamByVersion, "1.27.0") + " This field is ignored; the `mongodbatlas_cloud_provider_access_authorization.azure.tenant_id` is used instead.",
77+
Type: schema.TypeString,
78+
Optional: true,
79+
Computed: true,
7880
},
7981
}
8082
}
@@ -85,7 +87,6 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
8587
projectID := d.Get("project_id").(string)
8688

8789
cloudProvider := d.Get("cloud_provider").(string)
88-
8990
request := &admin.DiskBackupSnapshotExportBucketRequest{
9091
IamRoleId: conversion.StringPtr(d.Get("iam_role_id").(string)),
9192
BucketName: d.Get("bucket_name").(string),
@@ -94,7 +95,6 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
9495
TenantId: conversion.StringPtr(d.Get("tenant_id").(string)),
9596
CloudProvider: cloudProvider,
9697
}
97-
9898
bucketResponse, _, err := conn.CloudBackupsApi.CreateExportBucket(ctx, projectID, request).Execute()
9999
if err != nil {
100100
return diag.Errorf("error creating snapshot export bucket: %s", err)

internal/service/cloudbackupsnapshotexportbucket/resource_cloud_backup_snapshot_export_bucket_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,13 @@ func basicAzureTestCase(t *testing.T) *resource.TestCase {
9191
"project_id": projectID,
9292
"bucket_name": bucketName,
9393
"service_url": serviceURL,
94-
"tenant_id": tenantID,
9594
"cloud_provider": "AZURE",
9695
}
9796
pluralAttrMapCheck = map[string]string{
9897
"project_id": projectID,
9998
"results.#": "1",
10099
"results.0.bucket_name": bucketName,
101100
"results.0.service_url": serviceURL,
102-
"results.0.tenant_id": tenantID,
103101
"results.0.cloud_provider": "AZURE",
104102
}
105103
attrsSet = []string{
@@ -291,7 +289,6 @@ func configAzureBasic(projectID, atlasAzureAppID, servicePrincipalID, tenantID,
291289
cloud_provider = "AZURE"
292290
service_url = %[6]q
293291
role_id = mongodbatlas_cloud_provider_access_authorization.auth_role.role_id
294-
tenant_id = %[4]q
295292
}
296293
297294
data "mongodbatlas_cloud_backup_snapshot_export_bucket" "test" {

0 commit comments

Comments
 (0)