User Tools

Site Tools


programming:variablevalidation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

programming:variablevalidation [2024/07/01 10:24] – created kamaradskiprogramming:variablevalidation [2024/07/01 10:32] (current) – removed kamaradski
Line 1: Line 1:
-====== Variable Validation ====== 
  
-You can add validation rules to ensure that input values meet certain criteria. 
- 
-<code hcl> 
-variable "instance_type" { 
-  description = "Type of EC2 instance" 
-  type        = string 
-  default     = "t2.micro" 
- 
-  validation { 
-    condition     = contains(["t2.micro", "t2.small", "t2.medium"], var.instance_type) 
-    error_message = "Instance type must be one of t2.micro, t2.small, or t2.medium." 
-  } 
-} 
-</code> 
programming/variablevalidation.1719829469.txt.gz · Last modified: 2024/07/01 10:24 by kamaradski