0
0
Terraformcloud~10 mins

Module versioning in Terraform - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the module source version.

Terraform
module "network" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "[1]"
}
Drag options to blanks, or click blank then click option'
A"1.2"
B"latest"
C"v1"
D"3.0.0"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'latest' as a version string
Omitting quotes around the version number
2fill in blank
medium

Complete the code to pin the module version to a specific release.

Terraform
module "storage" {
  source  = "terraform-aws-modules/s3-bucket/aws"
  version = "[1]"
}
Drag options to blanks, or click blank then click option'
A"latest"
B">= 1.0.0"
C"~> 2.5.0"
D"2"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'latest' which is invalid
Using only a major version without constraint operator
3fill in blank
hard

Fix the error in the module version specification.

Terraform
module "compute" {
  source  = "terraform-aws-modules/ec2-instance/aws"
  version = [1]
}
Drag options to blanks, or click blank then click option'
A"1.4.0"
B1.4.0
C"latest"
Dlatest
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the version string
Using 'latest' without quotes
4fill in blank
hard

Fill both blanks to specify a module with a version constraint and a source registry.

Terraform
module "database" {
  source  = "[1]"
  version = "[2]"
}
Drag options to blanks, or click blank then click option'
Aterraform-aws-modules/rds/aws
B1.0.0
C~> 3.2.1
Daws-modules/rds
Attempts:
3 left
💡 Hint
Common Mistakes
Using incomplete source paths
Using exact version instead of constraint
5fill in blank
hard

Fill all three blanks to define a module with a Git source and a specific ref version.

Terraform
module "app" {
  source = "git::https://github.com/terraform-modules/app.git?ref=[1]"
  version = "[2]"
  providers = { aws = [3] }
}
Drag options to blanks, or click blank then click option'
Av1.2.3
B1.2.3
Caws.default
Daws.main
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting 'v' in the Git ref
Using wrong provider alias