-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathmain.tf
76 lines (60 loc) · 1.86 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
provider "azurerm" {
features {
}
}
resource "azurerm_resource_group" "rg1" {
name = var.rgname
location = var.location
}
module "ServicePrincipal" {
source = "./modules/ServicePrincipal"
service_principal_name = var.service_principal_name
depends_on = [
azurerm_resource_group.rg1
]
}
resource "azurerm_role_assignment" "rolespn" {
scope = "/subscriptions/5f5470df-f806-47ee-8f78-6520f817df59"
role_definition_name = "Contributor"
principal_id = module.ServicePrincipal.service_principal_object_id
depends_on = [
module.ServicePrincipal
]
}
module "keyvault" {
source = "./modules/keyvault"
keyvault_name = var.keyvault_name
location = var.location
resource_group_name = var.rgname
service_principal_name = var.service_principal_name
service_principal_object_id = module.ServicePrincipal.service_principal_object_id
service_principal_tenant_id = module.ServicePrincipal.service_principal_tenant_id
depends_on = [
module.ServicePrincipal
]
}
resource "azurerm_key_vault_secret" "example" {
name = module.ServicePrincipal.client_id
value = module.ServicePrincipal.client_secret
key_vault_id = module.keyvault.keyvault_id
depends_on = [
module.keyvault
]
}
#create Azure Kubernetes Service
module "aks" {
source = "./modules/aks/"
service_principal_name = var.service_principal_name
client_id = module.ServicePrincipal.client_id
client_secret = module.ServicePrincipal.client_secret
location = var.location
resource_group_name = var.rgname
depends_on = [
module.ServicePrincipal
]
}
resource "local_file" "kubeconfig" {
depends_on = [module.aks]
filename = "./kubeconfig"
content = module.aks.config
}