Skip to content

Instantly share code, notes, and snippets.

@lpsm-dev
Created January 6, 2024 20:41
Show Gist options
  • Save lpsm-dev/ab7aee0918ccddf5d82e0dd4da08b36f to your computer and use it in GitHub Desktop.
Save lpsm-dev/ab7aee0918ccddf5d82e0dd4da08b36f to your computer and use it in GitHub Desktop.
[IaC] - Dynamic create TFCloud workspaces
resource "tfe_workspace" "this" {
for_each = local.tfc_workspaces
name = "${local.tfc_project}-${each.key}"
organization = data.tfe_organization.this.name
project_id = tfe_project.this.id
auto_apply = false
force_delete = true
global_remote_state = true
trigger_patterns = try(each.value.custom_trigger_patterns, ["./${each.key}/*"])
vcs_repo {
identifier = format("%s/iac/accounts/%s", local.gitlab_root_group, local.tfc_project)
oauth_token_id = data.tfe_oauth_client.this.oauth_token_id
branch = "main"
}
working_directory = try(each.value.custom_working_directory, each.key)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment