This template repository is built on the Terraform Plugin Framework. The template repository built on the Terraform Plugin SDK can be found at terraform-provider-scaffolding. See Which SDK Should I Use? in the Terraform documentation for additional information.
This is a small example of how to create contact. Please read the documentation for more information.
provider "webitel" {
endpoint = "https://webitel.example.com/api"
token = "token"
insecure = false
retry {
attempts = 3
delay_ms = 2000
}
}
resource "webitel_contact" "example" {
name = "foo"
about = "about foo bar"
labels = ["label-foo", "label-bar"]
variables = [
{
key = "foo-key"
value = "foo-value"
}
]
phones = [
{
code = "1"
destination = "123"
}
]
}
If you're new to provider development, a good place to start is the Extending Terraform docs.
If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).
Terraform allows to use local provider builds by setting a dev_overrides
block in a configuration
file called .terraformrc
. This block overrides all other configured installation methods. Terraform searches for
the .terraformrc
file in your home directory and applies any configuration settings you set.
- Find the
GOBIN
path where Go installs your binaries. Your path may vary depending on how your Go environment variables are configured.
$ go env GOBIN
/Users/<Username>/go/bin
- Create a new file called
.terraformrc
in your home directory (~
), then add thedev_overrides
block below. Change the<PATH>
to the value returned from the go envGOBIN
command above.
provider_installation {
dev_overrides {
"webitel/webitel" = "<PATH>" # this path is the directory where the binary is built
}
# For all other providers, install them directly from their origin provider
# registries as normal. If you omit this, Terraform will _only_ use
# the dev_overrides block, and so no other providers will be available.
direct {}
}
- Use the
go install
command from the repository's root directory to compile the provider into a binary and install it in yourGOBIN
path. Terraform will use the binary you just built for everyterraform plan
/apply
(it should print out a warning). No need to runterraform init
.
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
Documentation is generated with
tfplugindocs. Generated
files are in docs/
and should not be updated manually. They are derived from:
- Schema
Description
fields in the provider Go code. - examples/
Use go generate ./..
to update generated docs.
Builds and releases are automated with GitHub Actions and GoReleaser.
Currently there are a few manual steps to this:
-
Kick off the release:
RELEASE_VERSION=v... \ make release
-
Publish release:
The Action creates the release, but leaves it in "draft" state. Open it up in a browser and if all looks well, click the
Auto-generate release notes
button and mash the publish button.