Azure / terraform-azurerm-aks

Terraform Module for deploying an AKS cluster
MIT License
361 stars 468 forks source link

Resource group has to exist before you can use this module #602

Open DeviaVir opened 2 weeks ago

DeviaVir commented 2 weeks ago

Is there an existing issue for this?

Greenfield/Brownfield provisioning

greenfield

Terraform Version

1.9.8

Module Version

9.2.0

AzureRM Provider Version

4.9.0

Affected Resource(s)/Data Source(s)

data.azurerm_resource_group.main

Terraform Configuration Files

resource "azurerm_resource_group" "resource_group" {
  name     = "${var.environment}-${var.uuid}-rg"
  location = var.location
}

module "aks" {
  source  = "Azure/aks/azurerm"
  version = "9.2.0"

  resource_group_name = var.resource_group_name
  location = var.location

  # otherwise assuming all defaults are set
}

tfvars variables values

environment=dev
uuid=test
location=westeurope

Debug Output/Panic Output

│ Error: Error: Resource Group "dev-test-rg" was not found
│ 
│   with module.cluster.module.aks.data.azurerm_resource_group.main,
│   on .terraform/modules/cluster.aks/main.tf line 1, in data "azurerm_resource_group" "main":
│    1: data "azurerm_resource_group" "main" {
│ 
╵
╷
│ Error: Error: Resource Group "dev-test-rg" was not found
│ 
│   with module.cluster.module.aks.data.azurerm_resource_group.aks_rg[0],
│   on .terraform/modules/cluster.aks/role_assignments.tf line 114, in data "azurerm_resource_group" "aks_rg":
│  114: data "azurerm_resource_group" "aks_rg" {
│ 
╵

Expected Behaviour

I expected the module to not try to read the resource group and expecting it to exist already on my first run.

Actual Behaviour

The data source fails.

Steps to Reproduce

  1. terraform apply

Important Factoids

No response

References

No response