generated from oracle-devrel/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 20
/
datasources.tf
134 lines (103 loc) · 4.27 KB
/
datasources.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
## Copyright (c) 2022 Oracle and/or its affiliates.
## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl
locals {
get_ad = "${lookup(data.oci_identity_availability_domains.ads.availability_domains[var.availability_domain_number - 1], "name")}"
standby1_ad = var.postgresql_hotstandby1_ad == "" ? null : "${lookup(data.oci_identity_availability_domains.ads.availability_domains[var.postgresql_hotstandby1_ad - 1], "name")}"
standby2_ad = var.postgresql_hotstandby2_ad == "" ? null : "${lookup(data.oci_identity_availability_domains.ads.availability_domains[var.postgresql_hotstandby2_ad - 1], "name")}"
}
data "oci_identity_availability_domains" "ads" {
#Required
compartment_id = var.compartment_ocid
}
data "oci_core_vnic_attachments" "postgresql_master_vnics" {
compartment_id = var.compartment_ocid
availability_domain = local.get_ad
instance_id = oci_core_instance.postgresql_master.id
}
data "oci_core_vnic_attachments" "postgresql_master_primaryvnic_attach" {
availability_domain = local.get_ad
compartment_id = var.compartment_ocid
instance_id = oci_core_instance.postgresql_master.id
}
data "oci_core_vnic" "postgresql_master_primaryvnic" {
vnic_id = data.oci_core_vnic_attachments.postgresql_master_primaryvnic_attach.vnic_attachments.0.vnic_id
}
data "oci_core_vnic_attachments" "postgresql_hotstandby1_primaryvnic_attach" {
count = var.postgresql_deploy_hotstandby1 ? 1 : 0
availability_domain = local.standby1_ad
compartment_id = var.compartment_ocid
instance_id = oci_core_instance.postgresql_hotstandby1[count.index].id
}
data "oci_core_vnic" "postgresql_hotstandby1_primaryvnic" {
count = var.postgresql_deploy_hotstandby1 ? 1 : 0
vnic_id = data.oci_core_vnic_attachments.postgresql_hotstandby1_primaryvnic_attach[count.index].vnic_attachments.0.vnic_id
}
data "oci_core_vnic_attachments" "postgresql_hotstandby2_primaryvnic_attach" {
count = var.postgresql_deploy_hotstandby2 ? 1 : 0
availability_domain = local.standby2_ad
compartment_id = var.compartment_ocid
instance_id = oci_core_instance.postgresql_hotstandby2[count.index].id
}
data "oci_core_vnic" "postgresql_hotstandby2_primaryvnic" {
count = var.postgresql_deploy_hotstandby2 ? 1 : 0
vnic_id = data.oci_core_vnic_attachments.postgresql_hotstandby2_primaryvnic_attach[count.index].vnic_attachments.0.vnic_id
}
# Get the latest Oracle Linux image
data "oci_core_images" "InstanceImageOCID_postgresql_instance_shape" {
compartment_id = var.compartment_ocid
operating_system = var.instance_os
operating_system_version = var.linux_os_version
shape = var.postgresql_instance_shape
filter {
name = "display_name"
values = ["^.*Oracle[^G]*$"]
regex = true
}
}
# Get the latest Oracle Linux image
data "oci_core_images" "InstanceImageOCID_postgresql_hotstandby1_shape" {
compartment_id = var.compartment_ocid
operating_system = var.instance_os
operating_system_version = var.linux_os_version
shape = var.postgresql_hotstandby1_shape
filter {
name = "display_name"
values = ["^.*Oracle[^G]*$"]
regex = true
}
}
# Get the latest Oracle Linux image
data "oci_core_images" "InstanceImageOCID_postgresql_hotstandby2_shape" {
compartment_id = var.compartment_ocid
operating_system = var.instance_os
operating_system_version = var.linux_os_version
shape = var.postgresql_hotstandby2_shape
filter {
name = "display_name"
values = ["^.*Oracle[^G]*$"]
regex = true
}
}
data "oci_identity_region_subscriptions" "home_region_subscriptions" {
tenancy_id = var.tenancy_ocid
filter {
name = "is_home_region"
values = [true]
}
}
data "oci_core_volume_backup_policies" "boot_volume_backup_policy" {
# count = var.add_iscsi_volume ? 1 : 0
filter {
name = "display_name"
values = [var.boot_volume_backup_policy_level]
regex = true
}
}
data "oci_core_volume_backup_policies" "block_volume_backup_policy" {
count = var.add_iscsi_volume ? 1 : 0
filter {
name = "display_name"
values = [var.block_volume_backup_policy_level]
regex = true
}
}