-
Notifications
You must be signed in to change notification settings - Fork 584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a new policy assignment forces the existing policy role assignments to be recreated #266
Comments
Thank you for raising this issue and corresponding PR @LaurentLesle. As a general rule, we wanted to avoid using 'lifecycle' blocks in the module due the potential result of unpredicted behaviour later on. In this case, I agree this is the right thing to do! Before I approve the PR, is it also worth re-merging the |
This is a good spot and definitely something we should fix regardless of which approach we take for this issue! |
Unfortunately, upon further testing this change causes incorrect handling of Role Assignments for policies. I have run an initial test deployment using the On first inspection everything looks OK. Only new Role Assignments were created as needed for the new Policy Assignments. But then I noticed that none of the Role Assignments got re-created for the Policy Assignments which had to be re-created due to updated parameter values. As the re-creation of a Policy Assignment results in a new system-assigned Managed Identity being created, I realised this behaviour is incorrect. I was able to confirm this by removing the We may still be able to make this work, but suspect this will need us to do what I mentioned offline about creating a new child-module covering the Policy Assignment + Role Assignment(s) logic and resource creation. |
On the positive side, the 15 policies above were correctly identified rather than all of them being re-created! |
Have raised an issue on the provider which would mitigate some of the triggers for this behaviour by fixing the root cause of Policy Assignments being incorrectly replaced by Terraform: However this would not address this being caused by adding/removing Policy Assignments which I believe would still require the "child module" approach for Policy Assignment + Role Assignment(s) logic and resource creation. |
Community Note
Versions
terraform: 1.1.3
azure provider: 2.93.1
module: 1.1.1
Description
Describe the bug
Updating the parameters of the policy assignment Enable-DDoS-VNET (could be any one) will force the existing policy role assignments to be re-created. This impact only the policies with an identity.
Steps to Reproduce
Deploy ESLZ with default settings.
step 2
Update the configuration files to update a policy assignment parameters
you get it...
Screenshots
Additional context
Note this only applies on subsequent changes in ESLZ. Note the DDOS policy was assigned on the initial deployment. Only when I update the parameters on a subsequent deployment I observe that cycle for previous policies role assignments.
It affects all role assignment in the MG tree, not just at the level where I setup the DDOS policy.
The text was updated successfully, but these errors were encountered: