Skip to content

fix: Use "virtual_machine_id" for instance identity with Azure #3355

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

Merged
merged 1 commit into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions provisioner/terraform/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ func applyAutomaticInstanceID(resource *tfjson.StateResource, agents []*proto.Ag
key, isValid := map[string]string{
"google_compute_instance": "instance_id",
"aws_instance": "id",
"azurerm_linux_virtual_machine": "id",
"azurerm_windows_virtual_machine": "id",
"azurerm_linux_virtual_machine": "virtual_machine_id",
"azurerm_windows_virtual_machine": "virtual_machine_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'm actually using azurerm_virtual_machine in the example template because azurerm_linux_virtual_machine doesn't support attaching the data disk before booting, meaning I can't format it in cloud-init

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh, I'll add that as a resource as well.

Copy link
Member Author

@kylecarbs kylecarbs Aug 3, 2022

Choose a reason for hiding this comment

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

Spike discovered that the deprecated azurerm_virtual_machine resource exposes the machine ID.

}[resource.Type]
if !isValid {
return
Expand Down
4 changes: 2 additions & 2 deletions provisioner/terraform/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,11 @@ func TestInstanceIDAssociation(t *testing.T) {
}, {
Auth: "azure-instance-identity",
ResourceType: "azurerm_linux_virtual_machine",
InstanceIDKey: "id",
InstanceIDKey: "virtual_machine_id",
}, {
Auth: "azure-instance-identity",
ResourceType: "azurerm_windows_virtual_machine",
InstanceIDKey: "id",
InstanceIDKey: "virtual_machine_id",
}} {
tc := tc
t.Run(tc.ResourceType, func(t *testing.T) {
Expand Down