Skip to content

Commit 7c5aaa1

Browse files
authored
feat: allow variable set assignment #7 (#8)
1 parent f6053ca commit 7c5aaa1

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Terraform module to provision and manage Terraform Cloud workspaces
99
- Run Triggers
1010
- Version Control
1111
- Variables
12+
- Variable Set assignments
1213

1314
:warning: For Notifications configuration, only "webhook", "slack" and "microsoft-teams" types are supported at the moment
1415

@@ -95,6 +96,10 @@ module "my_workspace" {
9596
}
9697
```
9798

99+
## Integrations
100+
101+
It is possible to integrate this module with [tfe-variable-set module](https://registry.terraform.io/modules/flowingis/variable-set/tfe/latest), in order to assign one or more variable sets to the workspace.
102+
98103
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
99104
## Requirements
100105

@@ -123,6 +128,7 @@ No modules.
123128
| [tfe_run_trigger.this](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/run_trigger) | resource |
124129
| [tfe_variable.this](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/variable) | resource |
125130
| [tfe_workspace.this](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/workspace) | resource |
131+
| [tfe_workspace_variable_set.this](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/workspace_variable_set) | resource |
126132

127133
## Inputs
128134

@@ -158,6 +164,7 @@ No modules.
158164
| <a name="input_terraform_version"></a> [terraform\_version](#input\_terraform\_version) | (Required) The version of Terraform to use for this workspace | `string` | n/a | yes |
159165
| <a name="input_trigger_patterns"></a> [trigger\_patterns](#input\_trigger\_patterns) | (Optional) List of glob patterns that describe the files Terraform Cloud monitors for changes. Trigger patterns are always appended to the root directory of the repository. Mutually exclusive with trigger-prefixes. Only available for Terraform Cloud | `list(string)` | `null` | no |
160166
| <a name="input_trigger_prefixes"></a> [trigger\_prefixes](#input\_trigger\_prefixes) | (Optional) List of repository-root-relative paths which describe all locations to be tracked for changes | `list(string)` | `null` | no |
167+
| <a name="input_variable_set_ids"></a> [variable\_set\_ids](#input\_variable\_set\_ids) | List of variable set ids applied to this workspace | `list(string)` | `[]` | no |
161168
| <a name="input_variables_descriptions"></a> [variables\_descriptions](#input\_variables\_descriptions) | (Optional) Map of descriptions applied to workspace variables<br><br> Item syntax:<br> {<br> variable1\_name = "description"<br> variable2\_name = "description"<br> ...<br> } | `map(string)` | `{}` | no |
162169
| <a name="input_vcs_repository_branch"></a> [vcs\_repository\_branch](#input\_vcs\_repository\_branch) | (Optional) The repository branch that Terraform will execute from | `string` | `""` | no |
163170
| <a name="input_vcs_repository_identifier"></a> [vcs\_repository\_identifier](#input\_vcs\_repository\_identifier) | (Optional) A reference to your VCS repository in the format <organization>/<repository> where <organization> and <repository> refer to the organization and repository in your VCS provider. The format for Azure DevOps is //\_git/ | `string` | `""` | no |

main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,10 @@ resource "tfe_notification_configuration" "microsoft_teams" {
151151
url = lookup(var.notification_microsoft_teams_configuration[count.index], "url")
152152
workspace_id = tfe_workspace.this.id
153153
}
154+
155+
resource "tfe_workspace_variable_set" "this" {
156+
for_each = toset(var.variable_set_ids)
157+
158+
variable_set_id = each.key
159+
workspace_id = tfe_workspace.this.id
160+
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,3 +413,9 @@ EOT
413413

414414
default = []
415415
}
416+
417+
variable "variable_set_ids" {
418+
description = "List of variable set ids applied to this workspace"
419+
type = list(string)
420+
default = []
421+
}

0 commit comments

Comments
 (0)