Terraform modules: Difference between revisions

From wikinotes
(Created page with "A terraform module is a collection of <code>*.tf</code> files within a specific directory.")
 
No edit summary
Line 1: Line 1:
A terraform module is a collection of <code>*.tf</code> files within a specific directory.
A terraform module is a collection of <code>*.tf</code> files within a specific directory.<br>
A '''root module''' is defined at the root of your project.
 
= Input Variables =
<blockquote>
Input variables expose optional configuration to the commandline interface.<br>
They are defined in the root module, within <code>variable</code> blocks.
 
<syntaxhighlight lang="tf">
variable "image_id" {
  type = string
}
 
variable "availability_zone_names" {
  type    = list(string)
  default = ["us-west-1a"]
}
</syntaxhighlight>
 
Modify variables on CLI
<syntaxhighlight lang="bash">
terraform apply -var="image_id=foobar"
</syntaxhighlight>
</blockquote><!-- Input Variables -->

Revision as of 17:37, 25 September 2022

A terraform module is a collection of *.tf files within a specific directory.
A root module is defined at the root of your project.

Input Variables

Input variables expose optional configuration to the commandline interface.
They are defined in the root module, within variable blocks.

variable "image_id" {
  type = string
}

variable "availability_zone_names" {
  type    = list(string)
  default = ["us-west-1a"]
}

Modify variables on CLI

terraform apply -var="image_id=foobar"