-
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
New Resource: azurerm_virtual_machine_data_disk_attachment
#1207
Conversation
Great to see this - thanks @tombuildsstuff ! 👍 |
"azurerm_virtual_network_gateway": resourceArmVirtualNetworkGateway(), | ||
"azurerm_virtual_network_gateway_connection": resourceArmVirtualNetworkGatewayConnection(), | ||
"azurerm_virtual_network_peering": resourceArmVirtualNetworkPeering(), | ||
"azurerm_application_gateway": resourceArmApplicationGateway(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you change so many lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because one space is added to align with each other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on that note: you can use ?w=1
to ignore whitespace changes in reviews in Github, it's really handy for things like this :)
dataDisks := make([]compute.DataDisk, 0) | ||
for _, dataDisk := range disks { | ||
if !strings.EqualFold(*dataDisk.Name, *expandedDisk.Name) { | ||
disks = append(disks, dataDisk) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that dataDisks is never used since initialization. I guess you were using it store the left disks. Then I think you should do:
dataDisks = append(dataDisks, dataDisk)
105d2e1
to
957cb32
Compare
957cb32
to
54fd5b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some concerns of introducing multiples ways to do one thing. It might cause updating issues similar to azurerm_network_security_rule
.
We need to carefully think of it if we are not able to mitigate this kind of thing.
azurerm/disks.go
Outdated
"strings" | ||
) | ||
|
||
type UnmanagedDiskMetadata struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any rules on custom types, like should it always be public, and the naming convention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they should be private, however this is a WIP before refactoring (and placing this somewhere in helpers/
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(also, we tend to rely directly on the SDK Structs rather than composing them ourselves, since this is information which should be provided by the SDK but isn't at this point)
"azurerm_virtual_network_gateway": resourceArmVirtualNetworkGateway(), | ||
"azurerm_virtual_network_gateway_connection": resourceArmVirtualNetworkGatewayConnection(), | ||
"azurerm_virtual_network_peering": resourceArmVirtualNetworkPeering(), | ||
"azurerm_application_gateway": resourceArmApplicationGateway(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because one space is added to align with each other.
@JunyiYi indeed, this is why this is still WIP whilst I've been thinking about how's best to implement this/chatting internally about it. We should be keeping both resources actually - the After mulling on this for a while, I'm coming around to the idea of forcing users to create a separate managed disk ahead of time, which allows us to remove the
rather than this:
The outstanding question is how we'd achieve the same thing with unmanaged disks, which I'm looking into at the moment :) |
07fd1ab
to
ca4b335
Compare
dismissing stale review
46c0f7c
to
bf3598b
Compare
Excited to see this merged. :D |
azurerm_virtual_machine_data_disk_attachment
azurerm_virtual_machine_data_disk_attachment
azurerm_virtual_machine_data_disk_attachment
azurerm_virtual_machine_data_disk_attachment
I've been doing some initial exploratory testing against this and it seems ok, but it needs some more (in particular verifying disks created inline -> split out are handled as expected, which I'll pick up when I'm back). I've also pushed a WIP commit which should prevent disk attachments created using the independent resource from being impacted when changes are made to the parent VM resource which uses the value of the computed fields, but this needs additional testing. |
Hi @tombuildsstuff , Any chance this will get merged soon? Need any help testing? -Brandon |
👋 @rohrerb I've been out for a couple of weeks, so I've not been working on this; but I'm working through the edge-case testing at the moment and hope to finish that this week. That said - we're definitely interested to hear your feedback if you're able to test this :) Thanks! |
d239408
to
32953a0
Compare
azurerm_virtual_machine_data_disk_attachment
azurerm_virtual_machine_data_disk_attachment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @tombuildsstuff,
Outside a couple minor comments this LGTM 👍
Required: true, | ||
ForceNew: true, | ||
DiffSuppressFunc: ignoreCaseDiffSuppressFunc, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be validated with validate.ValidateResourceId
|
||
dataDisks := make([]compute.DataDisk, 0) | ||
for _, dataDisk := range *virtualMachine.StorageProfile.DataDisks { | ||
// since this field isn't (and shouldn't be) case-sensitive; we're deliberately not using `strings.Equals` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean strings.EqualFold()
@@ -1,7 +1,7 @@ | |||
--- | |||
layout: "azurerm" | |||
page_title: "Azure Resource Manager: azurerm_virtual_machine" | |||
sidebar_current: "docs-azurerm-resource-compute-virtual-machine" | |||
sidebar_current: "docs-azurerm-resource-compute-virtual-machine-x" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was the -x
supposed to be added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, there's an incorrect highlight on the sidebar at the moment
92c522e
to
ab9171f
Compare
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 👉 [email protected]. Thanks! |
This PR creates a new resource which can be used for attaching disks to Virtual Machine. The acceptance tests for this need some more thought and this needs some extensive testing, in general.
After spending a lot of time investigating/thinking about this - I've ended up adapting this resource such that it only supports attaching existing Managed Disks. This makes supporting this resource considerably simpler (since supporting creating new Managed Disks involves manipulating the
create_option
field); unfortunately it appears this approach isn't possible for Unmanaged Disks due to this bug - as such I've dropped support for Unmanaged Disks at this time.Fixes #795