Getting a Job's State File

Download the Terraform state file (.json) from a completed apply, apply rollback, or import job in Resource Manager.

Note

To prevent errors caused by unavailable files, wait a second after the job finishes to download the job information. An error appears if the job information doesn't exist yet. For example, a 409 error appears if you attempt to download the Terraform configuration immediately after running a job. In this case, the Terraform configuration is still being copied to a location using a background process. The Terraform configuration is available about a second after the job finishes.
  • These steps show how to get the state for a job in a compartment. You can also get the state for a job in a stack.
    1. Open the navigation menu and click Developer Services. Under Resource Manager, click Jobs.
    2. On the Jobs page, select the compartment that contains the job that you want.
    3. Click the name of the job that you want.
    4. On the Job details page, under Resources, click View state.
      Don't see View state? Check that the job has finished running, and that it's an apply job, apply rollback job, or import job. No state files are available for canceled jobs.
    5. (Optional) Select Show changes in this version.
    6. (Optional) Click Download Terraform state.
  • Use the oci resource-manager job get-job-tf-state command and required parameters to get a job's state.

    oci resource-manager job get-job-tf-state [OPTIONS]

    For a complete list of parameters and values for CLI commands, see the Command Line Reference for Resource Manager.

  • Use the GetJobTfState operation to get a job's state.

    Example Response
    {
      "data": 
      {
        "lineage": "57ef4f0c-c8cd-8a32-d45f-d2c40be7b915",
        "modules": 
        [
          {
            "depends_on": [],
            "outputs": {},
            "path": 
            [
              "root"
            ],
            "resources": 
            {
              "oci_core_virtual_network.vcn1": {
              "depends_on": [],
              "deposed": [],
              "primary": 
              {
                "attributes": {
                "cidr_block": "10.0.0.0/16",
                "compartment_id": "ocid1.tenancy.oc1..uniqueid",
                "default_dhcp_options_id": "ocid1.dhcpoptions.oc1.phx.uniqueid",
                "default_route_table_id": "ocid1.routetable.oc1.phx.uniqueid",
                "default_security_list_id": "ocid1.securitylist.oc1.phx.uniqueid",
                "display_name": "My VCN display name",
                "dns_label": "myvcntest",
                "id": "ocid1.vcn.oc1.phx.uniqueid",
                "state": "AVAILABLE",
                "time_created": "2018-05-24 01:13:05.855 +0000 UTC",
                "vcn_domain_name": "myvcntest.oraclevcn.com"
              },
              "id": "ocid1.vcn.oc1.phx.uniqueid",
              "meta": 
              {
                "e2bfb730-ecaa-11e6-8f88-34363bc7c4c0": {
                "create": 300000000000,
                "delete": 300000000000,
                "update": 300000000000
              }
            },
            "tainted": false
          },
          "provider": "provider.oci",
          "type": "oci_core_virtual_network"
              }
            }
          }
        ],
      "serial": 4,
      "terraform_version": "0.11.7",
      "version": 3
    }
    }