Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data call for resource group breaks in some circumstances #68

Closed
1 task done
cfBrianMiller opened this issue Apr 5, 2024 · 7 comments
Closed
1 task done

Data call for resource group breaks in some circumstances #68

cfBrianMiller opened this issue Apr 5, 2024 · 7 comments
Assignees
Labels
bug Something isn't working Status: Fixed ✅ Auto label applied when issue fixed by merged PR

Comments

@cfBrianMiller
Copy link

cfBrianMiller commented Apr 5, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Greenfield/Brownfield provisioning

greenfield

Terraform Version

1.7.5

Module Version

0.1.1

AzureRM Provider Version

3.98.0

Affected Resource(s)/Data Source(s)

azurerm_resource_group

Terraform Configuration Files

terraform {
  required_version = ">= 1.0.11"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "3.98.0"
    }
  }
}

locals {
  subId = "xxxx"
}

provider "azurerm" {
  environment     = "Public"
  subscription_id = local.subId
  features {
    log_analytics_workspace {
      permanently_delete_on_destroy = true
    }
    key_vault {
      purge_soft_delete_on_destroy = true
    }
  }
}

resource "azurerm_resource_group" "sample" {
  location = "eastus"
  name     = "sample"
}

module "avm_res_storage_storageaccount" {
  source  = "Azure/avm-res-storage-storageaccount/azurerm"
  version = "0.1.1"
  name    = "sample"
  resource_group_name = azurerm_resource_group.sample.name
}

tfvars variables values

N/A

Debug Output/Panic Output

module.avm_res_storage_storageaccount.data.azurerm_client_config.this: Reading...
module.avm_res_storage_storageaccount.data.azurerm_client_config.this: Read complete after 0s [id=Y2xpZW50Q29uZmlncy9jbGllbnRJZD0wNGIwNzc5NS04ZGRiLTQ2MWEtYmJlZS0wMmY5ZTFiZjdiNDY7b2JqZWN0SWQ9OGE4N2ZmMGUtNzRhMi00MGZjLWIwMTAtMjNiNWZkMDBhNmQ2O3N1YnNjcmlwdGlvbklkPWFkZmQ5NjEyLWZmMmYtNGJlZC04YTQwLTYyNmMyZGFiZGQzNjt0ZW5hbnRJZD01N2Y5Y2UyYi1kNTMwLTQ1MDEtOWQ2Mi1jNzI0NzIwOGRlOGM=]
module.avm_res_storage_storageaccount.data.azurerm_resource_group.rg: Reading...

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform planned the following actions, but then encountered a problem:

  # azurerm_resource_group.sample will be created
  + resource "azurerm_resource_group" "sample" {
      + id       = (known after apply)
      + location = "eastus"
      + name     = "sample"
    }

  # module.avm_res_storage_storageaccount.azurerm_resource_group_template_deployment.telemetry[0] will be created
  + resource "azurerm_resource_group_template_deployment" "telemetry" {
      + deployment_mode     = "Incremental"
      + id                  = (known after apply)
      + name                = (known after apply)
      + output_content      = (known after apply)
      + parameters_content  = (known after apply)
      + resource_group_name = "sample"
      + template_content    = jsonencode(
            {
              + "$schema"      = "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"
              + contentVersion = "1.0.0.0"
              + outputs        = {
                  + telemetry = {
                      + type  = "String"
                      + value = "For more information, see https://aka.ms/avm/telemetry"
                    }
                }
              + parameters     = {}
              + resources      = []
              + variables      = {}
            }
        )
    }

  # module.avm_res_storage_storageaccount.random_id.telemetry[0] will be created
  + resource "random_id" "telemetry" {
      + b64_std     = (known after apply)
      + b64_url     = (known after apply)
      + byte_length = 4
      + dec         = (known after apply)
      + hex         = (known after apply)
      + id          = (known after apply)
    }

Plan: 3 to add, 0 to change, 0 to destroy.
╷
│ Error: Error: Resource Group "sample" was not found
│ 
│   with module.avm_res_storage_storageaccount.data.azurerm_resource_group.rg,
│   on .terraform/modules/avm_res_storage_storageaccount/main.tf line 3, in data "azurerm_resource_group" "rg":
│    3: data "azurerm_resource_group" "rg" {
│ 
╵

Expected Behaviour

Module deploys successfully

Actual Behaviour

Resource Group data module can't find resource group created in previous call

Steps to Reproduce

terraform plan

Important Factoids

No response

References

This appears to be related to: hashicorp/terraform-provider-azurerm#5233

No response

@cfBrianMiller cfBrianMiller added the bug Something isn't working label Apr 5, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Triage 🔍 Maintainers need to triage still label Apr 5, 2024
@chinthakaru chinthakaru self-assigned this Apr 7, 2024
@matt-FFFFFF
Copy link
Member

I concur, if the resource group is created in the same apply then the data source fails - recommend removing the data source and making the location input mandatory

@the-blesss
Copy link

I'm also seeing this behavior when deploying the resource group when using the avm storage account module. Work-around is to create the resource group outside of the terraform apply and import it, which is not ideal, but a minor annoyance. I haven't experienced this with any other avms.

@davidzenisu
Copy link

Agreed, my workaround is adding a "depends_on" block for the module containing the resource group but obviously that's less than ideal. Agree with your approach @matt-FFFFFF.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Status: Response Overdue 🚩 When an issue/PR has not been responded to for X amount of days label Apr 26, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Immediate Attention ‼️ Immediate attention of module owner / AVM team is needed label May 3, 2024
@matt-FFFFFF
Copy link
Member

Hi @chinthakaru any update here?

@kewalaka
Copy link
Contributor

kewalaka commented Jun 2, 2024

this has been fixed in #70, released in v0.1.2

@kewalaka
Copy link
Contributor

kewalaka commented Jun 2, 2024

the variable description for the location should be updated to removed the reference to it using the data source, and the commented out data source in main.tf should be removed.

@chinthakaru chinthakaru added Status: Fixed ✅ Auto label applied when issue fixed by merged PR and removed Needs: Immediate Attention ‼️ Immediate attention of module owner / AVM team is needed Needs: Triage 🔍 Maintainers need to triage still Status: Response Overdue 🚩 When an issue/PR has not been responded to for X amount of days labels Jun 4, 2024
@chinthakaru
Copy link
Collaborator

This has been fixed in #70.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Status: Fixed ✅ Auto label applied when issue fixed by merged PR
Projects
Development

No branches or pull requests

6 participants