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,
});
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)
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.
- Destination
File string - The path to where the file should be uploaded
or copied to on the destination
datastore
in vSphere. - Source
File 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 thedestination_file
path is changed in subsequent applies.- Datacenter string
- The name of a datacenter to which the file will be uploaded.
- Source
Datacenter string - The name of a datacenter from which the file will be copied. Forces a new resource if changed.
- Source
Datastore 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.
- Destination
File string - The path to where the file should be uploaded
or copied to on the destination
datastore
in vSphere. - Source
File 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 thedestination_file
path is changed in subsequent applies.- Datacenter string
- The name of a datacenter to which the file will be uploaded.
- Source
Datacenter string - The name of a datacenter from which the file will be copied. Forces a new resource if changed.
- Source
Datastore 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.
- destination
File String - The path to where the file should be uploaded
or copied to on the destination
datastore
in vSphere. - source
File String - create
Directories 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 thedestination_file
path is changed in subsequent applies.- datacenter String
- The name of a datacenter to which the file will be uploaded.
- source
Datacenter String - The name of a datacenter from which the file will be copied. Forces a new resource if changed.
- source
Datastore 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.
- destination
File string - The path to where the file should be uploaded
or copied to on the destination
datastore
in vSphere. - source
File string - create
Directories 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 thedestination_file
path is changed in subsequent applies.- datacenter string
- The name of a datacenter to which the file will be uploaded.
- source
Datacenter string - The name of a datacenter from which the file will be copied. Forces a new resource if changed.
- source
Datastore 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 thedestination_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.
- destination
File String - The path to where the file should be uploaded
or copied to on the destination
datastore
in vSphere. - source
File String - create
Directories 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 thedestination_file
path is changed in subsequent applies.- datacenter String
- The name of a datacenter to which the file will be uploaded.
- source
Datacenter String - The name of a datacenter from which the file will be copied. Forces a new resource if changed.
- source
Datastore 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.
- 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 thedestination_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.
- Destination
File string - The path to where the file should be uploaded
or copied to on the destination
datastore
in vSphere. - Source
Datacenter string - The name of a datacenter from which the file will be copied. Forces a new resource if changed.
- Source
Datastore string - The name of the datastore from which file will be copied. Forces a new resource if changed.
- Source
File 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 thedestination_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.
- Destination
File string - The path to where the file should be uploaded
or copied to on the destination
datastore
in vSphere. - Source
Datacenter string - The name of a datacenter from which the file will be copied. Forces a new resource if changed.
- Source
Datastore string - The name of the datastore from which file will be copied. Forces a new resource if changed.
- Source
File string
- create
Directories 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 thedestination_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.
- destination
File String - The path to where the file should be uploaded
or copied to on the destination
datastore
in vSphere. - source
Datacenter String - The name of a datacenter from which the file will be copied. Forces a new resource if changed.
- source
Datastore String - The name of the datastore from which file will be copied. Forces a new resource if changed.
- source
File String
- create
Directories 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 thedestination_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.
- destination
File string - The path to where the file should be uploaded
or copied to on the destination
datastore
in vSphere. - source
Datacenter string - The name of a datacenter from which the file will be copied. Forces a new resource if changed.
- source
Datastore string - The name of the datastore from which file will be copied. Forces a new resource if changed.
- source
File 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 thedestination_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
- create
Directories 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 thedestination_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.
- destination
File String - The path to where the file should be uploaded
or copied to on the destination
datastore
in vSphere. - source
Datacenter String - The name of a datacenter from which the file will be copied. Forces a new resource if changed.
- source
Datastore String - The name of the datastore from which file will be copied. Forces a new resource if changed.
- source
File String
Package Details
- Repository
- vSphere pulumi/pulumi-vsphere
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
vsphere
Terraform Provider.