Overview
How modules are structured
The code in the module repositories is organized into three primary folders:
-
modules
: This folder contains the core implementation code. All modules you use and deploy are defined here. For example, you can locate the ECS cluster module in theterraform-aws-ecs
repository within themodules/ecs-cluster
folder. -
examples
: This folder includes sample code demonstrating how to use the modules in themodules
folder. These examples allow you to try the modules without writing code. Navigate to one of the example directories, follow the steps in the README (e.g., runtofu apply
), and you will have a working module. These examples serve as executable documentation. -
test
: This folder contains automated tests for the code in both themodules
andexamples
folders.
The structure of these files follows HashiCorp's Standard Module Structure, including main.tf
, variables.tf
, and outputs.tf
. In the variables.tf
file, required variables are listed first, followed by optional ones. Although many configurations are possible, the modules are designed with reasonable defaults to simplify setup for the most common use cases.
How services are structured
The terraform-aws-service-catalog
repository organizes its code into three main folders:
-
modules
: This folder contains the core implementation code for the services you use and deploy. For instance, the EKS cluster service resides inmodules/services/eks-cluster
. -
examples
: This folder provides sample code demonstrating how to use the services in themodules
folder. These examples enable you to deploy services without writing code. Navigate to a directory, follow the README instructions (e.g., runtofu apply
), and you'll have working infrastructure. This folder contains two sub-folders: -
for-learning-and-testing
: These examples are optimized for experimentation and testing but not for direct production use. They often rely on default VPCs or mock database URLs for convenience. -
for-production
: These examples are optimized for direct production use. They showcase how Gruntwork's Reference Architecture integrates a complete tech stack using the Gruntwork Service Catalog. To keep the code DRY and manage dependencies, you can deploy these examples using Terragrunt. Terragrunt is not required to use the Gruntwork Service Catalog; you can use OpenTofu, Terraform or Terraform Cloud/Enterprise, as described here. -
Not all modules include a
for-production
example. However, you can create a production-grade configuration using the template provided in this discussion. -
test
: This folder includes automated tests for the code in themodules
andexamples
folders.
Tools used in Library
Gruntwork Library actively supports OpenTofu. If you encounter any issues using the library with OpenTofu please reach out to support@gruntwork.io.
Gruntwork built its IaC Library using the following tools:
-
OpenTofu/Terraform. The Library contains nearly 300 OpenTofu/Terraform modules covering common AWS use cases. All modules are compatible with OpenTofu, Terraform, Terragrunt, or third-party pipeline tools like Terraform Cloud and Terraform Enterprise.
-
Packer. The Library includes definitions for machine images (e.g., VM images) using Packer. A common use case is creating Amazon Machine Images (AMIs) for EC2 instances, where configuration is defined entirely in code. After building an AMI, you can deploy it using OpenTofu/Terraform.
-
Terratest. All modules are functionally validated with automated tests written using Terratest.