This guide describes how to migrate Terraform from one tenant to another. This is useful for making backups or rolling out a standardized configuration to several tenants.
Ensure OneAgent communication is reconfigured via oneagentctl
for migration.
Direct OneAgent migration might generate new entity IDs, potentially causing configuration loss.
Improper migration can cause significant environment issues.
For more info about oneagentctl
, see OneAgent configuration via command-line interface.
Before you use Terraform to migrate between Dynatrace environments, you must:
PATH
.
For more information, see Install Terraform.Define the environment variables to identify the Dynatrace tenant for configuration retrieval.
There are two ways to invoke the export utility and subsequent Terraform execution, the difference being how variables are used.
Setting the source and target environment variables separately is beneficial with the iterative method, where you might run multiple exports and Terraform executions within the same command line shell.
With this method, you use the same variables for both environments.
Optionally, the environment variable DYNATRACE_TARGET_FOLDER
can be set to specify an output directory.
If the variable is not set, the default folder ./configuration
will be used.
There are two main approaches for migration:
For iterative migration, use the Terraform Migration Helper spreadsheet. It aids in tracking migration order and completion.
Ensure the target environment doesn't have any existing configurations.
Use the -migrate
flag.
This will create all the necessary files with resource dependencies and hardcoded entity IDs.
terraform-provider-dynatrace.exe -export -migrate
To view the resources that are excluded from the default export, run the provider with the -list-exclusions
flag.
To export any of the excluded resources, see Example usage.
The iterative approach is useful for migrating specific resource groups or to environments with existing configurations.
Set environment variables to handle duplicates:
DYNATRACE_DUPLICATE_REJECT=ALL
: Prevents overwriting existing configurations.DYNATRACE_DUPLICATE_HIJACK=ALL
: Allows overwriting existing configurations.Use the -migrate
and -datasources
flags.
This will create all the necessary files with dependencies via data sources and hardcoded entity IDs.
terraform-provider-dynatrace.exe -export -migrate -datasources <resourcename>
optional
Common issues causing resources to fail during the migration:
If you experience any other errors, please create an issue in the Dynatrace GitHub repo.