Creating an Apply Rollback Job

Create an apply rollback job in Resource Manager.

When you create (run) an apply rollback job for a stack, Terraform provisions the resources and executes the action defined in the target job's Terraform configuration, applying the execution plan to the associated stack. This job rolls back your Oracle Cloud Infrastructure resources to a previous state.

We recommend creating (running) a plan rollback job (generating an execution plan) before running an apply rollback job, using the following flow.

  1. Identify the successful apply job that you want to roll back to.

    The job you want to roll back to is also known as the "target job."

  2. Create a plan rollback job for the target job.

  3. Confirm that the plan rollback job succeeded.

  4. Confirm that the generated execution plan meets expectations.

  5. Create an apply rollback job using the generated execution plan (executionPlanRollbackStrategy).

    Instructions are on this page.

Tip

Depending on the number and type of resources specified, a given apply rollback job can take some time.

After running an apply rollback job, get the job's details to check its status. You can optionally view the Terraform state file, view the logs, and confirm existence of provisioned resources.

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.

To confirm existence of newly provisioned resources, inspect resources in the compartment.

    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. In the Jobs list, locate the job that you want to use for creating an apply rollback job.
      You can choose a plan rollback job (recommended) or an apply job.
    5. For the job you want, click the Actions menu and then select Rollback.
      The Rollback panel opens, showing the OCID and name of the selected job.
    6. In the Rollback panel, fill in the fields.
      FieldDescription
      Rollback job type Type of rollback job. Select Apply to create an apply rollback job.
      Name of this rollback job Name of job. A default name is provided.
      Execution plan rollback strategy

      Plan resolution:

    7. To configure advanced options, click Show advanced options and fill in the fields.
      FieldDescription
      Detailed log level

      Detailed log level: Verbosity to use for Terraform detailed log content for this job. Default: None (no detailed log content is generated).

      For more information, see Debugging Terraform.

      Maximum number of parallel operations

      Maximum number of parallel operations: Concurrent operations as Terraform walks the graph. Default: 10.

      Use this option to speed up the job.

      Note

      A high value might cause throttling of resources. For example, consider a Terraform configuration that defines hundreds of compute instances. An Apply job attempts to create as many instances as possible at the same time. In this example, a value of 100 might cause throttling by the Compute service.

      Refresh resource states before checking for differences

      Refresh resource states before checking for differences: Fetch the latest state of stack infrastructure before running the job. Default: Enabled.

      Use this option to refresh the state first. For example, consider using this option with an Apply job that you intend to run on manually updated (existing) infrastructure.

      Note

      Refreshing the state can affect performance. Consider disabling if the configuration includes several resources.

      Tags Optionally apply tags to the job.
    8. Click OK.

    The apply rollback job is created. The new job is listed under Jobs.

  • Use the oci resource-manager job create-apply-rollback-job command and required parameters to run an apply rollback job.

    oci resource-manager job create-apply-rollback-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 apply rollback job.

    For examples of details for an apply rollback job, see ApplyRollbackJobOperationDetails.