All Projects → env0 → terraform-provider-env0

env0 / terraform-provider-env0

Licence: MPL-2.0 license
Terraform Provider for env0

Programming Languages

go
31211 projects - #10 most used programming language
HCL
1544 projects

Projects that are alternatives of or similar to terraform-provider-env0

terraform-provider-mysql
Terraform MySQL provider – This Terraform provider is archived per our provider archiving process: https://terraform.io/docs/internals/archiving.html
Stars: ✭ 59 (+110.71%)
Mutual labels:  terraform-provider
terraform-provider-scaleway
Terraform Scaleway provider
Stars: ✭ 171 (+510.71%)
Mutual labels:  terraform-provider
terraform-provider-fusionauth
registry.terraform.io/providers/gpsinsight/fusionauth/latest
Stars: ✭ 23 (-17.86%)
Mutual labels:  terraform-provider
terraform-provider-hcp
Terraform provider for HashiCorp Cloud Platform.
Stars: ✭ 36 (+28.57%)
Mutual labels:  terraform-provider
terraform-provider-commercetools
Terraform provider for commercetools
Stars: ✭ 58 (+107.14%)
Mutual labels:  terraform-provider
terraform-provider-argocd
Terraform provider for ArgoCD
Stars: ✭ 245 (+775%)
Mutual labels:  terraform-provider
Terraform Provider Auth0
Auth0 Terraform Provider
Stars: ✭ 252 (+800%)
Mutual labels:  terraform-provider
terraform-provider-sysdig
Sysdig Terraform provider. Allow to handle Sysdig Secure policies as code.
Stars: ✭ 41 (+46.43%)
Mutual labels:  terraform-provider
terraform-provider-rancher
Terraform Rancher provider
Stars: ✭ 35 (+25%)
Mutual labels:  terraform-provider
terraform-provider-artifactory
Terraform provider for managing Artifactory
Stars: ✭ 17 (-39.29%)
Mutual labels:  terraform-provider
terraform-provider-oneview
Automates the provisioning of physical infrastructure from a private cloud using templates from HPE OneView with Terraform
Stars: ✭ 46 (+64.29%)
Mutual labels:  terraform-provider
terraform-provider-twitter
No description or website provided.
Stars: ✭ 24 (-14.29%)
Mutual labels:  terraform-provider
terraform-provider-cisco-aci
Terraform provider for automating Cisco ACI enabled networks
Stars: ✭ 14 (-50%)
Mutual labels:  terraform-provider
terraform-provider-external
Utility provider that exists to provide an interface between Terraform and external programs. Useful for integrating Terraform with a system for which a first-class provider does not exist.
Stars: ✭ 136 (+385.71%)
Mutual labels:  terraform-provider
terraform-provider-redfish
Terraform provider for Redfish REST APIs
Stars: ✭ 54 (+92.86%)
Mutual labels:  terraform-provider
terraform-provider-tsuru
Terraform provider for tsuru
Stars: ✭ 17 (-39.29%)
Mutual labels:  terraform-provider
terraform-provider-circleci
Terraform provider for CircleCI
Stars: ✭ 94 (+235.71%)
Mutual labels:  terraform-provider
terraform-provider-mcbroken
Base the count of your infrastucture resources on the current number of broken mcdonald's ice cream machines nationally or by a city of your choosing. Powered by https://mcbroken.com/
Stars: ✭ 29 (+3.57%)
Mutual labels:  terraform-provider
terraform-provider-upcloud
Terraform provider for UpCloud
Stars: ✭ 52 (+85.71%)
Mutual labels:  terraform-provider
terraform-provider-azurerm
Terraform provider for Azure Resource Manager
Stars: ✭ 3,829 (+13575%)
Mutual labels:  terraform-provider
env0 logo

Terraform Provider for env0

Go Report Card

Quick Start

terraform {
  required_providers {
    env0 = {
      source = "env0/env0"
    }
  }
}

provider "env0" {}

data "env0_project" "default_project" {
  name = "My First Project"
}

resource "env0_template" "example" {
  name        = "example"
  description = "Example template"
  repository  = "https://github.com/env0/templates"
  path        = "aws/hello-world"
}

resource "env0_configuration_variable" "in_a_template" {
  name        = "VARIABLE_NAME"
  value       = "some value"
  template_id = env0_template.tested1.id
}

Authentication

  1. Generate an api_key and api_secret from the Organization Settings page. See here.

  2. These can be provided by one of two methods:

    1. Set ENV0_API_KEY and ENV0_API_SECRET environment variables, and just declaring the provider with no parameters:
       provider "env0" {}
    1. Specify these fields as parameters to the provider:
    variable "env0_api_key" {}
    variable "env0_api_secret" {}
    
    provider "env0" {
      api_key = var.env0_api_key
      api_secret = var.env0_api_secret
    }

Development Setup

Supported Go Version: 1.18

Build

  • Use the ./build.sh script.
  • The output binary is called terraform-provider-env0

Run local version of the provider

  • Build - ./build.sh
  • Create the plugins folder - mkdir -p ~/.terraform.d/plugins/terraform.env0.com/local/env0/6.6.6/darwin_amd64 (for M1 processor, replace amd64 with arm64)
  • Copy the built binary - cp ./terraform-provider-env0 ~/.terraform.d/plugins/terraform.env0.com/local/env0/6.6.6/darwin_amd64 (Replace darwin with linux on Linux)
  • Require the local provider in your main.tf -
terraform {
  required_providers {
    env0 = {
      version = "6.6.6"
      source  = "terraform.env0.com/local/env0"
    }
  }
}

Installing pre-commit hooks

For consistent coding style, install pre-commit hooks.

go install golang.org/x/tools/...@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
pre-commit install
pre-commit install --hook-type pre-push

Testing

Integration tests

  • The integration tests run against the real env0 API
  • Have ENV0_API_KEY and ENV0_API_SECRET environment variables defined.
  • Also set ENV0_API_ENDPOINT if you want to run against a non-prod environment.
  • Run go run tests/harness.go (from the project root folder) to run all the tests.
  • Use go run tests/harness.go 003_configuration_variable to run a specific test.

Each test perform the following steps:

  • terraform init
  • terraform apply -auto-approve -var second_run=0
  • terraform apply -auto-approve -var second_run=1
  • terraform outputs -json - and verifies expected outputs from expected_outputs.json
  • terraform destroy

The harness has two modes to help while developing: If an environment variable DESTROY_MODE exists and it's value is NO_DESTROY, the harness will avoid calling terraform destroy, allowing the developer to inspect the resources created, through the dashboard, for example. Afterwards, when cleanup is required, just set DESTROY_MODE to DESTROY_ONLY and only terraform destroy will run.

Integration Test Prerequisites

Unit Testing

How to run tests

Run from root directory:

go test -v ./...

Running a single provider test

export TEST_PATTERN="TestUnitConfigurationVariableResource/Create" && go test -v ./env0

How to use mocks

  1. Make sure GOPATH is in your PATH
go env GOPATH
echo $PATH
export PATH=$PATH:$(go env GOPATH)  # if not
  1. Install mockgen
go install github.com/golang/mock/[email protected]
  1. Make sure to add this line in files that include the interface you'd wish to mock:
//go:generate mockgen -destination=<file>_mock.go -package=<package> . <interface>
  1. Run from root directory:
go generate ./...

Documentation

  • Docs are generated using github.com/hashicorp/terraform-plugin-docs
  • Run ./generate-docs.sh to generate docs
  • Must be run manually before releasing a version
  • Please add an example to examples/<resources or data-sources>/env0_<name> dir and make sure it is added to the docs.

Release

To release a version to the Terraform Public Registry:

  1. Validate that all status checks are on main branch (specifically that docs generation is complete)
  2. Pull from remote first - git pull origin main
  3. Create and push a tag locally, in semver format - git tag v0.0.9 && git push origin --tags
  4. New release with binaries will be automatically generated by the GitHub action defined in .github/workflows/release.yml.
  5. The Registry will automatically pick up on the new version.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].