Open linak-lukasmendez opened 1 year ago
@linak-lukasmendez thanks for opening this issue. Could you provide the terraform log to help troubleshoot for this case?
@linak-lukasmendez thanks for your response. Per the line 5857 in provided terraform.log, we could find that the API does not return the identity
(e.g. the following identity) information when terraform calls GET /subscriptions/XXX/resourceGroups/rg-moc-global-weu-test-q7r8/providers/Microsoft.Sql/servers/sql-moc-global-weu-test-q7r8?api-version=2021-02-01-preview
(in line 5836 of terraform.log). Also, whether data.azurerm_mssql_server.global.identity[0].principal_id
or azurerm_mssql_server.global.identity[0].principal_id
calls the same flattenSqlServerIdentity method in terraform code. There is no difference in the implementation of terraform. So I am assuming that this is an Azure API issue. Could you file an issue for your case in Azure API repo for troubleshooting?
"identity":{
"principalId":"0000000-0000-0000-0000-00000000",
"type":"SystemAssigned",
"tenantId":"12345678-0000-0000-0000-000000000"
}
Is there an existing issue for this?
Community Note
Terraform Version
1.2.8
AzureRM Provider Version
3.46.0
Affected Resource(s)/Data Source(s)
azurerm_mssql_server and azuread_directory_role_assignment
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
I expect the principal id from azurerm_mssql_server to be read, even though it was created in another terraform execution and be able to use it in another resource
Actual Behaviour
I get an error saying that the "principal_object_id" is required, but no definition is found
Steps to Reproduce
Just apply it and the error will be shown
Important Factoids
I've solved it by adding the azurerm_mssql_server as a datasource and then reading the principal id from there instead, like here:
References
No response