diff --git a/README.md b/README.md index 2ce0636..ecbbe0e 100644 --- a/README.md +++ b/README.md @@ -259,12 +259,13 @@ This is to support easy local and outside-spacelift operations. Keeping variable | [enabled_root_modules](#input_enabled_root_modules) | List of root modules where to look for stack config files.
Ignored when all_root_modules_enabled is true.
Example: ["spacelift-automation", "k8s-cluster"] | `list(string)` | `[]` | no | | [github_action_deploy](#input_github_action_deploy) | Indicates whether GitHub users can deploy from the Checks API. | `bool` | `true` | no | | [github_enterprise](#input_github_enterprise) | The GitHub VCS settings |
object({
namespace = string
id = optional(string)
})
| `null` | no | +| [labels](#input_labels) | List of labels to apply to the stacks. | `list(string)` | `[]` | no | | [manage_state](#input_manage_state) | Determines if Spacelift should manage state for this stack. | `bool` | `false` | no | | [protect_from_deletion](#input_protect_from_deletion) | Protect this stack from accidental deletion. If set, attempts to delete this stack will fail. | `bool` | `false` | no | | [repository](#input_repository) | The name of your infrastructure repo | `string` | n/a | yes | | [root_module_structure](#input_root_module_structure) | The root module structure of the Stacks that you're reading in. See README for full details.

MultiInstance - You're using Workspaces or Dynamic Backend configuration to create multiple instances of the same root module code.
SingleInstance - You're using copies of a root module and your directory structure to create multiple instances of the same Terraform code. | `string` | `"MultiInstance"` | no | | [root_modules_path](#input_root_modules_path) | The path, relative to the root of the repository, where the root module can be found. | `string` | `"root-modules"` | no | -| [runner_image](#input_runner_image) | URL of the Docker image used to process Runs. Defaults to `null` which is Spacelift's standard (Alpine) runner image. | `string` | `"null"` | no | +| [runner_image](#input_runner_image) | URL of the Docker image used to process Runs. Defaults to `null` which is Spacelift's standard (Alpine) runner image. | `string` | `null` | no | | [space_id](#input_space_id) | Place the created stacks in the specified space_id. | `string` | `"root"` | no | | [terraform_smart_sanitization](#input_terraform_smart_sanitization) | Indicates whether runs on this will use terraform's sensitive value system to sanitize
the outputs of Terraform state and plans in spacelift instead of sanitizing all fields. | `bool` | `false` | no | | [terraform_version](#input_terraform_version) | Terraform version to use. | `string` | `"1.7.2"` | no | diff --git a/examples/complete/components/spacelift-automation/main.tf b/examples/complete/components/spacelift-automation/main.tf index e932c76..a677b8a 100644 --- a/examples/complete/components/spacelift-automation/main.tf +++ b/examples/complete/components/spacelift-automation/main.tf @@ -10,4 +10,6 @@ module "automation" { aws_integration_id = var.aws_integration_id aws_integration_enabled = true + + labels = var.labels } diff --git a/examples/complete/components/spacelift-automation/tfvars/example.tfvars b/examples/complete/components/spacelift-automation/tfvars/example.tfvars index 4163048..2d39114 100644 --- a/examples/complete/components/spacelift-automation/tfvars/example.tfvars +++ b/examples/complete/components/spacelift-automation/tfvars/example.tfvars @@ -5,3 +5,4 @@ repository = "terraform-spacelift-automation" root_modules_path = "../../../../examples/complete/components" all_root_modules_enabled = true aws_integration_id = "01JEC7ZACVKHTSVY4NF8QNZVVB" +labels = ["nobackend"] diff --git a/examples/complete/components/spacelift-automation/variables.tf b/examples/complete/components/spacelift-automation/variables.tf index 395f434..fd028a1 100644 --- a/examples/complete/components/spacelift-automation/variables.tf +++ b/examples/complete/components/spacelift-automation/variables.tf @@ -23,6 +23,12 @@ variable "github_enterprise" { description = "The GitHub VCS settings" } +variable "labels" { + type = list(string) + description = "List of labels to apply to the stacks." + default = [] +} + variable "repository" { type = string description = "The name of your infrastructure repo" diff --git a/main.tf b/main.tf index cae957d..bb532ae 100644 --- a/main.tf +++ b/main.tf @@ -244,6 +244,7 @@ locals { lookup(local._folder_labels, stack, []), lookup(local._dependency_labels, stack, []), try(local.stack_configs[stack].labels, []), + var.labels, ])) } diff --git a/tests/main.tftest.hcl b/tests/main.tftest.hcl index a73d81d..b7dba3d 100644 --- a/tests/main.tftest.hcl +++ b/tests/main.tftest.hcl @@ -10,6 +10,19 @@ variables { before_init = [ "echo 'Hello'" ] + labels = [ + "nobackend" + ] +} + +#Test that the global labels are created correctly +run "test_labels_are_created_correctly" { + command = plan + + assert { + condition = contains(local.labels["root-module-a-test"], "nobackend") + error_message = "Global labels were not created correctly: ${jsonencode(local.labels)}" + } } # Test that the root module fileset is created correctly diff --git a/variables.tf b/variables.tf index 65120ed..20d2868 100644 --- a/variables.tf +++ b/variables.tf @@ -268,6 +268,12 @@ variable "github_action_deploy" { default = true } +variable "labels" { + type = list(string) + description = "List of labels to apply to the stacks." + default = [] +} + variable "manage_state" { type = bool description = "Determines if Spacelift should manage state for this stack."