# Working with Terraform modules in 2026

Source: https://www.thirdrocktechkno.com/blog/working-with-terraform-modules/
Updated: 2026-04-23T06:58:17.000Z

Terraform is a powerful tool for creating and managing infrastructure as code. One of the key features of Terraform is the ability to use modules to encapsulate and reuse infrastructure configuration. In this blog post, we'll explore how to work with Terraform modules, including how to create and publish your own modules.

First, let's define what a Terraform module is. A module is a collection of Terraform files that define a set of resources.  A module can be thought of as a reusable piece of 

Author: Abhilash
Published: 2024-12-30T14:22:38.000Z

Terraform is a powerful tool for creating and managing infrastructure as code. One of the key features of Terraform is the ability to use modules to encapsulate and reuse infrastructure configuration. In this blog post, we'll explore how to work with Terraform modules, including how to create and publish your own modules.

First, let's define what a Terraform module is. A module is a collection of Terraform files that define a set of resources.  A module can be thought of as a reusable piece of infrastructure configuration that can be easily shared and reused across different projects.

Creating a Terraform module is relatively straightforward. You'll need to create a directory that contains all of the Terraform files that make up the module and then use the `module` block in your Terraform configuration to reference that directory. For example, let's say you have a module that creates an S3 bucket. Your directory structure might look something like this:

```
modules/
├─ s3/
│  ├─ s3.tf
│  ├─ vars.tf
│  ├─ output.tf
```




In your Terraform configuration, you would then reference the `modules/s3-bucket` directory to use the module:

```hcl
module "s3-bucket" {
  source         = "./modules/s3"
  name           = "GalleryApp"
  environment    = "Dev"
  s3_bucket_name = "mygalleryapptrt"
}
```
dev/main.tf

Let's create a Terraform Module for a sample demo app in which we will deploy the same applications in different environments.

Our terraform module will be related to Three tier Application which consists of a React js Frontend, a Nodejs backend and a database where the database will be in a private subnet and React and Nodejs app in a public subnet

![Article illustration](/api/media/file/blog-0aaad56dc251af0db1479a26.png?prefix=payload%2Ftrt-platform&v=2026-11-12T13%3A23%3A47.370Z)

Three Tier ArchitectureHere in the above diagram, we are using S3, VPC, EC2 and RDS.
And now we will start creating terraform modules for the above infra.

Assuming you have already gone through the earlier blog i.e [Getting started with terraform ](/blog/getting-started-with-terraform/)

Let us start with S3 terraform module.

```hcl
resource "aws_s3_bucket" "react_website" {
  bucket = var.bucket_name
  tags = {
    Name        = var.name
    Environment = var.environment
  }
}

resource "aws_s3_bucket_website_configuration" "react_website" {
  bucket = aws_s3_bucket.react_website.id

  index_document {
    suffix = "index.html"
  }

  error_document {
    key = "404.html"
  }
}
```
main.tf

-  Create  S3 bucket to host a static website 
- Set index.html as the entry point whenever the website is loaded and 404.html page if something goes wrong

```hcl
variable "name" {
  description = "the name of your stack, e.g. \"demo\""
}

variable "environment" {
  description = "the name of your environment, e.g. \"prod\""
}

variable "bucket_name" {
  description = "name for the s3 bucket"
}
```
vars.tf

- Create variables for terraform stack, here `name` and `environment` is used to identify the stack
- `bucket_name` is used to create bucket names in the s3

```tf
output "react_website_endpoint" {
    value = aws_s3_bucket_website_configuration.react_website.website_endpoint
}
```
output.tf

- Terraform outputs are a means of exporting resource information in a structured format. This data can then be utilized to automate the configuration of other components within your infrastructure or as a source of information.

As shown earlier how to import a module created, let's use the same code and create a dev environment.

```
dev/
├─ main.tf
├─ output.tf
├─ vars.tf
modules/
├─ s3/
│  ├─ main.tf
│  ├─ output.tf
│  ├─ vars.tf

```
Folder structure

Let's plan and apply terraform s3 module for the DEV environment. once everything runs successfully. you will able to see the output.

![Article illustration](/api/media/file/blog-1ed75a98383ee206d7aaf0f0.png?prefix=payload%2Ftrt-platform&v=2026-11-12T13%3A23%3A47.361Z)



## Featured Insights

### Build vs Buy Adaptive Learning Platform: A Decision Framework for 2026



Tapan Patel
July 9, 2026

![Build vs Buy Adaptive Learning Platform: A Decision Framework for 2026](https://www.thirdrocktechkno.com/api/media/file/06b6cdc76812181392c4.png?prefix=payload%2Ftrt-platform%2F&v=2026-11-12T11%3A58%3A47.810Z)
[Build vs Buy Adaptive Learning Platform: A Decision Framework for 2026](/blog/build-vs-buy-adaptive-learning-platform/)

### Academic Integrity in the Age of AI: How GCC Universities Are Responding in 2026



Tapan Patel
July 1, 2026

![Academic Integrity in the Age of AI: How GCC Universities Are Responding in 2026](https://www.thirdrocktechkno.com/api/media/file/6a0617955855edc91996.png?prefix=payload%2Ftrt-platform%2F&v=2026-11-12T11%3A58%3A46.968Z)
[Academic Integrity in the Age of AI: How GCC Universities Are Responding in 2026](/blog/academic-integrity-ai-gcc-universities/)

### How to Modernise Your School ERP System With AI in the UAE and Saudi Arabia



Krunal Shah
June 26, 2026

![How to Modernise Your School ERP System With AI in the UAE and Saudi Arabia](https://www.thirdrocktechkno.com/api/media/file/faf6e4c86c928d59c483.png?prefix=payload%2Ftrt-platform%2F&v=2026-11-12T11%3A58%3A46.230Z)
[How to Modernise Your School ERP System With AI in the UAE and Saudi Arabia](/blog/ai-school-erp-modernisation-uae-saudi-arabia/)

### Best LMS for Corporate Training in 2026: AI-Powered Platforms and Custom Build Options



Tapan Patel
June 26, 2026

![Best LMS for Corporate Training in 2026: AI-Powered Platforms and Custom Build Options](https://www.thirdrocktechkno.com/api/media/file/c3f804b3109ad726e6af.png?prefix=payload%2Ftrt-platform%2F&v=2026-11-12T11%3A58%3A45.328Z)
[Best LMS for Corporate Training in 2026: AI-Powered Platforms and Custom Build Options](/blog/best-lms-for-corporate-training/)

### AI Powered LMS in 2026: What to Look For and When to Build Custom



Krunal Shah
June 24, 2026

![AI Powered LMS in 2026: What to Look For and When to Build Custom](https://www.thirdrocktechkno.com/api/media/file/9f82f160cfd29db7f3c0.png?prefix=payload%2Ftrt-platform%2F&v=2026-11-12T11%3A58%3A44.582Z)
[AI Powered LMS in 2026: What to Look For and When to Build Custom](/blog/custom-build-ai-powered-lms/)

### AI Teacher Training in Saudi Arabia: What Schools Need to Prepare For in 2026



Tapan Patel
June 24, 2026

![AI Teacher Training in Saudi Arabia: What Schools Need to Prepare For in 2026](https://www.thirdrocktechkno.com/api/media/file/fcc5c83e0bbcfb752bb7.png?prefix=payload%2Ftrt-platform%2F&v=2026-11-12T11%3A58%3A43.901Z)
[AI Teacher Training in Saudi Arabia: What Schools Need to Prepare For in 2026](/blog/ai-teacher-training-saudi-arabia-2/)

### AI Student Assessment Platforms in 2026: Best Tools, Core Features, and When to Build Custom



Tapan Patel
June 23, 2026

![AI Student Assessment Platforms in 2026: Best Tools, Core Features, and When to Build Custom](https://www.thirdrocktechkno.com/api/media/file/1598bcacdb680382c52f.png?prefix=payload%2Ftrt-platform%2F&v=2026-11-12T11%3A58%3A43.241Z)
[AI Student Assessment Platforms in 2026: Best Tools, Core Features, and When to Build Custom](/blog/ai-student-assessment-platform/)

### School Management Software in 2026: Best Platforms, Features, and Custom Development



Tapan Patel
June 19, 2026

![School Management Software in 2026: Best Platforms, Features, and Custom Development](https://www.thirdrocktechkno.com/api/media/file/59062fa23089b6025851.png?prefix=payload%2Ftrt-platform%2F&v=2026-11-12T11%3A58%3A42.220Z)
[School Management Software in 2026: Best Platforms, Features, and Custom Development](/blog/school-management-software-best-platforms-features-custom-development/)

### Generative AI in Education 2026: Platforms, Use Cases, and a Custom Build Guide for EdTech Teams



Tapan Patel
June 19, 2026

![Generative AI in Education 2026: Platforms, Use Cases, and a Custom Build Guide for EdTech Teams](https://www.thirdrocktechkno.com/api/media/file/f45fea34e6170d13209f.png?prefix=payload%2Ftrt-platform%2F&v=2026-11-12T11%3A58%3A41.219Z)
[Generative AI in Education 2026: Platforms, Use Cases, and a Custom Build Guide for EdTech Teams](/blog/generative-ai-education-2026/)

### ChatGPT Integration for EdTech Platforms: What Buyers Need to Know in 2026



Tapan Patel
June 15, 2026

![ChatGPT Integration for EdTech Platforms: What Buyers Need to Know in 2026](https://www.thirdrocktechkno.com/api/media/file/8e4109a5e4ce945568c4.png?prefix=payload%2Ftrt-platform%2F&v=2026-11-12T11%3A58%3A40.563Z)
[ChatGPT Integration for EdTech Platforms: What Buyers Need to Know in 2026](/blog/chatgpt-integration-edtech-platforms/)

### Is Your School Ready for AI? 12 Questions Every UAE School Should Answer First



Krunal Shah
June 15, 2026

![Is Your School Ready for AI? 12 Questions Every UAE School Should Answer First](https://www.thirdrocktechkno.com/api/media/file/f3eb1350eb13dc17270d.png?prefix=payload%2Ftrt-platform%2F&v=2026-11-12T11%3A58%3A39.740Z)
[Is Your School Ready for AI? 12 Questions Every UAE School Should Answer First](/blog/is-your-school-ready-for-ai/)

### Parent-Teacher Communication in 2026: How AI Is Replacing Manual Systems in UAE Schools



Tapan Patel
June 10, 2026

![Parent-Teacher Communication in 2026: How AI Is Replacing Manual Systems in UAE Schools](https://www.thirdrocktechkno.com/api/media/file/88ec24db5c15d1b7673e.png?prefix=payload%2Ftrt-platform%2F&v=2026-11-12T11%3A58%3A38.645Z)
[Parent-Teacher Communication in 2026: How AI Is Replacing Manual Systems in UAE Schools](/blog/ai-parent-teacher-communication-uae-schools/)

### Custom AI Education Platform Development Cost, Timeline, and What to Expect in 2026



Krunal Shah
June 9, 2026

![Custom AI Education Platform Development Cost, Timeline, and What to Expect in 2026](https://www.thirdrocktechkno.com/api/media/file/ed2767b3f4420fe7d0bc.png?prefix=payload%2Ftrt-platform%2F&v=2026-11-12T11%3A58%3A37.734Z)
[Custom AI Education Platform Development Cost, Timeline, and What to Expect in 2026](/blog/custom-ai-education-platform-development/)

### How to Choose a FlutterFlow Development Company in 2026



Krunal Shah
May 28, 2026

![How to Choose a FlutterFlow Development Company in 2026](https://www.thirdrocktechkno.com/api/media/file/blog-50f472074c46d9c4f3669725.webp?prefix=payload%2Ftrt-platform&v=2026-11-12T13%3A28%3A08.901Z)
[How to Choose a FlutterFlow Development Company in 2026](/blog/choose-flutterflow-development-company/)

### FlutterFlow: Complete Beginner's Guide 2026



Krunal Shah
May 12, 2026

![FlutterFlow: Complete Beginner's Guide 2026](https://www.thirdrocktechkno.com/api/media/file/blog-30816a0d79da3c386d2ecb15.webp?prefix=payload%2Ftrt-platform&v=2026-11-12T13%3A28%3A11.319Z)
[FlutterFlow: Complete Beginner's Guide 2026](/blog/flutterflow-complete-beginners-guide/)


## LET'S WORK
TOGETHER

Team up with us to enhance and achieve your business objectives.

![Third Rock Techkno 3d logo ](https://www.thirdrocktechkno.com/api/media/file/61f6a30d228988df7f79.svg?prefix=payload%2Ftrt-platform%2F&v=2026-11-12T11%3A58%3A47.940Z)
[Consult Our Experts](/contact-us/)
