GithubHelp home page GithubHelp logo

isabella232 / terraform-provider-hcs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hashicorp/terraform-provider-hcs

0.0 0.0 0.0 539 KB

Terraform provider for HashiCorp Consul Service on Azure.

License: Mozilla Public License 2.0

Makefile 0.93% Go 98.53% Shell 0.54%

terraform-provider-hcs's Introduction

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                    = "[email protected]"
  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                    = "[email protected]"
  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
}

terraform-provider-hcs's People

Contributors

aclaygray avatar alexmunda avatar chapmanc avatar crhino avatar dependabot[bot] avatar fitzse avatar hashicorp-cloud avatar janet avatar mkeeler avatar paultyng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.