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.6k stars 4.65k forks source link

Import of `azurerm_mysql_flexible_server` triggers replace when subscription changes #25165

Open therealjsie opened 8 months ago

therealjsie commented 8 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.5.7

AzureRM Provider Version

3.91.0

Affected Resource(s)/Data Source(s)

azurerm_mysql_flexible_server

Terraform Configuration Files

I wasn't able to reproduce the issue yet, but will try to come up with a working example.

Debug Output/Panic Output

The Terraform Cloud output displays (among other things) the following line:

➕ create_mode : "Default" *Forces replacement*

However, the `create_mode` has not changed (as the server was only moved between subscriptions). The `create_mode` is `Default` in the state as well.

Expected Behaviour

We have moved an azurerm_mysql_flexible_server instance between two subscriptions. As the azurerm provider cannot keep track of resources between subscriptions, we opted to remove the original resource from state and then import the moved resource. There are no other configuration changes on the flexible server during the move.

This report is mainly to find out if there are known issues with the import of azurerm_mysql_flexible_server resources (looking through the GitHub issues was not conclusive).

I expect the flexible server to be imported without any changes shown in the Terraform Cloud UI after moving it between subscriptions.

Actual Behaviour

The moved flexible server can only be imported with multiple values being Known after apply (e.g. fqdn), Removed (e.g. private_dns_zone_id) or Created (e.g. create_mode). None of these values should have any changes (afaict).

Steps to Reproduce

No response

Important Factoids

No response

References

No response

therealjsie commented 8 months ago

Quick update: Adding create_mode and administrator_password to the lifecycle -> ignore changes actually resolves the issue. After adding these two fields to the ignore list, no other changes are shown and the database can (supposedly) be imported. I haven't run the apply yet, but it looks good in the plan.

rcskosir commented 8 months ago

Thank you for taking the time to open this issue. Please subscribe to PR #25179 created by @neil-yechenwei for this issue.