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

vsphere.File

Explore with Pulumi AI

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,
});
Copy
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)
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.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
	})
}
Copy
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,
    });

});
Copy
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());

    }
}
Copy
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
Copy

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,
});
Copy
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)
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.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
	})
}
Copy
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,
    });

});
Copy
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());

    }
}
Copy
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
Copy

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 This property is required. string
The unique name of the resource.
args This property is required. FileArgs
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. 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 This property is required. string
The unique name of the resource.
args This property is required. FileArgs
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. FileArgs
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. 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",
});
Copy
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"),
})
Copy
var fileResource = new File("fileResource", FileArgs.builder()
    .datastore("string")
    .destinationFile("string")
    .sourceFile("string")
    .createDirectories(false)
    .datacenter("string")
    .sourceDatacenter("string")
    .sourceDatastore("string")
    .build());
Copy
file_resource = vsphere.File("fileResource",
    datastore="string",
    destination_file="string",
    source_file="string",
    create_directories=False,
    datacenter="string",
    source_datacenter="string",
    source_datastore="string")
Copy
const fileResource = new vsphere.File("fileResource", {
    datastore: "string",
    destinationFile: "string",
    sourceFile: "string",
    createDirectories: false,
    datacenter: "string",
    sourceDatacenter: "string",
    sourceDatastore: "string",
});
Copy
type: vsphere:File
properties:
    createDirectories: false
    datacenter: string
    datastore: string
    destinationFile: string
    sourceDatacenter: string
    sourceDatastore: string
    sourceFile: string
Copy

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 This property is required. string
The name of the datastore to which to upload the file.
DestinationFile This property is required. string
The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
SourceFile
This property is required.
Changes to this property will trigger replacement.
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 Changes to this property will trigger replacement. string
The name of a datacenter from which the file will be copied. Forces a new resource if changed.
SourceDatastore Changes to this property will trigger replacement. string
The name of the datastore from which file will be copied. Forces a new resource if changed.
Datastore This property is required. string
The name of the datastore to which to upload the file.
DestinationFile This property is required. string
The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
SourceFile
This property is required.
Changes to this property will trigger replacement.
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 Changes to this property will trigger replacement. string
The name of a datacenter from which the file will be copied. Forces a new resource if changed.
SourceDatastore Changes to this property will trigger replacement. string
The name of the datastore from which file will be copied. Forces a new resource if changed.
datastore This property is required. String
The name of the datastore to which to upload the file.
destinationFile This property is required. String
The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
sourceFile
This property is required.
Changes to this property will trigger replacement.
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 Changes to this property will trigger replacement. String
The name of a datacenter from which the file will be copied. Forces a new resource if changed.
sourceDatastore Changes to this property will trigger replacement. String
The name of the datastore from which file will be copied. Forces a new resource if changed.
datastore This property is required. string
The name of the datastore to which to upload the file.
destinationFile This property is required. string
The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
sourceFile
This property is required.
Changes to this property will trigger replacement.
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 Changes to this property will trigger replacement. string
The name of a datacenter from which the file will be copied. Forces a new resource if changed.
sourceDatastore Changes to this property will trigger replacement. string
The name of the datastore from which file will be copied. Forces a new resource if changed.
datastore This property is required. str
The name of the datastore to which to upload the file.
destination_file This property is required. str
The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
source_file
This property is required.
Changes to this property will trigger replacement.
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 Changes to this property will trigger replacement. str
The name of a datacenter from which the file will be copied. Forces a new resource if changed.
source_datastore Changes to this property will trigger replacement. str
The name of the datastore from which file will be copied. Forces a new resource if changed.
datastore This property is required. String
The name of the datastore to which to upload the file.
destinationFile This property is required. String
The path to where the file should be uploaded or copied to on the destination datastore in vSphere.
sourceFile
This property is required.
Changes to this property will trigger replacement.
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 Changes to this property will trigger replacement. String
The name of a datacenter from which the file will be copied. Forces a new resource if changed.
sourceDatastore Changes to this property will trigger replacement. 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)
resources:  _:    type: vsphere:File    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:
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 Changes to this property will trigger replacement. string
The name of a datacenter from which the file will be copied. Forces a new resource if changed.
SourceDatastore Changes to this property will trigger replacement. string
The name of the datastore from which file will be copied. Forces a new resource if changed.
SourceFile Changes to this property will trigger replacement. 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 Changes to this property will trigger replacement. string
The name of a datacenter from which the file will be copied. Forces a new resource if changed.
SourceDatastore Changes to this property will trigger replacement. string
The name of the datastore from which file will be copied. Forces a new resource if changed.
SourceFile Changes to this property will trigger replacement. 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 Changes to this property will trigger replacement. String
The name of a datacenter from which the file will be copied. Forces a new resource if changed.
sourceDatastore Changes to this property will trigger replacement. String
The name of the datastore from which file will be copied. Forces a new resource if changed.
sourceFile Changes to this property will trigger replacement. 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 Changes to this property will trigger replacement. string
The name of a datacenter from which the file will be copied. Forces a new resource if changed.
sourceDatastore Changes to this property will trigger replacement. string
The name of the datastore from which file will be copied. Forces a new resource if changed.
sourceFile Changes to this property will trigger replacement. 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 Changes to this property will trigger replacement. str
The name of a datacenter from which the file will be copied. Forces a new resource if changed.
source_datastore Changes to this property will trigger replacement. str
The name of the datastore from which file will be copied. Forces a new resource if changed.
source_file Changes to this property will trigger replacement. 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 Changes to this property will trigger replacement. String
The name of a datacenter from which the file will be copied. Forces a new resource if changed.
sourceDatastore Changes to this property will trigger replacement. String
The name of the datastore from which file will be copied. Forces a new resource if changed.
sourceFile Changes to this property will trigger replacement. String

Package Details

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