Open seblatre opened 1 month ago
Hi @seblatre, thanks for opening the issue.
There might 2 issues involved, first is the provider does not produce the correct plan value. Second is the somehow azuread_group_member. member
did not get the value of azurerm_logic_app_workflow.logic_app.identity[0].principal_id
after the modification finished. I'm still working on it and will let you know once I made progress.
Thanks
@ziyeqf, for what I could understand here is that the plan is not complete in the third case I presented.
Looking at the plan, there is absolutely no mention of identity.principal_id
(with a value or a not yet known value).
Without that, I think that the engine is lost and not able to propose any value for this field (hence the no definition found error)
Hi @seblatre,
I have reproduced this issue before but with the latest Terraform and provider, it works properly, it might because of this PR(https://github.com/hashicorp/terraform/pull/35644) on Terraform, do you mind try it again? my versions:
❯❯ tf version
Terraform v1.9.7
on darwin_arm64
+ provider registry.terraform.io/hashicorp/azurerm v4.5.0
my configuration:
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "test-logic"
location = "westus2"
}
resource "azurerm_logic_app_workflow" "test" {
name = "test-workflow"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
lifecycle {
ignore_changes = [ tags, identity ]
}
}
import {
id = "/subscriptions/<sub_id>/resourceGroups/test-logic/providers/Microsoft.Logic/workflows/test-logic"
to = azurerm_logic_app_workflow.test
}
output "identity_id" {
value = azurerm_logic_app_workflow.test.identity[0].principal_id
}
Hello @ziyeqf, I just saw you answer but I'm on vacation right now. I'll check that at my return. But that sounds good :)
Hello @ziyeqf, I just tested the behavior on the following stack:
$ terraform version
Terraform v1.9.8
on windows_amd64
+ provider registry.terraform.io/hashicorp/azurerm v4.5.0
[...]
and just hit the exact same issue.
In your example, I think that the following block is missing in your logic app to reproduce the same issue.
identity {
type = "SystemAssigned"
}
Also the logic app must not have any identity defined on it (set it to off).
The use of azuread_group_member
resource may be needed as well because I think the issue lies within the plan workflow and just outputting the value may not be sufficient to make the issue appear.
Oh, I reproduced the issue, still looking into it
Is there an existing issue for this?
Community Note
Terraform Version
1.9.5
AzureRM Provider Version
3.116.0
Affected Resource(s)/Data Source(s)
azurerm_logic_app_workflow
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Being able to Import an existing logic app without system managed identity yet
Actual Behaviour
When the logic app is created from scratch, the following plan is prepared with identity.principal_id as "known after apply" which is expected:
When the logic app already exist outside Terraform with a system managed identity and imported, the following plan is prepared with identity.principal_id as "known" which is expected as well:
But when the logic app already exist outside Terraform without system managed identity and imported, the following plan is prepared with identity.principal_id as "undefined" which shouldn't be expected:
And so in this last case, the creation of the group membership in AD is failing because principal_id is considered as "null" and not as "know after apply":
Steps to Reproduce
/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/DEVA42TEST/providers/Microsoft.Logic/workflows/my-wonderful-logic-app
terraform plan
Important Factoids
None
References
No response