Ravi Sir's Cards › AWS
Modules for reuse
This revision card explains Modules for reuse. It starts from the need that copy-pasting the same VPC block into five apps drifts and breaks fixes. A module is a folder of.tf with variables and outputs. Root modules call it with different inputs. The how-to section notes write modules/vpc; call it from app-a and app-b with different cidr variables. An example on the card is one security fix inside the module reaches every app on the next plan/apply.
Read card text
What this card says
Why do we need it?
Copy-pasting the same VPC block into five apps drifts and breaks fixes.
What is it?
A module is a folder of .tf with variables and outputs. Root modules call it with different inputs.
module "vpc"
How to do it
Write modules/vpc; call it from app-a and app-b with different cidr variables.
Example
One security fix inside the module reaches every app on the next plan/apply.