generated from pulumi/pulumi-tf-provider-boilerplate
/
instanceGrant.go
340 lines (291 loc) · 11.2 KB
/
instanceGrant.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
330
331
332
333
334
335
336
337
338
339
340
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package cen
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a CEN child instance grant resource, which allow you to authorize a VPC or VBR to a CEN of a different account.
//
// For more information about how to use it, see [Attach a network in a different account](https://www.alibabacloud.com/help/doc-detail/73645.htm).
//
// ## Example Usage
//
// # Basic Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
// "github.com/rhysmdnz/pulumi-alicloud/sdk/go/alicloud"
// "github.com/rhysmdnz/pulumi-alicloud/sdk/go/alicloud/cen"
// "github.com/rhysmdnz/pulumi-alicloud/sdk/go/alicloud/vpc"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := alicloud.NewProvider(ctx, "account1", &alicloud.ProviderArgs{
// AccessKey: pulumi.String("access123"),
// SecretKey: pulumi.String("secret123"),
// })
// if err != nil {
// return err
// }
// _, err = alicloud.NewProvider(ctx, "account2", &alicloud.ProviderArgs{
// AccessKey: pulumi.String("access456"),
// SecretKey: pulumi.String("secret456"),
// })
// if err != nil {
// return err
// }
// cfg := config.New(ctx, "")
// name := "tf-testAccCenInstanceGrantBasic"
// if param := cfg.Get("name"); param != "" {
// name = param
// }
// cen, err := cen.NewInstance(ctx, "cen", nil, pulumi.Provider(alicloud.Account2))
// if err != nil {
// return err
// }
// vpc, err := vpc.NewNetwork(ctx, "vpc", &vpc.NetworkArgs{
// CidrBlock: pulumi.String("192.168.0.0/16"),
// }, pulumi.Provider(alicloud.Account1))
// if err != nil {
// return err
// }
// fooInstanceGrant, err := cen.NewInstanceGrant(ctx, "fooInstanceGrant", &cen.InstanceGrantArgs{
// CenId: cen.ID(),
// ChildInstanceId: vpc.ID(),
// CenOwnerId: pulumi.String("uid2"),
// }, pulumi.Provider(alicloud.Account1))
// if err != nil {
// return err
// }
// _, err = cen.NewInstanceAttachment(ctx, "fooInstanceAttachment", &cen.InstanceAttachmentArgs{
// InstanceId: cen.ID(),
// ChildInstanceId: vpc.ID(),
// ChildInstanceType: pulumi.String("VPC"),
// ChildInstanceRegionId: pulumi.String("cn-qingdao"),
// ChildInstanceOwnerId: pulumi.Int("uid1"),
// }, pulumi.Provider(alicloud.Account2), pulumi.DependsOn([]pulumi.Resource{
// fooInstanceGrant,
// }))
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// CEN instance can be imported using the id, e.g.
//
// ```sh
//
// $ pulumi import alicloud:cen/instanceGrant:InstanceGrant example cen-abc123456:vpc-abc123456:uid123456
//
// ```
type InstanceGrant struct {
pulumi.CustomResourceState
// The ID of the CEN.
CenId pulumi.StringOutput `pulumi:"cenId"`
// The owner UID of the CEN which the child instance granted to.
CenOwnerId pulumi.StringOutput `pulumi:"cenOwnerId"`
// The ID of the child instance to grant.
ChildInstanceId pulumi.StringOutput `pulumi:"childInstanceId"`
}
// NewInstanceGrant registers a new resource with the given unique name, arguments, and options.
func NewInstanceGrant(ctx *pulumi.Context,
name string, args *InstanceGrantArgs, opts ...pulumi.ResourceOption) (*InstanceGrant, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.CenId == nil {
return nil, errors.New("invalid value for required argument 'CenId'")
}
if args.CenOwnerId == nil {
return nil, errors.New("invalid value for required argument 'CenOwnerId'")
}
if args.ChildInstanceId == nil {
return nil, errors.New("invalid value for required argument 'ChildInstanceId'")
}
opts = pkgResourceDefaultOpts(opts)
var resource InstanceGrant
err := ctx.RegisterResource("alicloud:cen/instanceGrant:InstanceGrant", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetInstanceGrant gets an existing InstanceGrant resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetInstanceGrant(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *InstanceGrantState, opts ...pulumi.ResourceOption) (*InstanceGrant, error) {
var resource InstanceGrant
err := ctx.ReadResource("alicloud:cen/instanceGrant:InstanceGrant", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering InstanceGrant resources.
type instanceGrantState struct {
// The ID of the CEN.
CenId *string `pulumi:"cenId"`
// The owner UID of the CEN which the child instance granted to.
CenOwnerId *string `pulumi:"cenOwnerId"`
// The ID of the child instance to grant.
ChildInstanceId *string `pulumi:"childInstanceId"`
}
type InstanceGrantState struct {
// The ID of the CEN.
CenId pulumi.StringPtrInput
// The owner UID of the CEN which the child instance granted to.
CenOwnerId pulumi.StringPtrInput
// The ID of the child instance to grant.
ChildInstanceId pulumi.StringPtrInput
}
func (InstanceGrantState) ElementType() reflect.Type {
return reflect.TypeOf((*instanceGrantState)(nil)).Elem()
}
type instanceGrantArgs struct {
// The ID of the CEN.
CenId string `pulumi:"cenId"`
// The owner UID of the CEN which the child instance granted to.
CenOwnerId string `pulumi:"cenOwnerId"`
// The ID of the child instance to grant.
ChildInstanceId string `pulumi:"childInstanceId"`
}
// The set of arguments for constructing a InstanceGrant resource.
type InstanceGrantArgs struct {
// The ID of the CEN.
CenId pulumi.StringInput
// The owner UID of the CEN which the child instance granted to.
CenOwnerId pulumi.StringInput
// The ID of the child instance to grant.
ChildInstanceId pulumi.StringInput
}
func (InstanceGrantArgs) ElementType() reflect.Type {
return reflect.TypeOf((*instanceGrantArgs)(nil)).Elem()
}
type InstanceGrantInput interface {
pulumi.Input
ToInstanceGrantOutput() InstanceGrantOutput
ToInstanceGrantOutputWithContext(ctx context.Context) InstanceGrantOutput
}
func (*InstanceGrant) ElementType() reflect.Type {
return reflect.TypeOf((**InstanceGrant)(nil)).Elem()
}
func (i *InstanceGrant) ToInstanceGrantOutput() InstanceGrantOutput {
return i.ToInstanceGrantOutputWithContext(context.Background())
}
func (i *InstanceGrant) ToInstanceGrantOutputWithContext(ctx context.Context) InstanceGrantOutput {
return pulumi.ToOutputWithContext(ctx, i).(InstanceGrantOutput)
}
// InstanceGrantArrayInput is an input type that accepts InstanceGrantArray and InstanceGrantArrayOutput values.
// You can construct a concrete instance of `InstanceGrantArrayInput` via:
//
// InstanceGrantArray{ InstanceGrantArgs{...} }
type InstanceGrantArrayInput interface {
pulumi.Input
ToInstanceGrantArrayOutput() InstanceGrantArrayOutput
ToInstanceGrantArrayOutputWithContext(context.Context) InstanceGrantArrayOutput
}
type InstanceGrantArray []InstanceGrantInput
func (InstanceGrantArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*InstanceGrant)(nil)).Elem()
}
func (i InstanceGrantArray) ToInstanceGrantArrayOutput() InstanceGrantArrayOutput {
return i.ToInstanceGrantArrayOutputWithContext(context.Background())
}
func (i InstanceGrantArray) ToInstanceGrantArrayOutputWithContext(ctx context.Context) InstanceGrantArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(InstanceGrantArrayOutput)
}
// InstanceGrantMapInput is an input type that accepts InstanceGrantMap and InstanceGrantMapOutput values.
// You can construct a concrete instance of `InstanceGrantMapInput` via:
//
// InstanceGrantMap{ "key": InstanceGrantArgs{...} }
type InstanceGrantMapInput interface {
pulumi.Input
ToInstanceGrantMapOutput() InstanceGrantMapOutput
ToInstanceGrantMapOutputWithContext(context.Context) InstanceGrantMapOutput
}
type InstanceGrantMap map[string]InstanceGrantInput
func (InstanceGrantMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*InstanceGrant)(nil)).Elem()
}
func (i InstanceGrantMap) ToInstanceGrantMapOutput() InstanceGrantMapOutput {
return i.ToInstanceGrantMapOutputWithContext(context.Background())
}
func (i InstanceGrantMap) ToInstanceGrantMapOutputWithContext(ctx context.Context) InstanceGrantMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(InstanceGrantMapOutput)
}
type InstanceGrantOutput struct{ *pulumi.OutputState }
func (InstanceGrantOutput) ElementType() reflect.Type {
return reflect.TypeOf((**InstanceGrant)(nil)).Elem()
}
func (o InstanceGrantOutput) ToInstanceGrantOutput() InstanceGrantOutput {
return o
}
func (o InstanceGrantOutput) ToInstanceGrantOutputWithContext(ctx context.Context) InstanceGrantOutput {
return o
}
// The ID of the CEN.
func (o InstanceGrantOutput) CenId() pulumi.StringOutput {
return o.ApplyT(func(v *InstanceGrant) pulumi.StringOutput { return v.CenId }).(pulumi.StringOutput)
}
// The owner UID of the CEN which the child instance granted to.
func (o InstanceGrantOutput) CenOwnerId() pulumi.StringOutput {
return o.ApplyT(func(v *InstanceGrant) pulumi.StringOutput { return v.CenOwnerId }).(pulumi.StringOutput)
}
// The ID of the child instance to grant.
func (o InstanceGrantOutput) ChildInstanceId() pulumi.StringOutput {
return o.ApplyT(func(v *InstanceGrant) pulumi.StringOutput { return v.ChildInstanceId }).(pulumi.StringOutput)
}
type InstanceGrantArrayOutput struct{ *pulumi.OutputState }
func (InstanceGrantArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*InstanceGrant)(nil)).Elem()
}
func (o InstanceGrantArrayOutput) ToInstanceGrantArrayOutput() InstanceGrantArrayOutput {
return o
}
func (o InstanceGrantArrayOutput) ToInstanceGrantArrayOutputWithContext(ctx context.Context) InstanceGrantArrayOutput {
return o
}
func (o InstanceGrantArrayOutput) Index(i pulumi.IntInput) InstanceGrantOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *InstanceGrant {
return vs[0].([]*InstanceGrant)[vs[1].(int)]
}).(InstanceGrantOutput)
}
type InstanceGrantMapOutput struct{ *pulumi.OutputState }
func (InstanceGrantMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*InstanceGrant)(nil)).Elem()
}
func (o InstanceGrantMapOutput) ToInstanceGrantMapOutput() InstanceGrantMapOutput {
return o
}
func (o InstanceGrantMapOutput) ToInstanceGrantMapOutputWithContext(ctx context.Context) InstanceGrantMapOutput {
return o
}
func (o InstanceGrantMapOutput) MapIndex(k pulumi.StringInput) InstanceGrantOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *InstanceGrant {
return vs[0].(map[string]*InstanceGrant)[vs[1].(string)]
}).(InstanceGrantOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*InstanceGrantInput)(nil)).Elem(), &InstanceGrant{})
pulumi.RegisterInputType(reflect.TypeOf((*InstanceGrantArrayInput)(nil)).Elem(), InstanceGrantArray{})
pulumi.RegisterInputType(reflect.TypeOf((*InstanceGrantMapInput)(nil)).Elem(), InstanceGrantMap{})
pulumi.RegisterOutputType(InstanceGrantOutput{})
pulumi.RegisterOutputType(InstanceGrantArrayOutput{})
pulumi.RegisterOutputType(InstanceGrantMapOutput{})
}