1. Packages
  2. Lxd Provider
  3. API Docs
  4. Snapshot
lxd 2.5.0 published on Thursday, Mar 13, 2025 by terraform-lxd

lxd.Snapshot

Explore with Pulumi AI

# lxd.Snapshot

Manages a snapshot of an LXD instance.

Example Usage

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

const instance = new lxd.Instance("instance", {
    image: "ubuntu",
    ephemeral: false,
});
const snap1 = new lxd.Snapshot("snap1", {instance: instance.name});
Copy
import pulumi
import pulumi_lxd as lxd

instance = lxd.Instance("instance",
    image="ubuntu",
    ephemeral=False)
snap1 = lxd.Snapshot("snap1", instance=instance.name)
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/lxd/v2/lxd"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		instance, err := lxd.NewInstance(ctx, "instance", &lxd.InstanceArgs{
			Image:     pulumi.String("ubuntu"),
			Ephemeral: pulumi.Bool(false),
		})
		if err != nil {
			return err
		}
		_, err = lxd.NewSnapshot(ctx, "snap1", &lxd.SnapshotArgs{
			Instance: instance.Name,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Lxd = Pulumi.Lxd;

return await Deployment.RunAsync(() => 
{
    var instance = new Lxd.Instance("instance", new()
    {
        Image = "ubuntu",
        Ephemeral = false,
    });

    var snap1 = new Lxd.Snapshot("snap1", new()
    {
        Instance = instance.Name,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.lxd.Instance;
import com.pulumi.lxd.InstanceArgs;
import com.pulumi.lxd.Snapshot;
import com.pulumi.lxd.SnapshotArgs;
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 instance = new Instance("instance", InstanceArgs.builder()
            .image("ubuntu")
            .ephemeral(false)
            .build());

        var snap1 = new Snapshot("snap1", SnapshotArgs.builder()
            .instance(instance.name())
            .build());

    }
}
Copy
resources:
  instance:
    type: lxd:Instance
    properties:
      image: ubuntu
      ephemeral: false
  snap1:
    type: lxd:Snapshot
    properties:
      instance: ${instance.name}
Copy

Create Snapshot Resource

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

Constructor syntax

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

@overload
def Snapshot(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             instance: Optional[str] = None,
             name: Optional[str] = None,
             project: Optional[str] = None,
             remote: Optional[str] = None,
             stateful: Optional[bool] = None)
func NewSnapshot(ctx *Context, name string, args SnapshotArgs, opts ...ResourceOption) (*Snapshot, error)
public Snapshot(string name, SnapshotArgs args, CustomResourceOptions? opts = null)
public Snapshot(String name, SnapshotArgs args)
public Snapshot(String name, SnapshotArgs args, CustomResourceOptions options)
type: lxd:Snapshot
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. SnapshotArgs
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. SnapshotArgs
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. SnapshotArgs
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. SnapshotArgs
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. SnapshotArgs
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 snapshotResource = new Lxd.Snapshot("snapshotResource", new()
{
    Instance = "string",
    Name = "string",
    Project = "string",
    Remote = "string",
    Stateful = false,
});
Copy
example, err := lxd.NewSnapshot(ctx, "snapshotResource", &lxd.SnapshotArgs{
Instance: pulumi.String("string"),
Name: pulumi.String("string"),
Project: pulumi.String("string"),
Remote: pulumi.String("string"),
Stateful: pulumi.Bool(false),
})
Copy
var snapshotResource = new Snapshot("snapshotResource", SnapshotArgs.builder()
    .instance("string")
    .name("string")
    .project("string")
    .remote("string")
    .stateful(false)
    .build());
Copy
snapshot_resource = lxd.Snapshot("snapshotResource",
    instance="string",
    name="string",
    project="string",
    remote="string",
    stateful=False)
Copy
const snapshotResource = new lxd.Snapshot("snapshotResource", {
    instance: "string",
    name: "string",
    project: "string",
    remote: "string",
    stateful: false,
});
Copy
type: lxd:Snapshot
properties:
    instance: string
    name: string
    project: string
    remote: string
    stateful: false
Copy

Snapshot 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 Snapshot resource accepts the following input properties:

Instance This property is required. string
Required - The name of the instance to snapshot.
Name string
Required - Name of the snapshot.
Project string
Optional - Name of the project where the snapshot will be stored.
Remote string
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
Stateful bool
Optional - Set to true to create a stateful snapshot, false for stateless. Stateful snapshots include runtime state. Defaults to false.
Instance This property is required. string
Required - The name of the instance to snapshot.
Name string
Required - Name of the snapshot.
Project string
Optional - Name of the project where the snapshot will be stored.
Remote string
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
Stateful bool
Optional - Set to true to create a stateful snapshot, false for stateless. Stateful snapshots include runtime state. Defaults to false.
instance This property is required. String
Required - The name of the instance to snapshot.
name String
Required - Name of the snapshot.
project String
Optional - Name of the project where the snapshot will be stored.
remote String
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
stateful Boolean
Optional - Set to true to create a stateful snapshot, false for stateless. Stateful snapshots include runtime state. Defaults to false.
instance This property is required. string
Required - The name of the instance to snapshot.
name string
Required - Name of the snapshot.
project string
Optional - Name of the project where the snapshot will be stored.
remote string
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
stateful boolean
Optional - Set to true to create a stateful snapshot, false for stateless. Stateful snapshots include runtime state. Defaults to false.
instance This property is required. str
Required - The name of the instance to snapshot.
name str
Required - Name of the snapshot.
project str
Optional - Name of the project where the snapshot will be stored.
remote str
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
stateful bool
Optional - Set to true to create a stateful snapshot, false for stateless. Stateful snapshots include runtime state. Defaults to false.
instance This property is required. String
Required - The name of the instance to snapshot.
name String
Required - Name of the snapshot.
project String
Optional - Name of the project where the snapshot will be stored.
remote String
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
stateful Boolean
Optional - Set to true to create a stateful snapshot, false for stateless. Stateful snapshots include runtime state. Defaults to false.

Outputs

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

CreatedAt double
The time LXD reported the snapshot was successfully created, in UTC.
Id string
The provider-assigned unique ID for this managed resource.
CreatedAt float64
The time LXD reported the snapshot was successfully created, in UTC.
Id string
The provider-assigned unique ID for this managed resource.
createdAt Double
The time LXD reported the snapshot was successfully created, in UTC.
id String
The provider-assigned unique ID for this managed resource.
createdAt number
The time LXD reported the snapshot was successfully created, in UTC.
id string
The provider-assigned unique ID for this managed resource.
created_at float
The time LXD reported the snapshot was successfully created, in UTC.
id str
The provider-assigned unique ID for this managed resource.
createdAt Number
The time LXD reported the snapshot was successfully created, in UTC.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing Snapshot Resource

Get an existing Snapshot 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?: SnapshotState, opts?: CustomResourceOptions): Snapshot
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        created_at: Optional[float] = None,
        instance: Optional[str] = None,
        name: Optional[str] = None,
        project: Optional[str] = None,
        remote: Optional[str] = None,
        stateful: Optional[bool] = None) -> Snapshot
func GetSnapshot(ctx *Context, name string, id IDInput, state *SnapshotState, opts ...ResourceOption) (*Snapshot, error)
public static Snapshot Get(string name, Input<string> id, SnapshotState? state, CustomResourceOptions? opts = null)
public static Snapshot get(String name, Output<String> id, SnapshotState state, CustomResourceOptions options)
resources:  _:    type: lxd:Snapshot    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:
CreatedAt double
The time LXD reported the snapshot was successfully created, in UTC.
Instance string
Required - The name of the instance to snapshot.
Name string
Required - Name of the snapshot.
Project string
Optional - Name of the project where the snapshot will be stored.
Remote string
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
Stateful bool
Optional - Set to true to create a stateful snapshot, false for stateless. Stateful snapshots include runtime state. Defaults to false.
CreatedAt float64
The time LXD reported the snapshot was successfully created, in UTC.
Instance string
Required - The name of the instance to snapshot.
Name string
Required - Name of the snapshot.
Project string
Optional - Name of the project where the snapshot will be stored.
Remote string
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
Stateful bool
Optional - Set to true to create a stateful snapshot, false for stateless. Stateful snapshots include runtime state. Defaults to false.
createdAt Double
The time LXD reported the snapshot was successfully created, in UTC.
instance String
Required - The name of the instance to snapshot.
name String
Required - Name of the snapshot.
project String
Optional - Name of the project where the snapshot will be stored.
remote String
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
stateful Boolean
Optional - Set to true to create a stateful snapshot, false for stateless. Stateful snapshots include runtime state. Defaults to false.
createdAt number
The time LXD reported the snapshot was successfully created, in UTC.
instance string
Required - The name of the instance to snapshot.
name string
Required - Name of the snapshot.
project string
Optional - Name of the project where the snapshot will be stored.
remote string
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
stateful boolean
Optional - Set to true to create a stateful snapshot, false for stateless. Stateful snapshots include runtime state. Defaults to false.
created_at float
The time LXD reported the snapshot was successfully created, in UTC.
instance str
Required - The name of the instance to snapshot.
name str
Required - Name of the snapshot.
project str
Optional - Name of the project where the snapshot will be stored.
remote str
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
stateful bool
Optional - Set to true to create a stateful snapshot, false for stateless. Stateful snapshots include runtime state. Defaults to false.
createdAt Number
The time LXD reported the snapshot was successfully created, in UTC.
instance String
Required - The name of the instance to snapshot.
name String
Required - Name of the snapshot.
project String
Optional - Name of the project where the snapshot will be stored.
remote String
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
stateful Boolean
Optional - Set to true to create a stateful snapshot, false for stateless. Stateful snapshots include runtime state. Defaults to false.

Package Details

Repository
lxd terraform-lxd/terraform-provider-lxd
License
Notes
This Pulumi package is based on the lxd Terraform Provider.