/
getDroplet.go
329 lines (289 loc) · 11 KB
/
getDroplet.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
// *** 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 (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Get information on a Droplet for use in other resources. This data source provides
// all of the Droplet's properties as configured on your DigitalOcean account. This
// is useful if the Droplet in question is not managed by this provider or you need to
// utilize any of the Droplet's data.
//
// **Note:** This data source returns a single Droplet. When specifying a `tag`, an
// error is triggered if more than one Droplet is found.
//
// ## Example Usage
//
// Get the Droplet by name:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// example, err := digitalocean.LookupDroplet(ctx, &GetDropletArgs{
// Name: pulumi.StringRef("web"),
// }, nil)
// if err != nil {
// return err
// }
// ctx.Export("dropletOutput", example.Ipv4Address)
// return nil
// })
// }
// ```
//
// Get the Droplet by tag:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := digitalocean.LookupDroplet(ctx, &GetDropletArgs{
// Tag: pulumi.StringRef("web"),
// }, nil)
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// Get the Droplet by ID:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := digitalocean.LookupDroplet(ctx, &GetDropletArgs{
// Id: pulumi.IntRef(digitalocean_kubernetes_cluster.Example.Node_pool[0].Nodes[0].Droplet_id),
// }, nil)
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
func LookupDroplet(ctx *pulumi.Context, args *LookupDropletArgs, opts ...pulumi.InvokeOption) (*LookupDropletResult, error) {
var rv LookupDropletResult
err := ctx.Invoke("digitalocean:index/getDroplet:getDroplet", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getDroplet.
type LookupDropletArgs struct {
// The ID of the Droplet
Id *int `pulumi:"id"`
// The name of the Droplet.
Name *string `pulumi:"name"`
// A tag applied to the Droplet.
Tag *string `pulumi:"tag"`
}
// A collection of values returned by getDroplet.
type LookupDropletResult struct {
// Whether backups are enabled.
Backups bool `pulumi:"backups"`
CreatedAt string `pulumi:"createdAt"`
// The size of the Droplets disk in GB.
Disk int `pulumi:"disk"`
Id int `pulumi:"id"`
// The Droplet image ID or slug.
Image string `pulumi:"image"`
// The Droplets public IPv4 address
Ipv4Address string `pulumi:"ipv4Address"`
// The Droplets private IPv4 address
Ipv4AddressPrivate string `pulumi:"ipv4AddressPrivate"`
// Whether IPv6 is enabled.
Ipv6 bool `pulumi:"ipv6"`
// The Droplets public IPv6 address
Ipv6Address string `pulumi:"ipv6Address"`
// The Droplets private IPv6 address
Ipv6AddressPrivate string `pulumi:"ipv6AddressPrivate"`
// Whether the Droplet is locked.
Locked bool `pulumi:"locked"`
// The amount of the Droplets memory in MB.
Memory int `pulumi:"memory"`
// Whether monitoring agent is installed.
Monitoring bool `pulumi:"monitoring"`
Name string `pulumi:"name"`
// Droplet hourly price.
PriceHourly float64 `pulumi:"priceHourly"`
// Droplet monthly price.
PriceMonthly float64 `pulumi:"priceMonthly"`
// Whether private networks are enabled.
PrivateNetworking bool `pulumi:"privateNetworking"`
// The region the Droplet is running in.
Region string `pulumi:"region"`
// The unique slug that indentifies the type of Droplet.
Size string `pulumi:"size"`
// The status of the Droplet.
Status string `pulumi:"status"`
Tag *string `pulumi:"tag"`
// A list of the tags associated to the Droplet.
Tags []string `pulumi:"tags"`
// The uniform resource name of the Droplet
Urn string `pulumi:"urn"`
// The number of the Droplets virtual CPUs.
Vcpus int `pulumi:"vcpus"`
// List of the IDs of each volumes attached to the Droplet.
VolumeIds []string `pulumi:"volumeIds"`
// The ID of the VPC where the Droplet is located.
VpcUuid string `pulumi:"vpcUuid"`
}
func LookupDropletOutput(ctx *pulumi.Context, args LookupDropletOutputArgs, opts ...pulumi.InvokeOption) LookupDropletResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (LookupDropletResult, error) {
args := v.(LookupDropletArgs)
r, err := LookupDroplet(ctx, &args, opts...)
return *r, err
}).(LookupDropletResultOutput)
}
// A collection of arguments for invoking getDroplet.
type LookupDropletOutputArgs struct {
// The ID of the Droplet
Id pulumi.IntPtrInput `pulumi:"id"`
// The name of the Droplet.
Name pulumi.StringPtrInput `pulumi:"name"`
// A tag applied to the Droplet.
Tag pulumi.StringPtrInput `pulumi:"tag"`
}
func (LookupDropletOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*LookupDropletArgs)(nil)).Elem()
}
// A collection of values returned by getDroplet.
type LookupDropletResultOutput struct{ *pulumi.OutputState }
func (LookupDropletResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*LookupDropletResult)(nil)).Elem()
}
func (o LookupDropletResultOutput) ToLookupDropletResultOutput() LookupDropletResultOutput {
return o
}
func (o LookupDropletResultOutput) ToLookupDropletResultOutputWithContext(ctx context.Context) LookupDropletResultOutput {
return o
}
// Whether backups are enabled.
func (o LookupDropletResultOutput) Backups() pulumi.BoolOutput {
return o.ApplyT(func(v LookupDropletResult) bool { return v.Backups }).(pulumi.BoolOutput)
}
func (o LookupDropletResultOutput) CreatedAt() pulumi.StringOutput {
return o.ApplyT(func(v LookupDropletResult) string { return v.CreatedAt }).(pulumi.StringOutput)
}
// The size of the Droplets disk in GB.
func (o LookupDropletResultOutput) Disk() pulumi.IntOutput {
return o.ApplyT(func(v LookupDropletResult) int { return v.Disk }).(pulumi.IntOutput)
}
func (o LookupDropletResultOutput) Id() pulumi.IntOutput {
return o.ApplyT(func(v LookupDropletResult) int { return v.Id }).(pulumi.IntOutput)
}
// The Droplet image ID or slug.
func (o LookupDropletResultOutput) Image() pulumi.StringOutput {
return o.ApplyT(func(v LookupDropletResult) string { return v.Image }).(pulumi.StringOutput)
}
// The Droplets public IPv4 address
func (o LookupDropletResultOutput) Ipv4Address() pulumi.StringOutput {
return o.ApplyT(func(v LookupDropletResult) string { return v.Ipv4Address }).(pulumi.StringOutput)
}
// The Droplets private IPv4 address
func (o LookupDropletResultOutput) Ipv4AddressPrivate() pulumi.StringOutput {
return o.ApplyT(func(v LookupDropletResult) string { return v.Ipv4AddressPrivate }).(pulumi.StringOutput)
}
// Whether IPv6 is enabled.
func (o LookupDropletResultOutput) Ipv6() pulumi.BoolOutput {
return o.ApplyT(func(v LookupDropletResult) bool { return v.Ipv6 }).(pulumi.BoolOutput)
}
// The Droplets public IPv6 address
func (o LookupDropletResultOutput) Ipv6Address() pulumi.StringOutput {
return o.ApplyT(func(v LookupDropletResult) string { return v.Ipv6Address }).(pulumi.StringOutput)
}
// The Droplets private IPv6 address
func (o LookupDropletResultOutput) Ipv6AddressPrivate() pulumi.StringOutput {
return o.ApplyT(func(v LookupDropletResult) string { return v.Ipv6AddressPrivate }).(pulumi.StringOutput)
}
// Whether the Droplet is locked.
func (o LookupDropletResultOutput) Locked() pulumi.BoolOutput {
return o.ApplyT(func(v LookupDropletResult) bool { return v.Locked }).(pulumi.BoolOutput)
}
// The amount of the Droplets memory in MB.
func (o LookupDropletResultOutput) Memory() pulumi.IntOutput {
return o.ApplyT(func(v LookupDropletResult) int { return v.Memory }).(pulumi.IntOutput)
}
// Whether monitoring agent is installed.
func (o LookupDropletResultOutput) Monitoring() pulumi.BoolOutput {
return o.ApplyT(func(v LookupDropletResult) bool { return v.Monitoring }).(pulumi.BoolOutput)
}
func (o LookupDropletResultOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v LookupDropletResult) string { return v.Name }).(pulumi.StringOutput)
}
// Droplet hourly price.
func (o LookupDropletResultOutput) PriceHourly() pulumi.Float64Output {
return o.ApplyT(func(v LookupDropletResult) float64 { return v.PriceHourly }).(pulumi.Float64Output)
}
// Droplet monthly price.
func (o LookupDropletResultOutput) PriceMonthly() pulumi.Float64Output {
return o.ApplyT(func(v LookupDropletResult) float64 { return v.PriceMonthly }).(pulumi.Float64Output)
}
// Whether private networks are enabled.
func (o LookupDropletResultOutput) PrivateNetworking() pulumi.BoolOutput {
return o.ApplyT(func(v LookupDropletResult) bool { return v.PrivateNetworking }).(pulumi.BoolOutput)
}
// The region the Droplet is running in.
func (o LookupDropletResultOutput) Region() pulumi.StringOutput {
return o.ApplyT(func(v LookupDropletResult) string { return v.Region }).(pulumi.StringOutput)
}
// The unique slug that indentifies the type of Droplet.
func (o LookupDropletResultOutput) Size() pulumi.StringOutput {
return o.ApplyT(func(v LookupDropletResult) string { return v.Size }).(pulumi.StringOutput)
}
// The status of the Droplet.
func (o LookupDropletResultOutput) Status() pulumi.StringOutput {
return o.ApplyT(func(v LookupDropletResult) string { return v.Status }).(pulumi.StringOutput)
}
func (o LookupDropletResultOutput) Tag() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupDropletResult) *string { return v.Tag }).(pulumi.StringPtrOutput)
}
// A list of the tags associated to the Droplet.
func (o LookupDropletResultOutput) Tags() pulumi.StringArrayOutput {
return o.ApplyT(func(v LookupDropletResult) []string { return v.Tags }).(pulumi.StringArrayOutput)
}
// The uniform resource name of the Droplet
func (o LookupDropletResultOutput) Urn() pulumi.StringOutput {
return o.ApplyT(func(v LookupDropletResult) string { return v.Urn }).(pulumi.StringOutput)
}
// The number of the Droplets virtual CPUs.
func (o LookupDropletResultOutput) Vcpus() pulumi.IntOutput {
return o.ApplyT(func(v LookupDropletResult) int { return v.Vcpus }).(pulumi.IntOutput)
}
// List of the IDs of each volumes attached to the Droplet.
func (o LookupDropletResultOutput) VolumeIds() pulumi.StringArrayOutput {
return o.ApplyT(func(v LookupDropletResult) []string { return v.VolumeIds }).(pulumi.StringArrayOutput)
}
// The ID of the VPC where the Droplet is located.
func (o LookupDropletResultOutput) VpcUuid() pulumi.StringOutput {
return o.ApplyT(func(v LookupDropletResult) string { return v.VpcUuid }).(pulumi.StringOutput)
}
func init() {
pulumi.RegisterOutputType(LookupDropletResultOutput{})
}