/
iambinding.go
425 lines (368 loc) · 17.6 KB
/
iambinding.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
// 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 folder
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"
)
// Allows creation and management of a single binding within IAM policy for
// an existing Google Cloud Platform folder.
//
// > **Note:** This resource _must not_ be used in conjunction with
//
// `folder.IAMPolicy` or they will fight over what your policy
// should be.
//
// > **Note:** On create, this resource will overwrite members of any existing roles.
//
// Use `pulumi import` and inspect the output to ensure
// your existing members are preserved.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/folder"
// "github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/organizations"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// department1, err := organizations.NewFolder(ctx, "department1", &organizations.FolderArgs{
// DisplayName: pulumi.String("Department 1"),
// Parent: pulumi.String("organizations/1234567"),
// })
// if err != nil {
// return err
// }
// _, err = folder.NewIAMBinding(ctx, "admin", &folder.IAMBindingArgs{
// Folder: department1.Name,
// Role: pulumi.String("roles/editor"),
// Members: pulumi.StringArray{
// pulumi.String("user:alice@gmail.com"),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// IAM binding imports use space-delimited identifiers; first the resource in question and then the role.
//
// These bindings can be imported using the `folder` and role, e.g.
//
// ```sh
//
// $ pulumi import gcp:folder/iAMBinding:IAMBinding viewer "folder-name roles/viewer"
//
// ```
//
// -> **Custom Roles**If you're importing a IAM binding with a custom role, make sure to use the
//
// full name of the custom role, e.g. `[projects/my-project|organizations/my-org]/roles/my-custom-role`.
type IAMBinding struct {
pulumi.CustomResourceState
Condition IAMBindingConditionPtrOutput `pulumi:"condition"`
// (Computed) The etag of the folder's IAM policy.
Etag pulumi.StringOutput `pulumi:"etag"`
// The resource name of the folder the policy is attached to. Its format is folders/{folder_id}.
Folder pulumi.StringOutput `pulumi:"folder"`
// An array of identities that will be granted the privilege in the `role`.
// Each entry can have one of the following values:
// * **user:{emailid}**: An email address that is associated with a specific Google account. For example, alice@gmail.com.
// * **serviceAccount:{emailid}**: An email address that represents a service account. For example, my-other-app@appspot.gserviceaccount.com.
// * **group:{emailid}**: An email address that represents a Google group. For example, admins@example.com.
// * **domain:{domain}**: A G Suite domain (primary, instead of alias) name that represents all the users of that domain. For example, google.com or example.com.
// * For more details on format and restrictions see https://cloud.google.com/billing/reference/rest/v1/Policy#Binding
Members pulumi.StringArrayOutput `pulumi:"members"`
// The role that should be applied. Only one
// `folder.IAMBinding` can be used per role. Note that custom roles must be of the format
// `[projects|organizations]/{parent-name}/roles/{role-name}`.
Role pulumi.StringOutput `pulumi:"role"`
}
// NewIAMBinding registers a new resource with the given unique name, arguments, and options.
func NewIAMBinding(ctx *pulumi.Context,
name string, args *IAMBindingArgs, opts ...pulumi.ResourceOption) (*IAMBinding, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Folder == nil {
return nil, errors.New("invalid value for required argument 'Folder'")
}
if args.Members == nil {
return nil, errors.New("invalid value for required argument 'Members'")
}
if args.Role == nil {
return nil, errors.New("invalid value for required argument 'Role'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource IAMBinding
err := ctx.RegisterResource("gcp:folder/iAMBinding:IAMBinding", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetIAMBinding gets an existing IAMBinding 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 GetIAMBinding(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *IAMBindingState, opts ...pulumi.ResourceOption) (*IAMBinding, error) {
var resource IAMBinding
err := ctx.ReadResource("gcp:folder/iAMBinding:IAMBinding", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering IAMBinding resources.
type iambindingState struct {
Condition *IAMBindingCondition `pulumi:"condition"`
// (Computed) The etag of the folder's IAM policy.
Etag *string `pulumi:"etag"`
// The resource name of the folder the policy is attached to. Its format is folders/{folder_id}.
Folder *string `pulumi:"folder"`
// An array of identities that will be granted the privilege in the `role`.
// Each entry can have one of the following values:
// * **user:{emailid}**: An email address that is associated with a specific Google account. For example, alice@gmail.com.
// * **serviceAccount:{emailid}**: An email address that represents a service account. For example, my-other-app@appspot.gserviceaccount.com.
// * **group:{emailid}**: An email address that represents a Google group. For example, admins@example.com.
// * **domain:{domain}**: A G Suite domain (primary, instead of alias) name that represents all the users of that domain. For example, google.com or example.com.
// * For more details on format and restrictions see https://cloud.google.com/billing/reference/rest/v1/Policy#Binding
Members []string `pulumi:"members"`
// The role that should be applied. Only one
// `folder.IAMBinding` can be used per role. Note that custom roles must be of the format
// `[projects|organizations]/{parent-name}/roles/{role-name}`.
Role *string `pulumi:"role"`
}
type IAMBindingState struct {
Condition IAMBindingConditionPtrInput
// (Computed) The etag of the folder's IAM policy.
Etag pulumi.StringPtrInput
// The resource name of the folder the policy is attached to. Its format is folders/{folder_id}.
Folder pulumi.StringPtrInput
// An array of identities that will be granted the privilege in the `role`.
// Each entry can have one of the following values:
// * **user:{emailid}**: An email address that is associated with a specific Google account. For example, alice@gmail.com.
// * **serviceAccount:{emailid}**: An email address that represents a service account. For example, my-other-app@appspot.gserviceaccount.com.
// * **group:{emailid}**: An email address that represents a Google group. For example, admins@example.com.
// * **domain:{domain}**: A G Suite domain (primary, instead of alias) name that represents all the users of that domain. For example, google.com or example.com.
// * For more details on format and restrictions see https://cloud.google.com/billing/reference/rest/v1/Policy#Binding
Members pulumi.StringArrayInput
// The role that should be applied. Only one
// `folder.IAMBinding` can be used per role. Note that custom roles must be of the format
// `[projects|organizations]/{parent-name}/roles/{role-name}`.
Role pulumi.StringPtrInput
}
func (IAMBindingState) ElementType() reflect.Type {
return reflect.TypeOf((*iambindingState)(nil)).Elem()
}
type iambindingArgs struct {
Condition *IAMBindingCondition `pulumi:"condition"`
// The resource name of the folder the policy is attached to. Its format is folders/{folder_id}.
Folder string `pulumi:"folder"`
// An array of identities that will be granted the privilege in the `role`.
// Each entry can have one of the following values:
// * **user:{emailid}**: An email address that is associated with a specific Google account. For example, alice@gmail.com.
// * **serviceAccount:{emailid}**: An email address that represents a service account. For example, my-other-app@appspot.gserviceaccount.com.
// * **group:{emailid}**: An email address that represents a Google group. For example, admins@example.com.
// * **domain:{domain}**: A G Suite domain (primary, instead of alias) name that represents all the users of that domain. For example, google.com or example.com.
// * For more details on format and restrictions see https://cloud.google.com/billing/reference/rest/v1/Policy#Binding
Members []string `pulumi:"members"`
// The role that should be applied. Only one
// `folder.IAMBinding` can be used per role. Note that custom roles must be of the format
// `[projects|organizations]/{parent-name}/roles/{role-name}`.
Role string `pulumi:"role"`
}
// The set of arguments for constructing a IAMBinding resource.
type IAMBindingArgs struct {
Condition IAMBindingConditionPtrInput
// The resource name of the folder the policy is attached to. Its format is folders/{folder_id}.
Folder pulumi.StringInput
// An array of identities that will be granted the privilege in the `role`.
// Each entry can have one of the following values:
// * **user:{emailid}**: An email address that is associated with a specific Google account. For example, alice@gmail.com.
// * **serviceAccount:{emailid}**: An email address that represents a service account. For example, my-other-app@appspot.gserviceaccount.com.
// * **group:{emailid}**: An email address that represents a Google group. For example, admins@example.com.
// * **domain:{domain}**: A G Suite domain (primary, instead of alias) name that represents all the users of that domain. For example, google.com or example.com.
// * For more details on format and restrictions see https://cloud.google.com/billing/reference/rest/v1/Policy#Binding
Members pulumi.StringArrayInput
// The role that should be applied. Only one
// `folder.IAMBinding` can be used per role. Note that custom roles must be of the format
// `[projects|organizations]/{parent-name}/roles/{role-name}`.
Role pulumi.StringInput
}
func (IAMBindingArgs) ElementType() reflect.Type {
return reflect.TypeOf((*iambindingArgs)(nil)).Elem()
}
type IAMBindingInput interface {
pulumi.Input
ToIAMBindingOutput() IAMBindingOutput
ToIAMBindingOutputWithContext(ctx context.Context) IAMBindingOutput
}
func (*IAMBinding) ElementType() reflect.Type {
return reflect.TypeOf((**IAMBinding)(nil)).Elem()
}
func (i *IAMBinding) ToIAMBindingOutput() IAMBindingOutput {
return i.ToIAMBindingOutputWithContext(context.Background())
}
func (i *IAMBinding) ToIAMBindingOutputWithContext(ctx context.Context) IAMBindingOutput {
return pulumi.ToOutputWithContext(ctx, i).(IAMBindingOutput)
}
func (i *IAMBinding) ToOutput(ctx context.Context) pulumix.Output[*IAMBinding] {
return pulumix.Output[*IAMBinding]{
OutputState: i.ToIAMBindingOutputWithContext(ctx).OutputState,
}
}
// IAMBindingArrayInput is an input type that accepts IAMBindingArray and IAMBindingArrayOutput values.
// You can construct a concrete instance of `IAMBindingArrayInput` via:
//
// IAMBindingArray{ IAMBindingArgs{...} }
type IAMBindingArrayInput interface {
pulumi.Input
ToIAMBindingArrayOutput() IAMBindingArrayOutput
ToIAMBindingArrayOutputWithContext(context.Context) IAMBindingArrayOutput
}
type IAMBindingArray []IAMBindingInput
func (IAMBindingArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*IAMBinding)(nil)).Elem()
}
func (i IAMBindingArray) ToIAMBindingArrayOutput() IAMBindingArrayOutput {
return i.ToIAMBindingArrayOutputWithContext(context.Background())
}
func (i IAMBindingArray) ToIAMBindingArrayOutputWithContext(ctx context.Context) IAMBindingArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(IAMBindingArrayOutput)
}
func (i IAMBindingArray) ToOutput(ctx context.Context) pulumix.Output[[]*IAMBinding] {
return pulumix.Output[[]*IAMBinding]{
OutputState: i.ToIAMBindingArrayOutputWithContext(ctx).OutputState,
}
}
// IAMBindingMapInput is an input type that accepts IAMBindingMap and IAMBindingMapOutput values.
// You can construct a concrete instance of `IAMBindingMapInput` via:
//
// IAMBindingMap{ "key": IAMBindingArgs{...} }
type IAMBindingMapInput interface {
pulumi.Input
ToIAMBindingMapOutput() IAMBindingMapOutput
ToIAMBindingMapOutputWithContext(context.Context) IAMBindingMapOutput
}
type IAMBindingMap map[string]IAMBindingInput
func (IAMBindingMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*IAMBinding)(nil)).Elem()
}
func (i IAMBindingMap) ToIAMBindingMapOutput() IAMBindingMapOutput {
return i.ToIAMBindingMapOutputWithContext(context.Background())
}
func (i IAMBindingMap) ToIAMBindingMapOutputWithContext(ctx context.Context) IAMBindingMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(IAMBindingMapOutput)
}
func (i IAMBindingMap) ToOutput(ctx context.Context) pulumix.Output[map[string]*IAMBinding] {
return pulumix.Output[map[string]*IAMBinding]{
OutputState: i.ToIAMBindingMapOutputWithContext(ctx).OutputState,
}
}
type IAMBindingOutput struct{ *pulumi.OutputState }
func (IAMBindingOutput) ElementType() reflect.Type {
return reflect.TypeOf((**IAMBinding)(nil)).Elem()
}
func (o IAMBindingOutput) ToIAMBindingOutput() IAMBindingOutput {
return o
}
func (o IAMBindingOutput) ToIAMBindingOutputWithContext(ctx context.Context) IAMBindingOutput {
return o
}
func (o IAMBindingOutput) ToOutput(ctx context.Context) pulumix.Output[*IAMBinding] {
return pulumix.Output[*IAMBinding]{
OutputState: o.OutputState,
}
}
func (o IAMBindingOutput) Condition() IAMBindingConditionPtrOutput {
return o.ApplyT(func(v *IAMBinding) IAMBindingConditionPtrOutput { return v.Condition }).(IAMBindingConditionPtrOutput)
}
// (Computed) The etag of the folder's IAM policy.
func (o IAMBindingOutput) Etag() pulumi.StringOutput {
return o.ApplyT(func(v *IAMBinding) pulumi.StringOutput { return v.Etag }).(pulumi.StringOutput)
}
// The resource name of the folder the policy is attached to. Its format is folders/{folder_id}.
func (o IAMBindingOutput) Folder() pulumi.StringOutput {
return o.ApplyT(func(v *IAMBinding) pulumi.StringOutput { return v.Folder }).(pulumi.StringOutput)
}
// An array of identities that will be granted the privilege in the `role`.
// Each entry can have one of the following values:
// * **user:{emailid}**: An email address that is associated with a specific Google account. For example, alice@gmail.com.
// * **serviceAccount:{emailid}**: An email address that represents a service account. For example, my-other-app@appspot.gserviceaccount.com.
// * **group:{emailid}**: An email address that represents a Google group. For example, admins@example.com.
// * **domain:{domain}**: A G Suite domain (primary, instead of alias) name that represents all the users of that domain. For example, google.com or example.com.
// * For more details on format and restrictions see https://cloud.google.com/billing/reference/rest/v1/Policy#Binding
func (o IAMBindingOutput) Members() pulumi.StringArrayOutput {
return o.ApplyT(func(v *IAMBinding) pulumi.StringArrayOutput { return v.Members }).(pulumi.StringArrayOutput)
}
// The role that should be applied. Only one
// `folder.IAMBinding` can be used per role. Note that custom roles must be of the format
// `[projects|organizations]/{parent-name}/roles/{role-name}`.
func (o IAMBindingOutput) Role() pulumi.StringOutput {
return o.ApplyT(func(v *IAMBinding) pulumi.StringOutput { return v.Role }).(pulumi.StringOutput)
}
type IAMBindingArrayOutput struct{ *pulumi.OutputState }
func (IAMBindingArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*IAMBinding)(nil)).Elem()
}
func (o IAMBindingArrayOutput) ToIAMBindingArrayOutput() IAMBindingArrayOutput {
return o
}
func (o IAMBindingArrayOutput) ToIAMBindingArrayOutputWithContext(ctx context.Context) IAMBindingArrayOutput {
return o
}
func (o IAMBindingArrayOutput) ToOutput(ctx context.Context) pulumix.Output[[]*IAMBinding] {
return pulumix.Output[[]*IAMBinding]{
OutputState: o.OutputState,
}
}
func (o IAMBindingArrayOutput) Index(i pulumi.IntInput) IAMBindingOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *IAMBinding {
return vs[0].([]*IAMBinding)[vs[1].(int)]
}).(IAMBindingOutput)
}
type IAMBindingMapOutput struct{ *pulumi.OutputState }
func (IAMBindingMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*IAMBinding)(nil)).Elem()
}
func (o IAMBindingMapOutput) ToIAMBindingMapOutput() IAMBindingMapOutput {
return o
}
func (o IAMBindingMapOutput) ToIAMBindingMapOutputWithContext(ctx context.Context) IAMBindingMapOutput {
return o
}
func (o IAMBindingMapOutput) ToOutput(ctx context.Context) pulumix.Output[map[string]*IAMBinding] {
return pulumix.Output[map[string]*IAMBinding]{
OutputState: o.OutputState,
}
}
func (o IAMBindingMapOutput) MapIndex(k pulumi.StringInput) IAMBindingOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *IAMBinding {
return vs[0].(map[string]*IAMBinding)[vs[1].(string)]
}).(IAMBindingOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*IAMBindingInput)(nil)).Elem(), &IAMBinding{})
pulumi.RegisterInputType(reflect.TypeOf((*IAMBindingArrayInput)(nil)).Elem(), IAMBindingArray{})
pulumi.RegisterInputType(reflect.TypeOf((*IAMBindingMapInput)(nil)).Elem(), IAMBindingMap{})
pulumi.RegisterOutputType(IAMBindingOutput{})
pulumi.RegisterOutputType(IAMBindingArrayOutput{})
pulumi.RegisterOutputType(IAMBindingMapOutput{})
}