IBM Cloud Docs
Downloading workspace job files

Downloading workspace job files

Schematics Job maintains a record of an automation run. You can use the job-id to view your job status, download job logs, and download the output files.

Workspace job execution

Schematics allows users to download the latest state-file of a workspace by using the existing API and CLI. In addition, you can use the new job files endpoint to download the state-file generated by the workspace apply command, for an automation job that was executed in the past, using the job-id.

You can use the older version of the state-file, to create a new workspace to roll-back to an older version of the state-file. You must be aware that the state-file contains a local representation of the cloud resources that was provisioned by using the Terraform template. And the state-file automatically refreshes by Terraform based on the remote state or current state of the cloud resources.

The Schematics Job file download endpoint is designed to support the ability to download any output files generated by the Job. Currently, it supports the ability to download state file. For example, in future you can download Terraform plan file in JSON format.

The response of this endpoint embeds the content of the file in the field file_content as shown in the example response.

{
    "job_id": "7df1491f47a111f31f3af7ecb42de5ae",
    "file_type": "state_file",
    "file_content": "{\n  \"version\": 4,\n  \"terraform_version\": \"0.15.5\",\n  \"serial\": 1,\n  \"lineage\": \"d415374e-08a8-7770-f009-f24a9c65b2e2\",\n  \"outputs\": {},\n  \"resources\": [\n    {\n      \"mode\": \"managed\",\n      \"type\": \"null_resource\",\n      \"name\": \"sleep\",\n      \"provider\": \"provider[\\\"registry.terraform.io/hashicorp/null\\\"]\",\n      \"instances\": [\n        {\n          \"schema_version\": 0,\n          \"attributes\": {\n            \"id\": \"5881126972189801242\",\n            \"triggers\": {\n              \"uuid\": \"78596474-ab23-91d4-0542-f4f75cdcb65a\"\n            }\n          },\n          \"sensitive_attributes\": [],\n          \"private\": \"bnVsbA==\"\n        }\n      ]\n    }\n  ]\n}\n",
    "updated_at": "2021-11-11T12:47:21.954546428Z"
}

Note

  • Automation script can read the Job content as a plain string and use it.
  • For a manual reader, Job file may not look very neat.
  • If the content is copied from the response, the content should be added with the JSON escaped character.