github.com/darmach/terratest@v0.34.8-0.20210517103231-80931f95e3ff/examples/azure/terraform-azure-aks-example/main.tf (about) 1 # --------------------------------------------------------------------------------------------------------------------- 2 # DEPLOY AN AZURE AKS CLUSTER 3 # This is an example of how to deploy an Azure AKS cluster with load balancer in front of the service 4 # to handle providing the public interface into the cluster. 5 # --------------------------------------------------------------------------------------------------------------------- 6 # See test/azure/terraform_azure_aks_example_test.go for how to write automated tests for this code. 7 # --------------------------------------------------------------------------------------------------------------------- 8 9 terraform { 10 # This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting 11 # 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it 12 # forwards compatible with 0.13.x code. 13 required_version = ">= 0.12.26" 14 } 15 16 # ------------------------------------------------------------------------------ 17 # CONFIGURE OUR AZURE CONNECTION 18 # ------------------------------------------------------------------------------ 19 20 provider "azurerm" { 21 features {} 22 } 23 24 # --------------------------------------------------------------------------------------------------------------------- 25 # DEPLOY A RESOURCE GROUP 26 # --------------------------------------------------------------------------------------------------------------------- 27 28 resource "azurerm_resource_group" "k8s" { 29 name = var.resource_group_name 30 location = var.location 31 } 32 33 # --------------------------------------------------------------------------------------------------------------------- 34 # DEPLOY AN AZURE KUBERNETES CLUSTER 35 # --------------------------------------------------------------------------------------------------------------------- 36 37 resource "azurerm_kubernetes_cluster" "k8s" { 38 name = var.cluster_name 39 location = azurerm_resource_group.k8s.location 40 resource_group_name = azurerm_resource_group.k8s.name 41 dns_prefix = var.dns_prefix 42 43 linux_profile { 44 admin_username = "ubuntu" 45 46 ssh_key { 47 key_data = file(var.ssh_public_key) 48 } 49 } 50 51 default_node_pool { 52 name = "agentpool" 53 node_count = var.agent_count 54 vm_size = "Standard_DS2_v2" 55 } 56 57 service_principal { 58 client_id = var.client_id 59 client_secret = var.client_secret 60 } 61 62 tags = { 63 Environment = "Development" 64 } 65 } 66 67 # --------------------------------------------------------------------------------------------------------------------- 68 # CREATE KUBECONFIG FILE 69 # --------------------------------------------------------------------------------------------------------------------- 70 71 resource "local_file" "kubeconfig" { 72 content = azurerm_kubernetes_cluster.k8s.kube_config_raw 73 filename = "kubeconfig" 74 75 depends_on = [ 76 azurerm_kubernetes_cluster.k8s 77 ] 78 }