hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.53k stars 4.6k forks source link

azurerm_data_factory_integration_runtime_self_hosted: error in resource_id #16498

Open Quazi-Ahmed opened 2 years ago

Quazi-Ahmed commented 2 years ago

Is there an existing issue for this?

Community Note

Terraform Version

1.0.11

AzureRM Provider Version

3.0.0

Affected Resource(s)/Data Source(s)

azurerm_data_factory_integration_runtime_self_hosted

Terraform Configuration Files

# -------------------------------------
#  ADF
# -------------------------------------
module "adf_commodities" {
  source = "../../../DAAS_MODULES/adf"

  rg                     = azurerm_resource_group.rg.name
  location               = azurerm_resource_group.rg.location
  name                   = "${local.resource_prefix}daicommadf01${module.common.env_suffix_code}${var.name_suffix}"

  public_network_enabled = false
  priv_endpt_name        = "${local.resource_prefix}daicommadf01pec${module.common.env_suffix_code}${var.name_suffix}"
  priv_endpt_subnet_id   = module.common.subnet_id_common
  priv_endpt_dnszone_ids = ["${module.common.private_dns_zone_prefix}/privatelink.datafactory.azure.net"]

  tags = local.tags
}

# -------------------------------------
#  ADF Linked Integration Runtime
# -------------------------------------
# In order to link to the shared ADF, the current ADF should have an appropriate role granted, so that
# the SHIR VM can be accessed.
# Ref : https://docs.microsoft.com/en-us/azure/data-factory/create-shared-self-hosted-integration-runtime-powershell#grant-permission
#
resource "azurerm_role_assignment" "linked_adf_role_assign_commodities" {
  scope                = contains(["UAT"], var.env) ? data.terraform_remote_state.tor_dlshared_rg.outputs.shrd_adf_dlake_id : data.terraform_remote_state.tor_dlshared_rg.outputs.shrd_adf_dai_id
  role_definition_name = "Contributor"
  principal_id         = module.adf_commodities.identity[0].principal_id
}

resource "azurerm_data_factory_integration_runtime_self_hosted" "shrd_ls_commodities" {
  depends_on          = [module.adf_commodities, azurerm_role_assignment.linked_adf_role_assign_commodities]
  name                = "adf-shrd-shir-ls"
  #resource_group_name = azurerm_resource_group.rg.name
  data_factory_id   = module.adf_commodities.id

  rbac_authorization {
    resource_id = contains(["UAT"], var.env) ? data.terraform_remote_state.tor_dlshared_rg.outputs.shrd_adf_dlake_id : data.terraform_remote_state.tor_dlshared_rg.outputs.shrd_adf_dai_id
  }
}

# -------------------------------------
# Outputs
# -------------------------------------
output "data_factory_commodities_id" {
  description = "The ID of Azure Data Factory for Commodities"
  value       = module.adf_commodities.id
}

Debug Output/Panic Output

# azurerm_data_factory_integration_runtime_self_hosted.shrd_ls_commodities must be replaced
-/+ resource "azurerm_data_factory_integration_runtime_self_hosted" "shrd_ls_commodities" {
      ~ data_factory_id             = "/subscriptions/fe9234c3-74d4-416e-902d-4940ddbf29e2/resourceGroups/TOR-DATAAI-DEV-RGcode/providers/Microsoft.DataFactory/factories/zcc1daicommadf01dcode" -> "/subscriptions/fe9234c3-74d4-416e-902d-4940ddbf29e2/resourceGroups/tor-dataai-dev-rgcode/providers/Microsoft.DataFactory/factories/zcc1daicommadf01dcode" # forces replacement

Expected Behaviour

data_factory_id should be "/subscriptions/fe9234c3-74d4-416e-902d-4940ddbf29e2/resourceGroups/TOR-DATAAI-DEV-RGcode/providers/Microsoft.DataFactory/factories/zcc1daicommadf01dcode"

Actual Behaviour

data_factory_id tending to "/subscriptions/fe9234c3-74d4-416e-902d-4940ddbf29e2/resourceGroups/tor-dataai-dev-rgcode/providers/Microsoft.DataFactory/factories/zcc1daicommadf01dcode"

Steps to Reproduce

terraform plan

Important Factoids

Canada central

References

0000

tombuildsstuff commented 2 years ago

hi @Quazi-Ahmed

Can you confirm the value of module.adf_commodities.id here?

Thanks!

Quazi-Ahmed commented 2 years ago

Hi Tom,

PFB value for module.adf_commodities.id: - "/subscriptions/fe9234c3-74d4-416e-902d-4940ddbf29e2/resourceGroups/tor-dataai-dev-rgcode/providers/Microsoft.DataFactory/factories/zcc1daicommadf01dcode"

Thanks & Regards, Quazi Furquan Ahmed TCS associate, Partnering with CN I&T, IMS | I&T T: via Microsoft Teams | C: What's New at CNhttps://www.cn.ca/whatsnew | Quoi de neuf au CNhttps://www.cn.ca/quoi-de-neuf

From: Tom Harvey @.> Sent: Friday, April 22, 2022 3:16 PM To: hashicorp/terraform-provider-azurerm @.> Cc: Quazi Ahmed @.>; Mention @.> Subject: Re: [hashicorp/terraform-provider-azurerm] azurerm_data_factory_integration_runtime_self_hosted: error in resource_id (Issue #16498)

CAUTION: This email originated from outside CN: DO NOT click links or open attachments unless you recognize the sender AND KNOW the content is safe.

AVERTISSEMENT : ce courriel provient d’une source externe au CN : NE CLIQUEZ SUR AUCUN lien ou pièce jointe à moins de reconnaitre l’expéditeur et d'avoir VÉRIFIÉ la sécurité du contenu.

hi @Quazi-Ahmedhttps://github.com/Quazi-Ahmed

Can you confirm the value of module.adf_commodities.id here?

Thanks!

— Reply to this email directly, view it on GitHubhttps://github.com/hashicorp/terraform-provider-azurerm/issues/16498#issuecomment-1106274049, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AYFBE3JEMQPJZMTL7SB2ZXTVGJYMVANCNFSM5UALL3MQ. You are receiving this because you were mentioned.Message ID: @.**@.>>

tombuildsstuff commented 2 years ago

@Quazi-Ahmed based on the Resource ID you've provided this looks correct - the value provided as the data_factory_id gets parsed and then used to build up the Resource ID for the Integration Runtime, which is in turn used to build up the Data Factory ID - as such this appears to be working as intended?

Quazi-Ahmed commented 2 years ago

@tombuildsstuff than while doing terraform plan, why is it showing force replacement ~ data_factory_id = "/subscriptions/fe9234c3-74d4-416e-902d-4940ddbf29e2/resourceGroups/TOR-DATAAI-DEV-RGcode/providers/Microsoft.DataFactory/factories/zcc1daicommadf01dcode" -> "/subscriptions/fe9234c3-74d4-416e-902d-4940ddbf29e2/resourceGroups/tor-dataai-dev-rgcode/providers/Microsoft.DataFactory/factories/zcc1daicommadf01dcode" # forces replacement

Also, we have 100+ data factories, some ADFs having rg name in small case alphabets in data_factory_id while others having it in upper case. I can't understand the issue.

tombuildsstuff commented 2 years ago

@Quazi-Ahmed were these created with 3.x, or an earlier version of the Provider? If so, which version?

Quazi-Ahmed commented 2 years ago

It was created on older version, but now we are upgrading our azureRM provider version and we facing this with ADFs.

Quazi-Ahmed commented 2 years ago

Hi @tombuildsstuff Can I have an update please.

Quazi-Ahmed commented 2 years ago

Hi @tombuildsstuff , Can I have an update please?

Quazi-Ahmed commented 2 years ago

Hi @tombuildsstuff , Can I have an update please?