vSphere
File
The vsphere.File
resource can be used to upload files (such as virtual disk
files) from the host machine that this provider is running on to a target
datastore. The resource can also be used to copy files between datastores, or
from one location to another on the same datastore.
Updates to destination parameters such as datacenter
, datastore
, or
destination_file
will move the managed file a new destination based on the
values of the new settings. If any source parameter is changed, such as
source_datastore
, source_datacenter
or source_file
), the resource will be
re-created. Depending on if destination parameters are being changed as well,
this may result in the destination file either being overwritten or deleted at
the old location.
Example Usage
Uploading a file
using Pulumi;
using VSphere = Pulumi.VSphere;
class MyStack : Stack
{
public MyStack()
{
var ubuntuDiskUpload = new VSphere.File("ubuntuDiskUpload", new VSphere.FileArgs
{
Datacenter = "my_datacenter",
Datastore = "local",
DestinationFile = "/my_path/disks/custom_ubuntu.vmdk",
SourceFile = "/home/ubuntu/my_disks/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, "ubuntuDiskUpload", &vsphere.FileArgs{
Datacenter: pulumi.String("my_datacenter"),
Datastore: pulumi.String("local"),
DestinationFile: pulumi.String("/my_path/disks/custom_ubuntu.vmdk"),
SourceFile: pulumi.String("/home/ubuntu/my_disks/custom_ubuntu.vmdk"),
})
if err != nil {
return err
}
return nil
})
}
Coming soon!
import pulumi
import pulumi_vsphere as vsphere
ubuntu_disk_upload = vsphere.File("ubuntuDiskUpload",
datacenter="my_datacenter",
datastore="local",
destination_file="/my_path/disks/custom_ubuntu.vmdk",
source_file="/home/ubuntu/my_disks/custom_ubuntu.vmdk")
import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";
const ubuntuDiskUpload = new vsphere.File("ubuntu_disk_upload", {
datacenter: "my_datacenter",
datastore: "local",
destinationFile: "/my_path/disks/custom_ubuntu.vmdk",
sourceFile: "/home/ubuntu/my_disks/custom_ubuntu.vmdk",
});
Coming soon!
Copying a file
using Pulumi;
using VSphere = Pulumi.VSphere;
class MyStack : Stack
{
public MyStack()
{
var ubuntuDiskCopy = new VSphere.File("ubuntuDiskCopy", new VSphere.FileArgs
{
Datacenter = "my_datacenter",
Datastore = "local",
DestinationFile = "/my_path/custom_ubuntu_id.vmdk",
SourceDatacenter = "my_datacenter",
SourceDatastore = "local",
SourceFile = "/my_path/disks/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, "ubuntuDiskCopy", &vsphere.FileArgs{
Datacenter: pulumi.String("my_datacenter"),
Datastore: pulumi.String("local"),
DestinationFile: pulumi.String("/my_path/custom_ubuntu_id.vmdk"),
SourceDatacenter: pulumi.String("my_datacenter"),
SourceDatastore: pulumi.String("local"),
SourceFile: pulumi.String("/my_path/disks/custom_ubuntu.vmdk"),
})
if err != nil {
return err
}
return nil
})
}
Coming soon!
import pulumi
import pulumi_vsphere as vsphere
ubuntu_disk_copy = vsphere.File("ubuntuDiskCopy",
datacenter="my_datacenter",
datastore="local",
destination_file="/my_path/custom_ubuntu_id.vmdk",
source_datacenter="my_datacenter",
source_datastore="local",
source_file="/my_path/disks/custom_ubuntu.vmdk")
import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";
const ubuntuDiskCopy = new vsphere.File("ubuntu_disk_copy", {
datacenter: "my_datacenter",
datastore: "local",
destinationFile: "/my_path/custom_ubuntu_id.vmdk",
sourceDatacenter: "my_datacenter",
sourceDatastore: "local",
sourceFile: "/my_path/disks/custom_ubuntu.vmdk",
});
Coming soon!
Create a File Resource
new File(name: string, args: FileArgs, opts?: CustomResourceOptions);
@overload
def File(resource_name: 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)
@overload
def File(resource_name: str,
args: FileArgs,
opts: Optional[ResourceOptions] = 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.
- 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.
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 in which to upload the file to.
- Destination
File string The path to where the file should be uploaded or copied to on vSphere.
- Source
File string The path to the file being uploaded from the host to vSphere or copied within vSphere. Forces a new resource if changed.
- Create
Directories bool Create directories in
destination_file
path parameter if any missing for copy operation.- Datacenter string
The name of a datacenter in which the file will be uploaded to.
- Source
Datacenter string The name of a datacenter in which the file will be copied from. Forces a new resource if changed.
- Source
Datastore string The name of the datastore in which file will be copied from. Forces a new resource if changed.
- Datastore string
The name of the datastore in which to upload the file to.
- Destination
File string The path to where the file should be uploaded or copied to on vSphere.
- Source
File string The path to the file being uploaded from the host to vSphere or copied within vSphere. Forces a new resource if changed.
- Create
Directories bool Create directories in
destination_file
path parameter if any missing for copy operation.- Datacenter string
The name of a datacenter in which the file will be uploaded to.
- Source
Datacenter string The name of a datacenter in which the file will be copied from. Forces a new resource if changed.
- Source
Datastore string The name of the datastore in which file will be copied from. Forces a new resource if changed.
- datastore String
The name of the datastore in which to upload the file to.
- destination
File String The path to where the file should be uploaded or copied to on vSphere.
- source
File String The path to the file being uploaded from the host to vSphere or copied within vSphere. Forces a new resource if changed.
- create
Directories Boolean Create directories in
destination_file
path parameter if any missing for copy operation.- datacenter String
The name of a datacenter in which the file will be uploaded to.
- source
Datacenter String The name of a datacenter in which the file will be copied from. Forces a new resource if changed.
- source
Datastore String The name of the datastore in which file will be copied from. Forces a new resource if changed.
- datastore string
The name of the datastore in which to upload the file to.
- destination
File string The path to where the file should be uploaded or copied to on vSphere.
- source
File string The path to the file being uploaded from the host to vSphere or copied within vSphere. Forces a new resource if changed.
- create
Directories boolean Create directories in
destination_file
path parameter if any missing for copy operation.- datacenter string
The name of a datacenter in which the file will be uploaded to.
- source
Datacenter string The name of a datacenter in which the file will be copied from. Forces a new resource if changed.
- source
Datastore string The name of the datastore in which file will be copied from. Forces a new resource if changed.
- datastore str
The name of the datastore in which to upload the file to.
- destination_
file str The path to where the file should be uploaded or copied to on vSphere.
- source_
file str The path to the file being uploaded from the host to vSphere or copied within vSphere. Forces a new resource if changed.
- create_
directories bool Create directories in
destination_file
path parameter if any missing for copy operation.- datacenter str
The name of a datacenter in which the file will be uploaded to.
- source_
datacenter str The name of a datacenter in which the file will be copied from. Forces a new resource if changed.
- source_
datastore str The name of the datastore in which file will be copied from. Forces a new resource if changed.
- datastore String
The name of the datastore in which to upload the file to.
- destination
File String The path to where the file should be uploaded or copied to on vSphere.
- source
File String The path to the file being uploaded from the host to vSphere or copied within vSphere. Forces a new resource if changed.
- create
Directories Boolean Create directories in
destination_file
path parameter if any missing for copy operation.- datacenter String
The name of a datacenter in which the file will be uploaded to.
- source
Datacenter String The name of a datacenter in which the file will be copied from. Forces a new resource if changed.
- source
Datastore String The name of the datastore in which file will be copied from. 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 an 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 if any missing for copy operation.- Datacenter string
The name of a datacenter in which the file will be uploaded to.
- Datastore string
The name of the datastore in which to upload the file to.
- Destination
File string The path to where the file should be uploaded or copied to on vSphere.
- Source
Datacenter string The name of a datacenter in which the file will be copied from. Forces a new resource if changed.
- Source
Datastore string The name of the datastore in which file will be copied from. Forces a new resource if changed.
- Source
File string The path to the file being uploaded from the host to vSphere or copied within vSphere. Forces a new resource if changed.
- Create
Directories bool Create directories in
destination_file
path parameter if any missing for copy operation.- Datacenter string
The name of a datacenter in which the file will be uploaded to.
- Datastore string
The name of the datastore in which to upload the file to.
- Destination
File string The path to where the file should be uploaded or copied to on vSphere.
- Source
Datacenter string The name of a datacenter in which the file will be copied from. Forces a new resource if changed.
- Source
Datastore string The name of the datastore in which file will be copied from. Forces a new resource if changed.
- Source
File string The path to the file being uploaded from the host to vSphere or copied within vSphere. Forces a new resource if changed.
- create
Directories Boolean Create directories in
destination_file
path parameter if any missing for copy operation.- datacenter String
The name of a datacenter in which the file will be uploaded to.
- datastore String
The name of the datastore in which to upload the file to.
- destination
File String The path to where the file should be uploaded or copied to on vSphere.
- source
Datacenter String The name of a datacenter in which the file will be copied from. Forces a new resource if changed.
- source
Datastore String The name of the datastore in which file will be copied from. Forces a new resource if changed.
- source
File String The path to the file being uploaded from the host to vSphere or copied within vSphere. Forces a new resource if changed.
- create
Directories boolean Create directories in
destination_file
path parameter if any missing for copy operation.- datacenter string
The name of a datacenter in which the file will be uploaded to.
- datastore string
The name of the datastore in which to upload the file to.
- destination
File string The path to where the file should be uploaded or copied to on vSphere.
- source
Datacenter string The name of a datacenter in which the file will be copied from. Forces a new resource if changed.
- source
Datastore string The name of the datastore in which file will be copied from. Forces a new resource if changed.
- source
File string The path to the file being uploaded from the host to vSphere or copied within vSphere. Forces a new resource if changed.
- create_
directories bool Create directories in
destination_file
path parameter if any missing for copy operation.- datacenter str
The name of a datacenter in which the file will be uploaded to.
- datastore str
The name of the datastore in which to upload the file to.
- destination_
file str The path to where the file should be uploaded or copied to on vSphere.
- source_
datacenter str The name of a datacenter in which the file will be copied from. Forces a new resource if changed.
- source_
datastore str The name of the datastore in which file will be copied from. Forces a new resource if changed.
- source_
file str The path to the file being uploaded from the host to vSphere or copied within vSphere. Forces a new resource if changed.
- create
Directories Boolean Create directories in
destination_file
path parameter if any missing for copy operation.- datacenter String
The name of a datacenter in which the file will be uploaded to.
- datastore String
The name of the datastore in which to upload the file to.
- destination
File String The path to where the file should be uploaded or copied to on vSphere.
- source
Datacenter String The name of a datacenter in which the file will be copied from. Forces a new resource if changed.
- source
Datastore String The name of the datastore in which file will be copied from. Forces a new resource if changed.
- source
File String The path to the file being uploaded from the host to vSphere or copied within vSphere. Forces a new resource if changed.
Package Details
- Repository
- https://github.com/pulumi/pulumi-vsphere
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
vsphere
Terraform Provider.