/
getVpc.go
196 lines (174 loc) · 6.14 KB
/
getVpc.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
// *** 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"
)
// Retrieve information about a VPC for use in other resources.
//
// This data source provides all of the VPC's properties as configured on your
// DigitalOcean account. This is useful if the VPC in question is not managed by
// the provider or you need to utilize any of the VPC's data.
//
// VPCs may be looked up by `id` or `name`. Specifying a `region` will
// return that that region's default VPC.
//
// ## Example Usage
// ### VPC 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 {
// _, err := digitalocean.LookupVpc(ctx, &GetVpcArgs{
// Name: pulumi.StringRef("example-network"),
// }, nil)
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// Reuse the data about a VPC to assign a Droplet to it:
//
// ```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 {
// exampleVpc, err := digitalocean.LookupVpc(ctx, &GetVpcArgs{
// Name: pulumi.StringRef("example-network"),
// }, nil)
// if err != nil {
// return err
// }
// _, err = digitalocean.NewDroplet(ctx, "exampleDroplet", &digitalocean.DropletArgs{
// Size: pulumi.String("s-1vcpu-1gb"),
// Image: pulumi.String("ubuntu-18-04-x64"),
// Region: pulumi.String("nyc3"),
// VpcUuid: pulumi.String(exampleVpc.Id),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
func LookupVpc(ctx *pulumi.Context, args *LookupVpcArgs, opts ...pulumi.InvokeOption) (*LookupVpcResult, error) {
var rv LookupVpcResult
err := ctx.Invoke("digitalocean:index/getVpc:getVpc", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getVpc.
type LookupVpcArgs struct {
// The unique identifier of an existing VPC.
Id *string `pulumi:"id"`
// The name of an existing VPC.
Name *string `pulumi:"name"`
// The DigitalOcean region slug for the VPC's location.
Region *string `pulumi:"region"`
}
// A collection of values returned by getVpc.
type LookupVpcResult struct {
// The date and time of when the VPC was created.
CreatedAt string `pulumi:"createdAt"`
// A boolean indicating whether or not the VPC is the default one for the region.
Default bool `pulumi:"default"`
// A free-form text field describing the VPC.
Description string `pulumi:"description"`
// The unique identifier for the VPC.
Id string `pulumi:"id"`
// The range of IP addresses for the VPC in CIDR notation.
IpRange string `pulumi:"ipRange"`
// The name of the VPC.
Name string `pulumi:"name"`
// The DigitalOcean region slug for the VPC's location.
Region string `pulumi:"region"`
// The uniform resource name (URN) for the VPC.
Urn string `pulumi:"urn"`
}
func LookupVpcOutput(ctx *pulumi.Context, args LookupVpcOutputArgs, opts ...pulumi.InvokeOption) LookupVpcResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (LookupVpcResult, error) {
args := v.(LookupVpcArgs)
r, err := LookupVpc(ctx, &args, opts...)
return *r, err
}).(LookupVpcResultOutput)
}
// A collection of arguments for invoking getVpc.
type LookupVpcOutputArgs struct {
// The unique identifier of an existing VPC.
Id pulumi.StringPtrInput `pulumi:"id"`
// The name of an existing VPC.
Name pulumi.StringPtrInput `pulumi:"name"`
// The DigitalOcean region slug for the VPC's location.
Region pulumi.StringPtrInput `pulumi:"region"`
}
func (LookupVpcOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*LookupVpcArgs)(nil)).Elem()
}
// A collection of values returned by getVpc.
type LookupVpcResultOutput struct{ *pulumi.OutputState }
func (LookupVpcResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*LookupVpcResult)(nil)).Elem()
}
func (o LookupVpcResultOutput) ToLookupVpcResultOutput() LookupVpcResultOutput {
return o
}
func (o LookupVpcResultOutput) ToLookupVpcResultOutputWithContext(ctx context.Context) LookupVpcResultOutput {
return o
}
// The date and time of when the VPC was created.
func (o LookupVpcResultOutput) CreatedAt() pulumi.StringOutput {
return o.ApplyT(func(v LookupVpcResult) string { return v.CreatedAt }).(pulumi.StringOutput)
}
// A boolean indicating whether or not the VPC is the default one for the region.
func (o LookupVpcResultOutput) Default() pulumi.BoolOutput {
return o.ApplyT(func(v LookupVpcResult) bool { return v.Default }).(pulumi.BoolOutput)
}
// A free-form text field describing the VPC.
func (o LookupVpcResultOutput) Description() pulumi.StringOutput {
return o.ApplyT(func(v LookupVpcResult) string { return v.Description }).(pulumi.StringOutput)
}
// The unique identifier for the VPC.
func (o LookupVpcResultOutput) Id() pulumi.StringOutput {
return o.ApplyT(func(v LookupVpcResult) string { return v.Id }).(pulumi.StringOutput)
}
// The range of IP addresses for the VPC in CIDR notation.
func (o LookupVpcResultOutput) IpRange() pulumi.StringOutput {
return o.ApplyT(func(v LookupVpcResult) string { return v.IpRange }).(pulumi.StringOutput)
}
// The name of the VPC.
func (o LookupVpcResultOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v LookupVpcResult) string { return v.Name }).(pulumi.StringOutput)
}
// The DigitalOcean region slug for the VPC's location.
func (o LookupVpcResultOutput) Region() pulumi.StringOutput {
return o.ApplyT(func(v LookupVpcResult) string { return v.Region }).(pulumi.StringOutput)
}
// The uniform resource name (URN) for the VPC.
func (o LookupVpcResultOutput) Urn() pulumi.StringOutput {
return o.ApplyT(func(v LookupVpcResult) string { return v.Urn }).(pulumi.StringOutput)
}
func init() {
pulumi.RegisterOutputType(LookupVpcResultOutput{})
}