-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #315 from dbt-labs/release-0.3.21
- Loading branch information
Showing
18 changed files
with
1,046 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
page_title: "dbtcloud_oauth_configuration Resource - dbtcloud" | ||
subcategory: "" | ||
description: |- | ||
Configure an external OAuth integration for the data warehouse. Currently supports Okta and Entra ID (i.e. Azure AD) for Snowflake. | ||
See the documentation https://docs.getdbt.com/docs/cloud/manage-access/external-oauth for more information on how to configure it. | ||
--- | ||
|
||
# dbtcloud_oauth_configuration (Resource) | ||
|
||
|
||
Configure an external OAuth integration for the data warehouse. Currently supports Okta and Entra ID (i.e. Azure AD) for Snowflake. | ||
|
||
See the [documentation](https://docs.getdbt.com/docs/cloud/manage-access/external-oauth) for more information on how to configure it. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "dbtcloud_oauth_configuration" "test" { | ||
type = "entra" | ||
name = "My Entra ID Oauth integration" | ||
client_id = "client-id" | ||
client_secret = "client-secret" | ||
redirect_uri = "http://example.com" | ||
token_url = "http://example.com" | ||
authorize_url = "http://example.com" | ||
application_id_uri = "uri" | ||
} | ||
resource "dbtcloud_oauth_configuration" "test" { | ||
type = "okta" | ||
name = "My Okta Oauth integration" | ||
client_id = "client-id" | ||
client_secret = "client-secret" | ||
redirect_uri = "http://example.com" | ||
token_url = "http://example.com" | ||
authorize_url = "http://example.com" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `authorize_url` (String) The Authorize URL for the OAuth integration | ||
- `client_id` (String) The Client ID for the OAuth integration | ||
- `client_secret` (String, Sensitive) The Client secret for the OAuth integration | ||
- `name` (String) The name of OAuth integration | ||
- `redirect_uri` (String) The redirect URL for the OAuth integration | ||
- `token_url` (String) The Token URL for the OAuth integration | ||
- `type` (String) The type of OAuth integration (`entra` or `okta`) | ||
|
||
### Optional | ||
|
||
- `application_id_uri` (String) The Application ID URI for the OAuth integration. Only for Entra | ||
|
||
### Read-Only | ||
|
||
- `id` (Number) The ID of the OAuth configuration | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# using import blocks (requires Terraform >= 1.5) | ||
import { | ||
to = dbtcloud_oauth_configuration.my_external_oauth | ||
id = "external_oauth_id" | ||
} | ||
|
||
import { | ||
to = dbtcloud_oauth_configuration.my_external_oauth | ||
id = "12345" | ||
} | ||
|
||
# using the older import command | ||
terraform import dbtcloud_oauth_configuration.my_external_oauth "external_oauth_id" | ||
terraform import dbtcloud_oauth_configuration.my_external_oauth 12345 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# using import blocks (requires Terraform >= 1.5) | ||
import { | ||
to = dbtcloud_oauth_configuration.my_external_oauth | ||
id = "external_oauth_id" | ||
} | ||
|
||
import { | ||
to = dbtcloud_oauth_configuration.my_external_oauth | ||
id = "12345" | ||
} | ||
|
||
# using the older import command | ||
terraform import dbtcloud_oauth_configuration.my_external_oauth "external_oauth_id" | ||
terraform import dbtcloud_oauth_configuration.my_external_oauth 12345 |
21 changes: 21 additions & 0 deletions
21
examples/resources/dbtcloud_oauth_configuration/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
resource "dbtcloud_oauth_configuration" "test" { | ||
type = "entra" | ||
name = "My Entra ID Oauth integration" | ||
client_id = "client-id" | ||
client_secret = "client-secret" | ||
redirect_uri = "http://example.com" | ||
token_url = "http://example.com" | ||
authorize_url = "http://example.com" | ||
application_id_uri = "uri" | ||
} | ||
|
||
resource "dbtcloud_oauth_configuration" "test" { | ||
type = "okta" | ||
name = "My Okta Oauth integration" | ||
client_id = "client-id" | ||
client_secret = "client-secret" | ||
redirect_uri = "http://example.com" | ||
token_url = "http://example.com" | ||
authorize_url = "http://example.com" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
package dbt_cloud | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
type OAuthConfiguration struct { | ||
ID *int64 `json:"id,omitempty"` | ||
AccountId int64 `json:"account_id"` | ||
Type string `json:"type"` | ||
Name string `json:"name"` | ||
ClientId string `json:"client_id"` | ||
ClientSecret string `json:"client_secret"` | ||
AuthorizeUrl string `json:"authorize_url"` | ||
TokenUrl string `json:"token_url"` | ||
RedirectUri string `json:"redirect_uri"` | ||
OAuthConfigurationExtra *OAuthConfigurationExtra `json:"extra_data,omitempty"` | ||
} | ||
|
||
type OAuthConfigurationExtra struct { | ||
ApplicationIdUri *string `json:"application_id_uri,omitempty"` | ||
} | ||
|
||
type OAuthConfigurationListResponse struct { | ||
Data []OAuthConfiguration `json:"data"` | ||
Status ResponseStatus `json:"status"` | ||
Extra ResponseExtra `json:"extra"` | ||
} | ||
|
||
type OAuthConfigurationResponse struct { | ||
Data OAuthConfiguration `json:"data"` | ||
Status ResponseStatus `json:"status"` | ||
} | ||
|
||
func (c *Client) GetOAuthConfiguration(oAuthConfigurationID int64) (*OAuthConfiguration, error) { | ||
req, err := http.NewRequest( | ||
"GET", | ||
fmt.Sprintf( | ||
"%s/v3/accounts/%s/oauth-configurations/%d/", | ||
c.HostURL, | ||
strconv.Itoa(c.AccountID), | ||
oAuthConfigurationID, | ||
), | ||
nil, | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
body, err := c.doRequest(req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
oAuthConfigurationResponse := OAuthConfigurationResponse{} | ||
err = json.Unmarshal(body, &oAuthConfigurationResponse) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &oAuthConfigurationResponse.Data, nil | ||
} | ||
|
||
func (c *Client) CreateOAuthConfiguration( | ||
oAuthType string, | ||
name string, | ||
clientId string, | ||
clientSecret string, | ||
authorizeUrl string, | ||
tokenUrl string, | ||
redirectUri string, | ||
applicationURI string, | ||
) (*OAuthConfiguration, error) { | ||
newOAuthConfiguration := OAuthConfiguration{ | ||
AccountId: int64(c.AccountID), | ||
Type: oAuthType, | ||
Name: name, | ||
ClientId: clientId, | ||
ClientSecret: clientSecret, | ||
AuthorizeUrl: authorizeUrl, | ||
TokenUrl: tokenUrl, | ||
RedirectUri: redirectUri, | ||
} | ||
|
||
if applicationURI != "" { | ||
newOAuthConfigurationExtra := OAuthConfigurationExtra{ | ||
ApplicationIdUri: &applicationURI, | ||
} | ||
newOAuthConfiguration.OAuthConfigurationExtra = &newOAuthConfigurationExtra | ||
} | ||
|
||
newOAuthConfigurationData, err := json.Marshal(newOAuthConfiguration) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
req, err := http.NewRequest( | ||
"POST", | ||
fmt.Sprintf( | ||
"%s/v3/accounts/%s/oauth-configurations/", | ||
c.HostURL, | ||
strconv.Itoa(c.AccountID), | ||
), | ||
strings.NewReader(string(newOAuthConfigurationData)), | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
body, err := c.doRequest(req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
oAuthConfigurationResponse := OAuthConfigurationResponse{} | ||
err = json.Unmarshal(body, &oAuthConfigurationResponse) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &oAuthConfigurationResponse.Data, nil | ||
} | ||
|
||
func (c *Client) UpdateOAuthConfiguration( | ||
oAuthConfigurationID int64, | ||
oAuthConfiguration OAuthConfiguration, | ||
) (*OAuthConfiguration, error) { | ||
oAuthConfigurationData, err := json.Marshal(oAuthConfiguration) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
req, err := http.NewRequest( | ||
"POST", | ||
fmt.Sprintf( | ||
"%s/v3/accounts/%s/oauth-configurations/%d/", | ||
c.HostURL, | ||
strconv.Itoa(c.AccountID), | ||
oAuthConfigurationID, | ||
), | ||
strings.NewReader(string(oAuthConfigurationData)), | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
body, err := c.doRequest(req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
oAuthConfigurationResponse := OAuthConfigurationResponse{} | ||
err = json.Unmarshal(body, &oAuthConfigurationResponse) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &oAuthConfigurationResponse.Data, nil | ||
} | ||
|
||
func (c *Client) DeleteOAuthConfiguration( | ||
oAuthConfigurationID int64, | ||
) error { | ||
req, err := http.NewRequest( | ||
"DELETE", | ||
fmt.Sprintf( | ||
"%s/v3/accounts/%s/oauth-configurations/%d/", | ||
c.HostURL, | ||
strconv.Itoa(c.AccountID), | ||
oAuthConfigurationID, | ||
), | ||
nil, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
body, err := c.doRequest(req) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
oAuthConfigurationResponse := OAuthConfigurationResponse{} | ||
err = json.Unmarshal(body, &oAuthConfigurationResponse) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.