-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.tf
71 lines (59 loc) · 2.26 KB
/
data.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
# primary
data "ibm_is_vpc" "vpc_primary" {
provider = ibm.primary
name = var.VPC
}
data "ibm_is_instance" "db-vsi-primary" {
provider = ibm.primary
count = var.HANA_SERVER_TYPE == "virtual" ? 1 : 0
name = var.DB_HOSTNAME_PRIMARY
}
data "ibm_is_bare_metal_server" "db-bms-primary" {
provider = ibm.primary
count = var.HANA_SERVER_TYPE != "virtual" ? 1 : 0
name = var.DB_HOSTNAME_PRIMARY
}
data "ibm_is_subnet" "subnet_primary" {
provider = ibm.primary
name = var.BASTION_SUBNET
}
# secondary
data "ibm_is_vpc" "vpc_secondary" {
depends_on = [ module.sg-dr ]
name = var.VPC_DR
}
data "ibm_is_instance" "db-vsi" {
count = var.HANA_SERVER_TYPE == "virtual" ? 1 : 0
depends_on = [module.db-vsi]
name = var.DB_HOSTNAME_DR
}
data "ibm_is_bare_metal_server" "db-bms" {
count = var.HANA_SERVER_TYPE != "virtual" ? 1 : 0
depends_on = [module.db-bms]
name = var.DB_HOSTNAME_DR
}
data "ibm_is_subnet" "subnet_secondary" {
depends_on = [ module.vpc-subnet-dr ]
name = var.SUBNET_DR
}
data "ibm_is_security_group" sg-dr-1 {
depends_on = [ module.sg-dr ]
name = "sg-dr-${var.DB_HOSTNAME_DR}"
}
data "ibm_is_security_group" sg-dr-2 {
depends_on = [ module.sg-dr ]
name = "repo-net-sg-dr-${var.DB_HOSTNAME_DR}"
}
######
locals {
vpc_primary = data.ibm_is_vpc.vpc_primary.resource_crn
vpc_secondary = data.ibm_is_vpc.vpc_secondary.resource_crn
subnet_primary = data.ibm_is_subnet.subnet_primary.ipv4_cidr_block
subnet_secondary = data.ibm_is_subnet.subnet_secondary.ipv4_cidr_block
subnet_primary_id = data.ibm_is_subnet.subnet_primary.id
subnet_secondary_id = data.ibm_is_subnet.subnet_secondary.id
sg_dr_1 = data.ibm_is_security_group.sg-dr-1.id
sg_dr_2 = data.ibm_is_security_group.sg-dr-2.id
ip_dr = lower(trimspace(var.HANA_SERVER_TYPE)) == "virtual" ? data.ibm_is_instance.db-vsi[0].primary_network_interface[0].primary_ip[0].address : data.ibm_is_bare_metal_server.db-bms[0].primary_network_interface[0].primary_ip[0].address
ip_primary = lower(trimspace(var.HANA_SERVER_TYPE)) == "virtual" ? data.ibm_is_instance.db-vsi-primary[0].primary_network_interface[0].primary_ip[0].address : data.ibm_is_bare_metal_server.db-bms-primary[0].primary_network_interface[0].primary_ip[0].address
}