In this lesson, you will learn how to leverage modules from the Terraform Registry to simplify your infrastructure provisioning. Terraform modules allow you to reuse and share configurations across projects, streamlining your workflow. While a local module resides on the same machine as Terraform, modules from the Registry offer the added benefit of being easily shared with the community.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
Local Module Example
A typical local module configuration might look like this:Terraform Registry Modules
Modules in the Terraform Registry are organized by the provider they support. They come in two categories:- Verified Modules: Tested and maintained by HashiCorp, these modules are marked with a blue tick. For example, AWS security group modules often appear as verified solutions.
- Community Modules: Created by users, these modules are not validated by HashiCorp.
Referencing a Security Group Module
The following example demonstrates how to reference an AWS security group module from the Terraform Registry:Creating an SSH Security Group
A common use case is to create a security group that permits inbound SSH access. The SSH module requires three mandatory inputs:- The name of the security group.
- The VPC in which it will be created.
- A list of ingress CIDR blocks allowed access for SSH.
It is highly recommended to specify the module version to ensure consistency and prevent unintended updates. Omitting the version may cause Terraform to download the latest module revision, potentially introducing changes that could disrupt your environment.
Initializing and Downloading Modules
To use a module from the Terraform Registry, start by initializing your Terraform configuration. If the provider plugins are already downloaded, you can simply run the command to fetch the module:terraform plan– to view the changes.terraform apply– to apply the configuration.