Migrating a Legacy Provider Source Configuration to the Supported Configuration

Migrate providers from the legacy hashicorp/oci source configuration to oracle/oci.

The required_providers block of a Terraform configuration file might use the legacy hashicorp/oci source configuration.

Example:

terraform {
  required_providers {
    oci = {
      source = "hashicorp/oci"
      version = "4.55.0"
    }
  }
}

This legacy hashicorp/oci source configuration won't be supported in the future.

Migrate any legacy source configuration to the current oracle/oci source configuration.

  1. Update the required_providers block in the Terraform configuration.

    Example:

    terraform {
      required_providers {
        oci = {
          source = "oracle/oci"
        }
      }
    }

    To specify a version, add a version line.

    Example (version 4.55.0):

    terraform {
      required_providers {
        oci = {
          source = "oracle/oci"
          version = "4.55.0"
        }
      }
    }
  2. If you use modules, then add the following block to each module.
    terraform {
      required_providers {
        oci = {
          source = "oracle/oci"
        }
      }
    }

    To specify a version, add a version line (see example in previous step).

    For information on providers in modules, see Providers Within Modules.

  3. Run terraform init.

    The state of the migration attempt is indicated by the response:

    • Successful command indicates successful migration.
    • The following error indicates failed migration.
      │ Error: Failed to load plugin schemas
      │
      │ Error while loading schemas for plugin components: Failed to obtain
      │ provider schema: Could not load the schema for provider
      │ registry.terraform.io/hashicorp/oci: failed to instantiate provider
      │ "registry.terraform.io/hashicorp/oci" to obtain schema: unavailable provider
      │ "registry.terraform.io/hashicorp/oci"..
  4. If the migration failed, then do the following:
    1. Run terraform state replace-provider -auto-approve hashicorp/oci oracle/oci.
    2. Run terraform init.

Was this article helpful?