Inputs

Input variables serve as parameters for a Terraform module, allowing aspects of the module to be customized without altering the module’s own source code and allowing modules to be shared between different configurations.

When we declare variables in the root module of our configuration, we can set their values using CLI options and environment variables. When we declare them in child modules, the calling module should pass values in the module block.

The example shown below passes inputs for the official vpc module on the Terraform Registry. The inputs can be variables from the root module, hard-coded values in the configuration, or values from other resources in the root module or child modules.

Get hands-on with 1200+ tech skills courses.