0
0
Terraformcloud~10 mins

Creating a child module in Terraform - Interactive Practice

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

Complete the code to call a child module named 'network'.

Terraform
module "network" {
  source = [1]
}
Drag options to blanks, or click blank then click option'
A"../network"
B"network-module"
C"./modules/network"
D"network"
Attempts:
3 left
💡 Hint
Common Mistakes
Using just the module name without a path.
Using a relative path that does not exist.
2fill in blank
medium

Complete the code to pass a variable 'region' with value 'us-west-1' to the child module.

Terraform
module "network" {
  source = "./modules/network"
  [1] = "us-west-1"
}
Drag options to blanks, or click blank then click option'
Aregion
Barea
Czone
Dlocation
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong variable name like 'location' or 'zone'.
Forgetting to pass the variable at all.
3fill in blank
hard

Fix the error in the child module call by completing the missing attribute to output the module's VPC ID.

Terraform
output "vpc_id" {
  value = module.network.[1]
}
Drag options to blanks, or click blank then click option'
Avpcid
BvpcId
CvpcID
Dvpc_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using camelCase or incorrect casing.
Using a name not defined in the child module outputs.
4fill in blank
hard

Fill both blanks to define a child module with source path and pass a variable 'cidr_block'.

Terraform
module "vpc" {
  source = [1]
  [2] = "10.0.0.0/16"
}
Drag options to blanks, or click blank then click option'
A"./modules/vpc"
Bcidr_block
Cvpc_cidr
D"vpc-module"
Attempts:
3 left
💡 Hint
Common Mistakes
Using an incorrect source path.
Using a wrong variable name like 'vpc_cidr'.
5fill in blank
hard

Fill all three blanks to define a child module, pass variables 'name' and 'environment', and output the module's subnet ID.

Terraform
module "subnet" {
  source      = [1]
  name        = [2]
  environment = [3]
}

output "subnet_id" {
  value = module.subnet.subnet_id
}
Drag options to blanks, or click blank then click option'
A"./modules/subnet"
B"prod-subnet"
C"production"
D"./subnet-module"
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect source paths.
Passing variables without quotes.
Using inconsistent variable names.