Running a workspace plan
A workspace plan, performs a Terraform plan to determine the IBM Cloud® resources that are created, modified or deleted on any subsequent workspace apply operation. Run the Schematics plan job against your workspace. You can use the plan summary logs to verify any resource changes before the template is applied.
IBM Cloud Schematics deprecates older version of Terraform. For more information, see Deprecating older version of Terraform process in IBM Cloud Schematics.
IBM Cloud Schematics deprecates creation of workspace using the IBM Cloud Provider Plug-in for Terraform v1.2, v1.3 template from 2nd week of April 2024.
Before you begin
- Create a Terraform configuration, and store the configuration in a
GitHub
,GitLab
, orBitbucket
repository. You can also upload a copy of the repo as atar
(tape archive file) from your local workstation to provide your template to IBM Cloud Schematics. For more information, see theibmcloud schematics workspace upload
command and see the upload atar
file to your workspace API. - Make sure that you have the permissions to create a workspace.
Ensure the location
and the url
endpoint are pointing to the same region when you list the Schematics workspaces and actions. For more information about location and endpoint, see Where is your information stored?
- Run a Schematics plan job against your workspace. An plan job calculates which resources are provisioned, modified, or removed. This process might take a few minutes.
During workspace plan execution, you cannot edit your workspace.
Generate a workspace plan using the UI
- Log in to IBM Cloud console.
- Click the Menu icon > Platform Automation > Schematics > Terraform.
- Click your workspace name.
- Click Generate Plan to create a plan for the workspace.
Verifying workspace plan
- Click on your workspace that is listed in the IBM Cloud console
- Click Jobs to see the job execution results. It are listed under the heading
Generate Plan
- On a successful plan, the cost for the proposed changes is reviewed by clicking on the
Cost Estimate
button. For more information, see Infrastructure cost estimation.
Generate a workspace plan using the CLI
-
Create a JSON file on your system and plan your workspace configuration. For more information about configuration options, see
ibmcloud schematics workspace new
command.Example
{ "name": "testwspace31jan", "type": [ "terraform_v1.4" ], "description": "terraform workspace", "location": "us-east", "tags": [ "department:HR", "application:compensation", "environment:production" ], "template_repo": { "url": "https://github.com/Anil-CM/newrepo" }, "workspace_status": { "frozen": true }, "template_data": [{ "folder": ".", "type": "terraform_v1.4", "variablestore": [{ "name": "sample_var", "secure": true, "value": "THIS IS IBM CLOUD TERRAFORM CLI DEMO", "description": "Description of sample_var" }, { "name": "sleepy_time", "value": "15" } ] }] }
Syntax
ibmcloud schematics plan --id WORKSPACE_ID [--output OUTPUT] [--var-file PATH_TO_VARIABLES_FILE] [--var-file PATH_TO_VARIABLES_FILE] []
For more information about syntax and arguments flags, see
ibmcloud schematics plan
command. -
Verify that your workspace plan is applied. Make sure that your workspace is in an Inactive state.
ibmcloud schematics workspace list
-
Refer to, Managing IBM Cloud resources with Schematics to view job logs.
Verifying workspace plan execution
Execute CLI command to check the status of the workspace plan is success.
```sh {: pre}
ibmcloud schematics workspace list
```
```text {: screen}
Retrieving workspaces...
Name ID Description Version Status Frozen
testwspace31jan us-east.workspace.testwspace31jan.a31438c6 terraform workspace Terraform v1.0.11 INACTIVE True
OK
```
On successful plan returns the update details of an existing workspace.
For more information about FAQ, see troubleshooting section.
Generate a workspace plan using the API
-
Follow the steps to retrieve your IAM access token and authenticate with IBM Cloud Schematics by using the API.
-
Generate plan for the existing workspace.
Example
POST /v1/workspaces/{w_id}/plan HTTP/1.1 Host: schematics.cloud.ibm.com Content-Type: application/json Authorization: <auth-token> Cache-Control: no-cache Postman-Token: bdc869fd-dc7c-06a6-5e99-4de6e3aa7dd9 { "name": "testwspace31jan", "type": [ "terraform_v1.4" ], "description": "terraform workspace", "location": "us-east", "tags": [ "department:HR", "application:compensation", "environment:production" ], "template_repo": { "url": "<gitrepo-url>" }, "workspace_status": { "frozen": true }, "template_data": [{ "folder": ".", "type": "terraform_v1.4", "variablestore": [{ "name": "sample_var", "secure": true, "value": "THIS IS IBM CLOUD TERRAFORM CLI DEMO", "description": "Description of sample_var" }, { "name": "sleepy_time", "value": "15" } ] }] }
-
See Managing IBM Cloud resources with Schematics to create, update, or delete IBM Cloud resources with Terraform.
Verifying workspace plan execution
Verify that the workspace plan is successfully listed with the list of workspace jobs that were created.
curl -X GET https://schematics.cloud.ibm.com/v1/workspaces -H "Authorization: <iam_access_token>"
Output
{
"activityid": "3815ef757cd34030bc43191f7d7c6744"
}
On successful, returns the list of the workspace.
For more information, see FAQ, and troubleshooting section.
Generating a workspace plan using Terraform
-
Follow the steps in Setting up Terraform for Schematics to create your workspace with Terraform.
-
See Managing IBM Cloud resources with Schematics to start creating, updating, or deleting IBM Cloud resources with Terraform.
Next steps
The next stage of working with workspace is deploying workspaces.
For more information, see FAQ, and troubleshooting section.