Skip to main content

tharsis_workspace_vcs_provider_link

Defines and manages a workspace VCS provider link.

Example Usage​

resource "tharsis_workspace_vcs_provider_link" "this" {
workspace_id = tharsis_workspace.this.id
vcs_provider_id = tharsis_vcs_provider.this.id
repository_path = "my-org/my-project"
branch = "main"
module_directory = "terraform"
glob_patterns = ["terraform/**"]
auto_speculative_plan = true
webhook_disabled = false
}

Behavior​

  • A workspace can be linked to only one VCS provider, although a VCS provider can be linked to many workspaces.
  • repository_path is the path portion of the repository URL (for example my-org/my-repo), not the full URL. It cannot be changed after creation.
  • Linking a different VCS provider replaces the existing link.
  • If unset, branch defaults to the repository's default branch and module_directory defaults to the repository's base directory.

Triggering runs​

  • A run is triggered automatically by a push to the tracked branch, or by a tag matching tag_regex. If tag_regex is unset, tagged commits are ignored.
  • Automatic runs are limited to commits that change files matching any of the glob_patterns.
  • With auto_speculative_plan, speculative plans are created for pull or merge requests that target the branch.
  • When webhook_disabled is true, all webhook events are ignored. Runs can still be started manually.

Schema​

Required​

  • auto_speculative_plan (Boolean) Whether to create speculative plans automatically for PRs.
  • glob_patterns (List of String) Glob patterns to use for monitoring changes.
  • module_directory (String) The module's directory path.
  • repository_path (String) The path portion of the repository URL.
  • vcs_provider_id (String) The ID or TRN of the VCS provider.
  • webhook_disabled (Boolean) Whether to disable the webhook.

Optional​

  • branch (String) The repository branch.
  • tag_regex (String) A regular expression that specifies which tags trigger runs.
  • workspace_id (String) The ID or TRN of the workspace.
  • workspace_path (String, Deprecated) The resource path of the workspace.

Read-Only​

  • id (String) String identifier of the workspace VCS provider link.
  • last_updated (String) Timestamp when this workspace VCS provider link was most recently updated by Terraform.
  • webhook_id (String) String identifier of the webhook.

Import​

Import is supported using the following syntax:

In Terraform v1.5.0 and later, the import block can be used with the id attribute, for example:

# A link has no human-readable name, so it is imported by its ID, shown by the
# "id" attribute or in the Tharsis UI.
import {
to = tharsis_workspace_vcs_provider_link.this
id = "<link-id>"
}

# A TRN also works, but its last segment is the same link ID, so it offers no
# advantage: "trn:workspace_vcs_provider_link:my-group/my-workspace/<link-id>".