-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
71 lines (61 loc) · 2.02 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
# Generate random resource group name
resource "random_pet" "rg_name" {
prefix = var.resource_group_name_prefix
}
resource "azurerm_resource_group" "rg_cc_gh_demo" {
location = var.location
name = random_pet.rg_name.id
}
resource "azurerm_kubernetes_cluster" "aks_gh_demo" {
location = azurerm_resource_group.rg_cc_gh_demo.location
name = var.cluster_name
resource_group_name = azurerm_resource_group.rg_cc_gh_demo.name
dns_prefix = var.dns_prefix
tags = {
Environment = "Production"
}
default_node_pool {
name = "agentpool"
vm_size = "Standard_D2_v2"
node_count = var.agent_count
}
identity {
type = "SystemAssigned"
}
network_profile {
network_plugin = "kubenet"
load_balancer_sku = "standard"
}
}
# NOTE: the Name used for Redis needs to be globally unique
resource "azurerm_redis_cache" "redis_gh_demo" {
name = "gh-demo"
location = azurerm_resource_group.rg_cc_gh_demo.location
resource_group_name = azurerm_resource_group.rg_cc_gh_demo.name
capacity = 2
family = "C"
sku_name = "Standard"
enable_non_ssl_port = false
minimum_tls_version = "1.2"
redis_configuration {
}
}
# Create an ACR
resource "azurerm_container_registry" "acr_gh_demo" {
name = "acraksghdemo"
resource_group_name = azurerm_resource_group.rg_cc_gh_demo.name
location = azurerm_resource_group.rg_cc_gh_demo.location
sku = "Premium"
}
#Attach it to the cluster
resource "azurerm_role_assignment" "acr_aks_role_assignment_gh_demo" {
principal_id = azurerm_kubernetes_cluster.aks_gh_demo.kubelet_identity[0].object_id
role_definition_name = "AcrPull"
scope = azurerm_container_registry.acr_gh_demo.id
skip_service_principal_aad_check = true
}
# Drift DEMO Delete
resource "azurerm_resource_group" "rg_cc_gh_demo_drift" {
location = var.location
name = "rg_cc_gh_demo_drift"
}