Skip to content

New Rsource: azurerm_virtual_machine_scale_set_managed_disk - #32715

Draft
ziyeqf wants to merge 13 commits into
hashicorp:mainfrom
ziyeqf:managed_disk_vmss
Draft

New Rsource: azurerm_virtual_machine_scale_set_managed_disk#32715
ziyeqf wants to merge 13 commits into
hashicorp:mainfrom
ziyeqf:managed_disk_vmss

Conversation

@ziyeqf

@ziyeqf ziyeqf commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

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

add a new managed disk resource to support managed disk attached to VMSS.
The existing resource azurerm_managed_disk by design does not support disk attached to a VMSS. e.g.: some properties requires the disk to be detached when it's attached to VMSS, but requires restart when it's attached to a VM. accroding to the comment #25582 (comment), adding a new resource instead of implementing this kind of logic in the existing resource.

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)
in progress

Change Log

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

  • New Rsource: azurerm_virtual_machine_scale_set_managed_disk [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 #26651
Fixes #14617

AI Assistance Disclosure

  • AI Assisted - This contribution was made by, or with the assistance of, AI/LLMs

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.

@ziyeqf

ziyeqf commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

/test -b

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new Terraform resource (azurerm_virtual_machine_scale_set_managed_disk) intended to manage Azure Managed Disks that may be attached to Virtual Machine Scale Set (VMSS) instances, enabling updates that would otherwise fail with azurerm_managed_disk when a disk is attached to a VMSS VM.

Changes:

  • Adds the new azurerm_virtual_machine_scale_set_managed_disk resource implementation, including hot-detach/update/reattach logic for VMSS instance-attached disks.
  • Adds a corresponding list resource implementation and acceptance tests (including identity + “attached to VMSS instance” behavior coverage).
  • Adds docs + name validation helper for Managed Disk names and updates issue triage labeler patterns.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
website/docs/r/virtual_machine_scale_set_managed_disk.html.markdown New resource documentation for VMSS-managed disk behavior and arguments.
website/docs/list-resources/virtual_machine_scale_set_managed_disk.html.markdown Adds list-resource documentation for the new resource type.
internal/services/compute/virtual_machine_scale_set_managed_disk_resource.go Core resource implementation, including update-with-detach workflow.
internal/services/compute/virtual_machine_scale_set_managed_disk_resource_test.go Acceptance tests for basic/complete/update/validation behaviors.
internal/services/compute/virtual_machine_scale_set_managed_disk_resource_list.go List resource implementation for enumerating disks.
internal/services/compute/virtual_machine_scale_set_managed_disk_resource_list_test.go Acceptance test coverage for list/query behavior.
internal/services/compute/virtual_machine_scale_set_managed_disk_resource_identity_gen_test.go Generated acceptance test validating resource identity fields.
internal/services/compute/virtual_machine_scale_set_managed_disk_attached_resource_test.go Acceptance test proving hot-detach/update/reattach behavior when attached to a VMSS instance.
internal/services/compute/validate/managed_disk_name.go Adds Managed Disk name validation helper.
internal/services/compute/validate/managed_disk_name_test.go Unit tests for Managed Disk name validation.
internal/services/compute/resource_names.go Adds VirtualMachineScaleSetResourceName constant used for locking.
internal/services/compute/registration.go Registers the new resource and list resource with the compute service.
.github/labeler-issue-triage.yml Updates issue triage labeler to recognize the new resource name.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/services/compute/virtual_machine_scale_set_managed_disk_resource.go Outdated
@hc-github-team-tf-azure

This comment has been minimized.

@hc-github-team-tf-azure

This comment has been minimized.

@ziyeqf

ziyeqf commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

/test -b

@hc-github-team-tf-azure

This comment has been minimized.

@hc-github-team-tf-azure

This comment has been minimized.

@ziyeqf

ziyeqf commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

/test -b

@hc-github-team-tf-azure

This comment has been minimized.

@hc-github-team-tf-azure

This comment has been minimized.

@ziyeqf

ziyeqf commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

/test -b

@hc-github-team-tf-azure

Copy link
Copy Markdown
Collaborator

Build: 700107
PR: #32715

Total: 11
Passed: 11
Failed: 0
Test Duration: 0h 7m 35s

Test Details
StatusTest NameDuration
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_validationErrors48.846s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_list86.964s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_requiresImport141.181s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_resourceIdentity173.363s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_complete186.434s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_basic187.506s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_diskSizeCannotShrink188.76s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_ultraSSD231.962s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_update233.196s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_osTypeUpdate235.26s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_encryptionSettings314.249s

@hc-github-team-tf-azure

Copy link
Copy Markdown
Collaborator

Testing in Beta version enabled

Build: 700108
PR: #32715

Total: 12
Passed: 12
Failed: 0
Test Duration: 0h 16m 37s

Test Details
StatusTest NameDuration
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_validationErrors41.227s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_list78.089s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_requiresImport155.647s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_resourceIdentity170.067s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_complete179.927s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_basic180.492s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_diskSizeCannotShrink181.581s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_ultraSSD224.247s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_update228.572s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_osTypeUpdate228.953s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_encryptionSettings310.762s
✅ PASSTestAccVirtualMachineScaleSetManagedDisk_attachedToScaleSetInstanceResize326.937s

@ziyeqf
ziyeqf requested review from gerrytan and teowa and removed request for gerrytan July 6, 2026 05:41
@rcskosir rcskosir added new-resource new-virtual-resource Resources which are split out to enhance the user experience labels Jul 28, 2026
@ziyeqf

ziyeqf commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

/test


TeamCity build triggered:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

5 participants