Conditional Expressions/Fxns Flashcards
1
Q
What are conditional expressions in terraform?
A
They allow you to choose between two values based on a condition
2
Q
Whats the syntax of conditional expressions in Terraform?
A
condition ? true_val : false_val
Ex: instance_type = var.environment == “dev” ? “t2.micro” : “m5.large”
3
Q
What conditions can you use in Terraform?
A
== Equal to
!= Not Equal to
&& - Both conditions have to be true
Ex: instance_type = var.environment == “prod” && var.region == “us-east-1” ? m5.large : t2.micro