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

Update azurerm_policy_set_definition - Support policy_definition_reference_id #7018

Merged
merged 4 commits into from
Jul 10, 2020

Conversation

ArcturusZhang
Copy link
Contributor

@ArcturusZhang ArcturusZhang commented May 20, 2020

  1. Upgrade api-version of policy from 2018-05-01 to 2019-09-01, fixed the compile errors and runtime type conversion errors.
  2. Update all the error messages in the policy service
  3. Deprecate policy_definitions in resource and data source azurerm_policy_set_definition and replaced with policy_definition_reference block which introduces policy_definition_reference_id (Fixes azurerm_policy_set_definition does not set policyDefinitionReferenceId #6843 )

@ArcturusZhang ArcturusZhang changed the title Update azurerm_policy_assignment, azurerm_policy_definition, azurerm_policy_set_definition, azurerm_policy_remediation Update azurerm_policy_assignment, azurerm_policy_definition, azurerm_policy_set_definition, azurerm_policy_remediation - Update policy api-version from 2018-05-01 to 2019-09-01 May 20, 2020
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.

@ArcturusZhang - i don't see any tests for the new properties?

@ArcturusZhang
Copy link
Contributor Author

ArcturusZhang commented May 27, 2020

Hi @katbyte there is a new block policy_definition_reference added to azurerm_policy_set_definition to replace the policy_definitions, therefore I have renamed all the old tests in policy_set_definition_resource_test.go by appending a Deprecated, and introduced some new test cases with the old name (using the new block policy_definition_reference), for instance, here

@ghost ghost added size/XL and removed size/XXL labels Jun 9, 2020
@ArcturusZhang ArcturusZhang changed the title Update azurerm_policy_assignment, azurerm_policy_definition, azurerm_policy_set_definition, azurerm_policy_remediation - Update policy api-version from 2018-05-01 to 2019-09-01 Update azurerm_policy_set_definition - Support policy_definition_reference_id Jun 10, 2020
Copy link
Member

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

@ArcturusZhang good catch on the additional error handling.

I'm getting failures with the ...Deprecated tests with the policy_definitions attribute:

policy_definitions: "[{\"parameters\":{\"listOfAllowedLocations\":{\"value\":\"[parameters('allowedLocations')]\"}},\"policyDefinitionId\":\"/providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988\",\"policyDefinitionReferenceId\":\"15086293629187003799\"}]" => " [\n {\n \"parameters\": {\n \"listOfAllowedLocations\": {\n \"value\": \"[parameters('allowedLocations')]\"\n }\n },\n \"policyDefinitionId\": \"/providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988\"\n }\n ]\n"

Also it looks like a rebase onto master is needed.

@ArcturusZhang
Copy link
Contributor Author

Hi @manicminer thanks for your review! I have merged master back to this branch, and on my local machine, all the tests are passing. Please have a look again

=== RUN   TestAccAzureRMPolicySetDefinition_builtInDeprecated
=== PAUSE TestAccAzureRMPolicySetDefinition_builtInDeprecated
=== CONT  TestAccAzureRMPolicySetDefinition_builtInDeprecated
--- PASS: TestAccAzureRMPolicySetDefinition_builtInDeprecated (129.04s)
=== RUN   TestAccAzureRMPolicySetDefinition_builtIn
=== PAUSE TestAccAzureRMPolicySetDefinition_builtIn
=== CONT  TestAccAzureRMPolicySetDefinition_builtIn
--- PASS: TestAccAzureRMPolicySetDefinition_builtIn (125.58s)
=== RUN   TestAccAzureRMPolicySetDefinition_requiresImport
=== PAUSE TestAccAzureRMPolicySetDefinition_requiresImport
=== CONT  TestAccAzureRMPolicySetDefinition_requiresImport
--- PASS: TestAccAzureRMPolicySetDefinition_requiresImport (134.04s)
=== RUN   TestAccAzureRMPolicySetDefinition_customDeprecated
=== PAUSE TestAccAzureRMPolicySetDefinition_customDeprecated
=== CONT  TestAccAzureRMPolicySetDefinition_customDeprecated
--- PASS: TestAccAzureRMPolicySetDefinition_customDeprecated (221.31s)
=== RUN   TestAccAzureRMPolicySetDefinition_custom
=== PAUSE TestAccAzureRMPolicySetDefinition_custom
=== CONT  TestAccAzureRMPolicySetDefinition_custom
--- PASS: TestAccAzureRMPolicySetDefinition_custom (219.19s)
=== RUN   TestAccAzureRMPolicySetDefinition_customWithPolicyReferenceID
=== PAUSE TestAccAzureRMPolicySetDefinition_customWithPolicyReferenceID
=== CONT  TestAccAzureRMPolicySetDefinition_customWithPolicyReferenceID
--- PASS: TestAccAzureRMPolicySetDefinition_customWithPolicyReferenceID (219.35s)
=== RUN   TestAccAzureRMPolicySetDefinition_managementGroupDeprecated
=== PAUSE TestAccAzureRMPolicySetDefinition_managementGroupDeprecated
=== CONT  TestAccAzureRMPolicySetDefinition_managementGroupDeprecated
--- PASS: TestAccAzureRMPolicySetDefinition_managementGroupDeprecated (213.57s)
=== RUN   TestAccAzureRMPolicySetDefinition_managementGroup
=== PAUSE TestAccAzureRMPolicySetDefinition_managementGroup
=== CONT  TestAccAzureRMPolicySetDefinition_managementGroup
--- PASS: TestAccAzureRMPolicySetDefinition_managementGroup (203.78s)
=== RUN   TestAccAzureRMPolicySetDefinition_metadataDeprecated
=== PAUSE TestAccAzureRMPolicySetDefinition_metadataDeprecated
=== CONT  TestAccAzureRMPolicySetDefinition_metadataDeprecated
--- PASS: TestAccAzureRMPolicySetDefinition_metadataDeprecated (129.81s)
=== RUN   TestAccAzureRMPolicySetDefinition_metadata
=== PAUSE TestAccAzureRMPolicySetDefinition_metadata
=== CONT  TestAccAzureRMPolicySetDefinition_metadata
--- PASS: TestAccAzureRMPolicySetDefinition_metadata (128.81s)
PASS

Copy link
Member

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

@ArcturusZhang test coverage looks good and they are now passing

Screenshot 2020-07-10 15 30 17

@manicminer manicminer added this to the v2.19.0 milestone Jul 10, 2020
@manicminer manicminer merged commit ddae6c9 into hashicorp:master Jul 10, 2020
manicminer added a commit that referenced this pull request Jul 10, 2020
@ArcturusZhang ArcturusZhang deleted the update-policy-api-version branch July 11, 2020 05:07
@ghost
Copy link

ghost commented Jul 16, 2020

This has been released in version 2.19.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.19.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Aug 9, 2020

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 Aug 9, 2020
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.

azurerm_policy_set_definition does not set policyDefinitionReferenceId
3 participants