Build and install the provider so that Terraform can use it:
make install
Go to folder with Terraform .tf
definition files for synthetic resources/data sources(/examples/*
):
- Configure provider with parameters:
provider "kentik-synthetics" {
// Synthetics API server URL. Can also be specified with KTAPI_URL environment variable.
api_url = "https://synthetics.api.kentik.com"
// Authorization email (required). Can also be specified with KTAPI_AUTH_EMAIL environment variable.
email = "dummy@acme.com"
// Authorization token (required). Can also be specified with KTAPI_AUTH_TOKEN environment variable.
token = "token"
// Debug flag enables verbose debug logs of requests and responses (optional).
// Can also be specified with TF_SYNTHETICS_DEBUG environment variable.
debug = true
}
or environment variables:
export KTAPI_AUTH_EMAIL="john@acme.com"
export KTAPI_AUTH_TOKEN="token123"
export KTAPI_URL="http://localhost:8080" # custom apiserver
- Invoke:
terraform init
terraform apply
Anybody who wants to contribute to development is welcome to provide pull requests.
To work on the provider, install tools listed in requirements section.
Optional tools:
- golangci-lint: local installation
Development steps:
- Build the provider:
make build
- Build and install the provider locally:
make install
- Run tests:
make test
- Run linter:
golangci-lint run
- Format the code:
./tools/fmt.sh
- Generate or update documentation:
go generate
Tests run the provider against a test-api-server
that serves data read from /synthetics/test-data.json
This allows to:
- avoid the necessity of providing valid API credentials
- avoid creating resources on remote server
- make the test results more reliable
Running make test
will:
- Build and run test-api-server which emulates Kentik API v6 by returning static preconfigured responses
- Run tests (communication with
test-api-server
) - Shut down
test-api-server
For debugging use Delve debugger
make build
dlv exec ./terraform-provider-kentik-synthetics
r -debug
c
# attach with terraform following the just-printed out instruction in your terminal