Skip to content
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

Prevent remediation when assignment_enforcement_mode=false #72

Merged
merged 10 commits into from
Apr 21, 2023

Conversation

pmatthews05
Copy link
Contributor

Description

  • When a assignment (initiative or definition) is set, and the assignment_enforcement_mode is set to false, it shouldn't apply a remediation. An extra condition to check for this assignment_enforcement_mode.
  • For data calls to azurerm_policy_set_definition change calls to lookup from name, as Microsoft changes display names, update examples, and readme files.
  • Switch data.azurerm_policy_definition to data.azurerm_policy_definition_built_in and using the name instead of the display name. Updated examples and readme files.
  • Updated azurerm version number to >=3.44.0 in examples and readme files, because data.azurerm_policy_definition_built_in is only available from that version onwards.
  • Formatted the tf files, using newly created script .\format-terraform.ps1

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Test Configuration:

  • Module Version: Latest
  • Terraform Version: 1.4.4 on Windows_amd64
  • AzureRM Provider Version: 3.5.0

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have checked my code and corrected any misspellings

@gettek
Copy link
Owner

gettek commented Apr 12, 2023

Hi @pmatthews05, thank you for raising this, great spot about preventing remediation when assignment_enforcement_mode=false.

Could you kindly update your branch with the changes made in #73, have finally caved into running terraform fmt on all modules since noticing this PR, have also modified the existing pre-commit script so we can remove format-terraform.ps1

@pmatthews05
Copy link
Contributor Author

@gettek I have pulled your code into mine using a separate branch. Went through all the conflicts. I then merged this branch into my main.
That should make this PR correct now, with no merge conflicts and has both #73 and #74.

@gettek gettek self-requested a review April 17, 2023 16:03
@gettek gettek added documentation Improvements or additions to documentation enhancement New feature or request labels Apr 19, 2023
@pmatthews05
Copy link
Contributor Author

@gettek I see you have added some tags and assigned to me. Is there anything else you require for me to do?

@gettek
Copy link
Owner

gettek commented Apr 20, 2023

@pmatthews05 looking forward to merge this but made a few comments above if you wouldn't mind resolving first please?

@pmatthews05
Copy link
Contributor Author

@gettek are the comments you referring to the following?

Could you kindly update your branch with the changes made in #73, have finally caved into running terraform fmt on all modules since noticing this PR, have also modified the existing pre-commit script so we can remove format-terraform.ps1

If so, I have updated my code with the changes made in #73, and removed format-terraform.ps1. You should se the 5 commits I made after that comment to complete what you requested.

If it's something else, please let me know.

@gettek
Copy link
Owner

gettek commented Apr 20, 2023

@pmatthews05 if you scroll through the file changes (or above) I have made a few more comments for minor changes 🙂

@pmatthews05
Copy link
Contributor Author

@gettek I'm sorry, I've looked at file changes and there are no comments from you for minor changes. Do you mind re-listing them in a comment back to me please?

@gettek gettek removed their request for review April 21, 2023 08:09
modules/def_assignment/main.tf Outdated Show resolved Hide resolved
modules/definition/versions.tf Outdated Show resolved Hide resolved
modules/exemption/versions.tf Outdated Show resolved Hide resolved
modules/initiative/versions.tf Outdated Show resolved Hide resolved
modules/def_assignment/README.md Show resolved Hide resolved
modules/def_assignment/README.md Show resolved Hide resolved
modules/definition/README.md Show resolved Hide resolved
@gettek
Copy link
Owner

gettek commented Apr 21, 2023

@pmatthews05 apologies, forgot to hit the submit review button!

Copy link
Owner

@gettek gettek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pmatthews05 - Please fix the final comment and run precommit to update the readme's back to the old tf versioning

modules/def_assignment/main.tf Outdated Show resolved Hide resolved
@gettek gettek merged commit a4dd521 into gettek:main Apr 21, 2023
1 check failed
@gettek gettek changed the title Stop remediation happening on policies where the assignment_enforcement_mode is set to false. Prevent remediation when assignment_enforcement_mode=false Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants