-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrds.tf
executable file
·114 lines (85 loc) · 2.38 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
## RDS Database + subnet group + security group
# RDS security group
resource "aws_security_group" "rancher_db" {
name = "${var.env_name}-rancher-db"
vpc_id = "${aws_vpc.rancher.id}"
description = "Rancher database"
ingress {
from_port = 3306
to_port = 3306
protocol = "tcp"
security_groups = ["${aws_security_group.rancher_srv.id}"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags {
Name = "${var.env_name}-rancher-db"
}
}
# RDS subnet group
resource "aws_db_subnet_group" "rancher" {
name = "${var.env_name}-rancher"
subnet_ids = ["${aws_subnet.priv_a.id}", "${aws_subnet.priv_b.id}"]
description = "${var.env_name}-rancher"
tags {
Name = "${var.env_name}-rancher"
}
}
# RDS instance
resource "aws_db_instance" "rancher" {
engine = "mysql"
storage_type = "gp2"
instance_class = "${var.db_class}"
name = "${var.db_name}"
username = "${var.db_username}"
password = "${var.db_password}"
allocated_storage = "${var.db_storage}"
backup_retention_period = "${var.db_backup_retention}"
multi_az = "${var.db_multi_az}"
identifier = "${var.env_name}-rancher"
db_subnet_group_name = "${aws_db_subnet_group.rancher.name}"
vpc_security_group_ids = ["${aws_security_group.rancher_db.id}"]
final_snapshot_identifier = "${var.env_name}-snapshot"
skip_final_snapshot = "${var.db_final_snapshot}"
#parameter_group_name = "rancher-pg"
}
#resource "aws_db_parameter_group" "rancher" {
# name = "rancher-pg"
# family = "mysql5.6"
# parameter {
# name = "character_set_client"
# value = "utf8"
# }
# parameter {
# name = "character_set_connection"
# value = "utf8"
# }
# parameter {
# name = "character_set_database"
# value = "utf8"
# }
# parameter {
# name = "character_set_filesystem"
# value = "utf8"
# }
# parameter {
# name = "character_set_results"
# value = "utf8"
# }
# parameter {
# name = "character_set_server"
# value = "utf8"
# }
# parameter {
# name = "collation_connection"
# value = "utf8_general_ci"
# }
# parameter {
# name = "collation_server"
# value = "utf8_general_ci"
# }
#}