- Website: https://www.terraform.io
- Mailing list: Google Groups
Clone repository to: $GOPATH/src/github.com/DataDog/terraform-provider-datadog
$ mkdir -p $GOPATH/src/github.com/DataDog; cd $GOPATH/src/github.com/DataDog
$ git clone git@github.com:DataDog/terraform-provider-datadog
Enter the provider directory and build the provider
$ cd $GOPATH/src/github.com/DataDog/terraform-provider-datadog
$ make build
Note: For contributions created from forks, the repository should still be cloned under the $GOPATH/src/github.com/DataDog/terraform-provider-datadog
directory to allow the provided make
commands to properly run, build, and test this project.
If you're building the provider, follow the instructions to install it as a plugin. After placing it into your plugins directory, run terraform init
to initialize it.
Further usage documentation is available on the Terraform website.
If you wish to build the provider locally to manually execute terraform examples, you'll first need Go installed on your machine (version 1.11+ is required). You'll also need to correctly setup a GOPATH, as well as adding $GOPATH/bin
to your $PATH
.
Terraform 0.13.x
To compile the provider, run `make build_013`. This will build the provider and put the provider binary in a locally mirrored plugin directory.$ make build_013
You also need a $HOME/.terraformrc
file that contains:
provider_installation {
filesystem_mirror {
path = "$HOME/.terraform.d/plugins_local/"
include = ["registry.terraform.io/datadog/datadog"]
}
direct {
exclude = ["registry.terraform.io/datadog/datadog"]
}
}
From there, you can run any terraform init
or plan/apply within an example terraform module directory.
Terraform <= 0.12.x
To compile the provider, run `make build`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.$ make build
...
$ $GOPATH/bin/terraform-provider-datadog
...
In order to test the provider, you can simply run make test
.
$ make test
Note that the above command runs acceptance tests by replaying pre-recorded API responses (cassettes) stored in datadog/cassettes/
. When tests are modified, the cassettes need to be re-recorded.
In order to make tests cassette friendly, it's necessary to ensure that resources always get manipulated in a predictable order. When creating a testing Terraform config that defines multiple resources at the same time, you need to set inter-resource dependencies (using depends_on
) in such a way that there is only one way for Terraform to manipulate them. For example, given resources A, B and C in the same config string, you can achieve this by making A depend on B and B depend on C. See PR #442 for an example of this.
Note: Recording cassettes creates/updates/destroys real resources. Never run this on a production Datadog organization.
In order to re-record all cassettes you need to have DD_API_KEY
and DD_APP_KEY
for your testing organization in your environment. With that, run make cassettes
. Do note that this would regenerate all cassettes and thus take a very long time; if you only need to re-record cassettes for one or two tests, you can run make cassettes TESTARGS ="-run XXX"
- this will effectively execute go test -run=XXX
, which would run all testcases that contain XXX
in their name.
In order to run the full suite of Acceptance tests, run make testacc
.
Note: Acceptance tests create/update/destroy real resources. Never run this on a production Datadog organization.
$ make testacc
In order to update the underlying API Clients that are used by this provider to interact with the Datadog API, run:
API_CLIENT_VERSION=vx.y.z ZORKIAN_VERSION=vx.y.z make update-go-client
where:
API_CLIENT_VERSION
is the version or commit ref of the https://github.com/DataDog/datadog-api-client-go client.ZORKIAN_VERSION
is the version or commit ref of the https://github.com/zorkian/go-datadog-api client.