-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrds.tf
61 lines (52 loc) · 1.35 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
54
55
56
57
58
59
60
61
resource "aws_db_subnet_group" "main" {
name = "${local.prefix}-main"
subnet_ids = [
aws_subnet.private_a.id,
aws_subnet.private_b.id,
]
tags = merge(
local.common_tags,
tomap(
{
"Name" = "${local.prefix}-main"
})
)
}
resource "aws_security_group" "rds" {
description = "Allow access to the RDS database instance"
name = "${local.prefix}-rds-inbound-access"
vpc_id = aws_vpc.main.id
ingress {
protocol = "tcp"
from_port = 5432
to_port = 5432
security_groups = [
aws_security_group.bastion.id,
aws_security_group.ecs_service.id
]
}
tags = local.common_tags
}
resource "aws_db_instance" "main" {
identifier = "${local.prefix}-db"
db_name = "demoecs"
allocated_storage = 20
storage_type = "gp2"
engine = "postgres"
engine_version = "11.14"
instance_class = "db.t2.micro"
db_subnet_group_name = aws_db_subnet_group.main.name
password = var.db_password
username = var.db_username
backup_retention_period = 0
multi_az = false
skip_final_snapshot = true
vpc_security_group_ids = [aws_security_group.rds.id]
tags = merge(
local.common_tags,
tomap(
{
"Name" = "${local.prefix}-main"
})
)
}