Skip to content

germanbrew/terraform-provider-dotenv

Repository files navigation

Terraform Provider DotEnv

Terraform OpenTofu GitHub Release GitHub Actions Workflow Status

A utility Terraform provider for .env files

Requirements

Installing and Using this Plugin

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.

Development

Requirements

Install and update development tools

Run the following command

make install-devtools

Makefile Commands

Check the subcommands in our Makefile for useful dev tools and scripts.

Building The Provider

  1. Clone the repository
  2. Enter the repository directory
  3. Build the provider using the Makefile install command:
make build

Adding Dependencies

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.

Developing the Provider

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

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:

    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
  3. 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
    ...
    
  4. Unset the env variable if you don't want to use the local provider anymore:

    unset TF_CLI_CONFIG_FILE