Open rknabben opened 1 week ago
@rknabben did you add assignable_scopes = []
to your HCL config? You should remove this from your script. The diff is generated from on the difference between state file and the HCL config.
Yes, the module does indeed add assignable_scopes = [] to the config as I didn't use dynamic for this parameter. So apart from you being correct on that aspect, i still consider this to be a "bug", because:
The terraform plan states it is going to remove the assignable_scope, where terraform apply does not actually remove the assignable_scope, as the scope is added to this assignable scope.
So in my humble opinion, the terraform should not state it is going to remove something that it will not actually remove. e.g. the statefile vs HCL config behaves differently from the actual "apply" execution of the plan.
This is the tricky part between service and Terraform. The sate file based on the service response while local HCl is user based. In some cases, some properties have default values from the service side. Take assignable_scopes
for example, local HCL set it to []
while service will set it with a different value.
Several workarounds for this:
assignable_scopes
assignable_scopes
in the HCl, let service handle it.assignable_scopes
based on the plan
output.
Is there an existing issue for this?
Community Note
Terraform Version
1.6.3
AzureRM Provider Version
3.106.0
Affected Resource(s)/Data Source(s)
azurerm_role_definition
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Nothing.
The result should have been: "No changes"
Actual Behaviour
The message was shown that the assignable scopes would be removed.
Which in theory is true, as the assignable scopes list is empty in the call. However as per the documentation, the scope of the role is automatically added to the assignable scope list if it is empty, so there will be no removal, and thus the output is wrong as it is not based on the final version of the assignable scope list (which includes the scope), and it keeps showing the scope to be removed from the "assignable scopes"where in fact it is not removed at all.
Currently the only workaround is to manually add the scope to the assignable scope list to avoid this "invalid" response.
Steps to Reproduce
terraform plan or terraform apply
Important Factoids
No response
References
No response