Incus Resource provider for Terraform
This provider is published in the Terraform Registry.
Follow the official instructions for declaring providers in your Terraform configuration here.
Add the following to your Terraform configuration:
terraform {
required_providers {
incus = {
source = "lxc/incus"
}
}
}- Follow these instructions to setup a Golang development environment.
- Checkout the repository
git clone ... - Compile from sources to a development binary:
cd terraform-provider-incus
go build -v- Configure Terraform (
~/.terraformrc) to use the development binary provider:
$ cat ~/.terraformrc
provider_installation {
dev_overrides {
"lxc/incus" = "/home/<REPLACE_ME>/git/terraform-provider-incus"
}
}This project uses gofumpt to format the
code, which is a stricter version of gofmt.
For your best experience, make sure your editor is configured to run
gofumpt on save. Find the installation section in
gofumpt's README.md.
This project uses golangci-lint and terraform fmt
to perform linting and static code analysis.
To run the linters locally, use:
make static-analysisIf your editor is configured to run golangci-lint on save, it is expected to
automatically pick up the configuration from .golangci.yml.
Most of the data sources are generated using the tool located in
./cmd/generate-datasources. The generated files have the suffix _gen.go as
well as a comment // Code generated by generate-datasources; DO NOT EDIT..
Do not edit these files manually but instead change the respective template in
./cmd/generate-datasources/tmpl and the generator if necessary.
The generator tool is controlled by the config file generate-datasources.yaml.
If the generator code, the templates of the generator's config file are changed, the generated files need to be regenerated.
Use the following command to regenerate the data sources:
make generateFor more details about the inner working of the generator tool as well as the
settings in the config file please refer to
cmd/generate-datasources/README.md.
There are two test suites, unit and acceptance. By default the acceptance tests are not run as they require a functional Incus environment.
make testmake testacc
# or run an individual test
TESTARGS="-run TestAccImage_basicVM" make testacc
# increase test verbosity. options are trace, debug, info, warn, or error (default)
TF_LOG=info make testaccFull documentation can be found in the docs directory.
Many of the base Incus images don't include an SSH server, therefore terraform
will be unable to execute any provisioners. Either use the base ubuntu images
from the ubuntu or ubuntu-daily or manually prepare a base image that
includes SSH.
Some recognition for great contributors to this project: