Skip to content

Commit

Permalink
Merge pull request #5 from adamrushuk/azurerm-v3
Browse files Browse the repository at this point in the history
Added support for azurerm v3
  • Loading branch information
adamrushuk authored Apr 22, 2022
2 parents 8d37782 + 13bcf50 commit d22ef5c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ terraform.tfvars
*.tfstate
*.tfstate.backup
tfplan
.terraform.lock.hcl

# Module directory
.terraform/
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ terraform {
# https://github.com/terraform-providers/terraform-provider-azurerm/releases
azurerm = {
source = "hashicorp/azurerm"
version = "2.76.0"
version = "3.3.0"
}
}
}
Expand All @@ -24,7 +24,7 @@ locals {
# version used for both main AKS API service, and default node pool
# https://github.com/Azure/AKS/releases
# az aks get-versions --location uksouth --output table
kubernetes_version = "1.20.9"
kubernetes_version = "1.21.9"
location = "uksouth"
resource_group_name = "${random_string.aks.result}-rg-azurerm-kubernetes-cluster"
name = "${random_string.aks.result}-aks-cluster"
Expand Down
41 changes: 18 additions & 23 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ locals {
orchestrator_version = var.kubernetes_version
vm_size = "Standard_D2s_v3"
os_type = "Linux"
availability_zones = null
enable_auto_scaling = false
min_count = null
max_count = null
Expand Down Expand Up @@ -54,7 +53,6 @@ resource "azurerm_kubernetes_cluster" "aks" {
orchestrator_version = local.default_node_pool.orchestrator_version
vm_size = local.default_node_pool.vm_size
node_count = local.default_node_pool.count
availability_zones = local.default_node_pool.availability_zones
enable_auto_scaling = local.default_node_pool.enable_auto_scaling
min_count = local.default_node_pool.min_count
max_count = local.default_node_pool.max_count
Expand All @@ -79,36 +77,33 @@ resource "azurerm_kubernetes_cluster" "aks" {
}
}

# managed identity block: https://www.terraform.io/docs/providers/azurerm/r/kubernetes_cluster.html#type-1
# managed identity block
# https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster#identity
identity {
type = "SystemAssigned"
}

# https://docs.microsoft.com/en-us/azure/aks/azure-ad-rbac
role_based_access_control {
enabled = true

# conditional dynamic block
dynamic "azure_active_directory" {
for_each = var.aad_auth_enabled ? [1] : []
content {
managed = true
admin_group_object_ids = [
azuread_group.aks_admins[0].id
]
}
# conditional dynamic block
dynamic "azure_active_directory_role_based_access_control" {
for_each = var.aad_auth_enabled ? [1] : []
content {
managed = true
admin_group_object_ids = [
azuread_group.aks_admins[0].id
]
}
}

addon_profile {
# https://docs.microsoft.com/en-ie/azure/governance/policy/concepts/policy-for-kubernetes
azure_policy {
enabled = var.azure_policy_enabled
}
# https://docs.microsoft.com/en-ie/azure/governance/policy/concepts/policy-for-kubernetes
azure_policy_enabled = var.azure_policy_enabled

oms_agent {
enabled = var.log_analytics_workspace_id != "" ? true : false
log_analytics_workspace_id = var.log_analytics_workspace_id != "" ? var.log_analytics_workspace_id : null
# https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster#oms_agent
# conditional dynamic block
dynamic "oms_agent" {
for_each = var.log_analytics_workspace_id != "" ? [1] : []
content {
log_analytics_workspace_id = var.log_analytics_workspace_id
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ cd test
terraform destroy

# Delete local TF state and plan
rm -rf terraform.tfstate* tfplan
rm -rf terraform.tfstate* tfplan .terraform.lock.hcl

# [OPTIONAL] Delete provider binaries and git modules
rm -rf .terraform
Expand Down
2 changes: 1 addition & 1 deletion test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ locals {
# version used for both main AKS API service, and default node pool
# https://github.com/Azure/AKS/releases
# az aks get-versions --location uksouth --output table
kubernetes_version = "1.20.9"
kubernetes_version = "1.21.9"
prefix = "rush"
location = "uksouth"
resource_group_name = "${local.prefix}-rg-azurerm-kubernetes-cluster"
Expand Down
7 changes: 6 additions & 1 deletion test/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ terraform {
# https://github.com/terraform-providers/terraform-provider-azurerm/releases
azurerm = {
source = "hashicorp/azurerm"
version = "2.78.0"
version = "~> 3.3.0"
}
# https://github.com/terraform-providers/terraform-provider-azuread/releases
azuread = {
source = "hashicorp/azuread"
version = "~> 2.21.0"
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ variable "aks_admin_group_member_name" {
variable "kubernetes_version" {
description = "Version for both main AKS API service, and default node pool"
type = string
default = "1.20.9"
default = "1.21.9"
}

variable "sla_sku" {
Expand All @@ -36,7 +36,7 @@ variable "sla_sku" {
variable "load_balancer_sku" {
description = "Specifies the SKU of the Load Balancer used for this Kubernetes Cluster"
type = string
default = "Basic"
default = "basic"
}

variable "tags" {
Expand Down Expand Up @@ -67,7 +67,6 @@ map(object({
count = number
vm_size = string
os_type = string
availability_zones = list(number)
enable_auto_scaling = bool
min_count = number
max_count = number
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ terraform {
# https://github.com/terraform-providers/terraform-provider-azurerm/releases
azurerm = {
source = "hashicorp/azurerm"
version = ">= 2.0"
version = ">= 3.0"
}

# https://github.com/terraform-providers/terraform-provider-azuread/releases
Expand Down

0 comments on commit d22ef5c

Please sign in to comment.