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
20 changes: 17 additions & 3 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,103 +110,117 @@ func Provider() *schema.Provider {
Schema: map[string]*schema.Schema{
"dt_env_url": {
Type: schema.TypeString,
Description: "The URL of the Dynatrace environment (e.g. `https://#####.live.dynatrace.com` or `https://#####.apps.dynatrace.com`).",
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"DYNATRACE_ENV_URL", "DT_ENV_URL", "DYNATRACE_ENVIRONMENT_URL", "DT_ENVIRONMENT_URL"}, nil),
},
"dt_api_token": {
Type: schema.TypeString,
Description: "The API token for classic Dynatrace APIs.",
Optional: true,
Sensitive: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"DYNATRACE_API_TOKEN", "DT_API_TOKEN"}, nil),
},
"dt_cluster_api_token": {
Type: schema.TypeString,
Description: "The API token for Dynatrace Managed cluster APIs.",
Optional: true,
Sensitive: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"DYNATRACE_CLUSTER_API_TOKEN", "DT_CLUSTER_API_TOKEN"}, nil),
},
"dt_cluster_url": {
Type: schema.TypeString,
Description: "The URL of the Dynatrace Managed cluster.",
Optional: true,
Sensitive: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"DYNATRACE_CLUSTER_URL", "DT_CLUSTER_URL"}, nil),
},
"client_id": {
Type: schema.TypeString,
Description: "The client ID of an OAuth client used for platform APIs. Also serves as a fallback for `iam_client_id` and `automation_client_id`.",
Optional: true,
Sensitive: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"DT_CLIENT_ID", "DYNATRACE_CLIENT_ID"}, nil),
},
"account_id": {
Type: schema.TypeString,
Description: "The Dynatrace account ID (UUID). Required for IAM (Account Management) resources. Also serves as a fallback for `iam_account_id`.",
Optional: true,
Sensitive: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"DT_ACCOUNT_ID", "DYNATRACE_ACCOUNT_ID"}, nil),
},
"client_secret": {
Type: schema.TypeString,
Description: "The client secret of an OAuth client used for platform APIs. Also serves as a fallback for `iam_client_secret` and `automation_client_secret`.",
Optional: true,
Sensitive: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"DT_CLIENT_SECRET", "DYNATRACE_CLIENT_SECRET"}, nil),
},
"iam_client_id": {
Type: schema.TypeString,
Description: "The client ID of an OAuth client used for the IAM (Account Management) API. Falls back to `client_id` if not specified.",
Optional: true,
Sensitive: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"IAM_CLIENT_ID", "DYNATRACE_IAM_CLIENT_ID", "DT_IAM_CLIENT_ID", "DT_CLIENT_ID", "DYNATRACE_CLIENT_ID"}, nil),
},
"iam_account_id": {
Type: schema.TypeString,
Description: "The Dynatrace account ID (UUID). Required for IAM (Account Management) resources. Falls back to `account_id` if not specified.",
Optional: true,
Sensitive: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"IAM_ACCOUNT_ID", "DYNATRACE_IAM_ACCOUNT_ID", "DT_IAM_ACCOUNT_ID", "DT_ACCOUNT_ID", "DYNATRACE_ACCOUNT_ID"}, nil),
},
"iam_client_secret": {
Type: schema.TypeString,
Description: "The client secret of an OAuth client used for the IAM (Account Management) API. Falls back to `client_secret` if not specified.",
Optional: true,
Sensitive: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"IAM_CLIENT_SECRET", "DYNATRACE_IAM_CLIENT_SECRET", "DT_IAM_CLIENT_SECRET", "DYNATRACE_CLIENT_SECRET", "DT_CLIENT_SECRET"}, nil),
},
"iam_endpoint_url": {
Type: schema.TypeString,
Description: "The endpoint URL for the IAM (Account Management) API. Default: `https://api.dynatrace.com`.",
Optional: true,
Sensitive: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"IAM_ENDPOINT_URL", "DYNATRACE_IAM_ENDPOINT_URL", "DT_IAM_ENDPOINT_URL", "DYNATRACE_ENDPOINT_URL", "DT_ENDPOINT_URL"}, nil),
},
"iam_token_url": {
Type: schema.TypeString,
Description: "The token URL for obtaining access tokens via OAuth for the IAM (Account Management) API. Default: `https://sso.dynatrace.com/sso/oauth2/token`.",
Optional: true,
Sensitive: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"IAM_TOKEN_URL", "DYNATRACE_IAM_TOKEN_URL", "DT_IAM_TOKEN_URL", "DYNATRACE_TOKEN_URL", "DT_TOKEN_URL"}, nil),
},
"automation_client_id": {
Type: schema.TypeString,
Description: "The client ID of an OAuth client used for platform APIs. Falls back to `client_id` if not specified.",
Optional: true,
Sensitive: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"AUTOMATION_CLIENT_ID", "DYNATRACE_AUTOMATION_CLIENT_ID", "DT_AUTOMATION_CLIENT_ID", "DT_CLIENT_ID", "DYNATRACE_CLIENT_ID"}, nil),
},
"automation_client_secret": {
Type: schema.TypeString,
Description: "The client secret of an OAuth client used for platform APIs. Falls back to `client_secret` if not specified.",
Optional: true,
Sensitive: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"AUTOMATION_CLIENT_SECRET", "DYNATRACE_AUTOMATION_CLIENT_SECRET", "DT_AUTOMATION_CLIENT_SECRET", "DYNATRACE_CLIENT_SECRET", "DT_CLIENT_SECRET"}, nil),
},
"automation_token_url": {
Type: schema.TypeString,
Description: "The token URL for obtaining access tokens via OAuth for the platform APIs. Default: `https://sso.dynatrace.com/sso/oauth2/token`.",
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"AUTOMATION_TOKEN_URL", "DT_AUTOMATION_TOKEN_URL", "DYNATRACE_AUTOMATION_TOKEN_URL"}, nil),
Description: "The URL that provides the Bearer tokens when accessing the Automation REST API. This is optional configuration when `dt_env_url` already specifies a SaaS Environment like `https://#####.live.dynatrace.com` or `https://#####.apps.dynatrace.com`",
},
"automation_env_url": {
Type: schema.TypeString,
Description: "The URL of the Dynatrace platform environment (`https://#####.apps.dynatrace.com`). Falls back to `dt_env_url` if not specified.",
Optional: true,
Description: "The URL of the Dynatrace Environment with Platform capabilities turned on (`https://#####.apps.dynatrace.com)`. This is optional configuration when `dt_env_url` already specifies a SaaS Environment like `https://#####.live.dynatrace.com` or `https://#####.apps.dynatrace.com`",
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"AUTOMATION_ENVIRONMENT_URL", "DT_AUTOMATION_ENVIRONMENT_URL", "DYNATRACE_AUTOMATION_ENVIRONMENT_URL", "DYNATRACE_AUTOMATION_ENV_URL", "DT_AUTOMATION_ENV_URL"}, nil),
},
"platform_token": {
Type: schema.TypeString,
Description: "The Dynatrace platform token used for platform APIs. When specified, it is used in preference to `client_id`, `client_secret`, `automation_client_id`, `automation_client_secret`, `automation_token_url`, and `automation_env_url` for platform requests. Platform tokens can't be used for IAM (Account Management) or classic resources.",
Optional: true,
Description: "A Dynatrace Platform Token. Specifying such a token allows for easy authentication against Platform resources. In such a case it supersedes `automation_client_id`, `automation_client_secret`, `automation_token_url` and `automation_env_url`",
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"DYNATRACE_PLATFORM_TOKEN", "DT_PLATFORM_TOKEN"}, nil),
},
},
Expand Down
26 changes: 14 additions & 12 deletions templates/index.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
layout: ""
page_title: "Provider: Dynatrace"
description: |-
The Dynatrace Terraform Provider provides resources to interact with the Dynatrace REST API.
The Dynatrace Terraform provider provides resources to interact with the Dynatrace API.
---

# Dynatrace Terraform Provider

The Dynatrace Terraform Provider is used to interact with the resources supported by the Dynatrace REST API. The provider needs to be configured with the proper credentials before it can be used.
The Dynatrace Terraform provider is used to interact with the resources supported by the Dynatrace API. The provider needs to be configured with the proper credentials before it can be used.

Use the navigation to the left to learn about the available resources and data sources. For additional information, refer to the official Dynatrace documentation on Terraform available [here](https://dt-url.net/3s63qyj).

The Dynatrace Terraform Provider is officially supported by Dynatrace.
The Dynatrace Terraform provider is officially supported by Dynatrace.

## Example

Expand All @@ -30,8 +30,8 @@ terraform {
The recommended approach is to configure the provider via environment variables.

Define `DYNATRACE_ENV_URL` for the Dynatrace environment URL.
* SaaS Environments: `https://########.live.dynatrace.com`
* Managed Enviroments: `https://<dynatrace-host>/e/#####################`
* SaaS environments: `https://########.live.dynatrace.com`
* Managed environments: `https://<dynatrace-host>/e/#####################`

To create an API token with full access to all resources, define `DYNATRACE_API_TOKEN` as an [access token](https://docs.dynatrace.com/docs/manage/identity-access-management/access-tokens-and-oauth-clients/access-tokens) with the following permissions.
* **Read settings** (`settings.read`)
Expand Down Expand Up @@ -101,9 +101,9 @@ Define `DT_CLIENT_ID`, `DT_CLIENT_SECRET`, `DT_ACCOUNT_ID` based off of the crea

### Authenticating with OAuth Credentials

The Terraform Provider supports using OAuth credentials for authentication with endpoints that allow both API Token and OAuth-based access.
The Terraform provider supports using OAuth credentials for authentication with endpoints that allow both API token and OAuth-based access.

> **Note:** Not all resources currently support OAuth. For example, the `dynatrace_json_dashboard` resource can only be configured using API Tokens.
> **Note:** Not all resources currently support OAuth. For example, the `dynatrace_json_dashboard` resource can only be configured using API tokens.

To enable OAuth-based authentication, set the environment variable:

Expand All @@ -113,13 +113,13 @@ DYNATRACE_HTTP_OAUTH_PREFERENCE=true

When this variable is set and OAuth credentials (e.g., `DT_CLIENT_ID` and `DT_CLIENT_SECRET`) are provided, the provider will prioritize using REST endpoints that support OAuth.

If `DYNATRACE_HTTP_OAUTH_PREFERENCE` is not set or is not `true`, the provider will default to using an API Token for authentication.
If `DYNATRACE_HTTP_OAUTH_PREFERENCE` is not set or is not `true`, the provider will default to using an API token for authentication.

---

### Authenticating with Platform Tokens
### Authenticating with platform tokens

You can authenticate using a Platform Token by setting the environment variable:
You can authenticate using a platform token by setting the environment variable:

```
DYNATRACE_PLATFORM_TOKEN=<<PLATFORM_TOKEN>>
Expand All @@ -129,8 +129,8 @@ Alternatively, you can use the `platform_token` attribute in the provider config

If `DYNATRACE_PLATFORM_TOKEN` is not defined, the provider will use the configured OAuth credentials (`DT_CLIENT_ID` and `DT_CLIENT_SECRET`) to obtain a Bearer token.

Platform Token authentication follows the same selection rules as OAuth credentials:
When the environment variable `DYNATRACE_HTTP_OAUTH_PREFERENCE` is set to `true`, the provider will favor Platform or OAuth tokens over API Tokens.
Platform token authentication follows the same selection rules as OAuth credentials:
When the environment variable `DYNATRACE_HTTP_OAUTH_PREFERENCE` is set to `true`, the provider will favor platform or OAuth tokens over API tokens.


## Exporting existing configuration from a Dynatrace environment
Expand All @@ -144,3 +144,5 @@ export DYNATRACE_LOG_HTTP=terraform-provider-dynatrace.http.log
export DYNATRACE_HTTP_RESPONSE=true
```
For assistance, please contact the Dynatrace Support team as described on the [support page](https://support.dynatrace.com/).

{{ .SchemaMarkdown | trimspace }}