Skip to content

Commit a3c7f14

Browse files
committed
Refactor
1 parent c862793 commit a3c7f14

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

terraform/data_replication/network.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,23 @@ resource "aws_subnet" "public_subnet" {
3939
}
4040

4141
resource "aws_internet_gateway" "internet_gateway" {
42-
count = min(length(var.allowed_egress_cidr_blocks), 1)
42+
count = local.shared_egress_infrastructure_count
4343
vpc_id = aws_vpc.vpc.id
4444
tags = {
4545
Name = "data-replication-igw-${var.environment}"
4646
}
4747
}
4848

4949
resource "aws_eip" "nat_ip" {
50+
count = local.shared_egress_infrastructure_count
5051
domain = "vpc"
5152
depends_on = [aws_internet_gateway.internet_gateway]
5253
}
5354

5455
resource "aws_nat_gateway" "nat_gateway" {
55-
count = min(length(var.allowed_egress_cidr_blocks), 1)
56+
count = local.shared_egress_infrastructure_count
5657
subnet_id = aws_subnet.public_subnet.id
57-
allocation_id = aws_eip.nat_ip.id
58+
allocation_id = aws_eip.nat_ip[0].id
5859
connectivity_type = "public"
5960
depends_on = [aws_internet_gateway.internet_gateway]
6061
tags = {

terraform/data_replication/variables.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ variable "rails_master_key_path" {
8282
}
8383

8484
locals {
85-
name_prefix = "mavis-${var.environment}-data-replication"
86-
subnet_list = [aws_subnet.subnet_a.id, aws_subnet.subnet_b.id]
85+
name_prefix = "mavis-${var.environment}-data-replication"
86+
subnet_list = [aws_subnet.subnet_a.id, aws_subnet.subnet_b.id]
87+
shared_egress_infrastructure_count = min(length(var.allowed_egress_cidr_blocks), 1)
88+
8789
task_envs = [
8890
{
8991
name = "DB_HOST"

0 commit comments

Comments
 (0)