Terraform variables: variables.tf

From wikieduonline
Revision as of 03:33, 11 July 2024 by Welcome (talk | contribs) (→‎Related term)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Variable declaration[edit]

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[edit]

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

AnyFieldToAssingAValue = var.YourVarName
AnyFieldToAssingAValue = "${var.YourVarName}-yourtext-here"
yourvar = "${aws_lb.your_lb_resource_name.dns_name}"

Errors[edit]

Related term[edit]

See also[edit]

Advertising: