From 83670e5963a26ae461e07be3f8dfa63fde9ad44a Mon Sep 17 00:00:00 2001 From: Justin King Date: Fri, 1 Apr 2022 14:40:22 -0700 Subject: [PATCH] update example --- examples/basic/main.tf | 78 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 14 deletions(-) diff --git a/examples/basic/main.tf b/examples/basic/main.tf index abc329c..0051e7c 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -1,12 +1,52 @@ provider azurerm { - features{} + features { + resource_group { + prevent_deletion_if_contains_resources = false # only good for demo, remove in prod + } + } } resource azurerm_resource_group "main" { - name = "test-aks-baseline" + name = "basic-aks-baseline" location = "westus2" } +# oms resources to connect to +resource "azurerm_log_analytics_workspace" "main" { + name = "basic-aks-la" + location = azurerm_resource_group.main.location + resource_group_name = azurerm_resource_group.main.name + sku = "PerGB2018" +} + +resource "random_string" "nameSuffix" { + length = 8 + special = false + upper = false +} + +resource "azurerm_storage_account" "main" { + name = "basicaks${random_string.nameSuffix.result}" # keeps the global name unique to avoid collisions + resource_group_name = azurerm_resource_group.main.name + location = azurerm_resource_group.main.location + account_tier = "Standard" + account_replication_type = "RAGRS" + allow_nested_items_to_be_public = true +} + +resource "azurerm_log_analytics_solution" "containerinsights" { + solution_name = "ContainerInsights" + location = azurerm_log_analytics_workspace.main.location + resource_group_name = azurerm_resource_group.main.name + workspace_resource_id = azurerm_log_analytics_workspace.main.id + workspace_name = azurerm_log_analytics_workspace.main.name + plan { + publisher = "Microsoft" + product = "OMSGallery/ContainerInsights" + } +} + +# network to run on module "myvnet" { source = "Justin-DynamicD/virtual_network/azurerm" global_settings = { @@ -24,22 +64,32 @@ module "myvnet" { } module "aks" { - source = "../" + source = "Justin-DynamicD/aks_baseline/azurerm" depends_on = [ - azurerm_resource_group.test + azurerm_resource_group.main, + azurerm_log_analytics_workspace.main, + azurerm_storage_account.main, + azurerm_log_analytics_solution.containerinsights ] - global_settings = { - location = azurerm_resource_group.main.location - name_prefix = "testaks" - resource_group_name = azurerm_resource_group.main.name - } - aks = { - os_disk_size_gb = 70 - subnet_id = module.myvnet.vnet_subnets["aks_nodes"].id - vm_size = "Standard_D2ds_v5" - } + location = azurerm_resource_group.main.location + name_prefix = "basicaks" + resource_group_name = azurerm_resource_group.main.name + subnet_id = module.myvnet.vnet_subnets["aks_nodes"].id app_gateway = { enabled = true subnet_id = module.myvnet.vnet_subnets["agw"].id } + node_default_pool = { + min_count = 1 + node_count = 1 + } + node_user_pool = { + min_count = 1 + node_count = 1 + } + oms = { + enabled = true + storage_account_id = azurerm_storage_account.main.id + workspace_id = azurerm_log_analytics_workspace.main.id + } }