-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrds.tf
73 lines (64 loc) · 2.16 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
62
63
64
65
66
67
68
69
70
71
72
73
data "aws_vpc" "vpc" {
id = module.vpc.vpc_id
}
resource "aws_security_group" "rds_sg" {
name = "rds-sg"
vpc_id = module.vpc.vpc_id
ingress {
from_port = 5432
to_port = 5432
protocol = "tcp"
cidr_blocks = [module.vpc.vpc_cidr_block]
}
ingress {
from_port = 5432
to_port = 5432
protocol = "udp"
cidr_blocks = [module.vpc.vpc_cidr_block]
}
}
# resource "aws_security_group" "rds_pod_sg" {
# name = "rds-pod-sg"
# vpc_id = module.vpc.vpc_id
# }
# resource "aws_security_group_rule" "pod_to_workers" {
# for_each = toset(["udp", "tcp"])
# type = "ingress"
# from_port = 53
# to_port = 53
# protocol = each.key
# source_security_group_id = aws_security_group.rds_pod_sg.id
# security_group_id = module.eks.worker_security_group_id
# }
# resource "aws_security_group_rule" "pod_to_rds" {
# type = "ingress"
# from_port = 5432
# to_port = 5432
# protocol = "tcp"
# source_security_group_id = aws_security_group.rds_pod_sg.id
# security_group_id = aws_security_group.rds_sg.id
# }
module "db" {
source = "terraform-aws-modules/rds/aws"
version = "~> 2.0"
name = "engineerx"
identifier = "engineerx"
instance_class = "db.t3.micro"
engine = "postgres"
family = "postgres11"
subnet_ids = module.vpc.public_subnets
vpc_security_group_ids = [aws_security_group.rds_sg.id]
username = "engineerx"
password = var.postgres_password
publicly_accessible = true
allocated_storage = 10
port = "5432"
backup_retention_period = 0
maintenance_window = "Mon:00:00-Mon:03:00"
backup_window = "03:00-06:00"
engine_version = "11.10"
}
# resource "aws_iam_role_policy_attachment" "cni_policy_attachment" {
# role = module.eks.worker_iam_role_name
# policy_arn = "arn:aws:iam::aws:policy/AmazonEKSVPCResourceController"
# }