/
iambinding.go
370 lines (309 loc) · 12.7 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
// *** 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 organizations
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Allows creation and management of a single binding within IAM policy for
// an existing Google Cloud Platform Organization.
//
// > **Note:** This resource __must not__ be used in conjunction with
// `organizations.IAMMember` for the __same role__ 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/v5/go/gcp/organizations"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := organizations.NewIAMBinding(ctx, "binding", &organizations.IAMBindingArgs{
// Members: pulumi.StringArray{
// pulumi.String("user:alice@gmail.com"),
// },
// OrgId: pulumi.String("123456789"),
// Role: pulumi.String("roles/browser"),
// })
// 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 `org_id` and role, e.g.
//
// ```sh
// $ pulumi import gcp:organizations/iAMBinding:IAMBinding my_org "your-org-id roles/viewer"
// ```
//
// -> **Custom Roles**If you're importing a IAM resource 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 organization's IAM policy.
Etag pulumi.StringOutput `pulumi:"etag"`
// A list of users that the role should apply to. For more details on format and restrictions see https://cloud.google.com/billing/reference/rest/v1/Policy#Binding
Members pulumi.StringArrayOutput `pulumi:"members"`
// The numeric ID of the organization in which you want to create a custom role.
OrgId pulumi.StringOutput `pulumi:"orgId"`
// The role that should be applied. Only one
// `organizations.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.Members == nil {
return nil, errors.New("invalid value for required argument 'Members'")
}
if args.OrgId == nil {
return nil, errors.New("invalid value for required argument 'OrgId'")
}
if args.Role == nil {
return nil, errors.New("invalid value for required argument 'Role'")
}
var resource IAMBinding
err := ctx.RegisterResource("gcp:organizations/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:organizations/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 organization's IAM policy.
Etag *string `pulumi:"etag"`
// A list of users that the role should apply to. For more details on format and restrictions see https://cloud.google.com/billing/reference/rest/v1/Policy#Binding
Members []string `pulumi:"members"`
// The numeric ID of the organization in which you want to create a custom role.
OrgId *string `pulumi:"orgId"`
// The role that should be applied. Only one
// `organizations.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 organization's IAM policy.
Etag pulumi.StringPtrInput
// A list of users that the role should apply to. For more details on format and restrictions see https://cloud.google.com/billing/reference/rest/v1/Policy#Binding
Members pulumi.StringArrayInput
// The numeric ID of the organization in which you want to create a custom role.
OrgId pulumi.StringPtrInput
// The role that should be applied. Only one
// `organizations.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"`
// A list of users that the role should apply to. For more details on format and restrictions see https://cloud.google.com/billing/reference/rest/v1/Policy#Binding
Members []string `pulumi:"members"`
// The numeric ID of the organization in which you want to create a custom role.
OrgId string `pulumi:"orgId"`
// The role that should be applied. Only one
// `organizations.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
// A list of users that the role should apply to. For more details on format and restrictions see https://cloud.google.com/billing/reference/rest/v1/Policy#Binding
Members pulumi.StringArrayInput
// The numeric ID of the organization in which you want to create a custom role.
OrgId pulumi.StringInput
// The role that should be applied. Only one
// `organizations.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))
}
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) ToIAMBindingPtrOutput() IAMBindingPtrOutput {
return i.ToIAMBindingPtrOutputWithContext(context.Background())
}
func (i *IAMBinding) ToIAMBindingPtrOutputWithContext(ctx context.Context) IAMBindingPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(IAMBindingPtrOutput)
}
type IAMBindingPtrInput interface {
pulumi.Input
ToIAMBindingPtrOutput() IAMBindingPtrOutput
ToIAMBindingPtrOutputWithContext(ctx context.Context) IAMBindingPtrOutput
}
type iambindingPtrType IAMBindingArgs
func (*iambindingPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**IAMBinding)(nil))
}
func (i *iambindingPtrType) ToIAMBindingPtrOutput() IAMBindingPtrOutput {
return i.ToIAMBindingPtrOutputWithContext(context.Background())
}
func (i *iambindingPtrType) ToIAMBindingPtrOutputWithContext(ctx context.Context) IAMBindingPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(IAMBindingPtrOutput)
}
// 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)
}
// 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)
}
type IAMBindingOutput struct{ *pulumi.OutputState }
func (IAMBindingOutput) ElementType() reflect.Type {
return reflect.TypeOf((*IAMBinding)(nil))
}
func (o IAMBindingOutput) ToIAMBindingOutput() IAMBindingOutput {
return o
}
func (o IAMBindingOutput) ToIAMBindingOutputWithContext(ctx context.Context) IAMBindingOutput {
return o
}
func (o IAMBindingOutput) ToIAMBindingPtrOutput() IAMBindingPtrOutput {
return o.ToIAMBindingPtrOutputWithContext(context.Background())
}
func (o IAMBindingOutput) ToIAMBindingPtrOutputWithContext(ctx context.Context) IAMBindingPtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v IAMBinding) *IAMBinding {
return &v
}).(IAMBindingPtrOutput)
}
type IAMBindingPtrOutput struct{ *pulumi.OutputState }
func (IAMBindingPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**IAMBinding)(nil))
}
func (o IAMBindingPtrOutput) ToIAMBindingPtrOutput() IAMBindingPtrOutput {
return o
}
func (o IAMBindingPtrOutput) ToIAMBindingPtrOutputWithContext(ctx context.Context) IAMBindingPtrOutput {
return o
}
func (o IAMBindingPtrOutput) Elem() IAMBindingOutput {
return o.ApplyT(func(v *IAMBinding) IAMBinding {
if v != nil {
return *v
}
var ret IAMBinding
return ret
}).(IAMBindingOutput)
}
type IAMBindingArrayOutput struct{ *pulumi.OutputState }
func (IAMBindingArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]IAMBinding)(nil))
}
func (o IAMBindingArrayOutput) ToIAMBindingArrayOutput() IAMBindingArrayOutput {
return o
}
func (o IAMBindingArrayOutput) ToIAMBindingArrayOutputWithContext(ctx context.Context) IAMBindingArrayOutput {
return o
}
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))
}
func (o IAMBindingMapOutput) ToIAMBindingMapOutput() IAMBindingMapOutput {
return o
}
func (o IAMBindingMapOutput) ToIAMBindingMapOutputWithContext(ctx context.Context) IAMBindingMapOutput {
return o
}
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.RegisterOutputType(IAMBindingOutput{})
pulumi.RegisterOutputType(IAMBindingPtrOutput{})
pulumi.RegisterOutputType(IAMBindingArrayOutput{})
pulumi.RegisterOutputType(IAMBindingMapOutput{})
}