Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mongodbatlas/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import (
type Config struct {
AtlasUsername string
AtlasAPIKey string
AtlasAPIURL string
}

func (c *Config) NewClient() *ma.Client {
t := dac.NewTransport(c.AtlasUsername, c.AtlasAPIKey)
httpClient := &http.Client{Transport: &t}
client := ma.NewClient(httpClient)
client := ma.NewCustomURLClient(httpClient, c.AtlasAPIURL)
return client
}
7 changes: 7 additions & 0 deletions mongodbatlas/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ func Provider() terraform.ResourceProvider {
DefaultFunc: schema.EnvDefaultFunc("MONGODB_ATLAS_API_KEY", ""),
Description: "MongoDB Atlas API Key",
},
"api_url": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("MONGODB_ATLAS_API_URL", "https://cloud.mongodb.com/api/atlas/v1.0/"),
Description: "MongoDB Atlas API base url",
},
},

DataSourcesMap: map[string]*schema.Resource{
Expand All @@ -45,6 +51,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config := Config{
AtlasUsername: d.Get("username").(string),
AtlasAPIKey: d.Get("api_key").(string),
AtlasAPIURL: d.Get("api_url").(string),
}

client := config.NewClient()
Expand Down
4 changes: 4 additions & 0 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,7 @@ Atlas `provider` block:
* `username` - (Optional) This is the MongoDB Atlas username. It must be
provided, but it can also be sourced from the `MONGODB_ATLAS_USERNAME`
environment variable.

* `api_url` - (Optional) This is the MongoDB API base URL. It can also be
sourced from the `MONGODB_ATLAS_API_URL` environment variable. Default
value is `https://cloud.mongodb.com/api/atlas/v1.0`.