terraform-provider-edgecenter

command module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2023 License: MPL-2.0 Imports: 3 Imported by: 0

README

Terraform EdgeCenter Provider

EdgeCenter ====================================================================================

Requirements

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

Latest provider

Building the provider

$ mkdir -p $GOPATH/src/github.com/terraform-providers
$ cd $GOPATH/src/github.com/terraform-providers
$ git clone https://github.com/Edge-Center/terraform-provider-edgecenter.git
$ cd $GOPATH/src/github.com/terraform-providers/terraform-provider-edgecenter
$ make build

Override Terraform provider

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

create Terraform configuration file

$ touch ~/.terraformrc

point provider to development path

provider_installation { 
 
  dev_overrides { 
      "local.edgecenter.ru/repo/edgecenter" = "/<dev-path>/terraform-provider-edgecenter/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 {} 
}

add local.edgecenter.ru/repo/edgecenter to .tf configuration file

terraform {
  required_version = ">= 0.13.0"

  required_providers {
    edgecenter = {
      source = "local.edgecenter.ru/repo/edgecenter"
      version = "{version_number}"  # need to specify
    }
  }
}

Using the provider

To use the provider, prepare configuration files based on examples

$ cp ./examples/... .
$ terraform init

Debugging

There are two ways to debbugging the provider:

vscode debugging

  1. create a launch.json file
  • In the the Run view, click create a launch.json file
  • Choose Go: Launch Package from the debug configuration drop-down menu.
  • VS Code will create a launch.json file in a .vscode folder in your workspace
  1. add a new configuration to launch.json:
  • the address arg must be equal to the source field from your provider.tf
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Terraform Provider",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceFolder}",
            "env": {},
            "args": [
                "-debug",
                "-address=local.edgecenter.ru/repo/edgecenter"
            ]
        }
    ]
}
  1. launch the debug mode: Run > Start Debugging (F5)
  2. copy TF_REATTACH_PROVIDERS env from the console and export it to the terminal as follows:
export TF_REATTACH_PROVIDERS='{"local.edgecenter.ru/repo/edgecenter":{...'
  1. set a breakpoint in your code and apply the terraform config: terraform apply
  2. debugging

using delve

  1. installing the delve lib - installation
  2. building binary without optimisation or use make build_debug
go build -o bin/$(BINARY_NAME) -gcflags '-N -l'
  1. open first terminal:
  • run the binary with debug option:
dlv exec bin/terraform-provider-edgecenter -- -debug
  • set a breakpoint for the create function with a resource that want to debug, e.g,
break resourceFloatingIPCreate
  • continue
  • copy TF_REATTACH_PROVIDERS with its value from output
  1. open second terminal:
  • exporting TF_REATTACH_PROVIDERS:
export TF_REATTACH_PROVIDERS='{"local.edgecenter.ru/repo/edgecenter":{...'
  • launch terraform apply
  • debugging with the continue command in the first terminal via delve

Thank You

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL