action.skip

Importing Existing Production Services

You might already have live services in your production environment. To transition to fully automated service management using the Megaport Terraform Provider, the corresponding Terraform configuration file must include resource definitions for all existing services, such as product name, speed, location, and so on.

To achieve this, you will need to import these services into the Terraform configuration file.

Importing production services

To import existing production services, follow these steps. We recommend testing the process in the staging environment first.

To import production services

  1. Create definitions matching the production service(s) in the target directory where related Terraform configuration files exist.

    For example, if you want to import an MCR then you need to add the following Terraform configuration file into the target directory.

    resource "megaport_mcr" "example" {
      product_name           = <importing service's name>
      product_speed          = <importing service's speed>
      location_id            = <importing service's location ID>
      contract_term_months   = <importing service's contract term>
      diversity_zone         = <blue or red>
    }
    
  2. You can find the product_UID in the Portal. Click the service to view the URL.

    The alphanumeric information at the end of the URL is the product_UID.

    You can find the product long UID in the portal

  3. Run the following command:

    terraform import <IMPORTING RESOURCE> "<PRODUCT_UID>"
    

    Example:

    terraform import megaport_mcr.example "example-uid-a123456-7000-3333-xyz"
    

    After the import is complete, you will see a message similar to the following:

    Import successfully message

    Confirm that the target service is imported into Terraform as intended by reviewing the terraform.tfstate file.

Helpful references