Skip to main content

Updating Versioned Modules

Updating a module or service requires changing the tagged version in the source attribute of the module block. For backwards-compatible changes, this involves incrementing the version number. For backwards-incompatible changes, review the release notes in the module's GitHub repository release page for migration guidance.

We recommend updating module versions in your development environment first, followed by staging, and then production. This approach ensures the update and any necessary changes are fully tested and understood.

Example: Update a version

Below is a Terraform configuration referencing version 0.15.3 of the single-server submodule from the terraform-aws-server module.

To update to version 0.15.4, change the value to the right of ref= in the source attribute. Since the version number indicates a backwards-compatible update, no additional changes should be required.

module "my_instance" {
# Old
# source = "git::git@github.com:gruntwork-io/terraform-aws-server.git//modules/single-server?ref=v0.15.3"
# New
source = "git::git@github.com:gruntwork-io/terraform-aws-server.git//modules/single-server?ref=v0.15.4"

name = "my_instance"
ami = "ami-123456"
instance_type = "t2.medium"
keypair_name = "my-keypair"
user_data = "${var.user_data}"

vpc_id = "${var.vpc_id}"
subnet_id = "${var.subnet_id}"
}

After making the change, run terraform plan, review the output to confirm it matches your expectations, then execute terraform apply.

Patcher

Keeping track of all references to modules and services is complex and prone to errors. To simplify this process, Gruntwork developed Patcher. Patcher displays the version of a module currently in use, the latest available version, and the corresponding changelog, enabling efficient and accurate updates.