-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rds.tf
65 lines (57 loc) · 1.82 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
#------------------------------------------#
# RDS Database Configuration
#------------------------------------------#
resource "aws_rds_cluster_instance" "rancher_ha" {
count = 2
identifier = "${var.name_prefix}-db-${count.index}"
cluster_identifier = "${aws_rds_cluster.rancher_ha.id}"
instance_class = "db.t2.medium"
publicly_accessible = false
db_subnet_group_name = "${aws_db_subnet_group.rancher_ha.name}"
}
resource "aws_rds_cluster" "rancher_ha" {
cluster_identifier = "${var.name_prefix}-db"
database_name = "${var.db_name}"
master_username = "${var.db_user}"
master_password = "${var.db_pass}"
db_subnet_group_name = "${aws_db_subnet_group.rancher_ha.name}"
vpc_security_group_ids = ["${aws_security_group.rancher_ha_rds.id}"]
storage_encrypted = true
}
resource "aws_db_subnet_group" "rancher_ha" {
name = "${var.name_prefix}-db-subnet-group"
description = "Rancher HA Subnet Group"
subnet_ids = ["${aws_subnet.rancher_ha.*.id}"]
tags {
Name = "${var.name_prefix}-db-subnet-group"
}
}
resource "aws_security_group" "rancher_ha_rds" {
name = "${var.name_prefix}-rds-secgroup"
description = "Rancher RDS Ports"
vpc_id = "${aws_vpc.rancher_ha.id}"
ingress {
from_port = 0
to_port = 65535
protocol = "tcp"
self = true
}
ingress {
from_port = 0
to_port = 65535
protocol = "udp"
self = true
}
ingress {
from_port = 3306
to_port = 3306
protocol = "tcp"
cidr_blocks = ["${var.vpc_cidr}"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}