Either:
- Devbox for dependencies and development
- install dependencies manually, see Requirements.
- GitHub's Codespaces which comes with
go
preinstalled out of the box- to run in Codespaces open this repo on GitHub, find green
<> Code
dropdown button and selectCodespaces
tab
- to run in Codespaces open this repo on GitHub, find green
devbox install
devbox shell
You have 2 options to run the provider locally:
-
Use development overrides (preferred):
- copy
dev.tfrc.example
todev.tfrc
- update
dev.tfrc
withecho $GOBIN
- if
GOBIN
is empty, tryecho $GOPATH
and append it with/bin/
. e.g.:echo $GOPATH
is/go
, updatedev.tfrc
to"sleuth.io/core/sleuth" = "/go/bin/"
- if
- run
export TF_CLI_CONFIG_FILE=dev.tfrc
- check that overrides are successfully applied with
terraform apply
-> you should seeProvider development overrides are in effect
in the output - run
make install
to build the provider and install it to$GOBIN
- Done! You can now use the provider locally with
terraform apply
- copy
-
Manually install the provider:
- run
make install_deprecated
- this will build the provider and put the provider binary in the
$GOPATH/bin
directory & in correct location for terraform providers - Note: if you're on macOS, change
OS_ARCH
inMakefile
todarwin_amd64
(Intel) ordarwin_arm64
(Apple silicon)
- this will build the provider and put the provider binary in the
- run
terraform init
to initialize the provider and use newly built binary - Done! You can now use the provider locally with
terraform apply
- run
Run make docs
. This will read files in /templates
and examples
folder and generate documentation in /docs
folder. Note that changes done directly in /docs
folder will be overwritten.
Run make fmt
.
In order to run the full suite of Acceptance tests, run make testacc
.
Note: Acceptance tests create real resources, and often cost money to run.
$ make testacc
To run against a local instance of Sleuth, do the following:
- Start Sleuth locally so that it is available on http://dev.sleuth.io
- Copy the
main.tf.example
file asmain.tf
and edit the file to changeapi_key
- Run terraform via
make dev
. Note this will delete the state each time.
When you have context availabe you should use tflog.LEVEL|(ctx)
for logging. This will print out the log message with context and level. For example tflog.DEBUG|(ctx)
will print out DEBUG: [terraform-provider-sleuth] (ctx) message
.
Note: Levels for provider can be adjusted using TF_LOG_PROVIDER=LEVEL
.
If context is not available you can use fmt.Print("here")
with combination of TF_LOG=DEBUG
env variable when running terraform plan
or terraform apply
.
This provider uses Go modules. Please see the Go documentation for the most up to date information about using Go modules.
To add a new dependency github.com/author/dependency
to your Terraform provider:
go get github.com/author/dependency
go mod tidy
Then commit the changes to go.mod
and go.sum
.