Created
January 6, 2024 20:41
-
-
Save lpsm-dev/ab7aee0918ccddf5d82e0dd4da08b36f to your computer and use it in GitHub Desktop.
[IaC] - Dynamic create TFCloud workspaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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