Sobes.tech
Junior — Middle

How is version control of modules managed in Terraform?

sobes.tech AI

Answer from AI

In Terraform, module version management is done by specifying the version in the source block when connecting a module. Modules are usually stored in the Terraform Registry or in version control systems (Git). To fix a version, syntax such as a tag or branch for Git, or the version parameter for the registry, is used.

Example of connecting a module with a version from the Terraform Registry:

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "3.14.0"
  # other parameters
}

For Git repositories, you can specify a specific tag or branch:

module "my_module" {
  source = "git::https://github.com/username/repo.git//path/to/module?ref=v1.2.3"
}

Thus, version management allows fixing the versions of modules used, ensuring stability and predictability of the infrastructure.