forked from appleboy/drone-terraform-in-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrds.tf
30 lines (27 loc) · 1.04 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
resource "aws_db_subnet_group" "db" {
name = "main"
subnet_ids = ["${aws_subnet.drone_a.id}", "${aws_subnet.drone_c.id}"]
tags {
Name = "My DB subnet group"
}
}
resource "random_string" "db_password" {
special = false
length = 20
}
resource "aws_db_instance" "drone" {
depends_on = ["aws_security_group.db"]
identifier = "${var.identifier}"
allocated_storage = "${var.storage}"
engine = "${var.engine}"
engine_version = "${lookup(var.engine_version, var.engine)}"
instance_class = "${var.instance_class}"
name = "${var.db_name}"
username = "${var.username}"
password = "${random_string.db_password.result}"
vpc_security_group_ids = ["${aws_security_group.db.id}"]
db_subnet_group_name = "${aws_db_subnet_group.db.id}"
skip_final_snapshot = true
final_snapshot_identifier = "drone-${md5(timestamp())}"
identifier = "drone-${var.environment}"
}