action.skip

Megaport Terraform Provider Frequently Asked Questions (FAQs)

This topic covers frequently asked questions about using the Megaport Terraform Provider. For more information, see Megaport Terraform Provider Overview.

How do I find DC location information?

The easiest way to find a location is with the location name in the Portal.

However, data center location information information, such as name or site code, is subject to change in the API. For reliable and stable Terraform configurations, we strongly recommend using the location ID instead of names or codes. The most up-to-date list of Megaport data center locations can be accessed through the GET /v3/locations API.

For more information, see step 2 in Creating a Megaport Terraform Provider Configuration File.

How do I avoid deleting live services in the production environment while deploying a Terraform configuration file?

Lock your live services via the Portal before deploying a Terraform configuration file. For more information, see Locking Megaport Services.

How do I add new VXCs to a Port?

If a service such as a Port already exists in the production environment but isn’t in your Terraform configuration file, you’ll need to import it. For more information, see Importing Existing Production Services.

Afterwards, add a new configuration line in the Terraform file to create a new VXC under that Port.

How do I change the name of a service?

Update the product_name field in the Terraform configuration file.

Example: Change product_name = “Name of Product” to product_name = “Updated Name of Product”, then run the terraform apply command.

Does the Megaport Terraform Provider support managing IX services?

Yes, it does.

How do I apply a service key while ordering a VXC?

First, set up a service key in the Portal. For more information, see Setting Up Service Keys.

Then apply it in the Terraform configuration file. See the example below.

   resource "megaport_vxc" "port_to_port" {
    product_name           = "Port-to-Port VXC Example"
    rate_limit             = 500
    contract_term_months   = 12
    service_key            = "example-service-key-from-the portal"
    cost_centre            = "Megaport VXC Example"
   }

You would also need to add the rest of the Terraform configuration syntax to define two services connecting to the VXC.

How do I find the current version of Terraform on my computer?

Run the terraform version command to check the version of Terraform you have installed.

This will output the version information for Terraform.

If the output is similar to the example below, visit Upgrading Guides (HashiCorp) to update your system.

   terraform version Your version of Terraform is out of date! 
   The latest version is x.y.z.
   You can update by downloading from 
   https://www.terraform.io/downloads.html

How do I find the current version of the Megaport Terraform Provider?

Megaport tests against the two latest major versions of Terraform. You can find the latest version of the Megaport Terraform Provider in the Megaport Terraform Provider HashiCorp Registry documentation. We highly recommend that you keep the version in your provider.tf file updated with the latest provider version.

Where do I update the Megaport Terraform Provider version number?

You update the version field in the provider.tf file.

See version = "1.3.6" in the following example.

terraform {
       required_providers {
       megaport = {
       source  = "megaport/megaport"
       version = "1.3.6"
           }
       }
   }

Do you support OpenTofu?

Previously named OpenTF, OpenTofu is an open-source Infrastructure as Code (IaC) tool that forked from HashiCorp Terraform in 2023. It provides the same core functionality as Terraform but is maintained by the Linux Foundation as a vendor-neutral, community-driven project.

OpenTofu maintains compatibility with Terraform configurations and providers. It uses the same HCL (HashiCorp Configuration Language) syntax, however, OpenTofu is not officially supported and is not actively tested against, so this could change in the future. For more information, see https://opentofu.org/.

Where are the most current examples?

Examples for Ports, VXCs, MCRs, and MVEs are available in the examples directory of the provider. Additional guidance can be found in the Guides section of the Megaport Terraform Provider Registry, which provides context and instructions to complement the examples.

How does terming work with the provider?

There should be no issues with putting a service on a contract term using Terraform.

Why is there a requested_product_uid field?

This is because when selecting a partner Port, we don’t allow the user to pick the specific Port, and the API will pick one dynamically for capacity reasons. This means that this field can be different to what the user requested, which would cause an error in the provider.

Helpful references