Terraform AWS Dynamic Subnets

Terraform module for public and private subnets provisioning in existing VPC

Blockchain & Cloud ComputingHCLApache-2.0

Abstract

Terraform AWS Dynamic Subnets is an open-source Blockchain & Cloud Computing project. Terraform module for public and private subnets provisioning in existing VPC. Terraform module to provision public and private subnets in an existing VPC. It is built using HCL, Terraform, AWS. The complete source code is publicly available on GitHub under the Apache License 2.0, making it a useful reference for students building a Blockchain & Cloud Computing mini project or final-year project.

1. Introduction

Terraform module to provision public and private subnets in an existing VPC

The core function of this module is to create 2 sets of subnets, a "public" set with bidirectional access to the public internet, and a "private" set behind a firewall with egress-only access to the public internet. This includes dividing up a given CIDR range so that a each subnet gets its own distinct CIDR range within that range, and then creating those subnets in the appropriate availability zones. The intention is to keep this module relatively simple and easy to use for the most popular use cases. In its default configuration, this module creates 1 public subnet and 1 private subnet in each of the specified availability zones. The public subnets are configured for bi-directional traffic to the public internet, while the private subnets are configured for egress-only traffic to the public internet.

The module supports creating different numbers of public and private subnets per availability zone. This is useful for common architectures where you need a single public subnet for load balancers but multiple private subnets for different application tiers (web, app, data). You can specify the number and names of public and private subnets independently using public_subnets_per_az_count/public_subnets_per_az_names and private_subnets_per_az_count/private_subnets_per_az_names variables.

2. Objective

Terraform module for public and private subnets provisioning in existing VPC

This project demonstrates how HCL, Terraform, AWS can be applied to a real-world Blockchain & Cloud Computing problem.

4. Technology Stack

HCLTerraformAWS

5. System Requirements

General requirements for this technology stack — check the README for exact versions.

  • Terraform CLI
  • Cloud provider account (e.g. AWS) with CLI configured
  • Git (to clone the repository)

6. Installation & Setup

git clone https://github.com/cloudposse/terraform-aws-dynamic-subnets.git
cd terraform-aws-dynamic-subnets
# 1 public + 1 private subnet per AZ, with NAT Gateway per AZ
public_subnets_enabled  = true
private_subnets_enabled = true
max_subnet_count        = 3  # Reserve space for 3 AZs
max_nats                = 999 # One NAT per AZ
# Single NAT Gateway shared across all private subnets
max_nats = 1
# Everything else default
# Private subnets only, routing through TGW
public_subnets_enabled  = false
private_subnets_enabled = true
nat_gateway_enabled     = false
# Add custom routes to TGW externally
# Public subnets only for internet-facing resources
public_subnets_enabled  = true
private_subnets_enabled = false

Full setup instructions are in the project README.

7. Future Enhancements

Suggested extensions you can add to make this your own project.

  • Add a CI/CD pipeline with GitHub Actions
  • Deploy to a public test network or cloud free tier
  • Add monitoring and cost alerts

8. Viva / Review Questions

Common questions examiners ask for projects in this domain.

  1. Why does this problem need a blockchain or cloud-native design?
  2. Explain the smart contract / infrastructure components and how they interact.
  3. How are gas costs or cloud costs kept under control?
  4. How is the system secured (keys, IAM, access control)?
  5. How would the solution scale to many more users?

9. Source Code & License

This project is developed by cloudposse and published on GitHub under the Apache License 2.0. Please follow the license terms and credit the original author when you use or modify this code.

Want to build this as your internship project?

Work on a Blockchain & Cloud Computing project like this with mentor guidance, weekly reviews and an internship certificate from Training Trains, Erode — online or offline.

Apply for Blockchain & Cloud Computing Internship