azurerm_mssql_managed_instance_failover_group : Fix "The given primary field in create or update instance failover group request body is empty or invalid" error #16705
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The customer is encountering "The given primary field in create or update instance failover group request body is empty or invalid" error when creating
azurerm_mssql_managed_instance_failover_group
resource. After investigation, it was found that the parameterPrimaryManagedInstanceID
was set to the ID of failover group instead of the primary managed instance ID. So, I submitted this PR to fix the error.It's worth mentioning that when the env variable ARM_TEST_LOCATION is set to
eastus
and the ARM_TEST_LOCATION_ALT is set towestus3
, the test caseTestAccMsSqlManagedInstanceFailoverGroup_update
fails with error "The async operation failed" while creatingazurerm_mssql_managed_instance
resource on my local(There is this error both before and after this fix. And it seems that team city has the same error). After replacing thewestcentralus
andwestus2
with theeastus
andwestus3
for AzureCloud, Storage, EventHub, Sql route in const managedInstanceStaticRoutes , this error went away. Since our test subscription does not support creatingazurerm_mssql_managed_instance
resource underwestcentralus
andwestus2
region, I could not test on these regions.Given that the resource
azurerm_mssql_managed_instance_failover_group
was contributed in PR #15203 by manicminer. @manicminer, do you have any suggesstions on how to resolve the test case failure? May I ask you help to review this PR to fix the invalid request body error to unblock the customer first?Additionally, this PR also fixes the "cannot import non-existent remote object" error by setting location to
id.LocationName
instead ofstate.Location
. This error is caused by the empty value of state.Location.Related issue: #16566.