Skip to content

Commit 34dad8b

Browse files
wtrockiGustavo Bazan
andauthored
CLOUDP-294985: created SA only needs read permission. (#510)
Co-authored-by: Gustavo Bazan <[email protected]>
1 parent b53e317 commit 34dad8b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

examples/service_account_management/sa_management.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
// Example for Service Account Management API
1313
// Example uses Service Account to create Service Account.
14-
// Please ensure that Service Account has organizational admin permission.
14+
// Please ensure that Service Account has ORG_OWNER permission.
1515

1616
// Required env variables to run example:
1717
// export MONGODB_ATLAS_CLIENT_ID="your_client_id"
@@ -58,14 +58,15 @@ func main() {
5858
admin.NewOrgServiceAccountRequest(
5959
"SA created by sdk-example",
6060
"example",
61-
[]string{"ORG_OWNER"},
61+
[]string{"ORG_READ_ONLY"},
6262
365*24,
6363
),
6464
)
6565
sa, _, err := request.Execute()
6666
if err != nil {
6767
log.Fatalf("Error: %v", err)
6868
}
69+
fmt.Println("Created new service account.")
6970

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

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

0 commit comments

Comments
 (0)