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.