Skip to content

Commit

Permalink
chore: Deprecates tenant_id for `mongodbatlas_cloud_backup_snapshot_e…
Browse files Browse the repository at this point in the history
…xport_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
  • Loading branch information
EspenAlbert authored Dec 31, 2024
1 parent 047bc7d commit 014d5f4
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/data-sources/cloud_backup_snapshot_export_bucket.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ In addition to all arguments above, the following attributes are exported:
* `cloud_provider` - Name of the provider of the cloud service where Atlas can access the S3 bucket.
* `role_id` - Unique identifier of the Azure Service Principal that Atlas can use to access the Azure Blob Storage Container.
* `service_url` - URL that identifies the blob Endpoint of the Azure Blob Storage Account.
* `tenant_id` - UUID that identifies the Azure Active Directory Tenant ID.
* `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.



Expand Down
6 changes: 3 additions & 3 deletions docs/data-sources/cloud_backup_snapshot_export_buckets.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ data "mongodbatlas_cloud_backup_snapshot_export_buckets" "test" {
## Argument Reference

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


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

### CloudProviderSnapshotExportBucket
* `project_id` - The unique identifier of the project for the Atlas cluster.
* `export_bucket_id` - Unique identifier of the snapshot bucket id.
* `export_bucket_id` - Unique identifier of the snapshot bucket id.
* `iam_role_id` - Unique identifier of the role that Atlas can use to access the bucket.
* `bucket_name` - Name of the bucket that the provided role ID is authorized to access.
* `cloud_provider` - Name of the provider of the cloud service where Atlas can access the S3 bucket.
* `role_id` - Unique identifier of the Azure Service Principal that Atlas can use to access the Azure Blob Storage Container.
* `service_url` - URL that identifies the blob Endpoint of the Azure Blob Storage Account.
* `tenant_id` - UUID that identifies the Azure Active Directory Tenant ID.
* `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.


For more information see: [MongoDB Atlas API Reference.](https://docs.atlas.mongodb.com/reference/api/cloud-backup/export/create-one-export-bucket/)
9 changes: 4 additions & 5 deletions docs/resources/cloud_backup_snapshot_export_bucket.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Resource: mongodbatlas_cloud_backup_snapshot_export_bucket

`mongodbatlas_cloud_backup_snapshot_export_bucket` allows you to create an export snapshot bucket for the specified project.
`mongodbatlas_cloud_backup_snapshot_export_bucket` allows you to create an export snapshot bucket for the specified project.


-> **NOTE:** Groups and projects are synonymous terms. You may find `groupId` in the official documentation.
Expand All @@ -26,7 +26,6 @@ resource "mongodbatlas_cloud_backup_snapshot_export_bucket" "test" {
project_id = "{PROJECT_ID}"
role_id = "{ROLE_ID}"
service_url = "{SERVICE_URL}"
tenant_id = "{TENANT_ID}"
bucket_name = "example-bucket"
cloud_provider = "AZURE"
}
Expand All @@ -40,20 +39,20 @@ resource "mongodbatlas_cloud_backup_snapshot_export_bucket" "test" {
* `iam_role_id` - Unique identifier of the role that Atlas can use to access the bucket. Required if `cloud_provider` is set to `AWS`.
* `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`.
* `service_url` - URL that identifies the blob Endpoint of the Azure Blob Storage Account. Required if `cloud_provider` is set to `AZURE`.
* `tenant_id` - UUID that identifies the Azure Active Directory Tenant ID. Required if `cloud_provider` is set to `AZURE`.
* `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.

## Attributes Reference

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

* `export_bucket_id` - Unique identifier of the snapshot export bucket.
* `export_bucket_id` - Unique identifier of the snapshot export bucket.

## Import

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.

```
$ terraform import mongodbatlas_cloud_backup_snapshot_export_bucket.test 5d0f1f73cf09a29120e173cf-5d116d82014b764445b2f9b5
terraform import mongodbatlas_cloud_backup_snapshot_export_bucket.test 5d0f1f73cf09a29120e173cf-5d116d82014b764445b2f9b5
```

For more information see: [MongoDB Atlas API Reference.](https://docs.atlas.mongodb.com/reference/api/cloud-backup/export/create-one-export-bucket/)
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ resource "mongodbatlas_cloud_provider_access_authorization" "auth_role" {


resource "mongodbatlas_cloud_backup_snapshot_export_bucket" "test" {
project_id = var.tenant_id
project_id = var.project_id
bucket_name = azurerm_storage_container.test_storage_container.name
cloud_provider = "AZURE"
service_url = azurerm_storage_account.test_storage_account.primary_blob_endpoint
role_id = mongodbatlas_cloud_provider_access_authorization.auth_role.role_id
tenant_id = var.tenant_id
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"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"
)
Expand Down Expand Up @@ -72,9 +73,10 @@ func Schema() map[string]*schema.Schema {
ForceNew: true,
},
"tenant_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Deprecated: fmt.Sprintf(constant.DeprecationParamByVersion, "1.27.0") + " This field is ignored; the `mongodbatlas_cloud_provider_access_authorization.azure.tenant_id` is used instead.",
Type: schema.TypeString,
Optional: true,
Computed: true,
},
}
}
Expand All @@ -85,7 +87,6 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
projectID := d.Get("project_id").(string)

cloudProvider := d.Get("cloud_provider").(string)

request := &admin.DiskBackupSnapshotExportBucketRequest{
IamRoleId: conversion.StringPtr(d.Get("iam_role_id").(string)),
BucketName: d.Get("bucket_name").(string),
Expand All @@ -94,7 +95,6 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.
TenantId: conversion.StringPtr(d.Get("tenant_id").(string)),
CloudProvider: cloudProvider,
}

bucketResponse, _, err := conn.CloudBackupsApi.CreateExportBucket(ctx, projectID, request).Execute()
if err != nil {
return diag.Errorf("error creating snapshot export bucket: %s", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,13 @@ func basicAzureTestCase(t *testing.T) *resource.TestCase {
"project_id": projectID,
"bucket_name": bucketName,
"service_url": serviceURL,
"tenant_id": tenantID,
"cloud_provider": "AZURE",
}
pluralAttrMapCheck = map[string]string{
"project_id": projectID,
"results.#": "1",
"results.0.bucket_name": bucketName,
"results.0.service_url": serviceURL,
"results.0.tenant_id": tenantID,
"results.0.cloud_provider": "AZURE",
}
attrsSet = []string{
Expand Down Expand Up @@ -291,7 +289,6 @@ func configAzureBasic(projectID, atlasAzureAppID, servicePrincipalID, tenantID,
cloud_provider = "AZURE"
service_url = %[6]q
role_id = mongodbatlas_cloud_provider_access_authorization.auth_role.role_id
tenant_id = %[4]q
}
data "mongodbatlas_cloud_backup_snapshot_export_bucket" "test" {
Expand Down

0 comments on commit 014d5f4

Please sign in to comment.