No description
  • Go 96.7%
  • HCL 1.9%
  • Makefile 0.9%
  • Shell 0.5%
Find a file
OpenTofu Core Development Team f88f63486e Apply GitHub workflow changes
2025-11-17 12:26:09 +00:00
.github Apply GitHub workflow changes 2025-11-17 12:26:09 +00:00
.release Updating actions-generate-metadata tag to sha and remvoing release branch 2025-07-31 11:11:54 +05:30
.vscode Initial commit 2020-11-23 12:49:16 -08:00
docs Allow example _configs to get latest minor. Run go generate 2021-02-25 10:26:18 -06:00
examples [COMPLIANCE] Add Copyright and License Headers 2023-02-06 16:34:20 +00:00
internal [COMPLIANCE] Add Copyright and License Headers 2023-02-06 16:34:20 +00:00
scripts [COMPLIANCE] Add Copyright and License Headers 2023-02-06 16:34:20 +00:00
templates Add guides to doc templates. 2020-12-18 11:07:09 -06:00
version Initial commit for go runner to CRT workflow migration 2025-07-01 14:15:07 +05:30
.gitignore Pass source_channel on AMA create and cluster update 2021-01-06 10:27:47 -06:00
.go-version Upgrade to Go 1.16 2021-02-24 16:53:57 -06:00
.goreleaser.yml [COMPLIANCE] Add Copyright and License Headers 2023-02-06 16:34:20 +00:00
CHANGELOG.md v0.5.1 2022-03-01 16:53:31 +00:00
go.mod Updating go version to 1.24.4 2025-07-01 15:53:19 +05:30
go.sum Updating go version to 1.24.4 2025-07-01 15:53:19 +05:30
LICENSE [COMPLIANCE] Update MPL 2.0 LICENSE 2022-10-12 21:03:06 +00:00
main.go [COMPLIANCE] Add Copyright and License Headers 2023-02-06 16:34:20 +00:00
Makefile Update Makefile 2021-01-15 10:41:12 -05:00
README.md Set min Go version to 1.15 to conform to provider-sdk 2.4.4 2021-02-25 09:36:25 -06:00
terraform-registry-manifest.json Migrate Provider Releases from TeamCity to GitHub Actions 2022-04-08 16:01:17 -04:00

HashiCorp Consul Service on Azure (HCS) Terraform Provider

Requirements

Building The Provider

  1. Clone the repository
  2. Enter the repository directory
  3. Build the provider using the make dev command

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 the latest models for the HCS Custom Resource Provider actions, run:

make generate-hcs-ama-api-spec-models

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

Generating Docs

From the root of the repo run:

go generate && go mod tidy

Using the provider

Please see the docs for details about a particular resource. Below is a complex example that leverages the Azure Terraform provider and creates a federation of two HCS clusters.

// Configure the provider
provider "hcs" {}

provider "azurerm" {
  features {}
}

// If you have not already done so, accept the HCS Marketplace agreement
data "hcs_plan_defaults" "hcs_plan" {}

resource "azurerm_marketplace_agreement" "hcs_marketplace_agreement" {
  publisher = data.hcs_plan_defaults.hcs_plan.publisher
  offer     = data.hcs_plan_defaults.hcs_plan.offer
  plan      = data.hcs_plan_defaults.hcs_plan.plan_name
}

// Create the Resource Group for the primary cluster
resource "azurerm_resource_group" "primary" {
  name     = "hcs-tf-federation-primary-rg"
  location = "westus2"
}

// Create the primary cluster
resource "hcs_cluster" "primary" {
  resource_group_name      = azurerm_resource_group.primary.name
  managed_application_name = "hcs-tf-federation-primary"
  email                    = "me@example.com"
  cluster_mode             = "production"
  min_consul_version       = "v1.9.0"
  vnet_cidr                = "172.25.16.0/24"
  consul_datacenter        = "hcs-tf-federation-example"
}

// Create a federation token
data "hcs_federation_token" "fed" {
  resource_group_name      = hcs_cluster.primary.resource_group_name
  managed_application_name = hcs_cluster.primary.managed_application_name
}

// Create the Resource Group for the secondary cluster
resource "azurerm_resource_group" "secondary" {
  name     = "hcs-tf-federation-secondary-rg"
  location = "eastus"
}

// Create the secondary cluster using the federation token from above
resource "hcs_cluster" "secondary" {
  resource_group_name      = azurerm_resource_group.secondary.name
  managed_application_name = "hcs-tf-federation-secondary"
  email                    = "me@example.com"
  cluster_mode             = "production"
  min_consul_version       = "v1.9.0"
  vnet_cidr                = "172.25.17.0/24"
  consul_datacenter        = "hcs-tf-federation-secondary"
  consul_federation_token  = data.hcs_federation_token.fed.token
}