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, 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. For the most up-to-date list of Megaport data center locations, see Megaport Location IDs.
Location IDs are also available through the GET /v3/locations Megaport 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.
Once the service key is created, you can apply it in your .tf configuration when ordering a VXC.
In the Megaport GitHub repository, there’s an example in resource.tf showing exactly how to do this.
Look for the block that starts like this:
resource "megaport_vxc" "service_key_vxc" {
Note
- Replace
"YOUR-SERVICE-KEY-HERE"with the value from the Portal. - The
b_endblock is where you specify the service key for the remote end. - You can still define other parameters (for example,
rate_limit, VLAN) as needed. - The provider docs on GitHub include multiple VXC examples, including MCR and cloud connectivity scenarios.
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 actively tests against the two latest major versions of Terraform to ensure compatibility and reliability.
You can find the latest version of the Megaport Terraform Provider in the Megaport Terraform Provider Releases page. This page also includes release notes for each version.
We highly recommend that you keep your Terraform configuration file updated with the latest provider version to take advantage of improvements, new features, and important fixes.
Where do I update the Megaport Terraform Provider version number?
You update the version field in the provider.tf file.
See version = ">= 1.4.1" in the following example. This is an example of a version coding that instructs Terraform to use a version of the provider that is 1.4.1 or newer.
terraform {
required_providers {
megaport = {
source = "megaport/megaport"
version = ">= 1.4.1"
}
}
}
Do you support OpenTofu?
Yes, the Megaport Terraform Provider has been tested and is compatible with OpenTofu starting from version v1.3.7.
OpenTofu is an open-source, community-driven fork of Terraform that maintains compatibility with the same providers and HashiCorp Configuration Language (HCL) syntax.
While we test for compatibility with new Megaport Terraform Provider releases, we recommend checking the Megaport Terraform Provider GitHub Releases page for the latest information.
For usage details, see the Megaport Provider on the OpenTofu Registry and refer to the Megaport Terraform Provider GitHub Readme file.
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.