-
Notifications
You must be signed in to change notification settings - Fork 2
/
rds.tf
53 lines (48 loc) · 1.43 KB
/
rds.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# RDS Security Group (traffic ECS -> RDS)
resource "aws_security_group" "rds" {
name = "rds-security-group"
description = "Allows inbound access from ECS only"
vpc_id = aws_vpc.main.id
ingress {
protocol = "tcp"
from_port = "5432"
to_port = "5432"
security_groups = [aws_security_group.ecs_tasks.id]
}
ingress {
protocol = "tcp"
from_port = "5432"
to_port = "5432"
security_groups = ["sg-011063d5486cff791"]
}
egress {
protocol = "-1"
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_db_subnet_group" "production" {
name = "main"
subnet_ids = aws_subnet.private.*.id
}
resource "aws_db_instance" "production" {
identifier = "production"
name = var.db_name
username = var.db_user
password = var.db_password
port = var.db_port
engine = "postgres"
engine_version = "12.3"
instance_class = var.rds_instance_class
allocated_storage = "20"
storage_encrypted = false
vpc_security_group_ids = [aws_security_group.rds.id]
db_subnet_group_name = aws_db_subnet_group.production.name
multi_az = false
storage_type = "gp2"
#true
publicly_accessible = false
backup_retention_period = 7
skip_final_snapshot = true
}