Dynatrace offers different options to authenticate API calls. The Dynatrace Terraform Provider supports the following authentication options.
For more information about Identity and Access Management (IAM), including platform tokens, OAuth clients, and API tokens / access tokens classic, see Tokens and OAuth clients.
Platform tokens can be used to authenticate API calls against Dynatrace. These platform tokens are long-lived access tokens. For the full list of supported platform token services, see Available services for platform tokens.
The following code blocks show you how to define environment variables for your environment URL and platform token for Windows and Linux.
set DYNATRACE_ENV_URL=https://<YOUR-DT-ENV-ID>.apps.dynatrace.comset DYNATRACE_PLATFORM_TOKEN=<YOUR_PLATFORM_TOKEN>
To create an OAuth client, follow the steps described in OAuth clients.
To ensure the OAuth client works as intended, verify that the service user's groups grant the same scopes as the OAuth client you have created for all environments you want to use it with. For more details on controlling permissions, see Working with policies.
The Dynatrace Terraform Provider requests OAuth access tokens using your client credentials to make authenticated API calls.
The following code blocks show you how to define environment variables for your environment URL, authentication client, and secret for Windows and Linux.
set DYNATRACE_ENV_URL=https://<YOUR-DT-ENV-ID>.apps.dynatrace.comset DYNATRACE_CLIENT_ID=<YOUR_CLIENT_ID>set DYNATRACE_CLIENT_SECRET=<YOUR_CLIENT_SECRET>
Use access tokens to authenticate Dynatrace Classic API calls. For more information on how to use a Dynatrace API token, see Dynatrace API - Tokens and authentication.
The following code blocks show you how to define environment variables for your environment URL and API token for Windows and Linux.
set DYNATRACE_ENV_URL=https://<YOUR-DT-ENV-ID>.apps.dynatrace.comset DYNATRACE_API_TOKEN=<YOUR_API_TOKEN>
The Dynatrace Terraform Provider contains most Dynatrace APIs. All supported resources are listed in the Dynatrace Terraform Provider documentation in the Terraform Registry.
Always consider the correct permission scopes that are needed for the selected API resources. Information can be found at IAM policy reference and the Dynatrace Terraform provider GitHub repository.