Terraform modules
- A Terraform module is a set of terrafom configuration files in a single directory.
- Terraform modules enable reusability of templates.
- There are lot of terraform modules developed by community for reusage
- Modules of terraform are hosted in public terraform registry Refer Here
- Now lets a simple terraform module in aws to create vpc Refer Here
- Now lets use this module to create a vpc Refer Here for the changeset
- now execute terraform init

- In the .terraform folder modules and providers folders will be created post init

- lets look into modules folder

- Now lets try to create resources using terraform apply

- When you are creating an architecture for application deployment try to find modules from the registry
- We also need to understand how to create our own modules for reusability within the team
Creating our own modules
- To demonstrate this, lets use the architecture which we have been creating

- This architecture has 3 major components
- networking
- database
- ec2 instances
- Now lets try to create 3 different modules and use it from a template
- Now every resource in terraform has
- arguments: inputs which we provide
- attributes: outputs which we get
- In the similar fashion modules also need to have arguments and attributes
- The inputs which we write in a template will become module arguments
- The outps which we mentioned in a template will become module attributes
- Refer Here for the changeset containing the changes to create 3 modules

- Using Terraform we can create infrastructure to deploy application, in the next session lets try to understand what happens when multiple users try to apply terraform from their systems and how to deal with multiple environments
