Skip to content

Commit

Permalink
CLOUDP-294985: created SA only needs read permission. (#510)
Browse files Browse the repository at this point in the history
Co-authored-by: Gustavo Bazan <[email protected]>
  • Loading branch information
wtrocki and gssbzn authored Jan 15, 2025
1 parent b53e317 commit 34dad8b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/service_account_management/sa_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

// Example for Service Account Management API
// Example uses Service Account to create Service Account.
// Please ensure that Service Account has organizational admin permission.
// Please ensure that Service Account has ORG_OWNER permission.

// Required env variables to run example:
// export MONGODB_ATLAS_CLIENT_ID="your_client_id"
Expand Down Expand Up @@ -58,14 +58,15 @@ func main() {
admin.NewOrgServiceAccountRequest(
"SA created by sdk-example",
"example",
[]string{"ORG_OWNER"},
[]string{"ORG_READ_ONLY"},
365*24,
),
)
sa, _, err := request.Execute()
if err != nil {
log.Fatalf("Error: %v", err)
}
fmt.Println("Created new service account.")

// 2. Rotate secret
newSecret, _, err := sdk.ServiceAccountsApi.CreateServiceAccountSecret(
Expand Down Expand Up @@ -110,4 +111,5 @@ func main() {

// 6. Remove created Service Account. We would not be able to use it afterward without access to Secret value.
sdk.ServiceAccountsApi.DeleteServiceAccount(ctx, sa.GetClientId(), orgID)
fmt.Println("Created service account was deleted.")
}

0 comments on commit 34dad8b

Please sign in to comment.