Difference between revisions of "Terraform variables: variables.tf"
Jump to navigation
Jump to search
Line 36: | Line 36: | ||
* <code>[[terraform apply]] -var ‘myvar=football’</code> | * <code>[[terraform apply]] -var ‘myvar=football’</code> | ||
* <code>[[local.]]</code> | * <code>[[local.]]</code> | ||
+ | * <code>[[module.]]</code> | ||
== See also == | == See also == |
Revision as of 00:17, 28 February 2022
- https://www.terraform.io/docs/language/values/variables.html
- https://learn.hashicorp.com/tutorials/terraform/aws-variables
Example 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" }
Usage in any terraform file, main.tf
:
AnyFieldToAssingAValue = var.YourVarName
Errors
Related term
main.tf
variable.tfvars
terraform.tfvars
- Variables
terraform apply -var ‘myvar=football’
local.
module.
See also
- Terraform configuration files, Terraform state files:
.tf
,.tfvars
,main.tf, outputs.tf
,variables.tf
,.terraform.d/
,terraform init
,providers.tf
,.terraform/
,terraform.tfstate
,.terraform.lock.hcl
,terraform.tfstate.d, override.tf, versions.tf
- Terraform variables, types, env variables,
variables.tf
,.tfvars
,nullable
,validation
,terraform.tfvars
Advertising: