-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrds.tf
51 lines (45 loc) · 1.99 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
resource "aws_rds_cluster" "cluster_rds" {
for_each = { for b in var.cluster_rds : try(b.cluster_identifier, "${b.cluster_identifier}") => b }
cluster_identifier = try(each.value.cluster_identifier)
availability_zones = try(each.value.availability_zones)
database_name = try(each.value.database_name)
deletion_protection = true
engine = try(each.value.engine)
engine_version = try(each.value.engine_version)
master_username = try(each.value.master_username)
master_password = try(each.value.master_password)
backup_retention_period = try(each.value.backup_retention_period)
preferred_backup_window = try(each.value.preferred_backup_window)
final_snapshot_identifier = try(each.value.password, "true")
skip_final_snapshot = try(each.value.skip_final_snapshot, "true")
vpc_security_group_ids = try(each.value.vpc_security_group_ids)
db_subnet_group_name = try(each.value.db_subnet_group_name)
# lifecycle {
# prevent_destroy = true
# }
}
resource "aws_db_subnet_group" "db_subnet_group" {
for_each = { for b in var.db_subnet_group : try(b.name, "${b.name}") => b }
name = try(each.value.name)
subnet_ids = try(each.value.subnet_ids)
# lifecycle {
# prevent_destroy = true
# }
}
resource "aws_rds_cluster_instance" "db_rds" {
for_each = { for b in var.db_rds : try(b.identifier, "${b.identifier}") => b }
engine = try(each.value.engine)
cluster_identifier = try(each.value.cluster_identifier)
identifier = try(each.value.identifier)
availability_zone = try(each.value.availability_zone)
publicly_accessible = try(each.value.publicly_accessible)
engine_version = try(each.value.engine_version)
instance_class = try(each.value.instance_class)
tags = try(each.value.tags)
depends_on = [
aws_rds_cluster.cluster_rds
]
# lifecycle {
# prevent_destroy = true
# }
}