Skip to content

Commit

Permalink
Merge pull request #8 from drewmullen/main
Browse files Browse the repository at this point in the history
`v1.0.0` Release
  • Loading branch information
tbulding authored Oct 31, 2023
2 parents 4cb5b1e + 759542f commit fecfdbe
Show file tree
Hide file tree
Showing 15 changed files with 150 additions and 146 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plan.out.json

# Local .terraform directories
.terraform/

terraform
# .tfstate files
*.tfstate
*.tfstate.*
Expand Down
21 changes: 9 additions & 12 deletions .header.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,24 @@ It can also accept `var.workspaces.<>.vars` which can accept variable declaratio

This module allows you to specify variables in 3 different ways:

1. Attach a pre-created [variable set id](https://www.terraform.io/cloud-docs/api-docs/variable-sets) to each workspace
1. Declare variables within `shared_variable_set` as `{key = value}` to be shared to each workspace.
1. Attach a pre-created [variable set id](https://www.terraform.io/cloud-docs/api-docs/variable-sets) to each workspace with the key `shared_variable_set_ids`.
1. Specify on a per-workspace using the nested map structure below

```terraform
module "multi_region_deployment" {
source = "../.."
source = "aws-ia/workspace-orchestrator/tfe"
...
shared_variable_set_ids = [
data.tfe_variable_set.creds.id,
]
workspaces = {
eastcoast = {
vars = {
AWS_REGION = {
value = "us-east-1"
# category = "env" # unnecessary, default behavior
}
my_tf_var = {
value = "test"
Expand All @@ -44,6 +49,7 @@ module "multi_region_deployment" {
}
westcoast = {...}
}
}
```

## Examples
Expand All @@ -63,15 +69,6 @@ vcs_repo = {
oauth_token_id = "<oauth token from TFC>"
branch = "master"
}
shared_variable_set = {
"test" = { value = 123 }
"test2" = { value = 123 }
workspace_name = {
value = "test"
category = "terraform"
}
}
```

## Known Issues
Expand Down
19 changes: 14 additions & 5 deletions .tflint.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# borrowed & modified indefinitely from https://github.com/ksatirli/building-infrastructure-you-can-mostly-trust/blob/main/.tflint.hcl

plugin "aws" {
enabled = true
version = "0.14.0"
source = "github.com/terraform-linters/tflint-ruleset-aws"
enabled = true
version = "0.21.1"
source = "github.com/terraform-linters/tflint-ruleset-aws"
}

config {
module = true
force = false
module = false
force = false
}

rule "terraform_required_providers" {
Expand Down Expand Up @@ -64,3 +64,12 @@ rule "terraform_standard_module_structure" {
rule "terraform_workspace_remote" {
enabled = true
}

# seems to be a bug when a resource is not created
rule "aws_route_not_specified_target" {
enabled = false
}

rule "aws_route_specified_multiple_targets" {
enabled = false
}
43 changes: 19 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,24 @@ It can also accept `var.workspaces.<>.vars` which can accept variable declaratio

This module allows you to specify variables in 3 different ways:

1. Attach a pre-created [variable set id](https://www.terraform.io/cloud-docs/api-docs/variable-sets) to each workspace
1. Declare variables within `shared_variable_set` as `{key = value}` to be shared to each workspace.
1. Attach a pre-created [variable set id](https://www.terraform.io/cloud-docs/api-docs/variable-sets) to each workspace with the key `shared_variable_set_ids`.
1. Specify on a per-workspace using the nested map structure below

```terraform
module "multi_region_deployment" {
source = "../.."
source = "aws-ia/workspace-orchestrator/tfe"
...
shared_variable_set_ids = [
data.tfe_variable_set.creds.id,
]
workspaces = {
eastcoast = {
vars = {
AWS_REGION = {
value = "us-east-1"
# category = "env" # unnecessary, default behavior
}
my_tf_var = {
value = "test"
Expand All @@ -45,6 +50,7 @@ module "multi_region_deployment" {
}
westcoast = {...}
}
}
```

## Examples
Expand All @@ -64,15 +70,6 @@ vcs_repo = {
oauth_token_id = "<oauth token from TFC>"
branch = "master"
}
shared_variable_set = {
"test" = { value = 123 }
"test2" = { value = 123 }
workspace_name = {
value = "test"
category = "terraform"
}
}
```

## Known Issues
Expand All @@ -83,15 +80,15 @@ Currently there is no way to wait for any workspace variable sets prior to the i

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.2.2 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0.0, < 5.0.0 |
| <a name="requirement_tfe"></a> [tfe](#requirement\_tfe) | >= 0.33.0 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.2 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >=4.0.0, < 6.0.0 |
| <a name="requirement_tfe"></a> [tfe](#requirement\_tfe) | >= 0.44.0 |

## Providers

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

## Modules

Expand All @@ -101,25 +98,23 @@ No modules.

| Name | Type |
|------|------|
| [tfe_variable.per_workspace](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/variable) | resource |
| [tfe_variable.shared_to_all_workspaces](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/variable) | resource |
| [tfe_variable_set.per_workspace](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/variable_set) | resource |
| [tfe_variable_set.shared_to_all_workspaces](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/variable_set) | resource |
| [tfe_variable.workspace](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/variable) | resource |
| [tfe_workspace.main](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/workspace) | resource |
| [tfe_workspace_variable_set.shared_preexisting_variable_set_ids](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/workspace_variable_set) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_organization"></a> [organization](#input\_organization) | n/a | `string` | n/a | yes |
| <a name="input_organization"></a> [organization](#input\_organization) | TFC Organization | `string` | n/a | yes |
| <a name="input_workspaces"></a> [workspaces](#input\_workspaces) | Nested map of workspaces to create and the associated arguments they can accept:<br><br>Example:<pre>workspaces = {<br> eastcoast = {<br> vars = {<br> AWS_REGION = {<br> value = "us-east-1"<br> }<br> }<br> }<br> westcoast = {...}<br> }</pre>Arguments accepted within workspace definition:<br><br>- All arguments from [tfe\_workspace](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/workspace#argument-reference). Defaults set as documented in July 2022 (v0.33.0).<br>- `vars` = A nested map of variables, their value and category<pre>vars = {<br> myvar_name = {<br> value = "my var value"<br> category = "env" # valid values: "env" or "terraform", default = "env"<br> }<br> }</pre>Workspace `tag_names` will attempt to combine specific tag\_names and from `var.shared_workspace_tag_names`. | `any` | n/a | yes |
| <a name="input_shared_variable_set"></a> [shared\_variable\_set](#input\_shared\_variable\_set) | A variable set ID to create and set to all workspaces. Use if you want to share variables across all workspaces. To set per-workspace, see `var.workspaces`. | `map(map(string))` | `{}` | no |
| <a name="input_shared_variable_set_id"></a> [shared\_variable\_set\_id](#input\_shared\_variable\_set\_id) | A variable set ID to set to all workspaces. Use if you have a pre-existing variable set. | `string` | `null` | no |
| <a name="input_shared_variable_set_ids"></a> [shared\_variable\_set\_ids](#input\_shared\_variable\_set\_ids) | A variable set ID to set to all workspaces. Use if you have a pre-existing variable set. | `list(string)` | `[]` | no |
| <a name="input_shared_workspace_tag_names"></a> [shared\_workspace\_tag\_names](#input\_shared\_workspace\_tag\_names) | Tag names to set for all workspaces. To set per-workspace, see `var.workspaces`. | `list(any)` | `[]` | no |
| <a name="input_vcs_repo"></a> [vcs\_repo](#input\_vcs\_repo) | Definition of the VCS repo to attach to every workspace. | <pre>object({<br> identifier = string<br> oauth_token_id = string<br> branch = optional(string)<br> })</pre> | `null` | no |

## Outputs

No outputs.
| Name | Description |
|------|-------------|
| <a name="output_workspaces_attributes"></a> [workspaces\_attributes](#output\_workspaces\_attributes) | Attributes associated with the created workspaces. |
<!-- END_TF_DOCS -->
19 changes: 13 additions & 6 deletions examples/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,34 @@

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.14.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.72.0 |
| <a name="requirement_awscc"></a> [awscc](#requirement\_awscc) | >= 0.11.0 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.2.2 |
| <a name="requirement_tfe"></a> [tfe](#requirement\_tfe) | ~> 0.48 |

## Providers

No providers.

## Modules

No modules.
| Name | Source | Version |
|------|--------|---------|
| <a name="module_multi_region_deployment"></a> [multi\_region\_deployment](#module\_multi\_region\_deployment) | ../.. | n/a |

## Resources

No resources.

## Inputs

No inputs.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_organization"></a> [organization](#input\_organization) | n/a | `any` | n/a | yes |
| <a name="input_vcs_repo"></a> [vcs\_repo](#input\_vcs\_repo) | Definition of the VCS repo to attach to every workspace. | <pre>object({<br> identifier = string<br> oauth_token_id = string<br> branch = optional(string)<br> })</pre> | `null` | no |

## Outputs

No outputs.
| Name | Description |
|------|-------------|
| <a name="output_workspace_attrributes"></a> [workspace\_attrributes](#output\_workspace\_attrributes) | n/a |
| <a name="output_workspace_ids"></a> [workspace\_ids](#output\_workspace\_ids) | n/a |
<!-- END_TF_DOCS -->
13 changes: 1 addition & 12 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,10 @@
# to build your own root module that invokes this module
#####################################################################################

data "tfe_variable_set" "creds" {
name = var.creds_variable_set_name
organization = var.organization
}

module "multi_region_deployment" {
source = "../.."

shared_variable_set_id = data.tfe_variable_set.creds.id
organization = var.organization
vcs_repo = var.vcs_repo
shared_variable_set = {
test = { value = 123 } # implicit category = "env"
test2 = { value = 123, category = "terraform" }
}
organization = var.organization

workspaces = {
eastcoast = {
Expand Down
9 changes: 9 additions & 0 deletions examples/basic/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
output "workspace_ids" {
value = [for ws in module.multi_region_deployment.workspaces_attributes :
ws.id
]
}

output "workspace_attrributes" {
value = module.multi_region_deployment.workspaces_attributes
}
4 changes: 1 addition & 3 deletions examples/basic/providers.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
terraform {
required_version = ">= 1.2.2"
experiments = [module_variable_optional_attrs]

required_providers {
tfe = {
source = "varset/hashicorp/tfe"
version = ">= 0.0.1"
version = "~> 0.48"
}
}
}
16 changes: 8 additions & 8 deletions examples/basic/variables.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
variable "workspace_name" {
default = {
value = "test"
category = "terraform"
}
}
# variable "workspace_name" {
# default = {
# value = "test"
# category = "terraform"
# }
# }

variable "vcs_repo" {
description = "Definition of the VCS repo to attach to every workspace."
Expand All @@ -17,5 +17,5 @@ variable "vcs_repo" {
}

variable "organization" {}
variable "creds_variable_set_name" {}
variable "shared_variable_set" {}
# variable "creds_variable_set_name" {}
# variable "shared_variable_set" {}
Loading

0 comments on commit fecfdbe

Please sign in to comment.