/
getVolume.go
121 lines (116 loc) · 3.56 KB
/
getVolume.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package digitalocean
import (
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// Get information on a volume for use in other resources. This data source provides
// all of the volumes properties as configured on your DigitalOcean account. This is
// useful if the volume in question is not managed by this provider or you need to utilize
// any of the volumes data.
//
// An error is triggered if the provided volume name does not exist.
//
// ## Example Usage
//
// Get the volume:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-digitalocean/sdk/v2/go/digitalocean"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// opt0 := "nyc3"
// _, err := digitalocean.LookupVolume(ctx, &digitalocean.LookupVolumeArgs{
// Name: "app-data",
// Region: &opt0,
// }, nil)
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// Reuse the data about a volume to attach it to a Droplet:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-digitalocean/sdk/v2/go/digitalocean"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// opt0 := "nyc3"
// exampleVolume, err := digitalocean.LookupVolume(ctx, &digitalocean.LookupVolumeArgs{
// Name: "app-data",
// Region: &opt0,
// }, nil)
// if err != nil {
// return err
// }
// exampleDroplet, err := digitalocean.NewDroplet(ctx, "exampleDroplet", &digitalocean.DropletArgs{
// Size: pulumi.String("s-1vcpu-1gb"),
// Image: pulumi.String("ubuntu-18-04-x64"),
// Region: pulumi.String("nyc3"),
// })
// if err != nil {
// return err
// }
// _, err = digitalocean.NewVolumeAttachment(ctx, "foobar", &digitalocean.VolumeAttachmentArgs{
// DropletId: exampleDroplet.ID(),
// VolumeId: pulumi.String(exampleVolume.Id),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
func LookupVolume(ctx *pulumi.Context, args *LookupVolumeArgs, opts ...pulumi.InvokeOption) (*LookupVolumeResult, error) {
var rv LookupVolumeResult
err := ctx.Invoke("digitalocean:index/getVolume:getVolume", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getVolume.
type LookupVolumeArgs struct {
// Text describing a block storage volume.
Description *string `pulumi:"description"`
// The name of block storage volume.
Name string `pulumi:"name"`
// The region the block storage volume is provisioned in.
Region *string `pulumi:"region"`
}
// A collection of values returned by getVolume.
type LookupVolumeResult struct {
// Text describing a block storage volume.
Description *string `pulumi:"description"`
// A list of associated Droplet ids.
DropletIds []int `pulumi:"dropletIds"`
// Filesystem label currently in-use on the block storage volume.
FilesystemLabel string `pulumi:"filesystemLabel"`
// Filesystem type currently in-use on the block storage volume.
FilesystemType string `pulumi:"filesystemType"`
// The provider-assigned unique ID for this managed resource.
Id string `pulumi:"id"`
Name string `pulumi:"name"`
Region *string `pulumi:"region"`
// The size of the block storage volume in GiB.
Size int `pulumi:"size"`
// A list of the tags associated to the Volume.
Tags []string `pulumi:"tags"`
Urn string `pulumi:"urn"`
}