1. Module call
A module block instantiates a reusable package of resources under the local name "vpc".
module "vpc" {Typorithm · medium
Step 1 of 8 · intro card
State & Modules
A module block instantiates a reusable bundle of resources: source addresses where it lives, inputs like cidr are passed in, and outputs are read back as module.vpc.vpc_id.
A module is a reusable package of resources you call by name. The module block here creates a VPC stack under the local label "vpc".
source tells Terraform where to fetch the module — a registry path like terraform-aws-modules/vpc/aws, a git URL, or a local path — and version pins a registry release.
Inputs (cidr) flow in like function arguments, and outputs flow back out: anywhere else in the config you read them as module.vpc.vpc_id, here wiring the VPC's id into an instance's subnet.
module "name" { ... } instantiates a reusable package.
source addresses the module; version pins a registry release.
Read outputs as module.<name>.<output>.
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "5.0.0"
cidr = "10.0.0.0/16"
}
resource "aws_instance" "web" {
subnet_id = module.vpc.vpc_id
}Connect each part of the code to the concept before you type.
A module block instantiates a reusable package of resources under the local name "vpc".
module "vpc" {source addresses where the module comes from — here a Terraform Registry path namespace/name/provider.
source = "terraform-aws-modules/vpc/aws"version pins the module release so upgrades are deliberate, not accidental.
version = "5.0.0"cidr is an input variable the module exposes; you pass values in just like function arguments.
cidr = "10.0.0.0/16"module.<name>.<output> reads a value the module exports — here the created VPC's id.
module.vpc.vpc_idRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.