@@ -2,6 +2,9 @@ resource "aws_vpc" "vpc" {
22 cidr_block = " 10.0.0.0/16"
33 enable_dns_hostnames = true
44 enable_dns_support = true
5+ tags = {
6+ Name = " data-replication-vpc-${ var . environment } "
7+ }
58}
69
710resource "aws_subnet" "subnet_a" {
@@ -18,6 +21,9 @@ resource "aws_subnet" "subnet_b" {
1821
1922resource "aws_route_table" "private" {
2023 vpc_id = aws_vpc. vpc . id
24+ tags = {
25+ Name = " data-replication-private-rt-${ var . environment } "
26+ }
2127}
2228
2329resource "aws_route_table_association" "private" {
@@ -26,6 +32,63 @@ resource "aws_route_table_association" "private" {
2632 subnet_id = local. subnet_list [count . index ]
2733}
2834
35+ resource "aws_subnet" "public_subnet" {
36+ vpc_id = aws_vpc. vpc . id
37+ cidr_block = " 10.0.3.0/24"
38+ availability_zone = " ${ var . region } a"
39+ }
40+
41+ resource "aws_internet_gateway" "internet_gateway" {
42+ count = local. shared_egress_infrastructure_count
43+ vpc_id = aws_vpc. vpc . id
44+ tags = {
45+ Name = " data-replication-igw-${ var . environment } "
46+ }
47+ }
48+
49+ resource "aws_eip" "nat_ip" {
50+ count = local. shared_egress_infrastructure_count
51+ domain = " vpc"
52+ depends_on = [aws_internet_gateway . internet_gateway ]
53+ }
54+
55+ resource "aws_nat_gateway" "nat_gateway" {
56+ count = local. shared_egress_infrastructure_count
57+ subnet_id = aws_subnet. public_subnet . id
58+ allocation_id = aws_eip. nat_ip [0 ]. id
59+ connectivity_type = " public"
60+ depends_on = [aws_internet_gateway . internet_gateway ]
61+ tags = {
62+ Name = " data-replication-nat-gateway-${ var . environment } "
63+ }
64+ }
65+
66+ resource "aws_route" "private_to_public" {
67+ count = length (var. allowed_egress_cidr_blocks )
68+ route_table_id = aws_route_table. private . id
69+ destination_cidr_block = var. allowed_egress_cidr_blocks [count . index ]
70+ nat_gateway_id = aws_nat_gateway. nat_gateway [0 ]. id
71+ }
72+
73+ resource "aws_route" "public_to_igw" {
74+ count = length (var. allowed_egress_cidr_blocks )
75+ route_table_id = aws_route_table. public . id
76+ destination_cidr_block = var. allowed_egress_cidr_blocks [count . index ]
77+ gateway_id = aws_internet_gateway. internet_gateway [0 ]. id
78+ }
79+
80+ resource "aws_route_table" "public" {
81+ vpc_id = aws_vpc. vpc . id
82+ tags = {
83+ Name = " data-replication-public-rt-${ var . environment } "
84+ }
85+ }
86+
87+ resource "aws_route_table_association" "public" {
88+ route_table_id = aws_route_table. public . id
89+ subnet_id = aws_subnet. public_subnet . id
90+ }
91+
2992locals {
3093 vpc_endpoints = tomap (
3194 {
0 commit comments