Skip to content

Instantly share code, notes, and snippets.

@johananl
Last active July 23, 2019 09:58
Show Gist options
  • Save johananl/374ef3346e7e2a42b5f72aac5ab967b4 to your computer and use it in GitHub Desktop.
Save johananl/374ef3346e7e2a42b5f72aac5ab967b4 to your computer and use it in GitHub Desktop.
AKS cluster using Terraform
provider "azurerm" {}
variable "cluster_name" {
default = "aks-test"
}
resource "azurerm_resource_group" "test" {
name = "${var.cluster_name}"
location = "West Europe"
}
resource "azuread_application" "test" {
name = "${var.cluster_name}"
}
resource "azuread_service_principal" "test" {
application_id = "${azuread_application.test.application_id}"
}
resource "random_string" "password" {
length = 20
override_special = "/@\" "
}
resource "azuread_application_password" "test" {
application_id = "${azuread_application.test.object_id}"
value = "${random_string.password.result}"
end_date_relative = "86000h"
}
resource "azurerm_kubernetes_cluster" "test" {
name = "${var.cluster_name}"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
dns_prefix = "${var.cluster_name}"
agent_pool_profile {
name = "default"
count = 2
vm_size = "Standard_B2s"
os_type = "Linux"
os_disk_size_gb = 30
}
service_principal {
client_id = "${azuread_service_principal.test.application_id}"
client_secret = "${azuread_application_password.test.value}"
}
}
output "client_certificate" {
value = "${azurerm_kubernetes_cluster.test.kube_config.0.client_certificate}"
sensitive = true
}
output "kube_config" {
value = "${azurerm_kubernetes_cluster.test.kube_config_raw}"
sensitive = true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment