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.52k stars 4.6k forks source link

root resource was present, but now absent - azurerm_api_management_product_group #17619

Open kiriltdrv opened 2 years ago

kiriltdrv commented 2 years ago

Is there an existing issue for this?

Community Note

Terraform Version

1.2.4

AzureRM Provider Version

3.13.0

Affected Resource(s)/Data Source(s)

azurerm_api_management_product_group

Terraform Configuration Files

resource "azurerm_api_management_product_group" "example2" {
  product_id          = azurerm_api_management_product.product1.product_id
  group_name          = "Guests"
  api_management_name = azurerm_api_management.example.name
  resource_group_name = azurerm_resource_group.apim-rg.name
}

Debug Output/Panic Output

2022-07-13T10:08:30.1584376Z azurerm_api_management_product_group.example2: Creating...
2022-07-13T10:08:30.1594101Z azurerm_api_management_product_group.example: Creating...
2022-07-13T10:08:33.9697516Z ╷
2022-07-13T10:08:33.9698152Z │ Error: Provider produced inconsistent result after apply
2022-07-13T10:08:33.9698538Z │ 
2022-07-13T10:08:33.9699573Z │ When applying changes to azurerm_api_management_product_group.example2,
2022-07-13T10:08:33.9700347Z │ provider "provider[\"registry.terraform.io/hashicorp/azurerm\"]" produced
2022-07-13T10:08:33.9701375Z │ an unexpected new value: Root resource was present, but now absent.
2022-07-13T10:08:33.9701758Z │ 
2022-07-13T10:08:33.9702135Z │ This is a bug in the provider, which should be reported in the provider's
2022-07-13T10:08:33.9702778Z │ own issue tracker.
2022-07-13T10:08:33.9703046Z ╵
2022-07-13T10:08:33.9703267Z ╷
2022-07-13T10:08:33.9703648Z │ Error: Provider produced inconsistent result after apply
2022-07-13T10:08:33.9703996Z │ 
2022-07-13T10:08:33.9704359Z │ When applying changes to azurerm_api_management_product_group.example,
2022-07-13T10:08:33.9704836Z │ provider "provider[\"registry.terraform.io/hashicorp/azurerm\"]" produced
2022-07-13T10:08:33.9705316Z │ an unexpected new value: Root resource was present, but now absent.
2022-07-13T10:08:33.9705646Z │ 
2022-07-13T10:08:33.9706020Z │ This is a bug in the provider, which should be reported in the provider's
2022-07-13T10:08:33.9706378Z │ own issue tracker.
2022-07-13T10:08:33.9706675Z ╵
2022-07-13T10:08:34.0516228Z ##[error]Terraform command 'apply' failed with exit code '1'.
2022-07-13T10:08:34.0598871Z ##[error]╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to azurerm_api_management_product_group.example2,
│ provider "provider[\"registry.terraform.io/hashicorp/azurerm\"]" produced
│ an unexpected new value: Root resource was present, but now absent.
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to azurerm_api_management_product_group.example,
│ provider "provider[\"registry.terraform.io/hashicorp/azurerm\"]" produced
│ an unexpected new value: Root resource was present, but now absent.
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
╵

2022-07-13T10:08:34.2145134Z ##[section]Finishing: terraform apply

Expected Behaviour

When executing Terraform task in Azure DevOps Release Pipeline I was trying assign one of the default API Management User Groups (Administrators, Developers and Guests) to a product I have created. When defining the group name in group_name = "Guests" (same behavior for Developers and Administrators) - Terraform task apply ended with error.

Actual Behaviour

Even though the Terraform task "apply" ended with error - the group was correctly assigned to the APIM Product.

Steps to Reproduce

this happened on terraform apply step

Important Factoids

No response

References

No response

gchiesa commented 2 years ago

probably it's related to similar issue https://github.com/hashicorp/terraform-provider-azurerm/issues/15281

KevinPecquet commented 2 years ago

got the same issue with azurerm 2.99 and terraform 1.1.9

│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to module.apim_custom_product.azurerm_api_management_product_group.group_association["Developers"], provider
│ "provider[\"registry.terraform.io/hashicorp/azurerm\"].abc" produced an unexpected new value: Root resource was present, but now absent.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵

Using this declaration :

resource "azurerm_api_management_product_group" "group_association" {
  provider = azurerm.abc
  for_each = toset(var.groups)

  product_id          = azurerm_api_management_product.product.product_id
  group_name          = each.key
  api_management_name = var.apim_name
  resource_group_name = var.apim_rg_name
}
Yaseen17 commented 2 years ago

we are facing same issue. any update ?

arunrajsb commented 1 year ago

Hi Same error happened to me. Any Updates?

arunrajsb commented 1 year ago

resource "azurerm_api_management_product_group" "portal_guest" { product_id = azurerm_api_management_product.product["pro"].product_id group_name = "Guests" -- > "guests" api_management_name = azurerm_api_management.apim.name resource_group_name = var.resource_group_name }

Updating group_name to "guests" resolved my issue

rcskosir commented 1 year ago

@kiriltdrv Thank you for opening this issue. Were you able to try @arunrajsb's solution of updating the group_name to "guests" instead of "Guests"?

arunrajsb commented 1 year ago

@kiriltdrv Thank you for opening this issue. Were you able to try @arunrajsb's solution of updating the group_name to "guests" instead of "Guests"?

Yes, issue has been resolved

piyushjain-15 commented 1 year ago

Thanks @arunrajsb solved my issue also do not use data block to read the display name otherwise it will change it back to "Guest" hardcode or get the id of group from the data block instead of name.

mfaisaltariq commented 10 months ago

I would still consider this an issue to be fixed in the documentation because it uses the ID instead on the NAME of the product. I had the same issue adding Developers group and when I changed it to all lower caps which is the ID, the issue got resolved.

kerbou commented 5 months ago

resource "azurerm_api_management_product_group" "portal_guest" { product_id = azurerm_api_management_product.product["pro"].product_id group_name = "Guests" -- > "guests" api_management_name = azurerm_api_management.apim.name resource_group_name = var.resource_group_name }

Updating group_name to "guests" resolved my issue

I tried lowercasing the 'Guests' string, but got a 'Resource already exists' error --> see details in #25648