Terraform Modules Lab (Beginner Intermediate Real-world)

Objective Build reusable Terraform modules and deploy infrastructure using them. You will: Create a VPC module Create an EC2 module Reuse modules Understand module inputs, outputs, and structure Pa...

By · · 1 min read
Terraform Modules Lab (Beginner Intermediate Real-world)

Source: DEV Community

Objective Build reusable Terraform modules and deploy infrastructure using them. You will: Create a VPC module Create an EC2 module Reuse modules Understand module inputs, outputs, and structure Part 1 – Project Structure (Real-world layout) terraform-modules-lab/ │ ├── modules/ │ ├── vpc/ │ │ ├── main.tf │ │ ├── variables.tf │ │ └── outputs.tf │ │ │ └── ec2/ │ ├── main.tf │ ├── variables.tf │ └── outputs.tf │ ├── env/ │ └── dev/ │ ├── main.tf │ ├── variables.tf │ └── terraform.tfvars Part 2 – Create VPC Module modules/vpc/main.tf resource "aws_vpc" "main" { cidr_block = var.cidr_block tags = { Name = var.name } } resource "aws_subnet" "public" { vpc_id = aws_vpc.main.id cidr_block = var.subnet_cidr availability_zone = var.az tags = { Name = "${var.name}-subnet" } } modules/vpc/variables.tf variable "cidr_block" {} variable "subnet_cidr" {} variable "az" {} variable "name" {} modules/vpc/outputs.tf output "vpc_id" { value = aws_vpc.main.id } output "subnet_id" { value = aws_subnet.publ

Similar Topics

#artificial intelligence (31552) #data science (24017) #ai (16747) #machine learning (14680) #research (8564) #deep learning (7655) #programming (3999) #large language models (3406) #events (3308) #data engineering (2565) #deep dives (2512) #llm (2120) #cloud (1919) #hands on tutorials (1874) #python (1819) #open source (1686) #networking (1471) #computer vision (1423) #gpu (1185) #solana (1103)

Related Posts

Trending on ShareHub

Latest on ShareHub

Browse Topics

#artificial intelligence (31552) #data science (24017) #ai (16738) #generative ai (15034) #crypto (14987) #machine learning (14680) #bitcoin (14229) #featured (13550) #news & insights (13064) #crypto news (11082)

Around the Network