Use Terraformer with Datadog
This provider uses the terraform-provider-datadog.
First you will need to install Terraformer with the Datadog provider. See the README.
Before you can use Terraformer, you need to create a template workspace so that Terraformer can access the DataDog/datadog provider.
To do this, create a new directory with a basic provider.tf file:
terraform {
required_providers {
datadog = {
source = "DataDog/datadog"
version = "3.20.0"
}
}
}
provider "datadog" {
# Configuration options
}then run:
$ terraform initYou should see the output: Terraform has been successfully initialized!
export DATADOG_API_KEY=Datadog API key. More information on this at https://docs.datadoghq.com/account_management/api-app-keys/
export DATADOG_HOST=Datadog API host i.e. https://api.datadoghq.eu which can be found at https://docs.datadoghq.com/getting_started/site/#access-the-datadog-site
export DATADOG_APP_KEY=Datadog APP key. More information on this at https://docs.datadoghq.com/account_management/api-app-keys/
./terraformer import datadog --resources=* You can also specify only certain kinds of resources to import as well, i.e. --resources=dashboard.
You should now see a generated/ subdirectory with generated files.
You can now initialize and use your new generated resources:
$ terraform init
$ terraform plan # No changes. Your infrastructure matches the configuration.You can use the filter argument to restrict the import of Terraform resources.
Filtering based on Tags follows the convention --filter="Name=tags;Value='your tag'".
# Import monitors based on multiple tags
./terraformer import datadog --resources=monitor --filter="Name=tags;Value='foo:bar'" --filter="Name=tags;Value='env:production'"
# Import monitor where tag doesn't include colon
./terraformer import datadog --resources=monitor --filter="Name=tags;Value=anExampleTag"Filtering based on resource ID:
# Import dashboard based on the dashboard ID
./terraformer import datadog --resources=dashboard --filter=dashboard=some-id
# Import based on multiple resource IDs
./terraformer import datadog --resources=monitor --filter=monitor=id1:id2:id4Tag filters are order specific. For example, if your monitor has tags (in the order) atag: atagvalue, foo:bar but you filter for --filter="Name=tags;Value='foo:bar'" --filter="Name=tags;Value='atag: atagvalue'", the monitor would not be imported.
dashboarddatadog_dashboard
dashboard_jsondatadog_dashboard_json
dashboard_listdatadog_dashboard_list
downtimedatadog_downtime
logs_archivedatadog_logs_archive
logs_archive_orderdatadog_logs_archive_order
logs_custom_pipelinedatadog_logs_custom_pipeline
logs_integration_pipelinedatadog_logs_integration_pipeline
logs_pipeline_orderdatadog_logs_pipeline_order
logs_indexdatadog_logs_index
logs_index_orderdatadog_logs_index_order
integration_awsdatadog_integration_aws
integration_aws_lambda_arndatadog_integration_aws_lambda_arn
integration_aws_log_collectiondatadog_integration_aws_log_collection
integration_azuredatadog_integration_azure- NOTE: Sensitive field
client_secretis not generated and needs to be manually set
- NOTE: Sensitive field
integration_gcpdatadog_integration_gcp- NOTE: Sensitive fields
private_key, private_key_id, client_idis not generated and needs to be manually set
- NOTE: Sensitive fields
integration_pagerdutydatadog_integration_pagerduty
integration_pagerduty_service_objectdatadog_integration_pagerduty_service_object
integration_slack_channeldatadog_integration_slack_channel- NOTE: Importing resource requires resource ID or
account_nameto be passed via Filter option
- NOTE: Importing resource requires resource ID or
metric_metadatadatadog_metric_metadata- NOTE: Importing resource requires resource ID's to be passed via Filter option
monitordatadog_monitor
roledatadog_role
security_monitoring_default_ruledatadog_security_monitoring_default_rule
security_monitoring_ruledatadog_security_monitoring_rule
service_level_objectivedatadog_service_level_objective
synthetics_testdatadog_synthetics_test
synthetics_global_variabledatadog_synthetics_global_variable- NOTE: Importing resource requires resource ID's to be passed via Filter option
synthetics_private_locationdatadog_synthetics_private_location
userdatadog_user