hashicorp / terraform-provider-vsphere

Terraform Provider for VMware vSphere
https://registry.terraform.io/providers/hashicorp/vsphere/
Mozilla Public License 2.0
609 stars 449 forks source link

Add support for shutdown or start VM #2234

Open ggjulio opened 5 days ago

ggjulio commented 5 days ago

Community Guidelines

Description

See the description of closed issue #1394.

However unlike the proposal of #1394. I think creating a new resource vsphere_virtual_machine_state would be more appropriate than adding a new key desired_status to vsphere_virtual_machine. It won't blur the lines between mutable vs. immutable infrastructure.

Example 1:

resource "vsphere_virtual_machine_state" "main" {
  uuid  = vsphere_virtual_machine_state.main.uuid
  state = data.coder_workspace.me.transition == "start" ? "running" : "stopped"
}

Example 2:

resource "vsphere_virtual_machine_state" "main" {
  name           = vsphere_virtual_machine_state.main.name
  datacenter_id  = data.vsphere_datacenter.datacenter.id
  state          = data.coder_workspace.me.transition == "start" ? "running" : "stopped"
}

Use Case(s)

Provide ability to start and stop a virtual machine from terraform. Feature parity with providers such as AWS

example image Source: https://registry.coder.com/templates/aws-linux

Potential Terraform Provider Configuration

No response

References

1394 #1533 #1394

github-actions[bot] commented 5 days ago

Hello, ggjulio! 🖐

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.