0
0
Terraformcloud~30 mins

Module versioning in Terraform - Mini Project: Build & Apply

Choose your learning style9 modes available
Terraform Module Versioning
📖 Scenario: You are managing infrastructure using Terraform. To keep your infrastructure code organized and reusable, you use modules. Modules can have different versions, and you want to specify which version to use to ensure stability.
🎯 Goal: Learn how to specify a module source and pin its version in Terraform configuration.
📋 What You'll Learn
Create a Terraform configuration that uses a module
Specify the module source as a public Terraform Registry module
Pin the module version to a specific version number
💡 Why This Matters
🌍 Real World
Terraform modules are reusable building blocks for infrastructure. Pinning module versions ensures your infrastructure does not unexpectedly change when modules update.
💼 Career
Cloud engineers and DevOps professionals use module versioning to maintain stable and predictable infrastructure deployments.
Progress0 / 4 steps
1
Create a Terraform configuration with a module block
Create a Terraform configuration file with a module block named vpc that uses the source terraform-aws-modules/vpc/aws.
Terraform
Need a hint?

Use the module block with the exact name vpc and set the source attribute to the module path.

2
Add a version constraint to the module
Add a version attribute to the vpc module block and set it to "3.14.0".
Terraform
Need a hint?

Specify the exact version string using the version attribute inside the module block.

3
Add a variable to configure the module
Inside the vpc module block, add the variable name and set it to "my-vpc".
Terraform
Need a hint?

Set the name variable inside the module block to configure the module.

4
Add Terraform required version and initialize
Add a terraform block at the top of the file specifying required_version as ">= 1.3.0" and add a required_providers block with aws provider version ">= 4.0.0".
Terraform
Need a hint?

Use the terraform block to specify the Terraform version and provider version constraints.