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)
Run the following command
make install-devtools
Check the subcommands in our Makefile for useful dev tools and scripts.
- Clone the repository
- Enter the repository directory
- Build the provider using the Makefile
install
command:
make build
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).
You will also need to install the devtools used in this project (see Install and update development tools).
To compile the provider, run make build
.
This will build the provider and put the provider binary in the ./bin
directory (see Testing the provider locally).
To generate or update documentation, run make generate
.
In order to run the full suite of Acceptance tests, run make testacc
.
make testacc
To test the provider locally:
-
Build the provider binary with
make build
. This will build and put the provider binary in the./bin
directory -
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