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

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 Go install command:
go install

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).

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

Testing the provider locally

To test the provider locally:

  1. Build the provider binary with make build

  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