Back to articles
production-style infrastructure: ALB module infra-modules + infra-live separation environment-based deployment
How-ToDevOps

production-style infrastructure: ALB module infra-modules + infra-live separation environment-based deployment

via Dev.toAisalkyn Aidarova

πŸ—οΈ FINAL STRUCTURE terraform-production-lab/ β”‚ β”œβ”€β”€ infra-modules/ β”‚ β”œβ”€β”€ vpc/ β”‚ β”œβ”€β”€ security-group/ β”‚ β”œβ”€β”€ ec2/ β”‚ └── alb/ β”‚ └── infra-live/ β”œβ”€β”€ dev/ └── prod/ 🧠 IDEA (VERY IMPORTANT) infra-modules β†’ reusable (write once) infra-live β†’ environment-specific (dev/prod) βš™οΈ STEP 1 β€” CREATE STRUCTURE mkdir -p terraform-production-lab/infra-modules/ { vpc,security-group,ec2,alb } mkdir -p terraform-production-lab/infra-live/ { dev,prod } cd terraform-production-lab πŸ”· MODULE 1 β€” VPC infra-modules/vpc/main.tf resource "aws_vpc" "this" { cidr_block = var . cidr_block tags = merge ( var . tags , { Name = var . name }) } resource "aws_subnet" "public" { count = length ( var . public_subnets ) vpc_id = aws_vpc . this . id cidr_block = var . public_subnets [ count . index ] availability_zone = var . azs [ count . index ] tags = merge ( var . tags , { Name = "${var.name}-public-${count.index}" }) } variables.tf variable "cidr_block" { type = string } variable "public_subnets" { type = list ( string ) }

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles