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]]
+
 
 
* 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
+
== Example variable declaration ==
number
 
bool
 
 
 
== Variable declaration ==
 
  
 
Definition in <code>[[variables.tf]]</code>
 
Definition in <code>[[variables.tf]]</code>
Line 26: Line 21:
 
  }
 
  }
  
== Variable usage ==
 
 
Usage in any terraform file (<code>[[main.tf]]</code>), using <code>[[var.]]</code> prefix:
 
Usage in any terraform file (<code>[[main.tf]]</code>), using <code>[[var.]]</code> prefix:
  
 
  <code>AnyFieldToAssingAValue = [[var.]]YourVarName</code>
 
  <code>AnyFieldToAssingAValue = [[var.]]YourVarName</code>
<code>[[AnyFieldToAssingAValue]] = "${var.YourVarName}-yourtext-here"</code>
 
 
yourvar = "${aws_lb.your_lb_resource_name.dns_name}"
 
  
 
== Errors ==
 
== Errors ==
 
* <code>[[Error: No value for required variable]]</code>
 
* <code>[[Error: No value for required variable]]</code>
 
* <code>[[Error: Reference to undeclared input variable]]</code>
 
* <code>[[Error: Reference to undeclared input variable]]</code>
* <code>[[Error: Variables not allowed]]</code>
 
  
 
== Related term ==
 
== Related term ==
Line 44: Line 34:
 
* <code>[[terraform.tfvars]]</code>
 
* <code>[[terraform.tfvars]]</code>
 
* <code>[[terraform apply]] -var 'myvar=football'</code>
 
* <code>[[terraform apply]] -var 'myvar=football'</code>
* <code>[[terraform plan]]</code>
 
 
* <code>[[local.]]</code>
 
* <code>[[local.]]</code>
 
* <code>[[module.]]</code>
 
* <code>[[module.]]</code>
 
* <code>[[data.]]</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 ==

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: