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

assign policy to a managementgroup #2490

Merged

Conversation

lawrenae
Copy link
Contributor

This pull request adds the ability to optionally define a policy on a management group level. The existing functionality -- define on a subscription or resource group is still intact.

I've done so by adding management_group_id to azurerm_policy_definition. IE:

data "azurerm_management_group" "test" {
  group_id = "00000000-0000-0000-0000-000000000000"
}

resource "azurerm_policy_definition" "policy" {
  name         = "accTestPolicy"
  policy_type  = "Custom"
  mode         = "Indexed"
  display_name = "acceptance test policy definition"
  management_group_id = "${data.azurerm_management_group.test.id}"
...
}

btw, azurerm_policy_assignment will need no change to support this.

Feedback most welcome -- this is my first PR for the azurerm terraform provider

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @lawrenae

Thanks for this PR - apologies for the delayed review here!

I've taken a look through and left some comments inline but this mostly LGTM - if we can fix up the comments (and the tests pass) this should otherwise be good to merge 👍

Thanks!

azurerm/resource_arm_policy_definition.go Outdated Show resolved Hide resolved
azurerm/resource_arm_policy_definition.go Outdated Show resolved Hide resolved
azurerm/resource_arm_policy_definition.go Outdated Show resolved Hide resolved
azurerm/resource_arm_policy_definition_test.go Outdated Show resolved Hide resolved
azurerm/resource_arm_policy_definition_test.go Outdated Show resolved Hide resolved
website/docs/r/policy_definition.html.markdown Outdated Show resolved Hide resolved
azurerm/resource_arm_policy_definition.go Show resolved Hide resolved
azurerm/resource_arm_policy_definition_test.go Outdated Show resolved Hide resolved
* remove else
* update docs
* separate setup method for management group policies
* just pull management_group_id from the policy
* rename to getPolicyDefinition
* parse the managementgroupid from the id in deletes
@lawrenae
Copy link
Contributor Author

@tombuildsstuff I've incorporated the feedback -- let me know what you think!

@ghost ghost removed the waiting-response label Dec 27, 2018
@katbyte katbyte added this to the 1.21.0 milestone Dec 28, 2018
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks for the updates @lawrenae, LGTM 👍

@katbyte
Copy link
Collaborator

katbyte commented Dec 28, 2018

tests pass:
screen shot 2018-12-27 at 18 47 15

@katbyte katbyte merged commit 8e88e2e into hashicorp:master Dec 28, 2018
@lawrenae lawrenae deleted the feature/policy_mgmt_group_assignment branch December 28, 2018 16:11
@ghost
Copy link

ghost commented Mar 5, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants