1. Packages
  2. Vsphere Provider
  3. API Docs
  4. VirtualMachineSnapshot
vSphere v4.13.1 published on Wednesday, Feb 5, 2025 by Pulumi

vsphere.VirtualMachineSnapshot

Explore with Pulumi AI

The vsphere.VirtualMachineSnapshot resource can be used to manage snapshots for a virtual machine.

For more information on managing snapshots and how they work in VMware, see here.

NOTE: A snapshot in VMware differs from traditional disk snapshots, and can contain the actual running state of the virtual machine, data for all disks that have not been set to be independent from the snapshot (including ones that have been attached via the attach parameter to the vsphere.VirtualMachine disk block), and even the configuration of the virtual machine at the time of the snapshot. Virtual machine, disk activity, and configuration changes post-snapshot are not included in the original state. Use this resource with care! Neither VMware nor HashiCorp recommends retaining snapshots for a extended period of time and does NOT recommend using them as as backup feature. For more information on the limitation of virtual machine snapshots, see here.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";

const demo1 = new vsphere.VirtualMachineSnapshot("demo1", {
    virtualMachineUuid: "9aac5551-a351-4158-8c5c-15a71e8ec5c9",
    snapshotName: "Snapshot Name",
    description: "This is Demo Snapshot",
    memory: true,
    quiesce: true,
    removeChildren: false,
    consolidate: true,
});
Copy
import pulumi
import pulumi_vsphere as vsphere

demo1 = vsphere.VirtualMachineSnapshot("demo1",
    virtual_machine_uuid="9aac5551-a351-4158-8c5c-15a71e8ec5c9",
    snapshot_name="Snapshot Name",
    description="This is Demo Snapshot",
    memory=True,
    quiesce=True,
    remove_children=False,
    consolidate=True)
Copy
package main

import (
	"github.com/pulumi/pulumi-vsphere/sdk/v4/go/vsphere"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := vsphere.NewVirtualMachineSnapshot(ctx, "demo1", &vsphere.VirtualMachineSnapshotArgs{
			VirtualMachineUuid: pulumi.String("9aac5551-a351-4158-8c5c-15a71e8ec5c9"),
			SnapshotName:       pulumi.String("Snapshot Name"),
			Description:        pulumi.String("This is Demo Snapshot"),
			Memory:             pulumi.Bool(true),
			Quiesce:            pulumi.Bool(true),
			RemoveChildren:     pulumi.Bool(false),
			Consolidate:        pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using VSphere = Pulumi.VSphere;

return await Deployment.RunAsync(() => 
{
    var demo1 = new VSphere.VirtualMachineSnapshot("demo1", new()
    {
        VirtualMachineUuid = "9aac5551-a351-4158-8c5c-15a71e8ec5c9",
        SnapshotName = "Snapshot Name",
        Description = "This is Demo Snapshot",
        Memory = true,
        Quiesce = true,
        RemoveChildren = false,
        Consolidate = true,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vsphere.VirtualMachineSnapshot;
import com.pulumi.vsphere.VirtualMachineSnapshotArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var demo1 = new VirtualMachineSnapshot("demo1", VirtualMachineSnapshotArgs.builder()
            .virtualMachineUuid("9aac5551-a351-4158-8c5c-15a71e8ec5c9")
            .snapshotName("Snapshot Name")
            .description("This is Demo Snapshot")
            .memory("true")
            .quiesce("true")
            .removeChildren("false")
            .consolidate("true")
            .build());

    }
}
Copy
resources:
  demo1:
    type: vsphere:VirtualMachineSnapshot
    properties:
      virtualMachineUuid: 9aac5551-a351-4158-8c5c-15a71e8ec5c9
      snapshotName: Snapshot Name
      description: This is Demo Snapshot
      memory: 'true'
      quiesce: 'true'
      removeChildren: 'false'
      consolidate: 'true'
Copy

Create VirtualMachineSnapshot Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new VirtualMachineSnapshot(name: string, args: VirtualMachineSnapshotArgs, opts?: CustomResourceOptions);
@overload
def VirtualMachineSnapshot(resource_name: str,
                           args: VirtualMachineSnapshotArgs,
                           opts: Optional[ResourceOptions] = None)

@overload
def VirtualMachineSnapshot(resource_name: str,
                           opts: Optional[ResourceOptions] = None,
                           description: Optional[str] = None,
                           memory: Optional[bool] = None,
                           quiesce: Optional[bool] = None,
                           snapshot_name: Optional[str] = None,
                           virtual_machine_uuid: Optional[str] = None,
                           consolidate: Optional[bool] = None,
                           remove_children: Optional[bool] = None)
func NewVirtualMachineSnapshot(ctx *Context, name string, args VirtualMachineSnapshotArgs, opts ...ResourceOption) (*VirtualMachineSnapshot, error)
public VirtualMachineSnapshot(string name, VirtualMachineSnapshotArgs args, CustomResourceOptions? opts = null)
public VirtualMachineSnapshot(String name, VirtualMachineSnapshotArgs args)
public VirtualMachineSnapshot(String name, VirtualMachineSnapshotArgs args, CustomResourceOptions options)
type: vsphere:VirtualMachineSnapshot
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. VirtualMachineSnapshotArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. VirtualMachineSnapshotArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. VirtualMachineSnapshotArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. VirtualMachineSnapshotArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. VirtualMachineSnapshotArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var virtualMachineSnapshotResource = new VSphere.VirtualMachineSnapshot("virtualMachineSnapshotResource", new()
{
    Description = "string",
    Memory = false,
    Quiesce = false,
    SnapshotName = "string",
    VirtualMachineUuid = "string",
    Consolidate = false,
    RemoveChildren = false,
});
Copy
example, err := vsphere.NewVirtualMachineSnapshot(ctx, "virtualMachineSnapshotResource", &vsphere.VirtualMachineSnapshotArgs{
	Description:        pulumi.String("string"),
	Memory:             pulumi.Bool(false),
	Quiesce:            pulumi.Bool(false),
	SnapshotName:       pulumi.String("string"),
	VirtualMachineUuid: pulumi.String("string"),
	Consolidate:        pulumi.Bool(false),
	RemoveChildren:     pulumi.Bool(false),
})
Copy
var virtualMachineSnapshotResource = new VirtualMachineSnapshot("virtualMachineSnapshotResource", VirtualMachineSnapshotArgs.builder()
    .description("string")
    .memory(false)
    .quiesce(false)
    .snapshotName("string")
    .virtualMachineUuid("string")
    .consolidate(false)
    .removeChildren(false)
    .build());
Copy
virtual_machine_snapshot_resource = vsphere.VirtualMachineSnapshot("virtualMachineSnapshotResource",
    description="string",
    memory=False,
    quiesce=False,
    snapshot_name="string",
    virtual_machine_uuid="string",
    consolidate=False,
    remove_children=False)
Copy
const virtualMachineSnapshotResource = new vsphere.VirtualMachineSnapshot("virtualMachineSnapshotResource", {
    description: "string",
    memory: false,
    quiesce: false,
    snapshotName: "string",
    virtualMachineUuid: "string",
    consolidate: false,
    removeChildren: false,
});
Copy
type: vsphere:VirtualMachineSnapshot
properties:
    consolidate: false
    description: string
    memory: false
    quiesce: false
    removeChildren: false
    snapshotName: string
    virtualMachineUuid: string
Copy

VirtualMachineSnapshot Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The VirtualMachineSnapshot resource accepts the following input properties:

Description
This property is required.
Changes to this property will trigger replacement.
string
A description for the snapshot.
Memory
This property is required.
Changes to this property will trigger replacement.
bool
If set to true, a dump of the internal state of the virtual machine is included in the snapshot.
Quiesce
This property is required.
Changes to this property will trigger replacement.
bool
If set to true, and the virtual machine is powered on when the snapshot is taken, VMware Tools is used to quiesce the file system in the virtual machine.
SnapshotName
This property is required.
Changes to this property will trigger replacement.
string
The name of the snapshot.
VirtualMachineUuid
This property is required.
Changes to this property will trigger replacement.
string
The virtual machine UUID.
Consolidate Changes to this property will trigger replacement. bool
If set to true, the delta disks involved in this snapshot will be consolidated into the parent when this resource is destroyed.
RemoveChildren Changes to this property will trigger replacement. bool
If set to true, the entire snapshot subtree is removed when this resource is destroyed.
Description
This property is required.
Changes to this property will trigger replacement.
string
A description for the snapshot.
Memory
This property is required.
Changes to this property will trigger replacement.
bool
If set to true, a dump of the internal state of the virtual machine is included in the snapshot.
Quiesce
This property is required.
Changes to this property will trigger replacement.
bool
If set to true, and the virtual machine is powered on when the snapshot is taken, VMware Tools is used to quiesce the file system in the virtual machine.
SnapshotName
This property is required.
Changes to this property will trigger replacement.
string
The name of the snapshot.
VirtualMachineUuid
This property is required.
Changes to this property will trigger replacement.
string
The virtual machine UUID.
Consolidate Changes to this property will trigger replacement. bool
If set to true, the delta disks involved in this snapshot will be consolidated into the parent when this resource is destroyed.
RemoveChildren Changes to this property will trigger replacement. bool
If set to true, the entire snapshot subtree is removed when this resource is destroyed.
description
This property is required.
Changes to this property will trigger replacement.
String
A description for the snapshot.
memory
This property is required.
Changes to this property will trigger replacement.
Boolean
If set to true, a dump of the internal state of the virtual machine is included in the snapshot.
quiesce
This property is required.
Changes to this property will trigger replacement.
Boolean
If set to true, and the virtual machine is powered on when the snapshot is taken, VMware Tools is used to quiesce the file system in the virtual machine.
snapshotName
This property is required.
Changes to this property will trigger replacement.
String
The name of the snapshot.
virtualMachineUuid
This property is required.
Changes to this property will trigger replacement.
String
The virtual machine UUID.
consolidate Changes to this property will trigger replacement. Boolean
If set to true, the delta disks involved in this snapshot will be consolidated into the parent when this resource is destroyed.
removeChildren Changes to this property will trigger replacement. Boolean
If set to true, the entire snapshot subtree is removed when this resource is destroyed.
description
This property is required.
Changes to this property will trigger replacement.
string
A description for the snapshot.
memory
This property is required.
Changes to this property will trigger replacement.
boolean
If set to true, a dump of the internal state of the virtual machine is included in the snapshot.
quiesce
This property is required.
Changes to this property will trigger replacement.
boolean
If set to true, and the virtual machine is powered on when the snapshot is taken, VMware Tools is used to quiesce the file system in the virtual machine.
snapshotName
This property is required.
Changes to this property will trigger replacement.
string
The name of the snapshot.
virtualMachineUuid
This property is required.
Changes to this property will trigger replacement.
string
The virtual machine UUID.
consolidate Changes to this property will trigger replacement. boolean
If set to true, the delta disks involved in this snapshot will be consolidated into the parent when this resource is destroyed.
removeChildren Changes to this property will trigger replacement. boolean
If set to true, the entire snapshot subtree is removed when this resource is destroyed.
description
This property is required.
Changes to this property will trigger replacement.
str
A description for the snapshot.
memory
This property is required.
Changes to this property will trigger replacement.
bool
If set to true, a dump of the internal state of the virtual machine is included in the snapshot.
quiesce
This property is required.
Changes to this property will trigger replacement.
bool
If set to true, and the virtual machine is powered on when the snapshot is taken, VMware Tools is used to quiesce the file system in the virtual machine.
snapshot_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the snapshot.
virtual_machine_uuid
This property is required.
Changes to this property will trigger replacement.
str
The virtual machine UUID.
consolidate Changes to this property will trigger replacement. bool
If set to true, the delta disks involved in this snapshot will be consolidated into the parent when this resource is destroyed.
remove_children Changes to this property will trigger replacement. bool
If set to true, the entire snapshot subtree is removed when this resource is destroyed.
description
This property is required.
Changes to this property will trigger replacement.
String
A description for the snapshot.
memory
This property is required.
Changes to this property will trigger replacement.
Boolean
If set to true, a dump of the internal state of the virtual machine is included in the snapshot.
quiesce
This property is required.
Changes to this property will trigger replacement.
Boolean
If set to true, and the virtual machine is powered on when the snapshot is taken, VMware Tools is used to quiesce the file system in the virtual machine.
snapshotName
This property is required.
Changes to this property will trigger replacement.
String
The name of the snapshot.
virtualMachineUuid
This property is required.
Changes to this property will trigger replacement.
String
The virtual machine UUID.
consolidate Changes to this property will trigger replacement. Boolean
If set to true, the delta disks involved in this snapshot will be consolidated into the parent when this resource is destroyed.
removeChildren Changes to this property will trigger replacement. Boolean
If set to true, the entire snapshot subtree is removed when this resource is destroyed.

Outputs

All input properties are implicitly available as output properties. Additionally, the VirtualMachineSnapshot resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing VirtualMachineSnapshot Resource

Get an existing VirtualMachineSnapshot resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: VirtualMachineSnapshotState, opts?: CustomResourceOptions): VirtualMachineSnapshot
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        consolidate: Optional[bool] = None,
        description: Optional[str] = None,
        memory: Optional[bool] = None,
        quiesce: Optional[bool] = None,
        remove_children: Optional[bool] = None,
        snapshot_name: Optional[str] = None,
        virtual_machine_uuid: Optional[str] = None) -> VirtualMachineSnapshot
func GetVirtualMachineSnapshot(ctx *Context, name string, id IDInput, state *VirtualMachineSnapshotState, opts ...ResourceOption) (*VirtualMachineSnapshot, error)
public static VirtualMachineSnapshot Get(string name, Input<string> id, VirtualMachineSnapshotState? state, CustomResourceOptions? opts = null)
public static VirtualMachineSnapshot get(String name, Output<String> id, VirtualMachineSnapshotState state, CustomResourceOptions options)
resources:  _:    type: vsphere:VirtualMachineSnapshot    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Consolidate Changes to this property will trigger replacement. bool
If set to true, the delta disks involved in this snapshot will be consolidated into the parent when this resource is destroyed.
Description Changes to this property will trigger replacement. string
A description for the snapshot.
Memory Changes to this property will trigger replacement. bool
If set to true, a dump of the internal state of the virtual machine is included in the snapshot.
Quiesce Changes to this property will trigger replacement. bool
If set to true, and the virtual machine is powered on when the snapshot is taken, VMware Tools is used to quiesce the file system in the virtual machine.
RemoveChildren Changes to this property will trigger replacement. bool
If set to true, the entire snapshot subtree is removed when this resource is destroyed.
SnapshotName Changes to this property will trigger replacement. string
The name of the snapshot.
VirtualMachineUuid Changes to this property will trigger replacement. string
The virtual machine UUID.
Consolidate Changes to this property will trigger replacement. bool
If set to true, the delta disks involved in this snapshot will be consolidated into the parent when this resource is destroyed.
Description Changes to this property will trigger replacement. string
A description for the snapshot.
Memory Changes to this property will trigger replacement. bool
If set to true, a dump of the internal state of the virtual machine is included in the snapshot.
Quiesce Changes to this property will trigger replacement. bool
If set to true, and the virtual machine is powered on when the snapshot is taken, VMware Tools is used to quiesce the file system in the virtual machine.
RemoveChildren Changes to this property will trigger replacement. bool
If set to true, the entire snapshot subtree is removed when this resource is destroyed.
SnapshotName Changes to this property will trigger replacement. string
The name of the snapshot.
VirtualMachineUuid Changes to this property will trigger replacement. string
The virtual machine UUID.
consolidate Changes to this property will trigger replacement. Boolean
If set to true, the delta disks involved in this snapshot will be consolidated into the parent when this resource is destroyed.
description Changes to this property will trigger replacement. String
A description for the snapshot.
memory Changes to this property will trigger replacement. Boolean
If set to true, a dump of the internal state of the virtual machine is included in the snapshot.
quiesce Changes to this property will trigger replacement. Boolean
If set to true, and the virtual machine is powered on when the snapshot is taken, VMware Tools is used to quiesce the file system in the virtual machine.
removeChildren Changes to this property will trigger replacement. Boolean
If set to true, the entire snapshot subtree is removed when this resource is destroyed.
snapshotName Changes to this property will trigger replacement. String
The name of the snapshot.
virtualMachineUuid Changes to this property will trigger replacement. String
The virtual machine UUID.
consolidate Changes to this property will trigger replacement. boolean
If set to true, the delta disks involved in this snapshot will be consolidated into the parent when this resource is destroyed.
description Changes to this property will trigger replacement. string
A description for the snapshot.
memory Changes to this property will trigger replacement. boolean
If set to true, a dump of the internal state of the virtual machine is included in the snapshot.
quiesce Changes to this property will trigger replacement. boolean
If set to true, and the virtual machine is powered on when the snapshot is taken, VMware Tools is used to quiesce the file system in the virtual machine.
removeChildren Changes to this property will trigger replacement. boolean
If set to true, the entire snapshot subtree is removed when this resource is destroyed.
snapshotName Changes to this property will trigger replacement. string
The name of the snapshot.
virtualMachineUuid Changes to this property will trigger replacement. string
The virtual machine UUID.
consolidate Changes to this property will trigger replacement. bool
If set to true, the delta disks involved in this snapshot will be consolidated into the parent when this resource is destroyed.
description Changes to this property will trigger replacement. str
A description for the snapshot.
memory Changes to this property will trigger replacement. bool
If set to true, a dump of the internal state of the virtual machine is included in the snapshot.
quiesce Changes to this property will trigger replacement. bool
If set to true, and the virtual machine is powered on when the snapshot is taken, VMware Tools is used to quiesce the file system in the virtual machine.
remove_children Changes to this property will trigger replacement. bool
If set to true, the entire snapshot subtree is removed when this resource is destroyed.
snapshot_name Changes to this property will trigger replacement. str
The name of the snapshot.
virtual_machine_uuid Changes to this property will trigger replacement. str
The virtual machine UUID.
consolidate Changes to this property will trigger replacement. Boolean
If set to true, the delta disks involved in this snapshot will be consolidated into the parent when this resource is destroyed.
description Changes to this property will trigger replacement. String
A description for the snapshot.
memory Changes to this property will trigger replacement. Boolean
If set to true, a dump of the internal state of the virtual machine is included in the snapshot.
quiesce Changes to this property will trigger replacement. Boolean
If set to true, and the virtual machine is powered on when the snapshot is taken, VMware Tools is used to quiesce the file system in the virtual machine.
removeChildren Changes to this property will trigger replacement. Boolean
If set to true, the entire snapshot subtree is removed when this resource is destroyed.
snapshotName Changes to this property will trigger replacement. String
The name of the snapshot.
virtualMachineUuid Changes to this property will trigger replacement. String
The virtual machine UUID.

Package Details

Repository
vSphere pulumi/pulumi-vsphere
License
Apache-2.0
Notes
This Pulumi package is based on the vsphere Terraform Provider.