Skip to content

Commit 7cd5791

Browse files
committed
chore: supports setting baseURL on realm client when cloud-dev is used
1 parent e0a1c8a commit 7cd5791

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cfn-resources/util/util.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"log"
2222
"net/http"
23+
"net/url"
2324
"os"
2425
"runtime"
2526
"strconv"
@@ -109,6 +110,15 @@ func GetRealmClient(ctx context.Context, req handler.Request, profileName *strin
109110

110111
optsRealm := []realm.ClientOpt{realm.SetUserAgent(userAgent)}
111112
authConfig := realmAuth.NewConfig(nil)
113+
114+
if p.BaseURL != "" {
115+
if strings.Contains(p.BaseURL, "-dev.") {
116+
adminURL := "https://services.cloud-dev.mongodb.com/api/admin/v3.0/"
117+
optsRealm = append(optsRealm, realm.SetBaseURL(adminURL))
118+
authConfig.AuthURL, _ = url.Parse(adminURL + "auth/providers/mongodb-cloud/login")
119+
}
120+
}
121+
112122
token, err := authConfig.NewTokenFromCredentials(ctx, p.PublicKey, p.PrivateKey)
113123
if err != nil {
114124
return nil, err

0 commit comments

Comments
 (0)