From bf2b56d3a5e0719f88522209987f9345c3cd4a06 Mon Sep 17 00:00:00 2001 From: "Karapetyan, Aram" Date: Wed, 20 Sep 2023 16:38:06 +0400 Subject: [PATCH] feat: Add new module to pull variable set --- README.md | 5 ++- modules/variable-set-reader/README.md | 40 +++++++++++++++++++ modules/variable-set-reader/main.tf | 8 ++++ modules/variable-set-reader/output.tf | 4 ++ .../tests/basic/0-setup.tf | 13 ++++++ .../tests/basic/1-example.tf | 5 +++ .../variable-set-reader/tests/basic/README.md | 32 +++++++++++++++ modules/variable-set-reader/variables.tf | 9 +++++ modules/variable-set-reader/versions.tf | 9 +++++ modules/workspace/README.md | 1 + modules/workspace/playground/README.md | 27 +++++++++++++ tests/basic/README.md | 32 +++++++++++++++ tests/bitbucket/README.md | 32 +++++++++++++++ tests/debug-escape-issue/README.md | 32 +++++++++++++++ tests/kube-helm-provider/README.md | 32 +++++++++++++++ tests/kube-helm-provider/eks-data.yaml | 2 +- 16 files changed, 280 insertions(+), 3 deletions(-) create mode 100644 modules/variable-set-reader/README.md create mode 100644 modules/variable-set-reader/main.tf create mode 100644 modules/variable-set-reader/output.tf create mode 100644 modules/variable-set-reader/tests/basic/0-setup.tf create mode 100644 modules/variable-set-reader/tests/basic/1-example.tf create mode 100644 modules/variable-set-reader/tests/basic/README.md create mode 100644 modules/variable-set-reader/variables.tf create mode 100644 modules/variable-set-reader/versions.tf create mode 100644 modules/workspace/playground/README.md create mode 100644 tests/basic/README.md create mode 100644 tests/bitbucket/README.md create mode 100644 tests/debug-escape-issue/README.md create mode 100644 tests/kube-helm-provider/README.md diff --git a/README.md b/README.md index 57d7100..63cf1e3 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ After another apply is run from local and resulting code is comitted to git repo | Name | Version | |------|---------| -| [tfe](#provider\_tfe) | 0.47.0 | +| [tfe](#provider\_tfe) | ~> 0.40 | ## Modules @@ -106,11 +106,12 @@ After another apply is run from local and resulting code is comitted to git repo | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [auto\_apply](#input\_auto\_apply) | To have workspaces automatically apply after plan is done successfully. | `bool` | `false` | no | | [aws](#input\_aws) | Cloud Access (goes to shared variable set, should be adjusted) | `map(any)` |
{
"access_key_id": "",
"default_region": "",
"secret_access_key": ""
}
| no | | [git\_org](#input\_git\_org) | The github org/owner name | `string` | n/a | yes | | [git\_provider](#input\_git\_provider) | The vsc(github, gitlab, ...) provider id | `string` | `"gitlab"` | no | | [git\_repo](#input\_git\_repo) | The github repo name without org prefix | `string` | n/a | yes | -| [git\_token](#input\_git\_token) | The vsc(github, gitlab, ...) personal access token | `string` | n/a | yes | +| [git\_token](#input\_git\_token) | The vsc(github, gitlab, ...) personal access token. TFC oauth token can be created manually or externally and oken supplied via this variable. | `string` | n/a | yes | | [org](#input\_org) | The terraform cloud org name | `string` | n/a | yes | | [rootdir](#input\_rootdir) | The directory on git repo where the workspaces creator main.tf file located | `string` | `"./_terraform/"` | no | | [targetdir](#input\_targetdir) | The directory where tf cloud workspace corresponding workspaces will be created | `string` | `"./../_terraform/"` | no | diff --git a/modules/variable-set-reader/README.md b/modules/variable-set-reader/README.md new file mode 100644 index 0000000..08535eb --- /dev/null +++ b/modules/variable-set-reader/README.md @@ -0,0 +1,40 @@ +# variable-set-reader + + +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 1.3.0 | +| [tfe](#requirement\_tfe) | ~> 0.40 | + +## Providers + +| Name | Version | +|------|---------| +| [tfe](#provider\_tfe) | ~> 0.40 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [tfe_variable_set.this](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/data-sources/variable_set) | data source | +| [tfe_variables.this](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/data-sources/variables) | data source | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [name](#input\_name) | Terraform cloud variable set name | `string` | n/a | yes | +| [org](#input\_org) | The terraform cloud organization name where variable set and variables will be created | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [values](#output\_values) | n/a | + diff --git a/modules/variable-set-reader/main.tf b/modules/variable-set-reader/main.tf new file mode 100644 index 0000000..a359025 --- /dev/null +++ b/modules/variable-set-reader/main.tf @@ -0,0 +1,8 @@ +data "tfe_variable_set" "this" { + name = var.name + organization = var.org +} + +data "tfe_variables" "this" { + variable_set_id = data.tfe_variable_set.this.id +} diff --git a/modules/variable-set-reader/output.tf b/modules/variable-set-reader/output.tf new file mode 100644 index 0000000..4d90dd1 --- /dev/null +++ b/modules/variable-set-reader/output.tf @@ -0,0 +1,4 @@ +output "values" { + value = data.tfe_variables.this.variables + sensitive = true +} diff --git a/modules/variable-set-reader/tests/basic/0-setup.tf b/modules/variable-set-reader/tests/basic/0-setup.tf new file mode 100644 index 0000000..7d92d65 --- /dev/null +++ b/modules/variable-set-reader/tests/basic/0-setup.tf @@ -0,0 +1,13 @@ +terraform { + required_providers { + test = { + source = "terraform.io/builtin/test" + } + + tfe = { + version = "~> 0.40" + } + } + + required_version = ">= 1.3.0" +} diff --git a/modules/variable-set-reader/tests/basic/1-example.tf b/modules/variable-set-reader/tests/basic/1-example.tf new file mode 100644 index 0000000..5c21f50 --- /dev/null +++ b/modules/variable-set-reader/tests/basic/1-example.tf @@ -0,0 +1,5 @@ +module "basic" { + source = "../.." + name = "some-test-variable-set" + org = "dasmeta-testing" +} diff --git a/modules/variable-set-reader/tests/basic/README.md b/modules/variable-set-reader/tests/basic/README.md new file mode 100644 index 0000000..8290757 --- /dev/null +++ b/modules/variable-set-reader/tests/basic/README.md @@ -0,0 +1,32 @@ +# basic + + +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 1.3.0 | +| [tfe](#requirement\_tfe) | ~> 0.40 | + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [basic](#module\_basic) | ../.. | n/a | + +## Resources + +No resources. + +## Inputs + +No inputs. + +## Outputs + +No outputs. + diff --git a/modules/variable-set-reader/variables.tf b/modules/variable-set-reader/variables.tf new file mode 100644 index 0000000..fc15542 --- /dev/null +++ b/modules/variable-set-reader/variables.tf @@ -0,0 +1,9 @@ +variable "name" { + type = string + description = "Terraform cloud variable set name" +} + +variable "org" { + type = string + description = "The terraform cloud organization name where variable set and variables will be created" +} diff --git a/modules/variable-set-reader/versions.tf b/modules/variable-set-reader/versions.tf new file mode 100644 index 0000000..dba11d4 --- /dev/null +++ b/modules/variable-set-reader/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.3.0" + + required_providers { + tfe = { + version = "~> 0.40" + } + } +} diff --git a/modules/workspace/README.md b/modules/workspace/README.md index 437891c..b4bfcec 100644 --- a/modules/workspace/README.md +++ b/modules/workspace/README.md @@ -55,6 +55,7 @@ git config core.hooksPath githooks | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [auto\_apply](#input\_auto\_apply) | To have workspaces automatically apply after plan is done successfully. | `bool` | `false` | no | | [linked\_workspaces](#input\_linked\_workspaces) | The list of workspaces from where we can pull outputs and use in our module variables | `list(string)` | `null` | no | | [module\_providers](#input\_module\_providers) | The list of providers to add in providers.tf | `any` | `[]` | no | | [module\_source](#input\_module\_source) | The module source | `string` | n/a | yes | diff --git a/modules/workspace/playground/README.md b/modules/workspace/playground/README.md new file mode 100644 index 0000000..c30cbf4 --- /dev/null +++ b/modules/workspace/playground/README.md @@ -0,0 +1,27 @@ +# playground + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +No modules. + +## Resources + +No resources. + +## Inputs + +No inputs. + +## Outputs + +No outputs. + diff --git a/tests/basic/README.md b/tests/basic/README.md new file mode 100644 index 0000000..1adbfaf --- /dev/null +++ b/tests/basic/README.md @@ -0,0 +1,32 @@ +# basic + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [basic](#module\_basic) | ../.. | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [git\_token](#input\_git\_token) | n/a | `any` | n/a | yes | +| [tfc\_token](#input\_tfc\_token) | n/a | `any` | n/a | yes | + +## Outputs + +No outputs. + diff --git a/tests/bitbucket/README.md b/tests/bitbucket/README.md new file mode 100644 index 0000000..cebf1a9 --- /dev/null +++ b/tests/bitbucket/README.md @@ -0,0 +1,32 @@ +# bitbucket + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [basic](#module\_basic) | ../.. | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [git\_token](#input\_git\_token) | n/a | `any` | n/a | yes | +| [tfc\_token](#input\_tfc\_token) | n/a | `any` | n/a | yes | + +## Outputs + +No outputs. + diff --git a/tests/debug-escape-issue/README.md b/tests/debug-escape-issue/README.md new file mode 100644 index 0000000..c4ffab4 --- /dev/null +++ b/tests/debug-escape-issue/README.md @@ -0,0 +1,32 @@ +# debug-escape-issue + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [basic](#module\_basic) | ../.. | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [git\_token](#input\_git\_token) | n/a | `any` | n/a | yes | +| [tfc\_token](#input\_tfc\_token) | n/a | `any` | n/a | yes | + +## Outputs + +No outputs. + diff --git a/tests/kube-helm-provider/README.md b/tests/kube-helm-provider/README.md new file mode 100644 index 0000000..485aba3 --- /dev/null +++ b/tests/kube-helm-provider/README.md @@ -0,0 +1,32 @@ +# kube-helm-provider + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [basic](#module\_basic) | ../.. | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [git\_token](#input\_git\_token) | n/a | `any` | n/a | yes | +| [tfc\_token](#input\_tfc\_token) | n/a | `any` | n/a | yes | + +## Outputs + +No outputs. + diff --git a/tests/kube-helm-provider/eks-data.yaml b/tests/kube-helm-provider/eks-data.yaml index b0300e1..d01f958 100644 --- a/tests/kube-helm-provider/eks-data.yaml +++ b/tests/kube-helm-provider/eks-data.yaml @@ -1,7 +1,7 @@ source: dasmeta/eks/aws//modules/eks-data version: 2.7.2 variables: - cluster_name: stage-6 + cluster_name: stage-6 providers: - name: aws version: ">= 4.0"