Difference between revisions of "Terraform types"

From wikieduonline
Jump to navigation Jump to search
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
* https://www.terraform.io/docs/language/expressions/types.html
 
* https://www.terraform.io/docs/language/expressions/types.html
 
  
 
== Types ==
 
== Types ==
* <code>string</code>: a sequence of Unicode characters representing some text, like "hello".
+
* <code>[[string]]</code>: a sequence of Unicode characters representing some text, like "hello".
* <code>number</code>: a numeric value. The number type can represent both whole numbers like 15 and fractional values like 6.283185.
+
* <code>[[number]]</code>: a numeric value. The number type can represent both whole numbers like 15 and fractional values like 6.283185.
* <code>[[bool]]</code>: a boolean value, either true or false. bool values can be used in conditional logic.
+
* <code>[[bool]]</code>: a boolean value, either <code>true</code> or <code>false</code>. bool values can be used in conditional logic.
* <code>[[Terraform: list type|list]]</code> or [[tuple]]: a sequence of values, like <code>["us-west-1a", "us-west-1c"]</code>. Elements in a list or tuple are identified by consecutive whole numbers, starting with zero.
+
* <code>[[Terraform: list type|list]]</code> or <code>[[tuple]]</code>: a sequence of values, like <code>["us-west-1a", "us-west-1c"]</code>. Elements in a list or tuple are identified by consecutive whole numbers, starting with zero.
* <code>[[map]]</code> or <code>object</code>: a group of values identified by named labels, like {name = "Mabel", age = 52}.
+
* <code>[[Terraform map type|map]]</code> or <code>object</code>: a group of values identified by named labels, like <code>{name = "Mabel", age = 52}</code>.
  
 
== Examples ==
 
== Examples ==
Line 13: Line 12:
 
   default    = []
 
   default    = []
  
List example: <code> ["us-west-1a", "us-west-1c"]</code>
+
List example: <code> ["us-west-1a", "us-west-1c"]</code>
 
 
 
 
  
 
   type        = string
 
   type        = string
Line 49: Line 46:
 
   }]
 
   }]
 
  }
 
  }
 +
 +
== Errors ==
 +
* Terraform error: <code>[[List of object required]]</code>
 +
* Error: [[Element 0: object required]]
 +
* [[Error: Incorrect attribute value type]]
  
 
== Related terms ==
 
== Related terms ==
* [[variable]]: [[Terraform variable types]]
+
* [[Variable]]: [[Terraform variable types]]
* Error: [[List of object required]]
+
* [[Terragrunt: inputs:]]
* Error: [[Element 0: object required]]
 
  
 
== See also ==
 
== See also ==
 
* {{Terraform types}}
 
* {{Terraform types}}
* {{terraform aws resources}}
+
* {{Terraform variables}}
* {{Terraform}}
 
  
 
[[Category:Terraform]]
 
[[Category:Terraform]]

Latest revision as of 10:53, 19 October 2023

Types[edit]

  • string: a sequence of Unicode characters representing some text, like "hello".
  • number: a numeric value. The number type can represent both whole numbers like 15 and fractional values like 6.283185.
  • bool: a boolean value, either true or false. bool values can be used in conditional logic.
  • list or tuple: a sequence of values, like ["us-west-1a", "us-west-1c"]. Elements in a list or tuple are identified by consecutive whole numbers, starting with zero.
  • map or object: a group of values identified by named labels, like {name = "Mabel", age = 52}.

Examples[edit]

 type        = list(string)
 default     = []
List example:  ["us-west-1a", "us-west-1c"]
 type        = string
 default     = null

Map/Object example[edit]

{
  name = "John"
  age  = 52
}
variable "amis" {
 type = "map"
 default = {
   "us-east-1" = "ami-b374d5a5"
   "us-west-2" = "ami-4b32be2b"
 }
}


Object list[edit]

variable "Your_Var_Name" {
  type = list
  default = [{
    "your_var_1" = "your_value_1"
    "your_var_2" = "your_value_1"
    "your_var_3" = "your_value_1"
  }]
}

Errors[edit]

Related terms[edit]

See also[edit]

Advertising: