Remote State Consumers

The Workspace resource

A Workspace is where Terraform runs are performed for a specific configuration, and where the resulting state file(s) are stored.

Workspaces belong to environments and can have variables configured to provide inputs to the configuration, authenticate providers etc.

Key path

Description

type* (string)

Available values: workspaces

id (string)

attributes.apply-schedule (string)

Cron expression for scheduled runs. Time should be in UTC.

attributes.auto-apply (boolean)

Indicates whether terraform apply should automatically run when terraform plan ends without error. Default false.

attributes.auto-queue-runs (object)

Available values: always, never, skip_first

Indicates if runs have to be queued automatically when a new configuration version is uploaded. skip_first - after the very first configuration version is uploaded into the workspace the run will not be triggered.

But the following configurations will do. This is the default behavior.

always - runs will be triggered automatically on every upload of the configuration version. never - configuration versions are uploaded into the workspace, but runs will not be triggered.

attributes.created-at (string)

The resource creation timestamp.

attributes.destroy-schedule (string)

Cron expression for scheduled destroy runs. Time should be in UTC.

attributes.execution-mode (string)

Available values: remote, local

Which execution mode to use. Valid values are remote and local. When set to local, the workspace will be used for state storage only.

attributes.force-latest-run (boolean)

Indicates whether force run should automatically apply to latest run. Default false.

attributes.global-remote-state (boolean)

Specifies if the state is globally shared within the environment.

attributes.has-resources (boolean)

Indicates whether the workspace’s current state version contains terraform resources.

attributes.hooks.post-apply (string)

Command that should be run after terraform apply operation executed.

attributes.hooks.post-plan (string)

Command that should be run after terraform plan operation executed.

attributes.hooks.pre-apply (string)

Command that should be run before terraform apply operation executed.

attributes.hooks.pre-init (string)

Command that should be run before terraform init operation executed.

attributes.hooks.pre-plan (string)

Command that should be run before terraform plan operation executed.

attributes.lock-reason (string)

The reason (if any) that the workspace has been locked.

attributes.locked (boolean)

Indicates whether the workspace is locked for operations. The lock-reason attribute carries the explanation.

This semaphore is acquired and released by terraform apply and can also manage it with Lock/Unlock Workspace.

Default: false

attributes.name* (string)

Workspace name which must be unique within the environment.

Comprises letters, numbers, -, and _ only.

attributes.operations (boolean)

The attribute operations is deprecated. Use execution-mode instead.

attributes.permissions (object)

attributes.run-operation-timeout (integer)

The timeout for the Terraform Run operations (in minutes).

attributes.terraform-version (string)

The version of Terraform the workspace performs runs on. If omitted, the system default version is assigned.

attributes.updated-at (string)

The resource last update timestamp.

attributes.updated-by-email (string)

The email of the last user, that updated this workspace.

attributes.var-files (array)

attributes.vcs-repo.branch (string)

Branch of a repository the workspace is associated with. If omitted, the repository default branch will be used.

attributes.vcs-repo.dry-runs-enabled (boolean)

When true once a pull request into the vcs-repo.branch is opened, every push to a pull request’s branch will trigger a dry run in the workspace. Default true

attributes.vcs-repo.identifier* (string)

A reference to your VCS repository.

For GitHub, GitHub Enterprise and GitLab the format is <org>/<repo>. Azure DevOps Services has the format <org>/<project>/<repo>.

attributes.vcs-repo.ingress-submodules (boolean)

Specifies whether git submodules should be fetched when cloning the VCS repository.

attributes.vcs-repo.path (string)

The attribute vcs-repo.path is deprecated. Use working-directory and trigger-prefixes instead.

attributes.vcs-repo.trigger-prefixes (array)

List of paths (relative to the configuration version root), whose changes will trigger a run for the workspace using this binding when the CV is created. If omitted, any change in he configuration version root will trigger a new run.

attributes.working-directory (string)

A relative path where Terraform commands will execute in.

relationships.agent-pool (object)

The ID of the agent pool.

relationships.agent-pool.data.type* (string)

Available values: agent-pools

relationships.agent-pool.data.id* (string)

relationships.configuration-version (object)

The latest uploaded configuration version.

relationships.configuration-version.data.type* (string)

Available values: configuration-versions

relationships.configuration-version.data.id* (string)

relationships.created-by (object)

The user, who has triggered the run.

relationships.created-by.data.type* (string)

Available values: users

relationships.created-by.data.id* (string)

relationships.current-run (object)

Currently executing Run.

relationships.current-run.data.type* (string)

Available values: runs

relationships.current-run.data.id* (string)

relationships.environment (object)

The environment this workspace belongs to.

relationships.environment.data.type* (string)

Available values: environments

relationships.environment.data.id* (string)

relationships.latest-configuration-version (object)

The configuration version of the latest non-dry Run in this workspace.

relationships.latest-configuration-version.data.type* (string)

Available values: configuration-versions

relationships.latest-configuration-version.data.id* (string)

relationships.latest-run (object)

Latest finished Run.

relationships.latest-run.data.type* (string)

Available values: runs

relationships.latest-run.data.id* (string)

relationships.locked-by.data.type* (string)

Available values: users

relationships.locked-by.data.id* (string)

relationships.locked-by-run.data.type* (string)

Available values: runs

relationships.locked-by-run.data.id* (string)

relationships.module-version (object)

The ID of the module version.

relationships.module-version.data.type* (string)

Available values: module-versions

relationships.module-version.data.id* (string)

relationships.tags.data* (array)

relationships.updated-by (object)

The last user, that updated this workspace.

relationships.updated-by.data.type* (string)

Available values: users

relationships.updated-by.data.id* (string)

relationships.vcs-provider (object)

VCS provider of the Run’s workspace

relationships.vcs-provider.data.type* (string)

Available values: vcs-providers

relationships.vcs-provider.data.id* (string)

links.self (string)

Delete remote state consumers

DELETE /workspaces/{workspace}/relationships/remote-state-consumers

This endpoint removes provided workspaces from a list of allowed remote state consumers for a given workspace.

Parameters
  • workspace (string) – The ID of the workspace.

Request body:

Key path

Description

data (array)

Example Request:

The body must contain a data member whose value is an empty array or an array of workspace identifier objects.

DELETE /workspaces/{workspace}/relationships/remote-state-consumers HTTP/1.1
Host: my.scalr.io
Content-Type: application/vnd.api+json
Prefer: profile=preview

{
"data": [
    {
      "id": "ws-u2gp3vv58g0b9vo",
      "type": "workspaces"
    },
    {
      "id": "ws-u2gp3cuiq67fh18",
      "type": "workspaces"
    }
  ]
}
Status Codes
  • 204 No Content – Success.

  • 403 Forbidden – User unauthorized to perform this action.

  • 404 Not Found – Workspace not found, or user unauthorized to perform action.

  • 409 Conflict – Not allowed. global-remote-state is enabled for the workspace.

  • 4XX – Client error.

  • 5XX – Server error.

Request Headers
  • Prefer – Specifies the API profile that server should use to handle this request. For the list of supported profiles check out the Scalr documentation. (Required)

List remote state consumers

GET /workspaces/{workspace}/relationships/remote-state-consumers

This endpoint returns a list of other workspaces that are allowed to access the given workspace’s state during runs.

Parameters
  • workspace (string) – The ID of the workspace.

Query Parameters
  • page[number] (string) – Page number

  • page[size] (string) – Page size

Example Request:

GET /workspaces/{workspace}/relationships/remote-state-consumers HTTP/1.1
Host: my.scalr.io
Prefer: profile=preview
Status Codes
  • 200 OK

    Request was successful.

    Example Respone:

    HTTP/1.1 200 OK
    Content-Type: application/vnd.api+json
    Preference-Applied: profile=preview
    
    {
      "data": [
        {
          "id": "ws-u3ep4of9hl5o4n8",
          "type": "workspaces"
        },
        {
          "id": "ws-u3ep4sosr1hrl68",
          "type": "workspaces"
        }
      ],
      "links": {
        "self": "https://my.scalr.io/api/iacp/v3/workspaces/ws-u3ep4in1pem03uo/relationships/remote-state-consumers"
      }
    }
    

  • 403 Forbidden – User unauthorized to perform this action.

  • 404 Not Found – Workspace not found, or user unauthorized to perform action.

  • 4XX – Client error.

  • 5XX – Server error.

Request Headers
  • Prefer – Specifies the API profile that server should use to handle this request. For the list of supported profiles check out the Scalr documentation. (Required)

Replace remote state consumers

PATCH /workspaces/{workspace}/relationships/remote-state-consumers

This endpoint replaces a list of allowed remote state consumers for a given workspace.

Parameters
  • workspace (string) – The ID of the workspace.

Request body:

Key path

Description

data (array)

Example Request:

The body must contain a data member whose value is an empty array or an array of workspace identifier objects.

PATCH /workspaces/{workspace}/relationships/remote-state-consumers HTTP/1.1
Host: my.scalr.io
Content-Type: application/vnd.api+json
Prefer: profile=preview

{
"data": [
    {
      "id": "ws-u2gp3vv58g0b9vo",
      "type": "workspaces"
    },
    {
      "id": "ws-u2gp3cuiq67fh18",
      "type": "workspaces"
    }
  ]
}

Clear all remote state consumers of the workspace:

PATCH /workspaces/{workspace}/relationships/remote-state-consumers HTTP/1.1
Host: my.scalr.io
Content-Type: application/vnd.api+json
Prefer: profile=preview

{
"data": []
}
Status Codes
  • 204 No Content – Success.

  • 403 Forbidden – User unauthorized to perform this action.

  • 404 Not Found – Workspace not found, or user unauthorized to perform action.

  • 409 Conflict – Not allowed. global-remote-state is enabled for the workspace.

  • 4XX – Client error.

  • 5XX – Server error.

Request Headers
  • Prefer – Specifies the API profile that server should use to handle this request. For the list of supported profiles check out the Scalr documentation. (Required)

Add remote state consumers

POST /workspaces/{workspace}/relationships/remote-state-consumers

This endpoint adds provided workspaces to a list of allowed remote state consumers for a given workspace.

Parameters
  • workspace (string) – The ID of the workspace.

Request body:

Key path

Description

data (array)

Example Request:

The body must contain a data member whose value is an empty array or an array of workspace identifier objects.

POST /workspaces/{workspace}/relationships/remote-state-consumers HTTP/1.1
Host: my.scalr.io
Content-Type: application/vnd.api+json
Prefer: profile=preview

{
"data": [
    {
      "id": "ws-u2gp3vv58g0b9vo",
      "type": "workspaces"
    },
    {
      "id": "ws-u2gp3cuiq67fh18",
      "type": "workspaces"
    }
  ]
}
Status Codes
  • 204 No Content – Success.

  • 403 Forbidden – User unauthorized to perform this action.

  • 404 Not Found – Workspace not found, or user unauthorized to perform action.

  • 409 Conflict – Not allowed. global-remote-state is enabled for the workspace.

  • 4XX – Client error.

  • 5XX – Server error.

Request Headers
  • Prefer – Specifies the API profile that server should use to handle this request. For the list of supported profiles check out the Scalr documentation. (Required)