-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
151 lines (121 loc) · 3.16 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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">=3.20.0"
}
}
required_version = ">= 1.2.7"
}
# Configure the Microsoft Azure Provider
provider "azurerm" {
features {}
}
data "azuread_client_config" "current" {}
data "azurerm_client_config" "current" {}
resource "azurerm_resource_group" "default" {
name = "default"
location = "Australia East"
}
resource "azuread_application" "default" {
display_name = "default"
owners = [data.azuread_client_config.current.object_id]
}
# module "aks-1" {
# source = "./modules/aks"
# prefix = "demo-1"
# location = var.resource_location
# cluster_name = "demo-1"
# pool_size = 3
# vm_size = var.aks_vm_size
# }
# module "aks-2" {
# source = "./modules/aks"
# prefix = "demo-2"
# location = "australiaeast"
# cluster_name = "demo-2"
# pool_size = 2
# vm_size = var.aks_vm_size
# }
resource "random_string" "rndstr" {
keepers = {
rg = azurerm_resource_group.default.name
}
length = 7
lower = true
upper = false
special = false
numeric = true
}
# module "storage_container" {
# source = "./modules/storage"
# account = random_string.store_id.result
# name = "blob"
# rg = azurerm_resource_group.default
# }
# resource "azurerm_storage_blob" "test_blob" {
# name = "a-blob"
# storage_account_name = random_string.store_id.result
# storage_container_name = "blob"
# type = "Block"
# source = "./README.md"
# }
# module "storage_container_2" {
# source = "./modules/storage"
# account = random_string.store_id_2.result
# name = "blob"
# rg = azurerm_resource_group.default
# }
# module "mssql" {
# source = "./modules/mssql"
# rg = azurerm_resource_group.default
# server_name = "mssql-toy1"
# database_name = "toydb1"
# admin_name = "toyadmin"
# admin_password = "admin!Passw0rd"
# sku_name = "GP_Gen5_2"
# }
# module "appi" {
# source = "./modules/appinsights"
# rg = azurerm_resource_group.default
# name = "appi-1"
# location = var.resource_location
# }
# module "acr" {
# source = "./modules/acr"
# rg = azurerm_resource_group.default
# name = "acr${random_string.rndstr.result}"
# # location = null
# }
module "sp" {
source = "./modules/sp"
app = azuread_application.default
owners = [data.azuread_client_config.current.object_id]
}
# resource "azurerm_role_assignment" "acr-contributer" {
# scope = module.acr.id
# role_definition_name = "Contributor"
# principal_id = module.sp.id
# }
# module "mongodb" {
# source = "./modules/cosmos_mongo"
# rg = azurerm_resource_group.default
# account_name = random_string.rndstr.result
# }
module "key-vault" {
source = "./modules/key-vault"
rg = azurerm_resource_group.default
tenant_id = data.azurerm_client_config.current.tenant_id
owner_id = data.azuread_client_config.current.object_id
}
resource "azurerm_key_vault_access_policy" "kv-sp" {
key_vault_id = module.key-vault.vault-id
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = module.sp.id
key_permissions = [
"Get",
"List",
"Encrypt",
"Decrypt"
]
}