1. Packages
  2. Vsphere Provider
  3. API Docs
  4. File
vSphere v4.12.1 published on Tuesday, Oct 22, 2024 by Pulumi

vsphere.File

Explore with Pulumi AI

vsphere logo
vSphere v4.12.1 published on Tuesday, Oct 22, 2024 by Pulumi

    Example Usage

    Uploading a File

    import * as pulumi from "@pulumi/pulumi";
    import * as vsphere from "@pulumi/vsphere";
    
    const ubuntuVmdkUpload = new vsphere.File("ubuntu_vmdk_upload", {
        datacenter: "dc-01",
        datastore: "datastore-01",
        sourceFile: "/my/src/path/custom_ubuntu.vmdk",
        destinationFile: "/my/dst/path/custom_ubuntu.vmdk",
        createDirectories: true,
    });
    
    import pulumi
    import pulumi_vsphere as vsphere
    
    ubuntu_vmdk_upload = vsphere.File("ubuntu_vmdk_upload",
        datacenter="dc-01",
        datastore="datastore-01",
        source_file="/my/src/path/custom_ubuntu.vmdk",
        destination_file="/my/dst/path/custom_ubuntu.vmdk",
        create_directories=True)
    
    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.NewFile(ctx, "ubuntu_vmdk_upload", &vsphere.FileArgs{
    			Datacenter:        pulumi.String("dc-01"),
    			Datastore:         pulumi.String("datastore-01"),
    			SourceFile:        pulumi.String("/my/src/path/custom_ubuntu.vmdk"),
    			DestinationFile:   pulumi.String("/my/dst/path/custom_ubuntu.vmdk"),
    			CreateDirectories: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using VSphere = Pulumi.VSphere;
    
    return await Deployment.RunAsync(() => 
    {
        var ubuntuVmdkUpload = new VSphere.File("ubuntu_vmdk_upload", new()
        {
            Datacenter = "dc-01",
            Datastore = "datastore-01",
            SourceFile = "/my/src/path/custom_ubuntu.vmdk",
            DestinationFile = "/my/dst/path/custom_ubuntu.vmdk",
            CreateDirectories = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.vsphere.File;
    import com.pulumi.vsphere.FileArgs;
    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 ubuntuVmdkUpload = new File("ubuntuVmdkUpload", FileArgs.builder()
                .datacenter("dc-01")
                .datastore("datastore-01")
                .sourceFile("/my/src/path/custom_ubuntu.vmdk")
                .destinationFile("/my/dst/path/custom_ubuntu.vmdk")
                .createDirectories(true)
                .build());
    
        }
    }
    
    resources:
      ubuntuVmdkUpload:
        type: vsphere:File
        name: ubuntu_vmdk_upload
        properties:
          datacenter: dc-01
          datastore: datastore-01
          sourceFile: /my/src/path/custom_ubuntu.vmdk
          destinationFile: /my/dst/path/custom_ubuntu.vmdk
          createDirectories: true
    

    Copying a File

    import * as pulumi from "@pulumi/pulumi";
    import * as vsphere from "@pulumi/vsphere";
    
    const ubuntuCopy = new vsphere.File("ubuntu_copy", {
        sourceDatacenter: "dc-01",
        datacenter: "dc-01",
        sourceDatastore: "datastore-01",
        datastore: "datastore-01",
        sourceFile: "/my/src/path/custom_ubuntu.vmdk",
        destinationFile: "/my/dst/path/custom_ubuntu.vmdk",
        createDirectories: true,
    });
    
    import pulumi
    import pulumi_vsphere as vsphere
    
    ubuntu_copy = vsphere.File("ubuntu_copy",
        source_datacenter="dc-01",
        datacenter="dc-01",
        source_datastore="datastore-01",
        datastore="datastore-01",
        source_file="/my/src/path/custom_ubuntu.vmdk",
        destination_file="/my/dst/path/custom_ubuntu.vmdk",
        create_directories=True)
    
    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.NewFile(ctx, "ubuntu_copy", &vsphere.FileArgs{
    			SourceDatacenter:  pulumi.String("dc-01"),
    			Datacenter:        pulumi.String("dc-01"),
    			SourceDatastore:   pulumi.String("datastore-01"),
    			Datastore:         pulumi.String("datastore-01"),
    			SourceFile:        pulumi.String("/my/src/path/custom_ubuntu.vmdk"),
    			DestinationFile:   pulumi.String("/my/dst/path/custom_ubuntu.vmdk"),
    			CreateDirectories: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using VSphere = Pulumi.VSphere;
    
    return await Deployment.RunAsync(() => 
    {
        var ubuntuCopy = new VSphere.File("ubuntu_copy", new()
        {
            SourceDatacenter = "dc-01",
            Datacenter = "dc-01",
            SourceDatastore = "datastore-01",
            Datastore = "datastore-01",
            SourceFile = "/my/src/path/custom_ubuntu.vmdk",
            DestinationFile = "/my/dst/path/custom_ubuntu.vmdk",
            CreateDirectories = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.vsphere.File;
    import com.pulumi.vsphere.FileArgs;
    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 ubuntuCopy = new File("ubuntuCopy", FileArgs.builder()
                .sourceDatacenter("dc-01")
                .datacenter("dc-01")
                .sourceDatastore("datastore-01")
                .datastore("datastore-01")
                .sourceFile("/my/src/path/custom_ubuntu.vmdk")
                .destinationFile("/my/dst/path/custom_ubuntu.vmdk")
                .createDirectories(true)
                .build());
    
        }
    }
    
    resources:
      ubuntuCopy:
        type: vsphere:File
        name: ubuntu_copy
        properties:
          sourceDatacenter: dc-01
          datacenter: dc-01
          sourceDatastore: datastore-01
          datastore: datastore-01
          sourceFile: /my/src/path/custom_ubuntu.vmdk
          destinationFile: /my/dst/path/custom_ubuntu.vmdk
          createDirectories: true
    

    Create File Resource

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

    Constructor syntax

    new File(name: string, args: FileArgs, opts?: CustomResourceOptions);
    @overload
    def File(resource_name: str,
             args: FileArgs,
             opts: Optional[ResourceOptions] = None)
    
    @overload
    def File(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             datastore: Optional[str] = None,
             destination_file: Optional[str] = None,
             source_file: Optional[str] = None,
             create_directories: Optional[bool] = None,
             datacenter: Optional[str] = None,
             source_datacenter: Optional[str] = None,
             source_datastore: Optional[str] = None)
    func NewFile(ctx *Context, name string, args FileArgs, opts ...ResourceOption) (*File, error)
    public File(string name, FileArgs args, CustomResourceOptions? opts = null)
    public File(String name, FileArgs args)
    public File(String name, FileArgs args, CustomResourceOptions options)
    
    type: vsphere:File
    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 FileArgs
    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 FileArgs
    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 FileArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args FileArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args FileArgs
    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 fileResource = new VSphere.File("fileResource", new()
    {
        Datastore = "string",
        DestinationFile = "string",
        SourceFile = "string",
        CreateDirectories = false,
        Datacenter = "string",
        SourceDatacenter = "string",
        SourceDatastore = "string",
    });
    
    example, err := vsphere.NewFile(ctx, "fileResource", &vsphere.FileArgs{
    	Datastore:         pulumi.String("string"),
    	DestinationFile:   pulumi.String("string"),
    	SourceFile:        pulumi.String("string"),
    	CreateDirectories: pulumi.Bool(false),
    	Datacenter:        pulumi.String("string"),
    	SourceDatacenter:  pulumi.String("string"),
    	SourceDatastore:   pulumi.String("string"),
    })
    
    var fileResource = new File("fileResource", FileArgs.builder()
        .datastore("string")
        .destinationFile("string")
        .sourceFile("string")
        .createDirectories(false)
        .datacenter("string")
        .sourceDatacenter("string")
        .sourceDatastore("string")
        .build());
    
    file_resource = vsphere.File("fileResource",
        datastore="string",
        destination_file="string",
        source_file="string",
        create_directories=False,
        datacenter="string",
        source_datacenter="string",
        source_datastore="string")
    
    const fileResource = new vsphere.File("fileResource", {
        datastore: "string",
        destinationFile: "string",
        sourceFile: "string",
        createDirectories: false,
        datacenter: "string",
        sourceDatacenter: "string",
        sourceDatastore: "string",
    });
    
    type: vsphere:File
    properties:
        createDirectories: false
        datacenter: string
        datastore: string
        destinationFile: string
        sourceDatacenter: string
        sourceDatastore: string
        sourceFile: string
    

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

    Datastore string
    The name of the datastore to which to upload the file.
    DestinationFile string
    The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
    SourceFile string
    CreateDirectories bool

    Create directories in destination_file path parameter on first apply if any are missing for copy operation.

    NOTE: Any directory created as part of the create_directories argument will not be deleted when the resource is destroyed. New directories are not created if the destination_file path is changed in subsequent applies.

    Datacenter string
    The name of a datacenter to which the file will be uploaded.
    SourceDatacenter string
    The name of a datacenter from which the file will be copied. Forces a new resource if changed.
    SourceDatastore string
    The name of the datastore from which file will be copied. Forces a new resource if changed.
    Datastore string
    The name of the datastore to which to upload the file.
    DestinationFile string
    The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
    SourceFile string
    CreateDirectories bool

    Create directories in destination_file path parameter on first apply if any are missing for copy operation.

    NOTE: Any directory created as part of the create_directories argument will not be deleted when the resource is destroyed. New directories are not created if the destination_file path is changed in subsequent applies.

    Datacenter string
    The name of a datacenter to which the file will be uploaded.
    SourceDatacenter string
    The name of a datacenter from which the file will be copied. Forces a new resource if changed.
    SourceDatastore string
    The name of the datastore from which file will be copied. Forces a new resource if changed.
    datastore String
    The name of the datastore to which to upload the file.
    destinationFile String
    The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
    sourceFile String
    createDirectories Boolean

    Create directories in destination_file path parameter on first apply if any are missing for copy operation.

    NOTE: Any directory created as part of the create_directories argument will not be deleted when the resource is destroyed. New directories are not created if the destination_file path is changed in subsequent applies.

    datacenter String
    The name of a datacenter to which the file will be uploaded.
    sourceDatacenter String
    The name of a datacenter from which the file will be copied. Forces a new resource if changed.
    sourceDatastore String
    The name of the datastore from which file will be copied. Forces a new resource if changed.
    datastore string
    The name of the datastore to which to upload the file.
    destinationFile string
    The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
    sourceFile string
    createDirectories boolean

    Create directories in destination_file path parameter on first apply if any are missing for copy operation.

    NOTE: Any directory created as part of the create_directories argument will not be deleted when the resource is destroyed. New directories are not created if the destination_file path is changed in subsequent applies.

    datacenter string
    The name of a datacenter to which the file will be uploaded.
    sourceDatacenter string
    The name of a datacenter from which the file will be copied. Forces a new resource if changed.
    sourceDatastore string
    The name of the datastore from which file will be copied. Forces a new resource if changed.
    datastore str
    The name of the datastore to which to upload the file.
    destination_file str
    The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
    source_file str
    create_directories bool

    Create directories in destination_file path parameter on first apply if any are missing for copy operation.

    NOTE: Any directory created as part of the create_directories argument will not be deleted when the resource is destroyed. New directories are not created if the destination_file path is changed in subsequent applies.

    datacenter str
    The name of a datacenter to which the file will be uploaded.
    source_datacenter str
    The name of a datacenter from which the file will be copied. Forces a new resource if changed.
    source_datastore str
    The name of the datastore from which file will be copied. Forces a new resource if changed.
    datastore String
    The name of the datastore to which to upload the file.
    destinationFile String
    The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
    sourceFile String
    createDirectories Boolean

    Create directories in destination_file path parameter on first apply if any are missing for copy operation.

    NOTE: Any directory created as part of the create_directories argument will not be deleted when the resource is destroyed. New directories are not created if the destination_file path is changed in subsequent applies.

    datacenter String
    The name of a datacenter to which the file will be uploaded.
    sourceDatacenter String
    The name of a datacenter from which the file will be copied. Forces a new resource if changed.
    sourceDatastore String
    The name of the datastore from which file will be copied. Forces a new resource if changed.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the File 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 File Resource

    Get an existing File 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?: FileState, opts?: CustomResourceOptions): File
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            create_directories: Optional[bool] = None,
            datacenter: Optional[str] = None,
            datastore: Optional[str] = None,
            destination_file: Optional[str] = None,
            source_datacenter: Optional[str] = None,
            source_datastore: Optional[str] = None,
            source_file: Optional[str] = None) -> File
    func GetFile(ctx *Context, name string, id IDInput, state *FileState, opts ...ResourceOption) (*File, error)
    public static File Get(string name, Input<string> id, FileState? state, CustomResourceOptions? opts = null)
    public static File get(String name, Output<String> id, FileState 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:
    CreateDirectories bool

    Create directories in destination_file path parameter on first apply if any are missing for copy operation.

    NOTE: Any directory created as part of the create_directories argument will not be deleted when the resource is destroyed. New directories are not created if the destination_file path is changed in subsequent applies.

    Datacenter string
    The name of a datacenter to which the file will be uploaded.
    Datastore string
    The name of the datastore to which to upload the file.
    DestinationFile string
    The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
    SourceDatacenter string
    The name of a datacenter from which the file will be copied. Forces a new resource if changed.
    SourceDatastore string
    The name of the datastore from which file will be copied. Forces a new resource if changed.
    SourceFile string
    CreateDirectories bool

    Create directories in destination_file path parameter on first apply if any are missing for copy operation.

    NOTE: Any directory created as part of the create_directories argument will not be deleted when the resource is destroyed. New directories are not created if the destination_file path is changed in subsequent applies.

    Datacenter string
    The name of a datacenter to which the file will be uploaded.
    Datastore string
    The name of the datastore to which to upload the file.
    DestinationFile string
    The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
    SourceDatacenter string
    The name of a datacenter from which the file will be copied. Forces a new resource if changed.
    SourceDatastore string
    The name of the datastore from which file will be copied. Forces a new resource if changed.
    SourceFile string
    createDirectories Boolean

    Create directories in destination_file path parameter on first apply if any are missing for copy operation.

    NOTE: Any directory created as part of the create_directories argument will not be deleted when the resource is destroyed. New directories are not created if the destination_file path is changed in subsequent applies.

    datacenter String
    The name of a datacenter to which the file will be uploaded.
    datastore String
    The name of the datastore to which to upload the file.
    destinationFile String
    The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
    sourceDatacenter String
    The name of a datacenter from which the file will be copied. Forces a new resource if changed.
    sourceDatastore String
    The name of the datastore from which file will be copied. Forces a new resource if changed.
    sourceFile String
    createDirectories boolean

    Create directories in destination_file path parameter on first apply if any are missing for copy operation.

    NOTE: Any directory created as part of the create_directories argument will not be deleted when the resource is destroyed. New directories are not created if the destination_file path is changed in subsequent applies.

    datacenter string
    The name of a datacenter to which the file will be uploaded.
    datastore string
    The name of the datastore to which to upload the file.
    destinationFile string
    The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
    sourceDatacenter string
    The name of a datacenter from which the file will be copied. Forces a new resource if changed.
    sourceDatastore string
    The name of the datastore from which file will be copied. Forces a new resource if changed.
    sourceFile string
    create_directories bool

    Create directories in destination_file path parameter on first apply if any are missing for copy operation.

    NOTE: Any directory created as part of the create_directories argument will not be deleted when the resource is destroyed. New directories are not created if the destination_file path is changed in subsequent applies.

    datacenter str
    The name of a datacenter to which the file will be uploaded.
    datastore str
    The name of the datastore to which to upload the file.
    destination_file str
    The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
    source_datacenter str
    The name of a datacenter from which the file will be copied. Forces a new resource if changed.
    source_datastore str
    The name of the datastore from which file will be copied. Forces a new resource if changed.
    source_file str
    createDirectories Boolean

    Create directories in destination_file path parameter on first apply if any are missing for copy operation.

    NOTE: Any directory created as part of the create_directories argument will not be deleted when the resource is destroyed. New directories are not created if the destination_file path is changed in subsequent applies.

    datacenter String
    The name of a datacenter to which the file will be uploaded.
    datastore String
    The name of the datastore to which to upload the file.
    destinationFile String
    The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
    sourceDatacenter String
    The name of a datacenter from which the file will be copied. Forces a new resource if changed.
    sourceDatastore String
    The name of the datastore from which file will be copied. Forces a new resource if changed.
    sourceFile String

    Package Details

    Repository
    vSphere pulumi/pulumi-vsphere
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the vsphere Terraform Provider.
    vsphere logo
    vSphere v4.12.1 published on Tuesday, Oct 22, 2024 by Pulumi