-
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
ability to tag OS disk in azurerm_linux_virtual_machine/azurerm_windows_virtual_machine #8162
Comments
Hi @kasenna thanks for this issue! The VM API does create a managed disk resource on Azure when you are assigning this |
Thank you for the quick response,
We're using tags to identify what project/service line the azure resource
belongs to and using this information to calculate how much money we spend
on each project.
And yes we definitely can assign tags to OS disk after VM being built,
assign manually or with some script, but we would like to assign it with
terraform so we don't have to perform extra steps, if it makes sense.
…On Tue, Aug 18, 2020, 23:04 Arcturus ***@***.***> wrote:
Hi @kasenna <https://github.com/kasenna> thanks for this issue!
The VM API does create a managed disk resource on Azure when you are
assigning this os_disk block, but the VM API does not support creating a
OS Disk with tags on. You will have to assign those tags to the disk
resource after the VM is created. Usually we do not manage the disk created
by the VM ourselves, and we do not expose the disk id created by the VM.
Could you explain your usage scenario of this feature requirement?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8162 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKSFDC5YM336O64IMKTCFLSBNFLTANCNFSM4QD35N5A>
.
|
Since the duplicate has been closed, kindly see my analysis and possible workaround |
@jpbuecken thanks for the suggestions in that issue, but that's a different ask to this issue - which is for the VM resource to manage the tags for the OS Disk directly (#8195 is tracking support for an existing OS Disk) |
thank you for the answer, |
@kasenna indeed, we've got several use-cases within the new VM resources where we call out to the Managed Disks API - so this is the approach we'd take here. At this point the larger question is how folks would expect this field to behave, presumably this wants to be Optional & Computed - meaning that if you don't specify the field, we'll use whatever values exist (e.g. don't update them) - but if you do we'll apply those tags; which allows folks who are interested in managing tags within this resource to manage them here or using the separate resource - but not both. However it's worth having a few use-cases here to be sure this is the righr behaviour here, since these are popular resources :) |
thank you,
this means you are going to implement that feature?
anyway I appreciate your help
…On Mon, Aug 31, 2020, 08:07 Tom Harvey ***@***.***> wrote:
@kasenna <https://github.com/kasenna> indeed, we've got several use-cases
within the new VM resources where we call out to the Managed Disks API - so
this is the approach we'd take here.
At this point the larger question is how folks would expect this field to
behave, presumably this wants to be Optional & Computed - meaning that if
you don't specify the field, we'll use whatever values exist (e.g. don't
update them) - but if you do we'll apply those tags; which allows folks who
are interested in managing tags within this resource to manage them here or
using the separate resource - but not both. However it's worth having a few
use-cases here to be sure this is the righr behaviour here, since these are
popular resources :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8162 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKSFDGTH2JLOLJBA5YBQPTSDON77ANCNFSM4QD35N5A>
.
|
Another approach would be a root_volume_tags resource, |
@tombuildsstuff Are there already plans to implement this feature? We are struggling with this issue, because sometimes we need to change cost-related tags on VM and all related resources. After applying the changes via Terraform you have do manually change the tags at all of the root volumes because of this limitation, which causes additional efforts. |
Hi @tombuildsstuff, Are there any plans to implement the "workaround" mentioned above by using Managed Disk API calls? This is really a required feature to be able to tag the disks properly. |
I fell over this when I was trying to modify tags of the OS Disk, I was expecting them to update with the VM Tags (because that is where the OS Disk tags originate at creation). But they are not updated. As a workaround: |
I've just been caught out by this too. Updated some tags on the I will write some PowerShell or use the above to work around it but is there a plan to fix this? |
Wrote the following to update all OSDisks with tags, posting it here in case it helps anyone else
Any idea when this will be fixed? |
If the tags on the os disk are going to be created by using the tags on the VM, then it is very unexpected behavior that updating the tags on the VM does NOT update the tags on the OS disk... Just got caught by this when updating tags for budgets and owners of existing VMs :-( |
Can you leverage the new import feature of Terraform 1.5 for a real solution here https://developer.hashicorp.com/terraform/language/import // hashicorp/terraform#33153 ? |
This sadly does not work, the new import feature only works for resources that already exist prior to running your terraform, not for resources that get created during your terraform apply. |
I opened a case with Microsoft and they came up with a workaround by directly using the api via azapi provider
And if you also want to catch a configuration drift:
|
This is an issue for us, as well. I had naively assumed that the storage_os_disk and storage_data_disk(s) would inherit the same tags the azurerm_virtual_machine was defined with, but no such luck. |
@sshipway if you are a hashicorp/azure customer you can try to open up a support case to show them there is a customer demand for this, apart from this I do not see Azure changing their API to accommodate terraform -- so best scenario I see at the moment is the possibility to allow providers to import resources that get implicitly created. |
Thank you, this has worked perfecntly fine for me ! |
Just confirmed; When creating the VM from scratch and setting tags, they get nicely propagated to the OS disk. Thanks! |
Thanks! This is nice to have - but as a work-around it only suffices in cases where you are not managing the VM resource in the same module in which this code appears, or in cases where you are making incremental updates and don't care about being able to recreate your environment end-to-end "from scratch". This is because the data block involved will usually fail at plan time if the VM does not already exist. As such, it would be far better if the provider were to either propagate the VM tags to the os_disk on update in addition to on create (which it does already), or to give us a mechanism for managing the os_disk tags ourselves, or both - where the VM tags propagate consistently unless overridden by explicit os_disk tags. |
I am facing the same exact issue. Is there any ETA or TF target version for this feature request/fix? I am working on maintaining an environment and be able to propagate tags across all resources and I am not able to update the os_disk as part of these updates. I have to manually go an update the os disks each time. |
azapi v2 had a breaking change -- https://registry.terraform.io/providers/Azure/azapi/latest/docs/guides/2.0-upgrade-guide#breaking-changes now it looks like this:
And if you also want to catch a configuration drift:
|
Community Note
Description
Hi all,
Issue:
It is not possible to provide tags for OS disk in azurerm_linux_virtual_machine/azurerm_windows_virtual_machine resources,
os_disk
block does not have such support.How i see this new feature:
and
OS disk tags we need for pricing reports.
Community Note
Description
New or Affected Resource(s)
Potential Terraform Configuration
References
The text was updated successfully, but these errors were encountered: