Actualiser vpc-production.tf
Some checks failed
Terraform Apply / Terraform Apply (push) Failing after 22s
Some checks failed
Terraform Apply / Terraform Apply (push) Failing after 22s
This commit is contained in:
@@ -13,18 +13,18 @@ variable "vpc_cidr" {
|
|||||||
|
|
||||||
variable "public_subnets_cidr" {
|
variable "public_subnets_cidr" {
|
||||||
type = list(any)
|
type = list(any)
|
||||||
default = ["10.0.0.0/20", "10.0.128.0/20"]
|
default = ["10.0.0.0/20", "10.0.32.0/20", "10.0.64.0/20"]
|
||||||
description = "CIDR block for Public Subnet"
|
description = "CIDR block for Public Subnet"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "private_subnets_cidr" {
|
variable "private_subnets_cidr" {
|
||||||
type = list(any)
|
type = list(any)
|
||||||
default = ["10.0.16.0/20", "10.0.144.0/20"]
|
default = ["10.0.16.0/20", "10.0.48.0/20", "10.0.80.0/20"]
|
||||||
description = "CIDR block for Private Subnet"
|
description = "CIDR block for Private Subnet"
|
||||||
}
|
}
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
availability_zones = ["${var.aws_region}a", "${var.aws_region}b"]
|
availability_zones = ["${var.aws_region}a", "${var.aws_region}b", "${var.aws_region}c"]
|
||||||
}
|
}
|
||||||
|
|
||||||
# VPC
|
# VPC
|
||||||
@@ -32,7 +32,7 @@ resource "aws_vpc" "default" {
|
|||||||
cidr_block = "10.0.0.0/16"
|
cidr_block = "10.0.0.0/16"
|
||||||
enable_dns_hostnames = true
|
enable_dns_hostnames = true
|
||||||
enable_dns_support = true
|
enable_dns_support = true
|
||||||
instance_tenancy = "default"
|
instance_tenancy = "default"
|
||||||
|
|
||||||
tags = {
|
tags = {
|
||||||
Name = "${var.environment}-vpc"
|
Name = "${var.environment}-vpc"
|
||||||
@@ -71,37 +71,28 @@ resource "aws_subnet" "private_subnet" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#Internet gateway
|
#Internet gateway
|
||||||
resource "aws_internet_gateway" "igw" {
|
resource "aws_internet_gateway" "default-internet-gw" {
|
||||||
vpc_id = aws_vpc.default.id
|
vpc_id = aws_vpc.default.id
|
||||||
|
|
||||||
tags = {
|
tags = {
|
||||||
"Name" = "${var.environment}-igw"
|
"Name" = "${var.environment}-default-internet-gw"
|
||||||
"Environment" = var.environment
|
"Environment" = var.environment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Elastic-IP (eip) for NAT
|
# Elastic-IP (eip) for NAT
|
||||||
#resource "aws_eip" "nat_eip" {
|
resource "aws_eip" "nat_eip" {
|
||||||
# vpc = true
|
vpc = true
|
||||||
# depends_on = [aws_internet_gateway.ig]
|
depends_on = [aws_internet_gateway.default-internet-gw]
|
||||||
#}
|
}
|
||||||
|
|
||||||
# NAT Gateway
|
# NAT Gateway
|
||||||
#resource "aws_nat_gateway" "nat" {
|
resource "aws_nat_gateway" "nat-gw" {
|
||||||
# allocation_id = aws_eip.nat_eip.id
|
allocation_id = aws_eip.nat_eip.id
|
||||||
# subnet_id = element(aws_subnet.public_subnet.*.id, 0)
|
subnet_id = element(aws_subnet.public_subnet.*.id, 0)
|
||||||
# tags = {
|
|
||||||
# Name = "nat-gateway-${var.environment}"
|
|
||||||
# Environment = "${var.environment}"
|
|
||||||
# }
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Routing tables to route traffic for Private Subnet
|
|
||||||
resource "aws_route_table" "private" {
|
|
||||||
vpc_id = aws_vpc.default.id
|
|
||||||
|
|
||||||
tags = {
|
tags = {
|
||||||
Name = "${var.environment}-private-route-table"
|
Name = "nat-gateway-${var.environment}"
|
||||||
Environment = "${var.environment}"
|
Environment = "${var.environment}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,21 +107,31 @@ resource "aws_route_table" "public" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Routing tables to route traffic for Private Subnet
|
||||||
|
resource "aws_route_table" "private" {
|
||||||
|
vpc_id = aws_vpc.default.id
|
||||||
|
|
||||||
|
tags = {
|
||||||
|
Name = "${var.environment}-private-route-table"
|
||||||
|
Environment = "${var.environment}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Route for Internet Gateway
|
# Route for Internet Gateway
|
||||||
resource "aws_route" "public_internet_gateway" {
|
resource "aws_route" "public_internet_gateway" {
|
||||||
route_table_id = aws_route_table.public.id
|
route_table_id = aws_route_table.public.id
|
||||||
|
|
||||||
destination_cidr_block = "0.0.0.0/0"
|
destination_cidr_block = "0.0.0.0/0"
|
||||||
gateway_id = aws_internet_gateway.igw.id
|
gateway_id = aws_internet_gateway.default-internet-gw.id
|
||||||
}
|
}
|
||||||
|
|
||||||
# Route for NAT Gateway
|
# Route for NAT Gateway
|
||||||
#resource "aws_route" "private_internet_gateway" {
|
resource "aws_route" "private_internet_gateway" {
|
||||||
# route_table_id = aws_route_table.private.id
|
route_table_id = aws_route_table.private.id
|
||||||
#
|
|
||||||
# destination_cidr_block = "0.0.0.0/0"
|
destination_cidr_block = "0.0.0.0/0"
|
||||||
# gateway_id = aws_nat_gateway.nat.id
|
gateway_id = aws_nat_gateway.nat-gw.id
|
||||||
#}
|
}
|
||||||
|
|
||||||
# Route table associations for both Public subnet
|
# Route table associations for both Public subnet
|
||||||
resource "aws_route_table_association" "public" {
|
resource "aws_route_table_association" "public" {
|
||||||
|
Reference in New Issue
Block a user