> ## Documentation Index
> Fetch the complete documentation index at: https://docs.megaport.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Importing Existing Production Services

> This help topic describes steps to import existing production services into a target Terraform configuration file.

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.

   ```terraform theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   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.

   <img src="https://mintcdn.com/megaport-b7713936/pyW7zaB5dtPD-GSa/images/terraform/product-long-uid.png?fit=max&auto=format&n=pyW7zaB5dtPD-GSa&q=85&s=df35085897c99ac0397a13ff0e369def" alt="You can find the product long UID in the portal" width="900" height="796" data-path="images/terraform/product-long-uid.png" />

3. Run the following command:

   ```shell theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}

   terraform import <IMPORTING RESOURCE> "<PRODUCT_UID>"

   ```

   Example:

   ```shell theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}

   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:

   <img src="https://mintcdn.com/megaport-b7713936/pyW7zaB5dtPD-GSa/images/terraform/tf-import-successfully-message.png?fit=max&auto=format&n=pyW7zaB5dtPD-GSa&q=85&s=0dcda3b55ebc766b3275c1e93b628b47" alt="Import successfully message" width="709" height="160" data-path="images/terraform/tf-import-successfully-message.png" />

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

## Helpful references

* [Megaport Terraform Provider GitHub Best Practice for Imports](https://github.com/megaport/terraform-provider-megaport?tab=readme-ov-file#best-practice-for-imports)
* [Megaport Terraform Provider GitHub Importing Existing Resources](https://github.com/megaport/terraform-provider-megaport?tab=readme-ov-file#importing-existing-resources)
* [Megaport Terraform Provider Registry documentation (import IX)](https://registry.terraform.io/providers/megaport/megaport/latest/docs/resources/ix#import)
* [Megaport Terraform Provider Registry documentation (import Lag Port)](https://registry.terraform.io/providers/megaport/megaport/latest/docs/resources/lag_port#import)
* [Megaport Terraform Provider Registry documentation (import MCR)](https://registry.terraform.io/providers/megaport/megaport/latest/docs/resources/mcr#import)
* [Megaport Terraform Provider Registry documentation (import MVE)](https://registry.terraform.io/providers/megaport/megaport/latest/docs/resources/mve#import)
* [Megaport Terraform Provider Registry documentation (import NAT Gateway)](https://registry.terraform.io/providers/megaport/megaport/latest/docs/resources/nat_gateway#import)
* [Megaport Terraform Provider Registry documentation (import optional VXC information)](https://registry.terraform.io/providers/megaport/megaport/latest/docs/resources/vxc#optional)
* [Megaport Terraform Provider Registry documentation (import VXC)](https://registry.terraform.io/providers/megaport/megaport/latest/docs/resources/vxc#import)
