-
Notifications
You must be signed in to change notification settings - Fork 1
/
rds.tf
43 lines (39 loc) · 1.26 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
# Create managed mysql server in RDS
resource "aws_db_instance" "wordpress" {
allocated_storage = 10
storage_type = "gp2"
engine = "mysql"
engine_version = "5.7"
instance_class = "db.t2.micro"
username = "testRootUser"
password = "${var.rds_root_password}"
port = "3306"
name = "wp_db"
parameter_group_name = "default.mysql5.7"
maintenance_window = "Sun:00:00-Sun:01:00"
publicly_accessible = false
vpc_security_group_ids = ["${aws_security_group.wordpressRdsSg.id}"]
db_subnet_group_name = "${aws_db_subnet_group.wordpressDb.id}"
}
# Database subnet group
resource "aws_db_subnet_group" "wordpressDb" {
subnet_ids = ["${aws_subnet.private.*.id}"]
}
# Database security groups
resource "aws_security_group" "wordpressRdsSg" {
name = "wordpress-rds-sg"
description = "Only allow ingress from wordpress EC2 instances on port 3306"
vpc_id = "${aws_vpc.wordpressVpc.id}"
ingress {
from_port = 3306
to_port = 3306
protocol = "tcp"
cidr_blocks = "${var.private_subnet_cidr_list}"
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}