-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.tf
More file actions
100 lines (82 loc) · 2.87 KB
/
variables.tf
File metadata and controls
100 lines (82 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Input Variables - Define the module's interface
# Following Terraform best practices for variable definitions
# This code was generated using GitHub Copilot AI
variable "project_name" {
description = "Name of the project. Used for resource naming and tagging."
type = string
default = "CASE NIGHTMARE GREEN"
validation {
condition = length(var.project_name) > 0 && length(var.project_name) <= 50
error_message = "Project name must be between 1 and 50 characters."
}
}
variable "environment" {
description = "Environment name (e.g., dev, staging, prod). Used for resource naming and tagging."
type = string
validation {
condition = contains([
"dev", "development",
"test", "testing",
"stage", "staging",
"prod", "production"
], var.environment)
error_message = "Environment must be one of: dev, development, test, testing, stage, staging, prod, production."
}
}
variable "string_list" {
description = "List of strings to be processed and combined in outputs."
type = list(string)
default = ["item1", "item2", "item3"]
validation {
condition = length(var.string_list) > 0
error_message = "String list must contain at least one item."
}
}
variable "default_tags" {
description = "Default tags to apply to all resources. Will be merged with automatically generated tags."
type = map(string)
default = {
Terraform = "true"
Module = "simple-tf-module"
}
}
variable "enable_random_pet" {
description = "Whether to create a random pet resource. Demonstrates conditional resource creation."
type = bool
default = true
}
variable "pet_length" {
description = "Number of words in the random pet name when enabled."
type = number
default = 2
validation {
condition = var.pet_length >= 1 && var.pet_length <= 4
error_message = "Pet length must be between 1 and 4 words."
}
}
variable "pet_separator" {
description = "Separator to use between words in the random pet name."
type = string
default = "-"
validation {
condition = contains(["-", "_", ".", ""], var.pet_separator)
error_message = "Pet separator must be one of: '-', '_', '.', or '' (empty string)."
}
}
variable "prefix" {
description = "Prefix for resource naming. Should be lowercase and hyphenated."
type = string
validation {
condition = can(regex("^[a-z0-9-]+$", var.prefix))
error_message = "Prefix must be lowercase, alphanumeric, and hyphenated."
}
}
variable "resource_group_name" {
description = "The name of the resource group where resources will be created."
type = string
default = "default-resource-group"
validation {
condition = can(regex("^[a-zA-Z0-9-]+$", var.resource_group_name))
error_message = "Resource group name must be alphanumeric and hyphenated."
}
}