https://github.com/germanbrew/terraform-provider-dotenv
A utility Terraform provider for .env files
https://github.com/germanbrew/terraform-provider-dotenv
dotenv env terraform terraform-provider utility
Last synced: 8 months ago
JSON representation
A utility Terraform provider for .env files
- Host: GitHub
- URL: https://github.com/germanbrew/terraform-provider-dotenv
- Owner: germanbrew
- License: mpl-2.0
- Created: 2024-06-11T14:42:57.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-13T02:08:05.000Z (about 1 year ago)
- Last Synced: 2025-04-23T08:58:48.335Z (about 1 year ago)
- Topics: dotenv, env, terraform, terraform-provider, utility
- Language: Go
- Homepage: https://registry.terraform.io/providers/germanbrew/dotenv/latest
- Size: 344 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Terraform Provider DotEnv
[](https://registry.terraform.io/providers/germanbrew/dotenv/latest)
[](https://search.opentofu.org/provider/germanbrew/dotenv/latest)
[](https://github.com/germanbrew/terraform-provider-dotenv/releases/latest)
[](https://github.com/germanbrew/terraform-provider-dotenv/actions/workflows/test.yaml)
A utility Terraform provider for .env files
## Requirements
- [Terraform](https://developer.hashicorp.com/terraform/downloads) >= 1.0
## Installing and Using this Plugin
You most likely want to download the provider from [Terraform Registry](https://registry.terraform.io/providers/germanbrew/dotenv/latest/docs).
The provider is also published in the [OpenTofu Registry](https://github.com/opentofu/registry/tree/main/providers/g/germanbrew).
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
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](https://registry.terraform.io/providers/germanbrew/dotenv/latest/docs).
## Development
### Requirements
- [Go](https://golang.org/) > 1.22 (to build the provider plugin)
- [golangci-lint](https://github.com/golangci/golangci-lint) (to lint code)
- [terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs) (to generate registry documentation)
### Install and update development tools
Run the following command
```sh
make install-devtools
```
### Makefile Commands
Check the subcommands in our [Makefile](Makefile) for useful dev tools and scripts.
### Building The Provider
1. Clone the repository
1. Enter the repository directory
1. Build the provider using the Makefile `install` command:
```shell
make build
```
### Adding Dependencies
This provider uses [Go modules](https://github.com/golang/go/wiki/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:
```shell
go get github.com/author/dependency
go mod tidy
```
Then commit the changes to `go.mod` and `go.sum`.
### Developing the Provider
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (see [Requirements](#requirements) above).
You will also need to install the devtools used in this project (see [Install and update development tools](#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](#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`.
```shell
make testacc
```
### Testing the provider locally
To test the provider locally:
1. Build the provider binary with `make build`. This will build and put the provider binary in the `./bin` directory
2. Create a new file `~/.terraform.rc` and point the provider to the absolute **directory** path of the binary file:
```hcl
provider_installation {
dev_overrides {
"germanbrew/dotenv" = "/path/to/your/terraform-provider-dotenv/bin/"
}
direct {}
}
```
3. - Set the variable before running terraform commands:
```sh
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.
```sh
export TF_CLI_CONFIG_FILE=~/.terraform.rc
```
4. 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
...
```
5. Unset the env variable if you don't want to use the local provider anymore:
```sh
unset TF_CLI_CONFIG_FILE
```