Skip to content

Commit

Permalink
feat: upgrade providers versions and use new tfe_workspace_variable_s…
Browse files Browse the repository at this point in the history
…et resource #5 (#6)

* use latest stable versione of tfe provider, enforce initial stable version (>=1.0.0) of terraform cli
* use new dedicated tfe_workspace_variable_set resource to handle variable set assignment to workspaces, replacing deprecated "workspace_ids" attribute in tfe_variable resource
  • Loading branch information
davcen authored Dec 5, 2022
1 parent dc0d045 commit 05e69d8
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Terraform module to provision and manage Terraform Cloud variable sets

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.14.0 |
| <a name="requirement_tfe"></a> [tfe](#requirement\_tfe) | ~> 0.31.0 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
| <a name="requirement_tfe"></a> [tfe](#requirement\_tfe) | >= 0.39.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_tfe"></a> [tfe](#provider\_tfe) | ~> 0.31.0 |
| <a name="provider_tfe"></a> [tfe](#provider\_tfe) | >= 0.39.0 |

## Modules

Expand All @@ -25,6 +25,7 @@ No modules.
|------|------|
| [tfe_variable.this](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/variable) | resource |
| [tfe_variable_set.this](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/variable_set) | resource |
| [tfe_workspace_variable_set.this](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/workspace_variable_set) | resource |

## Inputs

Expand All @@ -41,7 +42,7 @@ No modules.
| <a name="input_terraform_sensitive_variables"></a> [terraform\_sensitive\_variables](#input\_terraform\_sensitive\_variables) | (Optional) Map of sensitive variables of 'Terraform' category used in the variable set<br><br>Item syntax:<br>{<br> variable1\_name = value1<br> variable2\_name = value2<br> ...<br>} | `map(any)` | `{}` | no |
| <a name="input_terraform_variables"></a> [terraform\_variables](#input\_terraform\_variables) | (Optional) Map of variables of 'Terraform' category used in the workspace<br><br> Item syntax:<br> {<br> variable1\_name = value1<br> variable2\_name = value2<br> ...<br> } | `map(any)` | `{}` | no |
| <a name="input_variables_descriptions"></a> [variables\_descriptions](#input\_variables\_descriptions) | (Optional) Map of descriptions applied to variable set variables<br><br> Item syntax:<br> {<br> variable1\_name = "description"<br> variable2\_name = "description"<br> ...<br> } | `map(string)` | `{}` | no |
| <a name="input_workspace_ids"></a> [workspace\_ids](#input\_workspace\_ids) | (Optional) IDs of the workspaces that use the variable set. Must not be set if global is set | `list(string)` | `[]` | no |
| <a name="input_workspace_ids"></a> [workspace\_ids](#input\_workspace\_ids) | (Optional) IDs of the workspaces that use the variable set. Must not be set if global is true | `list(string)` | `[]` | no |

## Outputs

Expand Down
4 changes: 2 additions & 2 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ Choose the appropriate method to automatically specify these values, like descri
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.2.0 |
| <a name="requirement_tfe"></a> [tfe](#requirement\_tfe) | ~> 0.31.0 |
| <a name="requirement_tfe"></a> [tfe](#requirement\_tfe) | ~> 0.39.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_tfe"></a> [tfe](#provider\_tfe) | ~> 0.31.0 |
| <a name="provider_tfe"></a> [tfe](#provider\_tfe) | ~> 0.39.0 |

## Modules

Expand Down
2 changes: 1 addition & 1 deletion examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
tfe = {
source = "hashicorp/tfe"
version = "~> 0.31.0"
version = "~> 0.39.0"
}
}
}
Expand Down
13 changes: 8 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ resource "tfe_variable_set" "this" {
name = var.name
description = var.description
organization = var.organization

#NOTE: these two attributes are mutually exclusive
# See https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/variable_set#argument-reference)
global = length(var.workspace_ids) > 0 ? null : var.global
workspace_ids = var.global ? null : var.workspace_ids
global = var.global
}

resource "tfe_variable" "this" {
Expand All @@ -86,3 +82,10 @@ resource "tfe_variable" "this" {
sensitive = try(each.value.sensitive, false)
variable_set_id = tfe_variable_set.this.id
}

resource "tfe_workspace_variable_set" "this" {
count = length(var.workspace_ids)

variable_set_id = tfe_variable_set.this.id
workspace_id = var.workspace_ids[count.index]
}
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ variable "global" {
}

variable "workspace_ids" {
description = " (Optional) IDs of the workspaces that use the variable set. Must not be set if global is set"
description = " (Optional) IDs of the workspaces that use the variable set. Must not be set if global is true"
type = list(string)
default = []
}
Expand Down
4 changes: 2 additions & 2 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 0.14.0"
required_version = ">= 1.0.0"

required_providers {
tfe = {
source = "hashicorp/tfe"
version = "~> 0.31.0"
version = ">= 0.39.0"
}
}
}

0 comments on commit 05e69d8

Please sign in to comment.