71be2abd2e
- Terraform modules: VPC, EC2, RDS, S3, CloudFront, Route53, Lambda, IAM, Security Groups - Ansible playbooks for server configuration - Scripts: create-test-environment.sh, destroy-test-environment.sh, validate-environment.sh - Documentation: README, QUICKSTART, AGENTS - Jenkins pipeline for automated deployment - Jenkins pipeline for environment destruction
51 lines
1.6 KiB
Terraform
51 lines
1.6 KiB
Terraform
variable "vpc_cidr" {}
|
|
variable "environment" {}
|
|
variable "availability_zones" { type = list(string) }
|
|
|
|
resource "aws_vpc" "main" {
|
|
cidr_block = var.vpc_cidr
|
|
enable_dns_hostnames = true
|
|
enable_dns_support = true
|
|
tags = { Name = "sacc4-vpc-${var.environment}" }
|
|
}
|
|
|
|
resource "aws_internet_gateway" "main" {
|
|
vpc_id = aws_vpc.main.id
|
|
tags = { Name = "sacc4-igw-${var.environment}" }
|
|
}
|
|
|
|
resource "aws_subnet" "public" {
|
|
count = 2
|
|
vpc_id = aws_vpc.main.id
|
|
cidr_block = cidrsubnet(var.vpc_cidr, 8, count.index + 1)
|
|
availability_zone = var.availability_zones[count.index]
|
|
map_public_ip_on_launch = true
|
|
tags = { Name = "sacc4-public-${count.index + 1}-${var.environment}" }
|
|
}
|
|
|
|
resource "aws_subnet" "private" {
|
|
count = 2
|
|
vpc_id = aws_vpc.main.id
|
|
cidr_block = cidrsubnet(var.vpc_cidr, 8, count.index + 11)
|
|
availability_zone = var.availability_zones[count.index]
|
|
tags = { Name = "sacc4-private-${count.index + 1}-${var.environment}" }
|
|
}
|
|
|
|
resource "aws_route_table" "public" {
|
|
vpc_id = aws_vpc.main.id
|
|
route {
|
|
cidr_block = "0.0.0.0/0"
|
|
gateway_id = aws_internet_gateway.main.id
|
|
}
|
|
tags = { Name = "sacc4-public-rt-${var.environment}" }
|
|
}
|
|
|
|
resource "aws_route_table_association" "public" {
|
|
count = 2
|
|
subnet_id = aws_subnet.public[count.index].id
|
|
route_table_id = aws_route_table.public.id
|
|
}
|
|
|
|
output "vpc_id" { value = aws_vpc.main.id }
|
|
output "public_subnet_ids" { value = aws_subnet.public[*].id }
|
|
output "private_subnet_ids" { value = aws_subnet.private[*].id } |