dynatracescripts/BMW_Terraform/EMEAPREPROD
SLW\YELGIM 21bee5c640 modified the file. updated cn url 2023-01-16 12:41:23 +01:00
..
modules/dynatrace/management_zones modified the file. updated cn url 2023-01-16 12:41:23 +01:00
.terraform.lock.hcl modified the file. updated cn url 2023-01-16 12:41:23 +01:00
README.md modified the file. updated cn url 2023-01-16 12:41:23 +01:00
main.tf modified the file. updated cn url 2023-01-16 12:41:23 +01:00
provider.tf modified the file. updated cn url 2023-01-16 12:41:23 +01:00
terraform-provider-dynatrace_v1.5.0 modified the file. updated cn url 2023-01-16 12:41:23 +01:00
terraform.tfstate modified the file. updated cn url 2023-01-16 12:41:23 +01:00
variables.tf modified the file. updated cn url 2023-01-16 12:41:23 +01:00

README.md

Dynatrace Terraform Provider

Requirements

Using the provider

If you want to run Terraform with the dynatrace provider plugin on your system, add the plug-in provider to the Terraform configuration file.

terraform {
    required_version = "~> 0.13.0"
    required_providers {
        dynatrace = {
            version = "1.5.0"
            source = "dynatrace-oss/dynatrace"
        }
    }
}   

In order to configure the provider, add a code section like this into your Terraform configuration file

    provider "dynatrace" {
        dt_env_url   = "https://#######.live.dynatrace.com"
        dt_api_token = "##########################################"
    }    

where dt_env_url represents the URL of your Dynatrace Environment and dt_api_token needs to be an API Token with the permissions Read configuration and Capture request data.

Currently supported configuration settings

  • Dashboards
  • Management Zones
  • Custom Services
  • Request Attributes
  • Alerting Profiles
  • Problem Notifiations
  • Auto Tag Configuration
  • Kubernetes Credentials
  • AWS Credentials
  • Azure Credentials
  • Maintenance Windows
  • Service Level Objectives
  • Service Naming
  • Host Naming
  • Process Group Naming
  • Calculated Service Metrics

Exporting existing configuration from a Dynatrace Environment

In addition to acting as a Terraform Provider Plugin the executable terraform-provider-dynatrace (terraform-provider-dynatrace.exe on Windows) can also get directly invoked. The utility then reaches out to the Dynatrace Environment specified by the command line arguments and fetches all currently supported configuration items. These results will then automatically get transformed into HCL (the configuration language to be used for .tf files) and places each configuration item into its own .tf file).

Command Line Syntax

Invoking the download functionality requires

  • The environment varibale DYNATRACE_ENV_URL as the URL of your Dynatrace Environment
  • The environment variable DYNATRACE_API_TOKEN as the API Token with the permissions Read configuration and Capture request data
  • Optinonally the environment variable DYNATRACE_TARGET_FOLDER. If it's not set, the output folder ./configuration is assumed

Windows

terraform-provider-dynatrace.exe export *[<resourcename>[=<id>]]

Linux

./terraform-provider-dynatrace export *[<resourcename>[=<id>]]

Usage Examples

  • ./terraform-provider-dynatrace export dynatrace_dashboard downloads all available dashboards
    • ./terraform-provider-dynatrace export dynatrace_dashboard dynatrace_slo downloads all available dashboards and all available SLOs
  • ./terraform-provider-dynatrace export dynatrace_dashboard=4f5942d4-3450-40a8-818f-c5faeb3563d0 downloads only the dashboard with the id 4f5942d4-3450-40a8-818f-c5faeb3563d0
  • ./terraform-provider-dynatrace export dynatrace_dashboard=4f5942d4-3450-40a8-818f-c5faeb3563d0 dynatrace_dashboard=9c4b75f1-9a64-4b44-a8e4-149154fd5325 downloads only the dashboards with the ids 4f5942d4-3450-40a8-818f-c5faeb3563d0 and 9c4b75f1-9a64-4b44-a8e4-149154fd5325
  • ./terraform-provider-dynatrace export dynatrace_slo dynatrace_dashboard=4f5942d4-3450-40a8-818f-c5faeb3563d0 dynatrace_dashboard=9c4b75f1-9a64-4b44-a8e4-149154fd5325 downloads all available SLOs and only the dashboards with the ids 4f5942d4-3450-40a8-818f-c5faeb3563d0 and 9c4b75f1-9a64-4b44-a8e4-149154fd5325

DEPRECATED Command Line Syntax (commonly known as "download functionality")

Invoking the download functionality requires

  • The URL of your Dynatrace Environment
  • An API Token with the permissions Read configuration and Capture request data
  • If the optional argument for the output folder is not specified ./configuration is assumed

Windows

terraform-provider-dynatrace.exe download https://<environment-id>.live.dynatrace.com <api-token> [<output-folder>]

Linux

./terraform-provider-dynatrace download https://<environment-id>.live.dynatrace.com <api-token> [<output-folder>]