Editing Terraform variables: variables.tf

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
TOMERGE [[Terraform variables]]
+
{{Draft}}
* https://www.terraform.io/docs/language/values/variables.html
 
* https://learn.hashicorp.com/tutorials/terraform/aws-variables
 
https://cloud.google.com/docs/terraform/best-practices-for-terraform#variables
 
  
string
 
number
 
bool
 
  
== Variable declaration ==
 
  
Definition in <code>[[variables.tf]]</code>
+
[[variables]]
  
[[variable]] "YourVarName" {}
 
variable "YourVarName" { default = "your_default_value" }
 
variable "your_subnets" { default = ["subnet-0d68d399b6cf9c2b3", "subnet-055f2f0b4de211111"] }
 
 
[[variable]] "YourVarName" {
 
  default = "your_default_value"
 
}
 
 
variable "YourVarName" {
 
  [[Terraform variable types|type]] = [[string]]
 
  description = "Description of your variable"
 
  default = "your_default_value"
 
}
 
 
== Variable usage ==
 
Usage in any terraform file (<code>[[main.tf]]</code>), using <code>[[var.]]</code> prefix:
 
 
<code>AnyFieldToAssingAValue = [[var.]]YourVarName</code>
 
<code>[[AnyFieldToAssingAValue]] = "${var.YourVarName}-yourtext-here"</code>
 
 
yourvar = "${aws_lb.your_lb_resource_name.dns_name}"
 
 
== Errors ==
 
* <code>[[Error: No value for required variable]]</code>
 
* <code>[[Error: Reference to undeclared input variable]]</code>
 
* <code>[[Error: Variables not allowed]]</code>
 
 
== Related term ==
 
* <code>[[main.tf]]</code>
 
* <code>[[variable.tfvars]]</code>
 
* <code>[[terraform.tfvars]]</code>
 
* <code>[[terraform apply]] -var 'myvar=football'</code>
 
* <code>[[terraform plan]]</code>
 
* <code>[[local.]]</code>
 
* <code>[[module.]]</code>
 
* <code>[[data.]]</code>
 
* <code>[[.name]]</code>
 
* <code>[[.dns_name]]</code>
 
* <code>[[.arn]]</code>
 
* [[Terraform best practices]]
 
* [[random_string.suffix.result]]
 
  
 
== See also ==
 
== See also ==
* {{tf files}}
+
* {{Terraform}}
* {{Terraform variables}}
 
  
 
[[Category:Terraform]]
 
[[Category:Terraform]]

Please note that all contributions to wikieduonline may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Wikieduonline:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Templates used on this page:

Advertising: