This Terraform provider allows you to manage DoiT Cloud Intelligence resources using the DoiT API.
While the provider does not yet support all available API endpoints, version 1.0.0 marks the first stable release.
Future releases will add support for additional resources and data sources.
Important
Version 1.0.0 is a major release with breaking changes. If you are upgrading from v0.x, please see the v1.0.0 Upgrade Guide for detailed migration instructions.
To get started with the provider, you first need to create an API key for the DoiT Console.
You then configure the provider like so:
terraform {
required_providers {
doit = {
source = "doitintl/doit"
version = "~> 1.0"
}
}
}
provider "doit" {
api_token = "your-api-key"
}If you are a Do'er, you also need to define the customer context:
provider "doit" {
api_token = "your-api-key"
customer_context = "your-customer-context"
}Alternatively, you can also use the DOIT_API_TOKEN and DOIT_CUSTOMER_CONTEXT environment variables.
If you have Nix installed with flakes enabled:
nix developOr with direnv for automatic environment loading:
direnv allowThis will automatically set up:
- Go 1.25
- Terraform v1.13.3
- golangci-lint v2.5.0
To enable flakes if not already enabled, add to your ~/.config/nix/nix.conf:
experimental-features = nix-command flakes
- Clone the repository
- Enter the repository directory
- Build the provider using the Go
installcommand:
go installThis provider uses Go modules. Please refer to the Go documentation for the most up-to-date information on using Go modules.
To add a new dependency github.com/author/dependency to your Terraform provider:
go get github.com/author/dependency
go mod tidyThen commit the changes to go.mod and go.sum.
Please check the docs folder to find an example to use the DoiT Console provider.
If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).
To compile the provider, run go install. This will build the provider and put the provider binary in the $GOPATH/bin directory.
To generate or update documentation, run go generate.
Acceptance tests create real resources in a DoiT account and require proper configuration.
| Variable | Description |
|---|---|
DOIT_API_TOKEN |
Your DoiT API token |
DOIT_HOST |
The DoiT API host (must be set; for most users this is https://api.doit.com) |
TEST_USER |
Email address for test budget collaborators/recipients |
TEST_ATTRIBUTION |
Attribution ID for test budget scope |
TEST_SLACK_CHAN |
Slack channel ID for notification tests |
TEST_PROJECT |
Project ID for allocation rule tests |
TEST_CUSTOMER_ID |
Customer ID for Slack channel recipient |
These variables are used by specific data source tests that will be skipped if unset:
| Variable | Description |
|---|---|
TEST_ATTRIBUTION_GROUP |
Attribution group ID for report tests |
TEST_INVOICE_ID |
Invoice ID for invoice data source tests |
TEST_ANOMALY_ID |
Anomaly ID for anomaly data source tests |
TEST_CLOUD_INCIDENT_ID |
Cloud incident ID for cloud incident data source tests |
TEST_COMMITMENT_ID |
Commitment ID for commitment data source tests |
If you use direnv, copy the example file and fill in your values:
cp .envrc.example .envrc.local
# Edit .envrc.local with your values
direnv allowThen run tests:
go test -v -timeout 120m ./...Set the required environment variables and run:
export TF_ACC=1
export DOIT_API_TOKEN="your-api-token"
export DOIT_HOST="https://api.doit.com"
export TEST_USER="your-email@example.com"
export TEST_ATTRIBUTION="your-attribution-id"
export TEST_SLACK_CHAN="your-slack-channel-id"
export TEST_PROJECT="your-project-id"
export TEST_CUSTOMER_ID="your-customer-id"
# Optional - specific data source tests will be skipped if these are unset
# export TEST_ATTRIBUTION_GROUP="your-attribution-group-id"
# export TEST_INVOICE_ID="your-invoice-id"
# export TEST_ANOMALY_ID="your-anomaly-id"
# export TEST_CLOUD_INCIDENT_ID="your-cloud-incident-id"
# export TEST_COMMITMENT_ID="your-commitment-id"
go test -v -timeout 120m ./...Important
DoiT employees only: You must also set the DOIT_CUSTOMER_CONTEXT environment variable
to the same value as TEST_CUSTOMER_ID for certain tests to work correctly.
Note: Acceptance tests create real resources and may incur costs.