Skip to content

Commit

Permalink
fix: Doesn't disable X.509 in the project when mongodbatlas_x509_auth…
Browse files Browse the repository at this point in the history
…entication_database_user resource is deleted (#1760)

* don't do anything in delete

* update doc

* fix version

* clarify doc

* clarify doc
  • Loading branch information
lantoli committed Dec 18, 2023
1 parent 77d4140 commit 953fe05
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,9 @@ func resourceMongoDBAtlasX509AuthDBUserRead(ctx context.Context, d *schema.Resou
}

func resourceMongoDBAtlasX509AuthDBUserDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
conn := meta.(*config.MongoDBClient).Atlas

ids := conversion.DecodeStateID(d.Id())
currentCertificate := ids["current_certificate"]
projectID := ids["project_id"]

if currentCertificate == "" {
_, err := conn.X509AuthDBUsers.DisableCustomerX509(ctx, projectID)
if err != nil {
return diag.FromErr(fmt.Errorf(errorCustomerX509AuthDBUsersDelete, projectID, err))
}
}

// We don't do anything because X.509 certificates can not be deleted or disassociated from a user.
// More info: https://jira.mongodb.org/browse/HELP-53363
d.SetId("")

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ description: |-

-> **NOTE:** Groups and projects are synonymous terms. You may find group_id in the official documentation.

-> **NOTE:** Before provider version 1.14.0, Self-managed X.509 Authentication was disabled for the project when this resource was deleted. Starting from that version onward, it will not be disabled, allowing other users to continue using X.509 within the same project.

## Example Usages

### Example Usage: Generate an Atlas-managed X.509 certificate for a MongoDB user
Expand Down

0 comments on commit 953fe05

Please sign in to comment.