Difference between revisions of "Terraform variables: variables.tf"

From wikieduonline
Jump to navigation Jump to search
Line 2: Line 2:
 
* https://www.terraform.io/docs/language/values/variables.html
 
* https://www.terraform.io/docs/language/values/variables.html
 
* https://learn.hashicorp.com/tutorials/terraform/aws-variables
 
* https://learn.hashicorp.com/tutorials/terraform/aws-variables
 +
https://cloud.google.com/docs/terraform/best-practices-for-terraform#variables
  
string
+
string
number
+
number
bool
+
bool
  
 
== Variable declaration ==
 
== Variable declaration ==

Revision as of 09:53, 17 February 2023

https://cloud.google.com/docs/terraform/best-practices-for-terraform#variables

string
number
bool

Variable declaration

Definition in variables.tf

variable "YourVarName" {}
variable "YourVarName" { default = "your_default_value" }
variable "your_subnets" { default = ["subnet-0d68d399b6cf9c2b3", "subnet-055f2f0b4de211111"] }
variable "YourVarName" {
  default = "your_default_value"
}
variable "YourVarName" {
  type = string
  description = "Description of your variable"
  default = "your_default_value"
}

Variable usage

Usage in any terraform file (main.tf), using var. prefix:

AnyFieldToAssingAValue = var.YourVarName
AnyFieldToAssingAValue = "{var.YourVarName}-yourtext-here}"

Errors

Related term

See also

Advertising: