-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.tf
52 lines (39 loc) · 1.34 KB
/
db.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
resource "aws_db_instance" "wordpress_db" {
allocated_storage = "${var.webapp_db_size}"
engine = "${var.webapp_db_engine}"
engine_version = "${var.webapp_db_engine_version}"
instance_class = "${var.webapp_db_instance_class}"
storage_type = "gp2"
name = "${var.webapp_db_name}"
username = "${var.webapp_db_user}"
password = "${var.webapp_db_password}"
publicly_accessible = false
db_subnet_group_name = "${aws_db_subnet_group.db_subnetgroup.id}"
port = 3306
vpc_security_group_ids = ["${aws_security_group.sg_dokerserver_db.id}"]
availability_zone = "${data.aws_availability_zones.available.names[0]}"
skip_final_snapshot = true
}
resource "aws_security_group" "sg_dokerserver_db" {
name = "SG_WordpressDb"
vpc_id = "${aws_vpc.vpc_hml.id}"
ingress {
from_port = 3306
to_port = 3306
protocol = "tcp"
cidr_blocks = ["${aws_vpc.vpc_hml.cidr_block}"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_db_subnet_group" "db_subnetgroup" {
name = "db-subnetgp"
subnet_ids = ["${aws_subnet.subnet_hmla.id}", "${aws_subnet.subnet_hmlb.id}"]
tags = {
Name = "My DB subnet group"
}
}