-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdata.tf
71 lines (54 loc) · 2.33 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
data "azurerm_client_config" "current" {}
############################################################
# kv_db_create (used for customer managed key)
# => ``null` then no key vault created or attached (default)
# => ``true` then enable creation of new key vault
# => ``false` then point to existing key vault
############################################################
data "azurerm_key_vault" "db" {
count = (var.kv_db_create == false) ? 1 : 0
name = var.kv_db_name
resource_group_name = var.kv_db_rg
}
######################################################################
# kv_pointer_enable (pointers in key vault for secrets state)
# => ``true` then state from key vault is used for creation
# => ``false` then state from terraform is used for creation (default)
######################################################################
data "azurerm_key_vault" "pointer" {
count = var.kv_pointer_enable ? 1 : 0
name = var.kv_pointer_name
resource_group_name = var.kv_pointer_rg
}
data "azurerm_key_vault_secret" "pointer_sqladmin_password" {
count = var.kv_pointer_enable ? 1 : 0
name = var.kv_pointer_sqladmin_password
key_vault_id = data.azurerm_key_vault.pointer[count.index].id
}
data "azurerm_key_vault_secret" "pointer_logging_name" {
count = var.kv_pointer_enable ? 1 : 0
name = var.kv_pointer_logging_name
key_vault_id = data.azurerm_key_vault.pointer[count.index].id
}
data "azurerm_storage_account" "pointer_logging_name" {
count = var.kv_pointer_enable ? 1 : 0
name = data.azurerm_key_vault_secret.pointer_logging_name[count.index].value
resource_group_name = var.kv_pointer_logging_rg
}
#########################################################
# vnet_create (used for storage account network rule)
# => ``null` then no vnet created or attached (default)
# => ``true` then enable creation of new vnet
# => ``false` then point to existing vnet
#########################################################
data "azurerm_virtual_network" "pgsql" {
count = (var.vnet_create == false) ? 1 : 0
name = var.vnet_name
resource_group_name = var.vnet_rg
}
data "azurerm_subnet" "pgsql" {
count = (var.vnet_create == false) ? 1 : 0
name = var.subnet_name
virtual_network_name = var.vnet_name
resource_group_name = var.vnet_rg
}