1. Packages
  2. Hcloud Provider
  3. API Docs
  4. Snapshot
Hetzner Cloud v1.21.0 published on Tuesday, Nov 12, 2024 by Pulumi

hcloud.Snapshot

Explore with Pulumi AI

hcloud logo
Hetzner Cloud v1.21.0 published on Tuesday, Nov 12, 2024 by Pulumi

    Provides a Hetzner Cloud snapshot to represent an image with type snapshot in the Hetzner Cloud. This resource makes it easy to create a snapshot of your server.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as hcloud from "@pulumi/hcloud";
    
    const node1 = new hcloud.Server("node1", {
        name: "node1",
        image: "debian-11",
        serverType: "cx22",
    });
    const my_snapshot = new hcloud.Snapshot("my-snapshot", {serverId: node1.id});
    
    import pulumi
    import pulumi_hcloud as hcloud
    
    node1 = hcloud.Server("node1",
        name="node1",
        image="debian-11",
        server_type="cx22")
    my_snapshot = hcloud.Snapshot("my-snapshot", server_id=node1.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-hcloud/sdk/go/hcloud"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		node1, err := hcloud.NewServer(ctx, "node1", &hcloud.ServerArgs{
    			Name:       pulumi.String("node1"),
    			Image:      pulumi.String("debian-11"),
    			ServerType: pulumi.String("cx22"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = hcloud.NewSnapshot(ctx, "my-snapshot", &hcloud.SnapshotArgs{
    			ServerId: node1.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using HCloud = Pulumi.HCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var node1 = new HCloud.Server("node1", new()
        {
            Name = "node1",
            Image = "debian-11",
            ServerType = "cx22",
        });
    
        var my_snapshot = new HCloud.Snapshot("my-snapshot", new()
        {
            ServerId = node1.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.hcloud.Server;
    import com.pulumi.hcloud.ServerArgs;
    import com.pulumi.hcloud.Snapshot;
    import com.pulumi.hcloud.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 node1 = new Server("node1", ServerArgs.builder()
                .name("node1")
                .image("debian-11")
                .serverType("cx22")
                .build());
    
            var my_snapshot = new Snapshot("my-snapshot", SnapshotArgs.builder()
                .serverId(node1.id())
                .build());
    
        }
    }
    
    resources:
      node1:
        type: hcloud:Server
        properties:
          name: node1
          image: debian-11
          serverType: cx22
      my-snapshot:
        type: hcloud:Snapshot
        properties:
          serverId: ${node1.id}
    

    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,
                 server_id: Optional[int] = None,
                 description: Optional[str] = None,
                 labels: Optional[Mapping[str, str]] = 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: hcloud:Snapshot
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args SnapshotArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args 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 string
    The unique name of the resource.
    args SnapshotArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SnapshotArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args 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 HCloud.Snapshot("snapshotResource", new()
    {
        ServerId = 0,
        Description = "string",
        Labels = 
        {
            { "string", "string" },
        },
    });
    
    example, err := hcloud.NewSnapshot(ctx, "snapshotResource", &hcloud.SnapshotArgs{
    	ServerId:    pulumi.Int(0),
    	Description: pulumi.String("string"),
    	Labels: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    })
    
    var snapshotResource = new Snapshot("snapshotResource", SnapshotArgs.builder()
        .serverId(0)
        .description("string")
        .labels(Map.of("string", "string"))
        .build());
    
    snapshot_resource = hcloud.Snapshot("snapshotResource",
        server_id=0,
        description="string",
        labels={
            "string": "string",
        })
    
    const snapshotResource = new hcloud.Snapshot("snapshotResource", {
        serverId: 0,
        description: "string",
        labels: {
            string: "string",
        },
    });
    
    type: hcloud:Snapshot
    properties:
        description: string
        labels:
            string: string
        serverId: 0
    

    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:

    ServerId int
    Server to the snapshot should be created from.
    Description string
    Description of the snapshot.
    Labels Dictionary<string, string>
    User-defined labels (key-value pairs) should be created with.
    ServerId int
    Server to the snapshot should be created from.
    Description string
    Description of the snapshot.
    Labels map[string]string
    User-defined labels (key-value pairs) should be created with.
    serverId Integer
    Server to the snapshot should be created from.
    description String
    Description of the snapshot.
    labels Map<String,String>
    User-defined labels (key-value pairs) should be created with.
    serverId number
    Server to the snapshot should be created from.
    description string
    Description of the snapshot.
    labels {[key: string]: string}
    User-defined labels (key-value pairs) should be created with.
    server_id int
    Server to the snapshot should be created from.
    description str
    Description of the snapshot.
    labels Mapping[str, str]
    User-defined labels (key-value pairs) should be created with.
    serverId Number
    Server to the snapshot should be created from.
    description String
    Description of the snapshot.
    labels Map<String>
    User-defined labels (key-value pairs) should be created with.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Snapshot 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 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,
            description: Optional[str] = None,
            labels: Optional[Mapping[str, str]] = None,
            server_id: Optional[int] = 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)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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:
    Description string
    Description of the snapshot.
    Labels Dictionary<string, string>
    User-defined labels (key-value pairs) should be created with.
    ServerId int
    Server to the snapshot should be created from.
    Description string
    Description of the snapshot.
    Labels map[string]string
    User-defined labels (key-value pairs) should be created with.
    ServerId int
    Server to the snapshot should be created from.
    description String
    Description of the snapshot.
    labels Map<String,String>
    User-defined labels (key-value pairs) should be created with.
    serverId Integer
    Server to the snapshot should be created from.
    description string
    Description of the snapshot.
    labels {[key: string]: string}
    User-defined labels (key-value pairs) should be created with.
    serverId number
    Server to the snapshot should be created from.
    description str
    Description of the snapshot.
    labels Mapping[str, str]
    User-defined labels (key-value pairs) should be created with.
    server_id int
    Server to the snapshot should be created from.
    description String
    Description of the snapshot.
    labels Map<String>
    User-defined labels (key-value pairs) should be created with.
    serverId Number
    Server to the snapshot should be created from.

    Import

    Snapshots can be imported using its image id:

    $ pulumi import hcloud:index/snapshot:Snapshot myimage id
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Hetzner Cloud pulumi/pulumi-hcloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the hcloud Terraform Provider.
    hcloud logo
    Hetzner Cloud v1.21.0 published on Tuesday, Nov 12, 2024 by Pulumi