/
bucketAccessControl.go
479 lines (422 loc) · 16.5 KB
/
bucketAccessControl.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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
// 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 storage
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumix"
)
// Bucket ACLs can be managed authoritatively using the
// `storageBucketAcl` resource. Do not use these two resources in conjunction to manage the same bucket.
//
// The BucketAccessControls resource manages the Access Control List
// (ACLs) for a single entity/role pairing on a bucket. ACLs let you specify who
// has access to your data and to what extent.
//
// There are three roles that can be assigned to an entity:
//
// READERs can get the bucket, though no acl property will be returned, and
// list the bucket's objects. WRITERs are READERs, and they can insert
// objects into the bucket and delete the bucket's objects. OWNERs are
// WRITERs, and they can get the acl property of a bucket, update a bucket,
// and call all BucketAccessControls methods on the bucket. For more
// information, see Access Control, with the caveat that this API uses
// READER, WRITER, and OWNER instead of READ, WRITE, and FULL_CONTROL.
//
// To get more information about BucketAccessControl, see:
//
// * [API documentation](https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls)
// * How-to Guides
// - [Official Documentation](https://cloud.google.com/storage/docs/access-control/lists)
//
// ## Example Usage
// ### Storage Bucket Access Control Public Bucket
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/storage"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// bucket, err := storage.NewBucket(ctx, "bucket", &storage.BucketArgs{
// Location: pulumi.String("US"),
// })
// if err != nil {
// return err
// }
// _, err = storage.NewBucketAccessControl(ctx, "publicRule", &storage.BucketAccessControlArgs{
// Bucket: bucket.Name,
// Role: pulumi.String("READER"),
// Entity: pulumi.String("allUsers"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// BucketAccessControl can be imported using any of these accepted formats:
//
// ```sh
//
// $ pulumi import gcp:storage/bucketAccessControl:BucketAccessControl default {{bucket}}/{{entity}}
//
// ```
type BucketAccessControl struct {
pulumi.CustomResourceState
// The name of the bucket.
Bucket pulumi.StringOutput `pulumi:"bucket"`
// The domain associated with the entity.
Domain pulumi.StringOutput `pulumi:"domain"`
// The email address associated with the entity.
Email pulumi.StringOutput `pulumi:"email"`
// The entity holding the permission, in one of the following forms:
// user-userId
// user-email
// group-groupId
// group-email
// domain-domain
// project-team-projectId
// allUsers
// allAuthenticatedUsers
// Examples:
// The user liz@example.com would be user-liz@example.com.
// The group example@googlegroups.com would be
// group-example@googlegroups.com.
// To refer to all members of the Google Apps for Business domain
// example.com, the entity would be domain-example.com.
//
// ***
Entity pulumi.StringOutput `pulumi:"entity"`
// The access permission for the entity.
// Possible values are: `OWNER`, `READER`, `WRITER`.
Role pulumi.StringPtrOutput `pulumi:"role"`
}
// NewBucketAccessControl registers a new resource with the given unique name, arguments, and options.
func NewBucketAccessControl(ctx *pulumi.Context,
name string, args *BucketAccessControlArgs, opts ...pulumi.ResourceOption) (*BucketAccessControl, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Bucket == nil {
return nil, errors.New("invalid value for required argument 'Bucket'")
}
if args.Entity == nil {
return nil, errors.New("invalid value for required argument 'Entity'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource BucketAccessControl
err := ctx.RegisterResource("gcp:storage/bucketAccessControl:BucketAccessControl", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetBucketAccessControl gets an existing BucketAccessControl 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 GetBucketAccessControl(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *BucketAccessControlState, opts ...pulumi.ResourceOption) (*BucketAccessControl, error) {
var resource BucketAccessControl
err := ctx.ReadResource("gcp:storage/bucketAccessControl:BucketAccessControl", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering BucketAccessControl resources.
type bucketAccessControlState struct {
// The name of the bucket.
Bucket *string `pulumi:"bucket"`
// The domain associated with the entity.
Domain *string `pulumi:"domain"`
// The email address associated with the entity.
Email *string `pulumi:"email"`
// The entity holding the permission, in one of the following forms:
// user-userId
// user-email
// group-groupId
// group-email
// domain-domain
// project-team-projectId
// allUsers
// allAuthenticatedUsers
// Examples:
// The user liz@example.com would be user-liz@example.com.
// The group example@googlegroups.com would be
// group-example@googlegroups.com.
// To refer to all members of the Google Apps for Business domain
// example.com, the entity would be domain-example.com.
//
// ***
Entity *string `pulumi:"entity"`
// The access permission for the entity.
// Possible values are: `OWNER`, `READER`, `WRITER`.
Role *string `pulumi:"role"`
}
type BucketAccessControlState struct {
// The name of the bucket.
Bucket pulumi.StringPtrInput
// The domain associated with the entity.
Domain pulumi.StringPtrInput
// The email address associated with the entity.
Email pulumi.StringPtrInput
// The entity holding the permission, in one of the following forms:
// user-userId
// user-email
// group-groupId
// group-email
// domain-domain
// project-team-projectId
// allUsers
// allAuthenticatedUsers
// Examples:
// The user liz@example.com would be user-liz@example.com.
// The group example@googlegroups.com would be
// group-example@googlegroups.com.
// To refer to all members of the Google Apps for Business domain
// example.com, the entity would be domain-example.com.
//
// ***
Entity pulumi.StringPtrInput
// The access permission for the entity.
// Possible values are: `OWNER`, `READER`, `WRITER`.
Role pulumi.StringPtrInput
}
func (BucketAccessControlState) ElementType() reflect.Type {
return reflect.TypeOf((*bucketAccessControlState)(nil)).Elem()
}
type bucketAccessControlArgs struct {
// The name of the bucket.
Bucket string `pulumi:"bucket"`
// The entity holding the permission, in one of the following forms:
// user-userId
// user-email
// group-groupId
// group-email
// domain-domain
// project-team-projectId
// allUsers
// allAuthenticatedUsers
// Examples:
// The user liz@example.com would be user-liz@example.com.
// The group example@googlegroups.com would be
// group-example@googlegroups.com.
// To refer to all members of the Google Apps for Business domain
// example.com, the entity would be domain-example.com.
//
// ***
Entity string `pulumi:"entity"`
// The access permission for the entity.
// Possible values are: `OWNER`, `READER`, `WRITER`.
Role *string `pulumi:"role"`
}
// The set of arguments for constructing a BucketAccessControl resource.
type BucketAccessControlArgs struct {
// The name of the bucket.
Bucket pulumi.StringInput
// The entity holding the permission, in one of the following forms:
// user-userId
// user-email
// group-groupId
// group-email
// domain-domain
// project-team-projectId
// allUsers
// allAuthenticatedUsers
// Examples:
// The user liz@example.com would be user-liz@example.com.
// The group example@googlegroups.com would be
// group-example@googlegroups.com.
// To refer to all members of the Google Apps for Business domain
// example.com, the entity would be domain-example.com.
//
// ***
Entity pulumi.StringInput
// The access permission for the entity.
// Possible values are: `OWNER`, `READER`, `WRITER`.
Role pulumi.StringPtrInput
}
func (BucketAccessControlArgs) ElementType() reflect.Type {
return reflect.TypeOf((*bucketAccessControlArgs)(nil)).Elem()
}
type BucketAccessControlInput interface {
pulumi.Input
ToBucketAccessControlOutput() BucketAccessControlOutput
ToBucketAccessControlOutputWithContext(ctx context.Context) BucketAccessControlOutput
}
func (*BucketAccessControl) ElementType() reflect.Type {
return reflect.TypeOf((**BucketAccessControl)(nil)).Elem()
}
func (i *BucketAccessControl) ToBucketAccessControlOutput() BucketAccessControlOutput {
return i.ToBucketAccessControlOutputWithContext(context.Background())
}
func (i *BucketAccessControl) ToBucketAccessControlOutputWithContext(ctx context.Context) BucketAccessControlOutput {
return pulumi.ToOutputWithContext(ctx, i).(BucketAccessControlOutput)
}
func (i *BucketAccessControl) ToOutput(ctx context.Context) pulumix.Output[*BucketAccessControl] {
return pulumix.Output[*BucketAccessControl]{
OutputState: i.ToBucketAccessControlOutputWithContext(ctx).OutputState,
}
}
// BucketAccessControlArrayInput is an input type that accepts BucketAccessControlArray and BucketAccessControlArrayOutput values.
// You can construct a concrete instance of `BucketAccessControlArrayInput` via:
//
// BucketAccessControlArray{ BucketAccessControlArgs{...} }
type BucketAccessControlArrayInput interface {
pulumi.Input
ToBucketAccessControlArrayOutput() BucketAccessControlArrayOutput
ToBucketAccessControlArrayOutputWithContext(context.Context) BucketAccessControlArrayOutput
}
type BucketAccessControlArray []BucketAccessControlInput
func (BucketAccessControlArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*BucketAccessControl)(nil)).Elem()
}
func (i BucketAccessControlArray) ToBucketAccessControlArrayOutput() BucketAccessControlArrayOutput {
return i.ToBucketAccessControlArrayOutputWithContext(context.Background())
}
func (i BucketAccessControlArray) ToBucketAccessControlArrayOutputWithContext(ctx context.Context) BucketAccessControlArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(BucketAccessControlArrayOutput)
}
func (i BucketAccessControlArray) ToOutput(ctx context.Context) pulumix.Output[[]*BucketAccessControl] {
return pulumix.Output[[]*BucketAccessControl]{
OutputState: i.ToBucketAccessControlArrayOutputWithContext(ctx).OutputState,
}
}
// BucketAccessControlMapInput is an input type that accepts BucketAccessControlMap and BucketAccessControlMapOutput values.
// You can construct a concrete instance of `BucketAccessControlMapInput` via:
//
// BucketAccessControlMap{ "key": BucketAccessControlArgs{...} }
type BucketAccessControlMapInput interface {
pulumi.Input
ToBucketAccessControlMapOutput() BucketAccessControlMapOutput
ToBucketAccessControlMapOutputWithContext(context.Context) BucketAccessControlMapOutput
}
type BucketAccessControlMap map[string]BucketAccessControlInput
func (BucketAccessControlMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*BucketAccessControl)(nil)).Elem()
}
func (i BucketAccessControlMap) ToBucketAccessControlMapOutput() BucketAccessControlMapOutput {
return i.ToBucketAccessControlMapOutputWithContext(context.Background())
}
func (i BucketAccessControlMap) ToBucketAccessControlMapOutputWithContext(ctx context.Context) BucketAccessControlMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(BucketAccessControlMapOutput)
}
func (i BucketAccessControlMap) ToOutput(ctx context.Context) pulumix.Output[map[string]*BucketAccessControl] {
return pulumix.Output[map[string]*BucketAccessControl]{
OutputState: i.ToBucketAccessControlMapOutputWithContext(ctx).OutputState,
}
}
type BucketAccessControlOutput struct{ *pulumi.OutputState }
func (BucketAccessControlOutput) ElementType() reflect.Type {
return reflect.TypeOf((**BucketAccessControl)(nil)).Elem()
}
func (o BucketAccessControlOutput) ToBucketAccessControlOutput() BucketAccessControlOutput {
return o
}
func (o BucketAccessControlOutput) ToBucketAccessControlOutputWithContext(ctx context.Context) BucketAccessControlOutput {
return o
}
func (o BucketAccessControlOutput) ToOutput(ctx context.Context) pulumix.Output[*BucketAccessControl] {
return pulumix.Output[*BucketAccessControl]{
OutputState: o.OutputState,
}
}
// The name of the bucket.
func (o BucketAccessControlOutput) Bucket() pulumi.StringOutput {
return o.ApplyT(func(v *BucketAccessControl) pulumi.StringOutput { return v.Bucket }).(pulumi.StringOutput)
}
// The domain associated with the entity.
func (o BucketAccessControlOutput) Domain() pulumi.StringOutput {
return o.ApplyT(func(v *BucketAccessControl) pulumi.StringOutput { return v.Domain }).(pulumi.StringOutput)
}
// The email address associated with the entity.
func (o BucketAccessControlOutput) Email() pulumi.StringOutput {
return o.ApplyT(func(v *BucketAccessControl) pulumi.StringOutput { return v.Email }).(pulumi.StringOutput)
}
// The entity holding the permission, in one of the following forms:
// user-userId
// user-email
// group-groupId
// group-email
// domain-domain
// project-team-projectId
// allUsers
// allAuthenticatedUsers
// Examples:
// The user liz@example.com would be user-liz@example.com.
// The group example@googlegroups.com would be
// group-example@googlegroups.com.
// To refer to all members of the Google Apps for Business domain
// example.com, the entity would be domain-example.com.
//
// ***
func (o BucketAccessControlOutput) Entity() pulumi.StringOutput {
return o.ApplyT(func(v *BucketAccessControl) pulumi.StringOutput { return v.Entity }).(pulumi.StringOutput)
}
// The access permission for the entity.
// Possible values are: `OWNER`, `READER`, `WRITER`.
func (o BucketAccessControlOutput) Role() pulumi.StringPtrOutput {
return o.ApplyT(func(v *BucketAccessControl) pulumi.StringPtrOutput { return v.Role }).(pulumi.StringPtrOutput)
}
type BucketAccessControlArrayOutput struct{ *pulumi.OutputState }
func (BucketAccessControlArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*BucketAccessControl)(nil)).Elem()
}
func (o BucketAccessControlArrayOutput) ToBucketAccessControlArrayOutput() BucketAccessControlArrayOutput {
return o
}
func (o BucketAccessControlArrayOutput) ToBucketAccessControlArrayOutputWithContext(ctx context.Context) BucketAccessControlArrayOutput {
return o
}
func (o BucketAccessControlArrayOutput) ToOutput(ctx context.Context) pulumix.Output[[]*BucketAccessControl] {
return pulumix.Output[[]*BucketAccessControl]{
OutputState: o.OutputState,
}
}
func (o BucketAccessControlArrayOutput) Index(i pulumi.IntInput) BucketAccessControlOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *BucketAccessControl {
return vs[0].([]*BucketAccessControl)[vs[1].(int)]
}).(BucketAccessControlOutput)
}
type BucketAccessControlMapOutput struct{ *pulumi.OutputState }
func (BucketAccessControlMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*BucketAccessControl)(nil)).Elem()
}
func (o BucketAccessControlMapOutput) ToBucketAccessControlMapOutput() BucketAccessControlMapOutput {
return o
}
func (o BucketAccessControlMapOutput) ToBucketAccessControlMapOutputWithContext(ctx context.Context) BucketAccessControlMapOutput {
return o
}
func (o BucketAccessControlMapOutput) ToOutput(ctx context.Context) pulumix.Output[map[string]*BucketAccessControl] {
return pulumix.Output[map[string]*BucketAccessControl]{
OutputState: o.OutputState,
}
}
func (o BucketAccessControlMapOutput) MapIndex(k pulumi.StringInput) BucketAccessControlOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *BucketAccessControl {
return vs[0].(map[string]*BucketAccessControl)[vs[1].(string)]
}).(BucketAccessControlOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*BucketAccessControlInput)(nil)).Elem(), &BucketAccessControl{})
pulumi.RegisterInputType(reflect.TypeOf((*BucketAccessControlArrayInput)(nil)).Elem(), BucketAccessControlArray{})
pulumi.RegisterInputType(reflect.TypeOf((*BucketAccessControlMapInput)(nil)).Elem(), BucketAccessControlMap{})
pulumi.RegisterOutputType(BucketAccessControlOutput{})
pulumi.RegisterOutputType(BucketAccessControlArrayOutput{})
pulumi.RegisterOutputType(BucketAccessControlMapOutput{})
}