A utility Terraform provider for .env files
- Terraform >= 1.0
You most likely want to download the provider from Terraform Registry. The provider is also published in the OpenTofu Registry.
Using Provider from Terraform Registry (TF >= 1.0) This provider is published and available there. If you want to use it, just add the following to your terraform.tf:
terraform {
required_providers {
dotenv = {
source = "germanbrew/dotenv"
version = "1.0.0" # Adjust to latest version
}
}
required_version = ">= 1.0"
}
Then run terraform init to download the provider.
The provider documentation can be found in the Terraform registry.
- Go > 1.22 (to build the provider plugin)
- golangci-lint (to lint code)
- terraform-plugin-docs (to generate registry documentation)
Check the subcommands in our Makefile for useful dev tools and scripts.
- Clone the repository
- Enter the repository directory
- Build the provider using the Go
install
command:
go install
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
.
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
.
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 test the provider locally:
-
Build the provider binary with
make build
-
Create a new file
~/.terraform.rc
and point the provider to the absolute directory path of the binary file:provider_installation { dev_overrides { "germanbrew/dotenv" = "/path/to/your/terraform-provider-dotenv/bin/" } direct {} }
-
- Set the variable before running terraform commands:
TF_CLI_CONFIG_FILE=~/.terraform.rc terraform plan
- Or set the env variable
TF_CLI_CONFIG_FILE
and point it to~/.terraform.rc
: e.g.
export TF_CLI_CONFIG_FILE=~/.terraform.rc
-
Now you can just use terraform normally. A warning will appear, that notifies you that you are using an provider override
Warning: Provider development overrides are in effect ...
-
Unset the env variable if you don't want to use the local provider anymore:
unset TF_CLI_CONFIG_FILE