To use the Chronosphere Terraform provider, you must first install Terraform. For
details, see the
Terraform documentation.
- Install the Terraform provider.
- Authenticate to Chronosphere.
- Bootstrap your Terraform configuration.
Install the provider
As of v1.0.0, the Chronosphere Terraform provider is open-source and available from the HashiCorp Terraform Registry.Install versions prior to v1.0.0
Chronosphere hosts older versions of the Terraform provider in a custom registry. Chronosphere doesn’t support these older versions, which include deprecated features removed in v1.0.0. To install and use these unsupported versions, configure your provider using the following code:Authenticate to Chronosphere
The Terraform provider requires an API token generated from an unrestricted service account with theSysAdmin
role to authenticate with the Chronosphere API. If you need to create a new service
account, you must use an account that belongs to a team with the SysAdmin role.
After you have the API token, you can use it to grant Terraform permission to modify
Chronosphere resources:
-
In the shell environment where you plan to run Terraform, set the
CHRONOSPHERE_API_TOKENenvironment variable:ReplaceAPI_TOKEN_VALUEwith the service account’s API token. -
Add your organization to the
providerconfiguration in your Terraform file:ReplaceMY_ORGwith your Chronosphere subdomain name, such asMY_ORG.chronosphere.io. -
Run
terraform initto set up the local data necessary to run Terraform with a new provider.
Bootstrap your Terraform configuration
You can use Terraform to manage new or existing supported resources. Thechronotf tool generates
Terraform configurations from existing resources and imports them into the Terraform state.
Install chronotf
Usecurl to download the latest version of chronotf, which is available for
Linux and macOS.
- macOS (Intel)
- macOS (M-series)
- Linux
-
Download the
darwin_amd64build ofchronotf: -
Make the
chronotfbinary executable. -
Move the binary into your
PATH:If you don’t have permission to install to/usr/local/bin, replace it with another directory in yourPATH. -
Test the
chronotfinstallation by running it:
Run chronotf
Terraform keeps local state to determine how to reconcile Terraform files with real resources. If you created some of your Terraform resources outside of Terraform, import them into the Terraform state with thechronotf import-state command before running
terraform apply.
-
Create Terraform configuration for existing resources.
Use the following command to export existing resources to a
main.tfTerraform file:Replace the following:API_TOKEN: A Chronosphere API token, such as from a service account.MY_ORG: Your Chronosphere subdomain name, such asMY_ORG.chronosphere.io.
-
Preview what Terraform adds when bootstrapping its state with the
--dry-runflag. From the directory with the Terraform files and state, run: -
Bootstrap the Terraform state.
From the directory with the Terraform files and state, run: