Creating an Import Job

Create an import job in Resource Manager to import state files for existing resources already managed by Terraform. An import job sets the provided Terraform state file as the current state of the stack.

For example, use an import job to migrate a local Terraform environment to Resource Manager.

Tip

After running an import job, get the job's details to check its status. You can optionally view the Terraform state file and view the logs.

Monitor the job status (lifecycle state) by getting the job: Succeeded (SUCCEEDED) indicates that the job has completed. Depending on the complexity the job, the operation can take some time. While the job runs, or after it completes, you can get the job logs content.

To view the Terraform state file (shows the state of your resources after running the job), click the name of the job to display the Job details page, then click View state under Resources. Optionally select Show changes in this version.

To view the logs for the job, click the name of the job to open the Job details page, then click Logs under Resources.

    1. Open the navigation menu and click Developer Services. Under Resource Manager, click Stacks.
    2. Choose a compartment that you have permission to work in (on the left side of the page).
    3. Click the name of the stack that you want.
      The Stack details page opens.
    4. Go to More actions and select Import state.
    5. In the Import panel, fill in the fields.
      FieldDescription
      Name Name of apply job.
      Select a Terraform state file to upload Add your Terraform state file, either by dragging and dropping it onto the dialog's control, or by clicking Browse and navigating to the file location.
    6. To configure advanced options, click Show advanced options and fill in the fields.
      FieldDescription
      Upgrade provider versions

      Upgrade provider versions (stack must be Terraform 0.14 and later; older stacks must be upgraded to use Terraform Registry): Retrieves the latest versions available from the configured source of Terraform providers.

      Required if provider versions in the Terraform configuration changed since the last time a job was run on the stack. Dependency lock files are automatically managed for new and updated stacks. Providers are updated within the version constraints of your Terraform configuration.

      Tags Optionally apply tags to the stack.
    7. Click Import.

    The import job is created. The new job is listed under Jobs.

  • Use the oci resource-manager job create-import-tf-state-job command and required parameters to run an import job.

    oci resource-manager job create-import-tf-state-job [OPTIONS]

    For a complete list of flags and variable options for CLI commands, see the Command Line Reference for Resource Manager.

  • Use the CreateJob operation to create an import job.

    For an example of the operation part of the request, see CreateImportTfStateJobOperationDetails.