Difference between revisions of "Terraform conditional expressions"

From wikieduonline
Jump to navigation Jump to search
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
* https://www.terraform.io/docs/language/expressions/conditionals.html
+
https://www.terraform.io/docs/language/expressions/conditionals.html
  
condition ? true_val : false_val
+
* <code>condition ? true_val : false_val</code>
  
 +
* <code>[[Terraform meta argument: count|count]]                = var.[[vpc_cidr_block]] != null ? 1 : 0</code>
  
  [[count]]               = var.[[vpc_cidr_block]] != null ? 1 : 0
+
  [[retention_in_days]] = var.yourenv == "prod" ? 14 : 1
 +
 
 +
 
 +
count = var.env == "prod" ? 1 : 0
 +
 
 +
 
 +
https://www.hashicorp.com/blog/announcing-terraform-0-12
 +
locals {
 +
  public_instances_by_az = {
 +
    for i in aws_instance.example : i.availability_zone => i...
 +
    if i.associate_public_ip_address
 +
  }
 +
}
 +
 
 +
== Related ==
 +
* <code>[[depends_on]]</code>
 +
* <code>[[if]]</code>
 +
* [[Terraform meta argument]]: <code>[[Terraform meta argument: count|count]]</code>
 +
[[Error: Unsupported attribute]]
  
 
== See also ==
 
== See also ==
 
* {{Terraform}}
 
* {{Terraform}}
 +
 +
[[Category:Terraform]]

Latest revision as of 15:44, 19 April 2023

Advertising: