IBM Cloud Docs
Running a workspace apply

Running a workspace apply

Schematics uses workspaces to deploy and manage resources in IBM Cloud® accounts.

IBM Cloud Schematics enables you to deploy and manage resources in any IBM Cloud location or region globally. The region where you create and work with your Schematics workspaces and actions is independent of the region where your IBM Cloud resources are deployed or configured.

IBM Cloud Schematics runs your jobs from the Schematics region hosting the workspace and remotely accesses services to provision resources in the target regions determined by your Terraform templates. Workspace operations in remote regions are unaffected by network latency between the management and target regions.

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

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 apply job against your workspace. An apply job provisions, modifies, or removes the IBM Cloud resources that you describe in the Terraform template that your workspace points. Depending on the type and number of resources that you want to provision or modify, this process might take a few minutes, or hours to complete. During this time, you cannot edit your workspace. After all updates are applied, the state of the files persists to determine what resources exist in your IBM Cloud account.

Perform a workspace apply using the UI

  1. Log in to IBM Cloud.
  2. Access Schematics > Workspaces > Workspace.
  3. Search your workspace in specific location.
  4. Click Workspaces > workspace.
  5. Click Apply plan to provision the configured resources.

Verifying workspace apply

  1. Click your workspace that is listed in the IBM Cloud console to view the results of the workspace apply job.

Perform a workspace apply using the CLI

  1. Create a JSON file on your system to pass the parameters to Schematics to run the workspace apply. For more information about configuration options, see ibmcloud schematics workspace new command.

    Example

    {
    	"name": "testwspace31jan",
    	"type": [
    		"terraform_v1.0"
    	],
    	"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.0",
    		"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 apply --id <Provide your workspace ID>
    
  2. Apply the workspace. For more information about the apply argument flag, see ibmcloud schematics apply command.

    ibmcloud schematics apply --id <workspace_id>
    
  3. Verify that your workspace apply has been executed successfully. Make sure that your workspace is in an Inactive state.

    ibmcloud schematics workspace list
    
  4. Refer to, Managing IBM Cloud resources with Schematics to view job logs .

Verifying workspace deploy

Execute CLI command to check the status of the workspace deploy is success.

```text {: screen}
ibmcloud schematics apply --id us-east.workspace.testwspace01feb.b5e8fdaa
Do you really want to perform this action? [y/N]> Y

Activity ID   df51c0e61a020592d3403a05d08692d7   

OK
```

On successful plan it returns the update details of an existing workspace.

For more information about FAQ, see troubleshooting section.

Perform the workspace deploy using the API

  1. Follow the steps to retrieve your IAM access token and authenticate with IBM Cloud Schematics by using the API.

  2. Perform deploy for the existing workspace.

    Example

    
    PUT /v1/workspaces/{w_id}/apply HTTP/1.1
    Host: schematics.cloud.ibm.com
    Content-Type: application/json
    Authorization: <auth-token>
    Cache-Control: no-cache
    Postman-Token: 77ef7f05-7290-0b60-781c-f8c147c78ed2
    
    {
    	"name": "testworkspacejanATTest",
    	"type": [
    		"terraform_v0.13"
    	],
    	"description": "terraform workspace",
    	"tags": [
    		"test:bbbranch"
    	],
    	"template_repo": {
    		"url": "https://github.com/srikar-git/tf_cloudless_sleepy/tree/v0.13"
    	},
    	"template_data": [{
    		"folder": ".",
    		"type": "terraform_v0.13",
    	
    	"variablestore": [
    	{
    	"value": "12",
    	"name": "sleepy_time",
    	"type": "string"
    	}
    ]
    	}]
    }
    
  3. Verify that the workspace deploy list all the workspace jobs that are created.

    curl -X GET https://schematics.cloud.ibm.com/v1/workspaces -H "Authorization: <iam_access_token>"
    
  4. see Managing IBM Cloud resources with Schematics to start creating, updating, or deleting IBM Cloud resources with Terraform.

Verifying workspace deploy

Verify that the workspace are deployed successfully as shown in the output.

Output

```text {: screen}
{
	"activityid": "a75d99109c80291faead70225b5409ee"
}
```

On successful workspace apply, it returns the job activity id performed on the workspace. For more information, see troubleshooting section.

Perform the workspace deploy with Terraform

  1. Follow the steps in Setting up Terraform for Schematics to create your workspace with Terraform.

  2. See Managing IBM Cloud resources with Schematics to create, update, or delete IBM Cloud resources with Terraform.

Next steps

To manage your workspace refer to, deploying workspace, destroying workspace, and deleting workspace.