In Terraform, variables are referred to using the syntax var.<variable_name>. Here, var is a special namespace that contains all input variables.
For example, if you have a variable named num_servers in your configuration and you want to pass it to a module, you would do it like this:
variable "num_servers" {
description = "The number of servers to create"
default = 5
}
module "server_module" {
source = "app.terraform.io/example/server"
version = "1.0.0"
servers = var.num_servers
}
In the above example, the input variable num_servers is defined with a default value of 5. Then, the server_module is being called and the servers argument is being set to the value of var.num_servers, which is 5.
D
to pass a value to a module the syntax is
<child module variable name > = <value>
Here child module variable name is servers
to reference the value of a variable in main/root module var. <name_of _the varibale>
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
tipzzz
Highly Voted 2 years, 7 months agovitasac
Highly Voted 2 years, 6 months agokanikachander
Most Recent 3 months, 3 weeks agoCololand
6 months, 2 weeks agoenook
10 months, 3 weeks agoghostGuiggs
1 year agoKizerfor
1 year, 2 months agoBere
1 year, 3 months agoShane_C
1 year, 4 months agoNi33
1 year, 6 months agoBluemoon22
1 year, 7 months agoPower123
1 year, 7 months agothor7
1 year, 7 months agoPower123
1 year, 7 months agokartikjena31
1 year, 10 months agolalgebala
2 years agoRVivek
2 years, 2 months ago