-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
94 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
resource "aws_cloudwatch_log_group" "ecs-app" { | ||
name = "/ecs/${var.project}/app/${var.environment}" | ||
name = "/ecs/${var.project}/app/${var.environment}" | ||
retention_in_days = 3 | ||
|
||
tags = { | ||
Project = var.project | ||
Project = var.project | ||
Environment = var.environment | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,77 @@ | ||
# Load balancer to receive all incoming traffic infront of the cluster | ||
resource "aws_security_group" "alb" { | ||
vpc_id = var.vpc_id | ||
name = "${var.project}-${var.environment}-alb" | ||
name = "${var.project}-${var.environment}-alb" | ||
tags = { | ||
Name = "${var.project}-${var.environment}-alb" | ||
Name = "${var.project}-${var.environment}-alb" | ||
Description = "Incoming internet traffic to Load Balancer" | ||
Project = var.project | ||
Project = var.project | ||
Environment = var.environment | ||
} | ||
|
||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = -1 | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = -1 | ||
cidr_blocks = ["0.0.0.0/0"] # TODO: Change this to internal IPs only | ||
} | ||
} | ||
|
||
resource "aws_security_group_rule" "lb-http" { | ||
type = "ingress" | ||
from_port = 80 | ||
to_port = 80 | ||
protocol = "tcp" | ||
type = "ingress" | ||
from_port = 80 | ||
to_port = 80 | ||
protocol = "tcp" | ||
security_group_id = aws_security_group.alb.id | ||
cidr_blocks = ["0.0.0.0/0"] | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
|
||
resource "aws_security_group_rule" "lb-https" { | ||
type = "ingress" | ||
from_port = 443 | ||
to_port = 443 | ||
protocol = "tcp" | ||
type = "ingress" | ||
from_port = 443 | ||
to_port = 443 | ||
protocol = "tcp" | ||
security_group_id = aws_security_group.alb.id | ||
cidr_blocks = ["0.0.0.0/0"] | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
|
||
|
||
|
||
# ECS cluster should only be able to receive traffic to container ports from the ALB | ||
resource "aws_security_group" "ecs" { | ||
vpc_id = var.vpc_id | ||
name = "${var.project}-${var.environment}-ecs" | ||
name = "${var.project}-${var.environment}-ecs" | ||
tags = { | ||
Name = "${var.project}-${var.environment}-ecs" | ||
Name = "${var.project}-${var.environment}-ecs" | ||
Description = "Internal ECS communication" | ||
Project = var.project | ||
Project = var.project | ||
Environment = var.environment | ||
} | ||
|
||
# This allows outbound traffic to systems like ECR, and internal rails application API calls | ||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = -1 | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = -1 | ||
cidr_blocks = ["0.0.0.0/0"] # TODO: Change this to only allow NAT/proxy traffic | ||
} | ||
} | ||
|
||
resource "aws_security_group_rule" "ecs-lb-3000" { | ||
type = "ingress" | ||
from_port = 3000 | ||
to_port = 3000 | ||
protocol = "tcp" | ||
security_group_id = aws_security_group.ecs.id | ||
type = "ingress" | ||
from_port = 3000 | ||
to_port = 3000 | ||
protocol = "tcp" | ||
security_group_id = aws_security_group.ecs.id | ||
source_security_group_id = aws_security_group.alb.id | ||
} | ||
|
||
resource "aws_security_group_rule" "ecs-ssh" { | ||
count = length(var.allowlisted_ssh_ips) > 0 ? 1 : 0 | ||
type = "ingress" | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
count = length(var.allowlisted_ssh_ips) > 0 ? 1 : 0 | ||
type = "ingress" | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
security_group_id = aws_security_group.ecs.id | ||
cidr_blocks = var.allowlisted_ssh_ips | ||
cidr_blocks = var.allowlisted_ssh_ips | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
resource "aws_kms_alias" "a" { | ||
name = "alias/${var.project}/${var.environment}/${var.alias}" | ||
name = "alias/${var.project}/${var.environment}/${var.alias}" | ||
target_key_id = aws_kms_key.key.key_id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
resource "aws_kms_key" "key" { | ||
description = var.description | ||
description = var.description | ||
deletion_window_in_days = var.deletion_window_in_days | ||
enable_key_rotation = true | ||
enable_key_rotation = true | ||
tags = { | ||
Project = var.project | ||
Project = var.project | ||
Environment = var.environment | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
resource "aws_db_instance" "main" { | ||
db_subnet_group_name = aws_db_subnet_group.main.name | ||
allocated_storage = var.allocated_storage | ||
storage_type = "gp2" | ||
engine = "postgres" | ||
engine_version = var.engine_version | ||
instance_class = var.instance_class | ||
identifier = "${var.project}-${var.environment}" | ||
skip_final_snapshot = true | ||
username = var.username | ||
password = var.password | ||
allocated_storage = var.allocated_storage | ||
storage_type = "gp2" | ||
engine = "postgres" | ||
engine_version = var.engine_version | ||
instance_class = var.instance_class | ||
identifier = "${var.project}-${var.environment}" | ||
skip_final_snapshot = true | ||
username = var.username | ||
password = var.password | ||
parameter_group_name = aws_db_parameter_group.postgres13.name | ||
apply_immediately = true | ||
multi_az = var.multi_az | ||
publicly_accessible = var.publicly_accessible | ||
deletion_protection = true | ||
apply_immediately = true | ||
multi_az = var.multi_az | ||
publicly_accessible = var.publicly_accessible | ||
deletion_protection = true | ||
vpc_security_group_ids = [ | ||
aws_security_group.db.id, | ||
] | ||
backup_retention_period = 7 | ||
storage_encrypted = true | ||
kms_key_id = var.kms_key_arn | ||
monitoring_interval = 5 | ||
monitoring_role_arn = aws_iam_role.rds-enhanced-monitoring.arn | ||
performance_insights_enabled = true | ||
backup_retention_period = 7 | ||
storage_encrypted = true | ||
kms_key_id = var.kms_key_arn | ||
monitoring_interval = 5 | ||
monitoring_role_arn = aws_iam_role.rds-enhanced-monitoring.arn | ||
performance_insights_enabled = true | ||
performance_insights_kms_key_id = var.kms_key_arn | ||
enabled_cloudwatch_logs_exports = [ | ||
"postgresql", | ||
"upgrade", | ||
] | ||
tags = { | ||
Name = "${var.project}-${var.environment}" | ||
Project = var.project | ||
Name = "${var.project}-${var.environment}" | ||
Project = var.project | ||
Environment = var.environment | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
resource "aws_db_subnet_group" "main" { | ||
name = "${var.project}-${var.environment}" | ||
name = "${var.project}-${var.environment}" | ||
subnet_ids = var.subnet_ids | ||
|
||
tags = { | ||
Name = "${var.project}-${var.environment}" | ||
Project = var.project | ||
Name = "${var.project}-${var.environment}" | ||
Project = var.project | ||
Environment = var.environment | ||
} | ||
} |