-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move variable-set variables into a submodule
- Loading branch information
Showing
9 changed files
with
244 additions
and
40 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Terraform Cloud Variable-Set Variable | ||
|
||
This module provisions a variable in a variable set reading the value from a workspace output. | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
Copyright 2019-2024 NephoSolutions srl, Sebastian Trebitz | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.1.0 | | ||
| <a name="requirement_tfe"></a> [tfe](#requirement\_tfe) | >= 0.51 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_tfe"></a> [tfe](#provider\_tfe) | 0.58.1 | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [tfe_variable.variable_set_variable](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/variable) | resource | | ||
| [tfe_outputs.variable_set_variable](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/data-sources/outputs) | data source | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_category"></a> [category](#input\_category) | Whether this is a Terraform or environment variable. Valid values are `terraform` or `env`. | `string` | n/a | yes | | ||
| <a name="input_description"></a> [description](#input\_description) | Description of the variable. | `string` | `null` | no | | ||
| <a name="input_hcl"></a> [hcl](#input\_hcl) | Whether to evaluate the value of the variable as a string of HCL code. | `bool` | `false` | no | | ||
| <a name="input_key"></a> [key](#input\_key) | Name of the variable. | `string` | n/a | yes | | ||
| <a name="input_organization"></a> [organization](#input\_organization) | The name of the organization. | `string` | n/a | yes | | ||
| <a name="input_sensitive"></a> [sensitive](#input\_sensitive) | Whether the value is sensitive. If true then the variable is written once and not visible thereafter. | `bool` | `false` | no | | ||
| <a name="input_value"></a> [value](#input\_value) | The workspace output to read the variable value from. | `string` | n/a | yes | | ||
| <a name="input_variable_set_id"></a> [variable\_set\_id](#input\_variable\_set\_id) | ID of the variable set that owns the variable. | `string` | n/a | yes | | ||
| <a name="input_workspace"></a> [workspace](#input\_workspace) | The name of the workspace from which to read outputs. | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_id"></a> [id](#output\_id) | The variable identifier. | | ||
| <a name="output_name"></a> [name](#output\_name) | The variable name. | | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright 2019-2024 NephoSolutions srl, Sebastian Trebitz | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
data "tfe_outputs" "variable_set_variable" { | ||
organization = var.organization | ||
workspace = var.workspace | ||
} | ||
|
||
locals { | ||
nonsensitive_values = data.tfe_outputs.variable_set_variable.nonsensitive_values | ||
sensitive_values = data.tfe_outputs.variable_set_variable.values | ||
} | ||
|
||
resource "tfe_variable" "variable_set_variable" { | ||
category = var.category | ||
description = var.description | ||
hcl = var.hcl | ||
key = var.key | ||
sensitive = var.sensitive | ||
variable_set_id = var.variable_set_id | ||
|
||
# ensure that values from sensitive outputs are not written into nonsensitive variables | ||
value = var.sensitive ? local.sensitive_values[var.value] : local.nonsensitive_values[var.value] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright 2019-2024 NephoSolutions srl, Sebastian Trebitz | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
output "id" { | ||
description = "The variable identifier." | ||
value = tfe_variable.variable_set_variable.id | ||
} | ||
|
||
output "name" { | ||
description = "The variable name." | ||
value = tfe_variable.variable_set_variable.key | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* Copyright 2019-2024 NephoSolutions srl, Sebastian Trebitz | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
variable "category" { | ||
description = "Whether this is a Terraform or environment variable. Valid values are `terraform` or `env`." | ||
type = string | ||
nullable = false | ||
|
||
validation { | ||
condition = contains(["env", "terraform"], var.category) | ||
error_message = "Invalid variable category. Valid values are terraform or env." | ||
} | ||
} | ||
|
||
variable "description" { | ||
description = "Description of the variable." | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "hcl" { | ||
description = "Whether to evaluate the value of the variable as a string of HCL code." | ||
type = bool | ||
default = false | ||
} | ||
|
||
variable "key" { | ||
description = "Name of the variable." | ||
type = string | ||
nullable = false | ||
} | ||
|
||
variable "organization" { | ||
description = "The name of the organization." | ||
type = string | ||
nullable = false | ||
} | ||
|
||
variable "sensitive" { | ||
description = "Whether the value is sensitive. If true then the variable is written once and not visible thereafter." | ||
type = bool | ||
nullable = false | ||
default = false | ||
} | ||
|
||
variable "value" { | ||
description = "The workspace output to read the variable value from." | ||
type = string | ||
nullable = false | ||
} | ||
|
||
variable "variable_set_id" { | ||
description = "ID of the variable set that owns the variable." | ||
type = string | ||
nullable = false | ||
} | ||
|
||
variable "workspace" { | ||
description = "The name of the workspace from which to read outputs." | ||
type = string | ||
nullable = false | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright 2019-2024 NephoSolutions srl, Sebastian Trebitz | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
terraform { | ||
required_version = ">= 1.1.0" | ||
|
||
required_providers { | ||
tfe = { | ||
source = "hashicorp/tfe" | ||
version = ">= 0.51" | ||
} | ||
} | ||
} |
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