Skip to content
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

[MS] Added support for custom images with VMSS + Managed Disks #203

Merged
merged 6 commits into from
Aug 2, 2017
Merged

[MS] Added support for custom images with VMSS + Managed Disks #203

merged 6 commits into from
Aug 2, 2017

Conversation

echuvyrov
Copy link
Contributor

Adding custom image support for virtual machine scale sets with managed disks

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

Hey @echuvyrov

Thanks for this PR - I've taken a look and left some comments inline, my main question is around the need for a state migration - but this is off to a good start :)

Thanks!

}
if image.ID != nil {
result["id"] = *image.ID
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a feeling it shouldn't - but does this change the hash? i.e. when having previously built a resource using the VMSS resource in master, then running terraform plan against this branch - are there any changes shown?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @tombuildsstuff thanks for a quick turnaround on this; I provisioned VMSS using TF v. 0.9.11, then ran terraform plan using my branch. Got the message

No changes. Infrastructure is up-to-date.

I believe this is expected behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome - thanks for checking/confirming that :)

}
if m["id"] != nil {
buf.WriteString(fmt.Sprintf("%s-", m["id"].(string)))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

(same as above - does this require a state migration?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(same as above) + I also ran a test where I created an Image resource and then set the id to point to that resource. Running terraform plan gave me the message

Plan: 3 to add, 0 to change, 1 to destroy.

which is also expected I believe (recreating VMSS).

Offer: &offer,
Sku: &sku,
Version: &version,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

tbh given this object is initialised above, we could we just assign these values here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

@@ -346,6 +346,27 @@ The following arguments are supported:

`storage_profile_image_reference` supports the following:

* `id` - (Optional) Specifies the ID of the (custom) image to use to create the virtual
machine scale set, for example:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd argue we might be better linking to an example for this, rather than having this in-line - what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I gave it a shot based on how I understood it - take a look and let me know if that's not what you had in mind.

Copy link
Contributor

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 - I was thinking more of linking to an example within the Examples directory on Github - but on reflection perhaps that's a future task once this has been merged, and this is fine for the moment?


resp, err := vmssClient.Get(resourceGroup, vmssName)
if err != nil {
return fmt.Errorf("Bad: Get on vmssClient: %s", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we make this formatting argument %+v to return the full error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

@@ -275,7 +275,7 @@ resource "azurerm_virtual_machine" "test" {
...

storage_image_reference {
image_id = "${azurerm_image.test.id}"
id = "${azurerm_image.test.id}"
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 good spot

@echuvyrov
Copy link
Contributor Author

echuvyrov commented Jul 31, 2017

Hey @tombuildsstuff I made the changes requested (hope I got them all right :)), reran the tests and checked in the code.

make testacc TESTARGS='-run=TestAccAzureRMVirtualMachineScaleSet_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run=TestAccAzureRMVirtualMachineScaleSet_basic -timeout 120m
?   	github.com/terraform-providers/terraform-provider-azurerm	[no test files]
=== RUN   TestAccAzureRMVirtualMachineScaleSet_basic
--- PASS: TestAccAzureRMVirtualMachineScaleSet_basic (451.08s)
=== RUN   TestAccAzureRMVirtualMachineScaleSet_basicLinux_managedDisk
--- PASS: TestAccAzureRMVirtualMachineScaleSet_basicLinux_managedDisk (316.75s)
=== RUN   TestAccAzureRMVirtualMachineScaleSet_basicLinux_managedDiskNoName
--- PASS: TestAccAzureRMVirtualMachineScaleSet_basicLinux_managedDiskNoName (336.32s)
=== RUN   TestAccAzureRMVirtualMachineScaleSet_basicLinux_disappears
--- PASS: TestAccAzureRMVirtualMachineScaleSet_basicLinux_disappears (415.10s)
PASS

make testacc TESTARGS='-run=TestAccAzureRMImageVMSS_customImageVMSSFromVHD'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run=TestAccAzureRMImageVMSS_customImageVMSSFromVHD -timeout 120m
?   	github.com/terraform-providers/terraform-provider-azurerm	[no test files]
=== RUN   TestAccAzureRMImageVMSS_customImageVMSSFromVHD
--- PASS: TestAccAzureRMImageVMSS_customImageVMSSFromVHD (810.90s)
PASS

"id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't it possible to change the image on a VMSS (and then either roll the VMSS instances automatically or manually)? As such, does this want to be without the ForceNew?

(same question for Publisher/Offer/Sku/Version)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right @tombuildsstuff the update operation should not force new VMSS. I have updated my code to reflect that.

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

Hey @echuvyrov

Thanks for pushing the latest changes - I've pushed a small commit to update the documentation for the publisher, offer, sku and product fields to be Optional to match the last change, but this otherwise LGTM :)

Thanks!

@tombuildsstuff tombuildsstuff merged commit 0cdc415 into hashicorp:master Aug 2, 2017
tombuildsstuff added a commit that referenced this pull request Aug 2, 2017
@ghost
Copy link

ghost commented Apr 1, 2020

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 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
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