Difference between revisions of "Terraform variables"
Jump to navigation
Jump to search
(34 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | + | TOMERGE: [[Terraform variables: variables.tf]] | |
* https://www.terraform.io/language/values/variables: <code>[[string]], number, [[bool]], any</code> | * https://www.terraform.io/language/values/variables: <code>[[string]], number, [[bool]], any</code> | ||
* [[Terraform Cloud]]: https://www.terraform.io/cloud-docs/workspaces/variables | * [[Terraform Cloud]]: https://www.terraform.io/cloud-docs/workspaces/variables | ||
+ | * Terraform variable definition: <code>[[Terraform variables: variables.tf|variables.tf]]</code> | ||
− | * <code>terraform apply [[-var]]="[[image_id]]=ami-abc123"</code> | + | == Examples == |
+ | Using command line parameters: | ||
+ | * <code>[[terraform apply]] [[-var]]="[[image_id]]=ami-abc123"</code> | ||
* <code>terraform apply [[-var]]="[[image_id]]=ami-abc123 [[-var]]="your_second_var=yourvalue"</code> | * <code>terraform apply [[-var]]="[[image_id]]=ami-abc123 [[-var]]="your_second_var=yourvalue"</code> | ||
+ | |||
+ | Using a file: | ||
* <code>terraform apply [[-var-file]]="your_file[[.tfvars]]"</code> | * <code>terraform apply [[-var-file]]="your_file[[.tfvars]]"</code> | ||
+ | |||
+ | == Errors == | ||
+ | * <code>[[Error: Reference to undeclared input variable]]</code> | ||
+ | * <code>[[Error: Variables not allowed]]</code> | ||
+ | * <code>[[Error: Duplicate variable declaration]]</code> | ||
+ | * <code>[[Error: No value for required variable]]</code> | ||
== Related == | == Related == | ||
− | * [[Terraform variable types]] | + | * [[Terraform variable types]]: <code>[[string]], [[number]], [[bool]], any</code> |
+ | * [[Terraform environment variables]] | ||
+ | * [[Terraform configuration variables]] | ||
* [[Terraform: variables.tf]] | * [[Terraform: variables.tf]] | ||
− | * [[ | + | * <code>[[auto.tfvars]]</code> |
− | * [[ | + | * <code>[[nullable]]</code> [[Terraform v1.1.0]] (Dec 2021) |
* <code>[[validation]]</code> block introduced in terraform CLI [[Terraform changelog|v0.13.0]] (August 2020) | * <code>[[validation]]</code> block introduced in terraform CLI [[Terraform changelog|v0.13.0]] (August 2020) | ||
− | * [[Terraform: output|output]] | + | * <code>[[Terraform: output|output]]</code> |
+ | * <code>[[-var-file]]</code> | ||
+ | * <code>[[locals]]: [[locals.tf]]</code>: https://www.terraform.io/language/values/locals | ||
+ | * [[Terragrunt: inputs:]] | ||
+ | * <code>[[TF_VAR_]]</code> | ||
== See also == | == See also == | ||
* {{Terraform variables}} | * {{Terraform variables}} | ||
− | * {{Terraform}} | + | * {{Terraform types}} |
[[Category:Terraform]] | [[Category:Terraform]] |
Latest revision as of 05:19, 12 February 2024
TOMERGE: Terraform variables: variables.tf
- https://www.terraform.io/language/values/variables:
string, number, bool, any
- Terraform Cloud: https://www.terraform.io/cloud-docs/workspaces/variables
- Terraform variable definition:
variables.tf
Contents
Examples[edit]
Using command line parameters:
terraform apply -var="image_id=ami-abc123"
terraform apply -var="image_id=ami-abc123 -var="your_second_var=yourvalue"
Using a file:
Errors[edit]
Error: Reference to undeclared input variable
Error: Variables not allowed
Error: Duplicate variable declaration
Error: No value for required variable
Related[edit]
- Terraform variable types:
string, number, bool, any
- Terraform environment variables
- Terraform configuration variables
- Terraform: variables.tf
auto.tfvars
nullable
Terraform v1.1.0 (Dec 2021)validation
block introduced in terraform CLI v0.13.0 (August 2020)output
-var-file
locals: locals.tf
: https://www.terraform.io/language/values/locals- Terragrunt: inputs:
TF_VAR_
See also[edit]
Advertising: