-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
New Resource: azurerm_policy_set_definition #2535
New Resource: azurerm_policy_set_definition #2535
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @olohmann,
Thank you for the new resource! Aside from a few (mostly minor) comments i've left inline this is looking pretty good. Once those issues have been addressed look forward to getting this merged for you 🙂
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
@katbyte - thanks so much for that quick and helpful review! Applied requested changes and ran acceptance tests again. > $ make testacc TESTARGS='-run=TestAccAzureRMPolicySetDefinition'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run=TestAccAzureRMPolicySetDefinition -timeout 180m -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc"
? github.com/terraform-providers/terraform-provider-azurerm [no test files]
=== RUN TestAccAzureRMPolicySetDefinition_basic
=== PAUSE TestAccAzureRMPolicySetDefinition_basic
=== CONT TestAccAzureRMPolicySetDefinition_basic
--- PASS: TestAccAzureRMPolicySetDefinition_basic (111.78s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @olohmann
Thanks for pushing those changes - I've taken a look through and left some minor comments in line but this is otherwise looking good; if we can fix those up (and add an extra test case) we should be able to get this merged 👍
Thanks!
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
Co-Authored-By: olohmann <[email protected]>
…erraform-provider-azurerm into azurerm_policy_set_definition
@tombuildsstuff - cheers for the review! Added requested changes. Acceptance test results: > $ make testacc TESTARGS='-run=TestAccAzureRMPolicySetDefinition'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run=TestAccAzureRMPolicySetDefinition -timeout 180m -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc"
? github.com/terraform-providers/terraform-provider-azurerm [no test files]
=== RUN TestAccAzureRMPolicySetDefinition_built_in_policy
=== PAUSE TestAccAzureRMPolicySetDefinition_built_in_policy
=== RUN TestAccAzureRMPolicySetDefinition_custom_policy
=== PAUSE TestAccAzureRMPolicySetDefinition_custom_policy
=== CONT TestAccAzureRMPolicySetDefinition_built_in_policy
=== CONT TestAccAzureRMPolicySetDefinition_custom_policy
--- PASS: TestAccAzureRMPolicySetDefinition_built_in_policy (111.13s)
--- PASS: TestAccAzureRMPolicySetDefinition_custom_policy (202.65s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @olohmann
Thanks for pushing those changes - aside from a few minor comments (which I'll push a commit to fix) this otherwise LGTM 👍
Thanks!
"github.com/hashicorp/terraform/helper/resource" | ||
) | ||
|
||
func TestAccAzureRMPolicySetDefinition_built_in_policy(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func TestAccAzureRMPolicySetDefinition_built_in_policy(t *testing.T) { | |
func TestAccAzureRMPolicySetDefinition_builtIn(t *testing.T) { |
}) | ||
} | ||
|
||
func TestAccAzureRMPolicySetDefinition_custom_policy(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func TestAccAzureRMPolicySetDefinition_custom_policy(t *testing.T) { | |
func TestAccAzureRMPolicySetDefinition_custom(t *testing.T) { |
CheckDestroy: testCheckAzureRMPolicySetDefinitionDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAzureRMPolicySetDefinition_built_in_policy(ri), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config: testAzureRMPolicySetDefinition_built_in_policy(ri), | |
Config: testAzureRMPolicySetDefinition_builtIn(ri), |
CheckDestroy: testCheckAzureRMPolicySetDefinitionDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAzureRMPolicySetDefinition_custom_policy(ri), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config: testAzureRMPolicySetDefinition_custom_policy(ri), | |
Config: testAzureRMPolicySetDefinition_custom(ri), |
}) | ||
} | ||
|
||
func testAzureRMPolicySetDefinition_built_in_policy(ri int) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func testAzureRMPolicySetDefinition_built_in_policy(ri int) string { | |
func testAzureRMPolicySetDefinition_builtIn(ri int) string { |
`, ri, ri) | ||
} | ||
|
||
func testAzureRMPolicySetDefinition_custom_policy(ri int) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func testAzureRMPolicySetDefinition_custom_policy(ri int) string { | |
func testAzureRMPolicySetDefinition_custom(ri int) string { |
ValidateFunc: validation.StringInSlice([]string{ | ||
string(policy.TypeBuiltIn), | ||
string(policy.TypeCustom), | ||
string(policy.TypeNotSpecified), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove NotSpecified
here
string(policy.TypeNotSpecified), |
d.Set("name", resp.Name) | ||
|
||
if props := resp.SetDefinitionProperties; props != nil { | ||
d.Set("policy_type", props.PolicyType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is returned as an Enum rather than a string, it's best to cast this to a string explicitly here:
d.Set("policy_type", props.PolicyType) | |
d.Set("policy_type", string(props.PolicyType)) |
|
||
* `name` - (Required) The name of the policy set definition. Changing this forces a new resource to be created. | ||
|
||
* `policy_type` - (Required) The policy set type. The value can be `BuiltIn`, `Custom` or `NotSpecified` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We tend to phrase this as:
* `policy_type` - (Required) The policy set type. The value can be `BuiltIn`, `Custom` or `NotSpecified` | |
* `policy_type` - (Required) The policy set type. Possible values are `BuiltIn` or `Custom`. Changing this forces a new resource to be created. |
(note I've removed NotSpecified
since I don't believe we need to support it)
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 👉 [email protected]. Thanks! |
This PR adds support for a new resource: Policy Set Definitions (aka Policy Initiatives).
Addresses issue #2193
Test Results:
(fixed #2193)