terraform-provider-gophers

command module
v0.0.0-...-1de19ad Latest Latest
Warning

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

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

README

Terraform Provider Gophers (Base on Terraform Plugin SDK)

Requirements

Building The Provider

  1. Clone the repository
  2. Enter the repository directory
  3. Build the provider using the make install command:
$ make install

Result:

go build -o terraform-provider-gophers
mkdir -p ~/.terraform.d/plugins/terraform.local/local/gophers/0.0.1/darwin_amd64
mv terraform-provider-gophers ~/.terraform.d/plugins/terraform.local/local/gophers/0.0.1/darwin_amd64

Using the provider

  1. Define the provider you want to use

The provider is defined in examples/provider.tf file:

terraform {
  required_providers {
    gophers = {
      source  = "terraform.local/local/gophers"
      version = "0.0.1"
    }
  }
}
  1. Define the datasources

We defined several datasources in examples/data.f file:

# List of available gophers
data "gophers" "my_gophers" {
}

output "return_gophers" {
  value = length(data.gophers.my_gophers.gophers) >= 1
}

# Display information about a Gopher
data "gophers_gopher" "moultipass" {
  name = "5th-element"
}
  1. Define resources

We defined a resource in examples/resource.f file:

resource "gophers_gopher" "x-files" {
  name = "x-files"
  displayname = "X Files"
  url  = "https://raw.githubusercontent.com/scraly/gophers/main/x-files.png"
}
  1. Init Terraform
rm .terraform.lock.hcl && terraform init
  1. Apply the configuration you defined
terraform apply
  1. destroy datasource and resources you created
terraform destroy

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 or update documentation, run go generate.

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

Documentation

When the plugin will be relkeased, add the following content in the main.tf file:

// Run the docs generation tool, check its repository for more information on how it works and how docs
// can be customized.
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs

And execute the go generate command to generate the documentation:

go generate

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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