variables.tf
  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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Variables ====================================================================

variable "stack_name" {
  description = "Name of the stack (tag: stack-name)"
  type        = string

  validation {
    condition     = length(trimspace(var.stack_name)) > 0
    error_message = "stack_name must not be empty."
  }
}

variable "application_name" {
  description = "Application name (tag: application-name)"
  type        = string

  validation {
    condition     = length(trimspace(var.application_name)) > 0
    error_message = "application_name must not be empty."
  }
}

variable "enable_map_tag" {
  description = "Enable the AWS Migration Accelerated Program (MAP) tag"
  type        = bool
  default     = false
}

variable "project" {
  description = "Project name (tag: project)"
  type        = string

  validation {
    condition     = length(trimspace(var.project)) > 0
    error_message = "project must not be empty."
  }
}

variable "cost_center_opex" {
  description = "OPEX cost center code (tag: cost-center-opex)"
  type        = string

  validation {
    condition     = length(trimspace(var.cost_center_opex)) > 0
    error_message = "cost_center_opex must not be empty."
  }
}

variable "cost_center_capex" {
  description = "CAPEX cost center code (tag: cost-center-capex)"
  type        = string

  validation {
    condition     = length(trimspace(var.cost_center_capex)) > 0
    error_message = "cost_center_capex must not be empty."
  }
}

variable "environment" {
  description = "Deployment environment (tag: environment)"
  type        = string

  validation {
    condition     = length(trimspace(var.environment)) > 0
    error_message = "environment must not be empty."
  }
}

variable "data_classification" {
  description = "Data classification level (tag: data-classification)"
  type        = string

  validation {
    condition     = length(trimspace(var.data_classification)) > 0
    error_message = "data_classification must not be empty."
  }
}

variable "availability_tier" {
  description = "Availability tier (tag: availability-tier)"
  type        = string

  validation {
    condition     = length(trimspace(var.availability_tier)) > 0
    error_message = "availability_tier must not be empty."
  }
}

variable "app_owner" {
  description = "Application owner role/title (tag: app-owner)"
  type        = string

  validation {
    condition     = length(trimspace(var.app_owner)) > 0
    error_message = "app_owner must not be empty."
  }
}

variable "team" {
  description = "Owning team (tag: team)"
  type        = string

  validation {
    condition     = length(trimspace(var.team)) > 0
    error_message = "team must not be empty."
  }
}

variable "assignment_group" {
  description = "Support assignment group (tag: assignment-group)"
  type        = string

  validation {
    condition     = length(trimspace(var.assignment_group)) > 0
    error_message = "assignment_group must not be empty."
  }
}

variable "owner" {
  description = "Owner contact email (tag: owner)"
  type        = string

  validation {
    condition     = length(trimspace(var.owner)) > 0
    error_message = "owner must not be empty."
  }
}

variable "business_unit" {
  description = "Business unit (tag: business-unit)"
  type        = string

  validation {
    condition     = length(trimspace(var.business_unit)) > 0
    error_message = "business_unit must not be empty."
  }
}

variable "additional_tags" {
  description = <<-EOT
    Additional tags to merge with the module's baseline tags.

    Baseline tags always take precedence. If a key here collides
    with a baseline tag, the baseline value wins and this value
    is silently dropped.
  EOT
  type        = map(string)
  default     = {}

  validation {
    condition = alltrue([
      for k in keys(var.additional_tags) : can(regex("^[a-z0-9]+(-[a-z0-9]+)*$", k))
    ])
    error_message = <<-EOT
      Invalid tag key(s) detected in "additional_tags".

      All keys must be kebab-case: lowercase alphanumeric
      segments separated by single hyphens.

        valid:   cost-center, owner, data-classification
        invalid: CostCenter, cost_center, Cost-Center, cost--center

      Fix the offending key(s) to proceed.
    EOT
  }
}