Skip to content

azurerm_subnet - add support for sharing_scope#30600

Merged
mbfrahry merged 6 commits intohashicorp:mainfrom
ms-zhenhua:subnet-sharingscope-33555599
Sep 15, 2025
Merged

azurerm_subnet - add support for sharing_scope#30600
mbfrahry merged 6 commits intohashicorp:mainfrom
ms-zhenhua:subnet-sharingscope-33555599

Conversation

@ms-zhenhua
Copy link
Collaborator

@ms-zhenhua ms-zhenhua commented Sep 11, 2025

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

re-submit PR for PR 30316. Changes are:

  1. The code, test and property doc description are the same with PR 30316.
  2. Remove the limitation description from the Notes doc

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)
image

Change Log

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

  • azurerm_subnet - support sharing_scope property

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.

@magodo magodo self-assigned this Sep 11, 2025
@magodo
Copy link
Collaborator

magodo commented Sep 11, 2025

Other than the document, this PR LGTM!

Tests are passing:

image

Copy link
Member

@mbfrahry mbfrahry 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 opening this PR. Just a few comments but it looks good otherwise

Type: pluginsdk.TypeString,
Optional: true,
// now only "Tenant" is supported, "DelegatedServices" is not supported, https://github.com/Azure/azure-rest-api-specs/issues/36446
ValidateFunc: validation.StringInSlice([]string{"Tenant"}, false),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ValidateFunc: validation.StringInSlice([]string{"Tenant"}, false),
ValidateFunc: validation.StringInSlice([]string{subnets.SharingScopeTenant}, false),

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated. Thanks.

serviceEndpointsRaw := d.Get("service_endpoints").(*pluginsdk.Set).List()
properties.ServiceEndpoints = expandSubnetServiceEndpoints(serviceEndpointsRaw)

properties.SharingScope = pointer.To(subnets.SharingScope(d.Get("sharing_scope").(string)))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
properties.SharingScope = pointer.To(subnets.SharingScope(d.Get("sharing_scope").(string)))
properties.SharingScope = pointer.ToEnum[subnets.SharingScope](d.Get("sharing_scope").(string))

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since Go generic currently can't infer the type from the LHS in an assignment statement, we have to explicitly specify the generic type as above. Wondering what is the benefit of using the ToEnum comparing to the To..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated. Thanks.


* `sharing_scope` - (Optional) The sharing scope of the subnet. Possible value is `Tenant`. This property cannot be set if `default_outbound_access_enabled` is set to `true`.

!> **Note:** The `sharing_scope` property is only available to users who have been explicitly registered and granted access by the Azure Networking Product Group.
Copy link
Member

Choose a reason for hiding this comment

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

I believe this note is unneeded

Suggested change
!> **Note:** The `sharing_scope` property is only available to users who have been explicitly registered and granted access by the Azure Networking Product Group.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated. Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

Apologies for the back and forth. This line is needed here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No worries. Added back.


-> **Note:** When configuring Azure Private Link service, the explicit setting `private_link_service_network_policies_enabled` must be set to `false` in the subnet since Private Link Service does not support network policies like user-defined Routes and Network Security Groups. This setting only affects the Private Link service. For other resources in the subnet, access is controlled based on the Network Security Group which can be configured using the `azurerm_subnet_network_security_group_association` resource. See more details from [Manage network policies for Private Link Services](https://learn.microsoft.com/en-gb/azure/private-link/disable-private-link-service-network-policy?tabs=private-link-network-policy-powershell).

* `sharing_scope` - (Optional) The sharing scope of the subnet. Possible value is `Tenant`. This property cannot be set if `default_outbound_access_enabled` is set to `true`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* `sharing_scope` - (Optional) The sharing scope of the subnet. Possible value is `Tenant`. This property cannot be set if `default_outbound_access_enabled` is set to `true`.
* `sharing_scope` - (Optional) The sharing scope of the subnet. Possible value is `Tenant`.
~> **Note:** This property cannot be set if `default_outbound_access_enabled` is set to `true`.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated. Thanks.

})
}

func TestAccSubnet_sharingScope(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

This test can be removed as it's captured by TestAccSubnet_sharingScopeUpdated

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated. Thanks

"sharing_scope": {
Type: pluginsdk.TypeString,
Optional: true,
// now only "Tenant" is supported, "DelegatedServices" is not supported, https://github.com/Azure/azure-rest-api-specs/issues/36446
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// now only "Tenant" is supported, "DelegatedServices" is not supported, https://github.com/Azure/azure-rest-api-specs/issues/36446
// todo "Tenant" is only supported until https://github.com/Azure/azure-rest-api-specs/issues/36446 is addressed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated. Thanks.

@ms-zhenhua
Copy link
Collaborator Author

Hi @mbfrahry , thanks for the review. I have updated the code and doc. Kindly help take another look.

image

@ms-zhenhua
Copy link
Collaborator Author

Hi @mbfrahry, I have added the Note back. Kindly take another review.

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

LGTM!

@mbfrahry mbfrahry added this to the v4.45.0 milestone Sep 15, 2025
@mbfrahry mbfrahry changed the title azurerm_subnet - support sharing_scope property azurerm_subnet - add support for sharing_scope Sep 15, 2025
@mbfrahry mbfrahry merged commit 8c78c9f into hashicorp:main Sep 15, 2025
35 checks passed
@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 Oct 16, 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.

3 participants