Skip to content

G-Core/terraform-provider-gcore

Repository files navigation

Terraform Gcore Provider

Gcore

====================================================================================

Requirements

  • Terraform 0.13.x
  • Go 1.21 (to build the provider plugin)

Upgrade state

To switch state from the deprecated provider (builds <= 0.3.64) please run

terraform state replace-provider registry.terraform.io/g-core/gcorelabs registry.terraform.io/g-core/gcore

Building the provider

GOPATH=$(go env GOPATH)
mkdir -p $GOPATH/src/github.com/terraform-providers
cd $GOPATH/src/github.com/terraform-providers
git clone https://github.com/G-Core/terraform-provider-gcore.git
cd $GOPATH/src/github.com/terraform-providers/terraform-provider-gcore
make build

Override Terraform provider

To override terraform provider for development goals you do next steps:

  • create Terraform configuration file and point provider to development path
  • comment out the override if you want to use published binary from the upstream
cat > ~/.terraformrc << EOF
provider_installation {

  dev_overrides {
      "local.gcore.com/repo/gcore" = "$(go env GOPATH)/src/github.com/terraform-providers/terraform-provider-gcore/bin"
      "registry.terraform.io/g-core/gcore" = "$(go env GOPATH)/src/github.com/terraform-providers/terraform-provider-gcore/bin"
  }

  # For all other providers, install them directly from their origin provider
  # registries as normal. If you omit this, Terraform will _only_ use
  # the dev_overrides block, and so no other providers will be available.
  direct {}
}
EOF

Optionally specify local.gcore.com/repo/gcore in main.tf configuration file

terraform {
  required_providers {
    gcore = {
      source  = "G-Core/gcore"
      version = ">= 0.3.65"
      # source = "local.gcore.com/repo/gcore"
      # version = ">=0.3.64"
    }
  }
  required_version = ">= 0.13.0"
}

Using the provider

To use the provider, prepare configuration files based on examples

$ cp ./examples/... .
$ terraform init # not needed when override is in use

Updating docs

Don't forget to add docs and examples to support your contribution. Update tfplugindocs when needed.

$ tfplugindocs
$ git add .

Thank You