Terraform Module Block Syntax: Difference between revisions
(8 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
=Overview= | =Overview= | ||
<font color=darkgray>TODO: this section must be expanded based on https://www.terraform.io/docs/configuration/modules.html and https://www.terraform.io/docs/modules/index.html</font> | <font color=darkgray>TODO: this section must be expanded based on https://www.terraform.io/docs/configuration/modules.html and https://www.terraform.io/docs/modules/index.html</font> | ||
After adding, removing, or modifying <code>module</code> blocks, [[Terraform_Operations#Initialization|terraform init]] must be re-run to allow Terraform the opportunity to adjust the installed modules. By default this command will not upgrade an already-installed module; use the [[Terraform_Operations#-upgrade|-upgrade]] option to instead upgrade to the newest available version. | |||
=Playground= | |||
{{External|}} | |||
=Example= | =Example= | ||
Line 30: | Line 35: | ||
==source== | ==source== | ||
The <code>source</code> argument is required. It is a <font color=darkgray>meta-argument</font> defined by the Terraform CLI. Its value is either the path to the local directory that contains the dependency module's [[Terraform_Concepts#Configuration|configuration]] files or a remote module source that Terraform should download and use. This value must be a literal string with no template sequences; arbitrary expressions are not allowed. | The <code>source</code> argument is required. It is a <font color=darkgray>meta-argument</font> defined by the Terraform CLI. Its value is either the path to the local directory that contains the dependency module's [[Terraform_Concepts#Configuration|configuration]] files or a remote module source that Terraform should download and use. This value must be a literal string with no template sequences; arbitrary expressions are not allowed. For more details see: {{Internal|Terraform_Concepts#Module_Sources|Module Sources}} | ||
===How to Specify a Remote Module=== | |||
The syntax specified below (no protocol qualifier) implies that the module path is relative to the [[Terraform_Concepts#Terraform_Registry|Terraform Registry]] URL, specifically https://registry.terraform.io/v1/modules/. This is obvious if [[Terraform_Operations#Verbose_Output_and_Debugging|TF_LOG]] environment variable is set to TRACE. | |||
<syntaxhighlight lang='json'> | |||
module "..." { | |||
source = "terraform-aws-modules/eks/aws" | |||
... | |||
} | |||
</syntaxhighlight> | |||
==version== | |||
{{External|https://www.terraform.io/docs/configuration/modules.html#module-versions}} | |||
Constraint on the dependency module version. |
Latest revision as of 01:26, 3 March 2020
External
- https://www.terraform.io/docs/configuration/modules.html
- https://www.terraform.io/docs/modules/index.html
Internal
Overview
TODO: this section must be expanded based on https://www.terraform.io/docs/configuration/modules.html and https://www.terraform.io/docs/modules/index.html
After adding, removing, or modifying module
blocks, terraform init must be re-run to allow Terraform the opportunity to adjust the installed modules. By default this command will not upgrade an already-installed module; use the -upgrade option to instead upgrade to the newest available version.
Playground
Example
module "some-module" {
source = "terraform-aws-modules/eks/aws"
version = "~> 9.0"
cluster_name = local.cluster_name
vpc_id = var.aws_vpc_id
...
tags = {
Environment = var.environment_name
}
}
Arguments
source
The source
argument is required. It is a meta-argument defined by the Terraform CLI. Its value is either the path to the local directory that contains the dependency module's configuration files or a remote module source that Terraform should download and use. This value must be a literal string with no template sequences; arbitrary expressions are not allowed. For more details see:
How to Specify a Remote Module
The syntax specified below (no protocol qualifier) implies that the module path is relative to the Terraform Registry URL, specifically https://registry.terraform.io/v1/modules/. This is obvious if TF_LOG environment variable is set to TRACE.
module "..." {
source = "terraform-aws-modules/eks/aws"
...
}
version
Constraint on the dependency module version.