1. Packages
  2. vSphere
  3. API Docs
  4. File
vSphere v4.10.0 published on Tuesday, Mar 12, 2024 by Pulumi

vsphere.File

Explore with Pulumi AI

vsphere logo
vSphere v4.10.0 published on Tuesday, Mar 12, 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("ubuntuVmdkUpload", {
        createDirectories: true,
        datacenter: "dc-01",
        datastore: "datastore-01",
        destinationFile: "/my/dst/path/custom_ubuntu.vmdk",
        sourceFile: "/my/src/path/custom_ubuntu.vmdk",
    });
    
    import pulumi
    import pulumi_vsphere as vsphere
    
    ubuntu_vmdk_upload = vsphere.File("ubuntuVmdkUpload",
        create_directories=True,
        datacenter="dc-01",
        datastore="datastore-01",
        destination_file="/my/dst/path/custom_ubuntu.vmdk",
        source_file="/my/src/path/custom_ubuntu.vmdk")
    
    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, "ubuntuVmdkUpload", &vsphere.FileArgs{
    			CreateDirectories: pulumi.Bool(true),
    			Datacenter:        pulumi.String("dc-01"),
    			Datastore:         pulumi.String("datastore-01"),
    			DestinationFile:   pulumi.String("/my/dst/path/custom_ubuntu.vmdk"),
    			SourceFile:        pulumi.String("/my/src/path/custom_ubuntu.vmdk"),
    		})
    		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("ubuntuVmdkUpload", new()
        {
            CreateDirectories = true,
            Datacenter = "dc-01",
            Datastore = "datastore-01",
            DestinationFile = "/my/dst/path/custom_ubuntu.vmdk",
            SourceFile = "/my/src/path/custom_ubuntu.vmdk",
        });
    
    });
    
    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()        
                .createDirectories(true)
                .datacenter("dc-01")
                .datastore("datastore-01")
                .destinationFile("/my/dst/path/custom_ubuntu.vmdk")
                .sourceFile("/my/src/path/custom_ubuntu.vmdk")
                .build());
    
        }
    }
    
    resources:
      ubuntuVmdkUpload:
        type: vsphere:File
        properties:
          createDirectories: true
          datacenter: dc-01
          datastore: datastore-01
          destinationFile: /my/dst/path/custom_ubuntu.vmdk
          sourceFile: /my/src/path/custom_ubuntu.vmdk
    

    Copying a File

    import * as pulumi from "@pulumi/pulumi";
    import * as vsphere from "@pulumi/vsphere";
    
    const ubuntuCopy = new vsphere.File("ubuntuCopy", {
        createDirectories: true,
        datacenter: "dc-01",
        datastore: "datastore-01",
        destinationFile: "/my/dst/path/custom_ubuntu.vmdk",
        sourceDatacenter: "dc-01",
        sourceDatastore: "datastore-01",
        sourceFile: "/my/src/path/custom_ubuntu.vmdk",
    });
    
    import pulumi
    import pulumi_vsphere as vsphere
    
    ubuntu_copy = vsphere.File("ubuntuCopy",
        create_directories=True,
        datacenter="dc-01",
        datastore="datastore-01",
        destination_file="/my/dst/path/custom_ubuntu.vmdk",
        source_datacenter="dc-01",
        source_datastore="datastore-01",
        source_file="/my/src/path/custom_ubuntu.vmdk")
    
    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, "ubuntuCopy", &vsphere.FileArgs{
    			CreateDirectories: pulumi.Bool(true),
    			Datacenter:        pulumi.String("dc-01"),
    			Datastore:         pulumi.String("datastore-01"),
    			DestinationFile:   pulumi.String("/my/dst/path/custom_ubuntu.vmdk"),
    			SourceDatacenter:  pulumi.String("dc-01"),
    			SourceDatastore:   pulumi.String("datastore-01"),
    			SourceFile:        pulumi.String("/my/src/path/custom_ubuntu.vmdk"),
    		})
    		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("ubuntuCopy", new()
        {
            CreateDirectories = true,
            Datacenter = "dc-01",
            Datastore = "datastore-01",
            DestinationFile = "/my/dst/path/custom_ubuntu.vmdk",
            SourceDatacenter = "dc-01",
            SourceDatastore = "datastore-01",
            SourceFile = "/my/src/path/custom_ubuntu.vmdk",
        });
    
    });
    
    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()        
                .createDirectories(true)
                .datacenter("dc-01")
                .datastore("datastore-01")
                .destinationFile("/my/dst/path/custom_ubuntu.vmdk")
                .sourceDatacenter("dc-01")
                .sourceDatastore("datastore-01")
                .sourceFile("/my/src/path/custom_ubuntu.vmdk")
                .build());
    
        }
    }
    
    resources:
      ubuntuCopy:
        type: vsphere:File
        properties:
          createDirectories: true
          datacenter: dc-01
          datastore: datastore-01
          destinationFile: /my/dst/path/custom_ubuntu.vmdk
          sourceDatacenter: dc-01
          sourceDatastore: datastore-01
          sourceFile: /my/src/path/custom_ubuntu.vmdk
    

    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.

    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

    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.10.0 published on Tuesday, Mar 12, 2024 by Pulumi