Skip to content

azure_policy_set_definition - ForceNew when number of parameters is less than before#29866

Merged
sreallymatt merged 2 commits intohashicorp:mainfrom
stanleyz:feat/force-new-for-parameter-change-policy-set
Jul 17, 2025
Merged

azure_policy_set_definition - ForceNew when number of parameters is less than before#29866
sreallymatt merged 2 commits intohashicorp:mainfrom
stanleyz:feat/force-new-for-parameter-change-policy-set

Conversation

@stanleyz
Copy link
Contributor

@stanleyz stanleyz commented Jun 15, 2025

This is a replicate of #26083 from azurerm_policy_definition to azurerm_policy_set_definition

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevant documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • azurerm_resource - support for the thing1 property [GH-00000]

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

Fixes #0000

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the provider.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

relates to #26083

@stanleyz
Copy link
Contributor Author

anybody keen to review this please Thanks. maybe @stephybun

@stanleyz
Copy link
Contributor Author

or @mbfrahry can you please check this one? Thanks.

Copy link
Collaborator

@sreallymatt sreallymatt left a comment

Choose a reason for hiding this comment

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

Hi @stanleyz, I've recently migrated the azurerm_policy_set_definition resource from azure-sdk-for-go to go-azure-sdk which involved significant changes including splitting this resource into 2 separate ones. (PR #29863)

Could you rebase this PR on main, and see what is required to incorporate this change into the new structure of the resource(s)?

Note: policy_set_definition_resource.go now contains 2 implementations of this resource, the original untyped resource, and a typed resource implementation that will only be active once 5.0 has been released. The CustomizeDiff would have to be added to both, so unfortunately that will add a bit of extra work. Let me know if you're still interested in continuing on this, thanks!

@sreallymatt sreallymatt self-assigned this Jul 3, 2025
@stanleyz stanleyz force-pushed the feat/force-new-for-parameter-change-policy-set branch from 5d2b923 to f3dd61f Compare July 4, 2025 09:33
@stanleyz
Copy link
Contributor Author

stanleyz commented Jul 4, 2025

Thanks @sreallymatt for looking into this. I've rebased it.

However I don't see how the CustomDiff if any is passed to pluginsdk.Resource with the new management_group_policy_set_definition, is it via the DiffFunc in the Update function?

@sreallymatt
Copy link
Collaborator

sreallymatt commented Jul 4, 2025

Hi @stanleyz, for typed resources there is another layer on top of the Terraform Plugin SDK, to add a CustomizeDiff you'll need to implement the sdk.ResourceWithCustomizeDiff interface.

If you add _ sdk.ResourceWithCustomizeDiff = ManagementGroupPolicySetDefinitionResource{} as a var (just like sdk.ResourceWithUpdate here), most IDEs will be able to populate the appropriate method. An example of a typed resource with a CustomizeDiff can be found here

For a bit of background on typed resources and the typed SDK within this repository, you can reference the glossary in the contributing guides

less than before

This is a replicate of hashicorp#26083 from `azurerm_policy_definition` to
`azurerm_policy_set_definition`, the same is also applied to to the new
`azurerm_management_group_policy_set` resource
@stanleyz stanleyz force-pushed the feat/force-new-for-parameter-change-policy-set branch from f3dd61f to 6b3658a Compare July 5, 2025 09:41
@github-actions github-actions bot added the size/L label Jul 5, 2025
@stanleyz
Copy link
Contributor Author

stanleyz commented Jul 5, 2025

Thanks @sreallymatt for the direction. Of course, implement multiple interface, please take a look, let me know any other update you want. Thanks.

@stanleyz stanleyz requested a review from sreallymatt July 11, 2025 01:08
Copy link
Collaborator

@sreallymatt sreallymatt 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 making those changes @stanleyz, I've left a couple more comments if you wouldn't mind taking a look

Copy link
Collaborator

@sreallymatt sreallymatt left a comment

Choose a reason for hiding this comment

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

Thanks @stanleyz, this LGTM now! ✅

@sreallymatt
Copy link
Collaborator

Test results:

image

5.0 beta mode:
image

@sreallymatt sreallymatt merged commit 0c1050e into hashicorp:main Jul 17, 2025
36 checks passed
@github-actions github-actions bot added this to the v4.38.0 milestone Jul 17, 2025
@stanleyz
Copy link
Contributor Author

Thanks @sreallymatt

@stanleyz stanleyz deleted the feat/force-new-for-parameter-change-policy-set branch July 17, 2025 21:44
sreallymatt added a commit that referenced this pull request Jul 18, 2025
jackofallops pushed a commit that referenced this pull request Jul 30, 2025
@github-actions
Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2025
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.

2 participants