-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.tf
78 lines (64 loc) · 2.25 KB
/
main.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
###################################
# Get ID of created RDSv3 Instance
###################################
locals {
rds_instance_id = var.create_rds ? concat(opentelekomcloud_rds_instance_v3.this.*.id, [""])[0] : var.rds_instance_id
}
########################
# RDSv3 Parameter Group
########################
resource "opentelekomcloud_rds_parametergroup_v3" "this" {
count = length(var.parametergroup_values) > 0 ? 1 : 0
name = "${var.prefix}_parametergroup"
description = var.parametergroup_description
values = var.parametergroup_values
datastore {
type = lower(var.db_type)
version = var.db_version
}
}
#################
# RDSv3 Instance
#################
resource "opentelekomcloud_rds_instance_v3" "this" {
count = var.create_rds ? 1 : 0
availability_zone = var.availability_zone
db {
password = var.db_password
type = var.db_type
version = var.db_version
port = var.db_port
}
name = "${var.prefix}_rds_instance"
security_group_id = var.secgroup_id
subnet_id = var.network_id
vpc_id = var.vpc_id
volume {
type = var.volume_type
size = var.volume_size
disk_encryption_id = var.volume_encryption_id
}
flavor = var.db_flavor
ha_replication_mode = var.ha_replication_mode
backup_strategy {
start_time = var.backup_start_time
keep_days = var.backup_keep_days
}
tags = var.tags
param_group_id = length(var.parametergroup_values) > 0 ? concat(opentelekomcloud_rds_parametergroup_v3.this.*.id)[0] : null
}
##############################
# RDSv3 Read Replica Instance
##############################
resource "opentelekomcloud_rds_read_replica_v3" "this" {
count = length(var.read_replica_config)
name = var.read_replica_config[count.index]["name"]
flavor_ref = var.read_replica_config[count.index]["flavor"]
availability_zone = var.read_replica_config[count.index]["availability_zone"]
replica_of_id = local.rds_instance_id
public_ips = var.read_replica_config[count.index]["public_ips"]
volume {
type = var.read_replica_config[count.index]["volume_type"]
disk_encryption_id = var.read_replica_config[count.index]["volume_encryption_id"]
}
}