megaport / terraform-provider-megaport

Terraform Provider for Megaport Network
Mozilla Public License 2.0
26 stars 16 forks source link
megaport megaport-terraform-provider terraform-provider

Megaport Terraform Provider

The terraform-provider-megaport or Megaport Terraform Provider lets you create and manage Megaport's product and services using the Megaport API.

This provides an opportunity for true multi-cloud hybrid environments supported by Megaport's Software Defined Network (SDN). Using the Terraform provider, you can create and manage Ports, Virtual Cross Connects (VXCs), Megaport Cloud Routers (MCRs), and Partner VXCs

The Megaport Terraform Provider is released as a tool for use with the Megaport API.

Important: The usage of the Megaport Terraform Provider constitutes your acceptance of the terms available in the Megaport Acceptable Use Policy and Global Services Agreement.

Documentation

Documentation is published on the Terraform Provider Megaport registry.

Installation

The preferred installation method is via the Terraform Provider Megaport registry.

Local Development

Set up a Go workspace

You don't need to do this if you're not modifying megaportgo, but if you need to modify it you can use a Go workspace to make this process easier. Take a look at this tutorial first to get familiar with how Go workspaces work, then create a workspace for local development. This will let you edit the megaportgo library while working on the Terraform Provider without needing to publish changes to Git or modify your go.mod file in the Terraform Provider with a replace statement.

go 1.22.0
use (
    ./megaportgo
    ./terraform-provider-megaport
)

Allow the provider to be run locally

First, find the GOBIN path where Go installs your binaries. Your path may vary depending on how your Go environment variables are configured.

$ go env GOBIN
/Users/<Username>/go/bin

If the GOBIN Go environment variable is not set, use the default path, /Users/<Username>/go/bin

Create a new file called .terraformrc in your home directory (~), then add the dev_overrides block below. Change the <PATH> to the value returned from the go env GOBIN command above.

provider_installation {
  dev_overrides {
      "registry.terraform.io/megaport/megaport" = "<PATH>"
  }
  # 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 {}
}

Once you’ve done that you can test out changes to the provider by installing it with

go install .

inside of the terraform-provider-megaport folder

Example Use Cases

A suite of tested examples is in the examples directory

Contributing

Contributions via pull request are welcome. Familiarize yourself with these guidelines to increase the likelihood of your pull request being accepted.

All contributions are subject to the Megaport Contributor Licence Agreement. The CLA clarifies the terms of the Mozilla Public Licence 2.0 used to Open Source this respository and ensures that contributors are explictly informed of the conditions. Megaport requires all contributors to accept these terms to ensure that the Megaport Terraform Provider remains available and licensed for the community.

When you open a Pull Request, all authors of the contributions are required to comment on the Pull Request confirming acceptance of the CLA terms. Pull Requests can not be merged until this is complete.

Megaport users are also bound by the Acceptable Use Policy.