action.skip

Troubleshooting the Megaport Terraform Provider

If you encounter problems with the Megaport Terraform Provider, step through these troubleshooting actions.

For information about troubleshooting API issues, see Troubleshooting the API.

Troubleshooting actions

Action Steps
Ensure you are using the latest version of Terraform and the Megaport Terraform Provider Make sure you are using a supported version of Terraform and the latest version of the Megaport Terraform Provider, as indicated in the Megaport Terraform Provider Registry. Megaport tests against the two latest major versions of Terraform.

To check both, run the command:

terraform version

which should output the version information like this:

Terraform v#.#.#
on darwin_arm64
+ provider registry.terraform.io/megaport/megaport v#.#.#

You can update Terraform by downloading from Upgrading Guides (HashiCorp).

The version of the Megaport Terraform Provider is what you declare when you create the provider in the Terraform file. For more information, see Creating a Megaport Terraform Provider Configuration File.
Resolve Azure VXC deletion error Deleting an Azure VXC leads to the error:

Error: Error deleting resource ****: has an attached peering connection that must be removed in Azure first:

To resolve this issue, the ExpressRoute peering should be managed using the Azure Terraform provider instead and it will then be torn down before the VXC. For more information, see the Azure provider documentation.
Resolve VXC being deleted issue when associated service is deleted The provider does not handle the situation when a Port is recreated, which then deletes the Port and its associated VXCs.

For example, if you had a Terraform file with a Port with a speed of 1000:

resource "megaport_port" "port_2" {
  product_name = "port2"
  port_speed = 1000
  location_id = data.megaport_location.loc.id
  contract_term_months = 12
  marketplace_visibility = false
  cost_centre = "test2"
  diversity_zone = "red"
}

and wanted to update the port_2 speed to 10000, it will trigger the Port to be recreated, which will first delete the Port and its associated VXCs. The provider does not currently handle this and will return an error like this:

Error: Error Updating VXC
Could not update VXC with ID a7b44cda-28bc-4d64-b05b-8703114a8fcd: PUT https://api-staging.megaport.com/v3/product/vxc/a7b44cda-28bc-4d64-b05b-8703114a8fcd: 400 (trace_id "89b4016d9f9d0b7545987092d0b17493") Product [a7b44cda-28bc-4d64-b05b-8703114a8fcd] Not Found

To resolve this, you can specify a lifecycle modifier to the Port resource like below, which will first create the new Port, perform the update on the VXC, then delete the old Port.

lifecycle {
  create_before_destroy = true
}
Report the provider error message If you see the following error message, it indicates a problem with the provider. Contact support or create a GitHub issue and include details of the process that caused it, to have this error recorded and investigated.

"This is a bug in the provider, which should be reported in the provider's own issue tracker."