/
iamcustomRole.go
392 lines (338 loc) · 15.5 KB
/
iamcustomRole.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
// 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 organizations
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Allows management of a customized Cloud IAM organization role. For more information see
// [the official documentation](https://cloud.google.com/iam/docs/understanding-custom-roles)
// and
// [API](https://cloud.google.com/iam/reference/rest/v1/organizations.roles).
//
// > **Warning:** Note that custom roles in GCP have the concept of a soft-delete. There are two issues that may arise
//
// from this and how roles are propagated. 1) creating a role may involve undeleting and then updating a role with the
// same name, possibly causing confusing behavior between undelete and update. 2) A deleted role is permanently deleted
// after 7 days, but it can take up to 30 more days (i.e. between 7 and 37 days after deletion) before the role name is
// made available again. This means a deleted role that has been deleted for more than 7 days cannot be changed at all
// by the provider, and new roles cannot share that name.
//
// ## Example Usage
//
// This snippet creates a customized IAM organization role.
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := organizations.NewIAMCustomRole(ctx, "my-custom-role", &organizations.IAMCustomRoleArgs{
// RoleId: pulumi.String("myCustomRole"),
// OrgId: pulumi.String("123456789"),
// Title: pulumi.String("My Custom Role"),
// Description: pulumi.String("A description"),
// Permissions: pulumi.StringArray{
// pulumi.String("iam.roles.list"),
// pulumi.String("iam.roles.create"),
// pulumi.String("iam.roles.delete"),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// Customized IAM organization role can be imported using their URI, e.g.
//
// ```sh
// $ pulumi import gcp:organizations/iAMCustomRole:IAMCustomRole my-custom-role organizations/123456789/roles/myCustomRole
// ```
type IAMCustomRole struct {
pulumi.CustomResourceState
// (Optional) The current deleted state of the role.
Deleted pulumi.BoolOutput `pulumi:"deleted"`
// A human-readable description for the role.
Description pulumi.StringPtrOutput `pulumi:"description"`
// The name of the role in the format `organizations/{{org_id}}/roles/{{role_id}}`. Like `id`, this field can be used as a reference in other resources such as IAM role bindings.
Name pulumi.StringOutput `pulumi:"name"`
// The numeric ID of the organization in which you want to create a custom role.
OrgId pulumi.StringOutput `pulumi:"orgId"`
// The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
Permissions pulumi.StringArrayOutput `pulumi:"permissions"`
// The role id to use for this role.
RoleId pulumi.StringOutput `pulumi:"roleId"`
// The current launch stage of the role.
// Defaults to `GA`.
// List of possible stages is [here](https://cloud.google.com/iam/reference/rest/v1/organizations.roles#Role.RoleLaunchStage).
Stage pulumi.StringPtrOutput `pulumi:"stage"`
// A human-readable title for the role.
Title pulumi.StringOutput `pulumi:"title"`
}
// NewIAMCustomRole registers a new resource with the given unique name, arguments, and options.
func NewIAMCustomRole(ctx *pulumi.Context,
name string, args *IAMCustomRoleArgs, opts ...pulumi.ResourceOption) (*IAMCustomRole, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.OrgId == nil {
return nil, errors.New("invalid value for required argument 'OrgId'")
}
if args.Permissions == nil {
return nil, errors.New("invalid value for required argument 'Permissions'")
}
if args.RoleId == nil {
return nil, errors.New("invalid value for required argument 'RoleId'")
}
if args.Title == nil {
return nil, errors.New("invalid value for required argument 'Title'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource IAMCustomRole
err := ctx.RegisterResource("gcp:organizations/iAMCustomRole:IAMCustomRole", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetIAMCustomRole gets an existing IAMCustomRole 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 GetIAMCustomRole(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *IAMCustomRoleState, opts ...pulumi.ResourceOption) (*IAMCustomRole, error) {
var resource IAMCustomRole
err := ctx.ReadResource("gcp:organizations/iAMCustomRole:IAMCustomRole", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering IAMCustomRole resources.
type iamcustomRoleState struct {
// (Optional) The current deleted state of the role.
Deleted *bool `pulumi:"deleted"`
// A human-readable description for the role.
Description *string `pulumi:"description"`
// The name of the role in the format `organizations/{{org_id}}/roles/{{role_id}}`. Like `id`, this field can be used as a reference in other resources such as IAM role bindings.
Name *string `pulumi:"name"`
// The numeric ID of the organization in which you want to create a custom role.
OrgId *string `pulumi:"orgId"`
// The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
Permissions []string `pulumi:"permissions"`
// The role id to use for this role.
RoleId *string `pulumi:"roleId"`
// The current launch stage of the role.
// Defaults to `GA`.
// List of possible stages is [here](https://cloud.google.com/iam/reference/rest/v1/organizations.roles#Role.RoleLaunchStage).
Stage *string `pulumi:"stage"`
// A human-readable title for the role.
Title *string `pulumi:"title"`
}
type IAMCustomRoleState struct {
// (Optional) The current deleted state of the role.
Deleted pulumi.BoolPtrInput
// A human-readable description for the role.
Description pulumi.StringPtrInput
// The name of the role in the format `organizations/{{org_id}}/roles/{{role_id}}`. Like `id`, this field can be used as a reference in other resources such as IAM role bindings.
Name pulumi.StringPtrInput
// The numeric ID of the organization in which you want to create a custom role.
OrgId pulumi.StringPtrInput
// The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
Permissions pulumi.StringArrayInput
// The role id to use for this role.
RoleId pulumi.StringPtrInput
// The current launch stage of the role.
// Defaults to `GA`.
// List of possible stages is [here](https://cloud.google.com/iam/reference/rest/v1/organizations.roles#Role.RoleLaunchStage).
Stage pulumi.StringPtrInput
// A human-readable title for the role.
Title pulumi.StringPtrInput
}
func (IAMCustomRoleState) ElementType() reflect.Type {
return reflect.TypeOf((*iamcustomRoleState)(nil)).Elem()
}
type iamcustomRoleArgs struct {
// A human-readable description for the role.
Description *string `pulumi:"description"`
// The numeric ID of the organization in which you want to create a custom role.
OrgId string `pulumi:"orgId"`
// The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
Permissions []string `pulumi:"permissions"`
// The role id to use for this role.
RoleId string `pulumi:"roleId"`
// The current launch stage of the role.
// Defaults to `GA`.
// List of possible stages is [here](https://cloud.google.com/iam/reference/rest/v1/organizations.roles#Role.RoleLaunchStage).
Stage *string `pulumi:"stage"`
// A human-readable title for the role.
Title string `pulumi:"title"`
}
// The set of arguments for constructing a IAMCustomRole resource.
type IAMCustomRoleArgs struct {
// A human-readable description for the role.
Description pulumi.StringPtrInput
// The numeric ID of the organization in which you want to create a custom role.
OrgId pulumi.StringInput
// The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
Permissions pulumi.StringArrayInput
// The role id to use for this role.
RoleId pulumi.StringInput
// The current launch stage of the role.
// Defaults to `GA`.
// List of possible stages is [here](https://cloud.google.com/iam/reference/rest/v1/organizations.roles#Role.RoleLaunchStage).
Stage pulumi.StringPtrInput
// A human-readable title for the role.
Title pulumi.StringInput
}
func (IAMCustomRoleArgs) ElementType() reflect.Type {
return reflect.TypeOf((*iamcustomRoleArgs)(nil)).Elem()
}
type IAMCustomRoleInput interface {
pulumi.Input
ToIAMCustomRoleOutput() IAMCustomRoleOutput
ToIAMCustomRoleOutputWithContext(ctx context.Context) IAMCustomRoleOutput
}
func (*IAMCustomRole) ElementType() reflect.Type {
return reflect.TypeOf((**IAMCustomRole)(nil)).Elem()
}
func (i *IAMCustomRole) ToIAMCustomRoleOutput() IAMCustomRoleOutput {
return i.ToIAMCustomRoleOutputWithContext(context.Background())
}
func (i *IAMCustomRole) ToIAMCustomRoleOutputWithContext(ctx context.Context) IAMCustomRoleOutput {
return pulumi.ToOutputWithContext(ctx, i).(IAMCustomRoleOutput)
}
// IAMCustomRoleArrayInput is an input type that accepts IAMCustomRoleArray and IAMCustomRoleArrayOutput values.
// You can construct a concrete instance of `IAMCustomRoleArrayInput` via:
//
// IAMCustomRoleArray{ IAMCustomRoleArgs{...} }
type IAMCustomRoleArrayInput interface {
pulumi.Input
ToIAMCustomRoleArrayOutput() IAMCustomRoleArrayOutput
ToIAMCustomRoleArrayOutputWithContext(context.Context) IAMCustomRoleArrayOutput
}
type IAMCustomRoleArray []IAMCustomRoleInput
func (IAMCustomRoleArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*IAMCustomRole)(nil)).Elem()
}
func (i IAMCustomRoleArray) ToIAMCustomRoleArrayOutput() IAMCustomRoleArrayOutput {
return i.ToIAMCustomRoleArrayOutputWithContext(context.Background())
}
func (i IAMCustomRoleArray) ToIAMCustomRoleArrayOutputWithContext(ctx context.Context) IAMCustomRoleArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(IAMCustomRoleArrayOutput)
}
// IAMCustomRoleMapInput is an input type that accepts IAMCustomRoleMap and IAMCustomRoleMapOutput values.
// You can construct a concrete instance of `IAMCustomRoleMapInput` via:
//
// IAMCustomRoleMap{ "key": IAMCustomRoleArgs{...} }
type IAMCustomRoleMapInput interface {
pulumi.Input
ToIAMCustomRoleMapOutput() IAMCustomRoleMapOutput
ToIAMCustomRoleMapOutputWithContext(context.Context) IAMCustomRoleMapOutput
}
type IAMCustomRoleMap map[string]IAMCustomRoleInput
func (IAMCustomRoleMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*IAMCustomRole)(nil)).Elem()
}
func (i IAMCustomRoleMap) ToIAMCustomRoleMapOutput() IAMCustomRoleMapOutput {
return i.ToIAMCustomRoleMapOutputWithContext(context.Background())
}
func (i IAMCustomRoleMap) ToIAMCustomRoleMapOutputWithContext(ctx context.Context) IAMCustomRoleMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(IAMCustomRoleMapOutput)
}
type IAMCustomRoleOutput struct{ *pulumi.OutputState }
func (IAMCustomRoleOutput) ElementType() reflect.Type {
return reflect.TypeOf((**IAMCustomRole)(nil)).Elem()
}
func (o IAMCustomRoleOutput) ToIAMCustomRoleOutput() IAMCustomRoleOutput {
return o
}
func (o IAMCustomRoleOutput) ToIAMCustomRoleOutputWithContext(ctx context.Context) IAMCustomRoleOutput {
return o
}
// (Optional) The current deleted state of the role.
func (o IAMCustomRoleOutput) Deleted() pulumi.BoolOutput {
return o.ApplyT(func(v *IAMCustomRole) pulumi.BoolOutput { return v.Deleted }).(pulumi.BoolOutput)
}
// A human-readable description for the role.
func (o IAMCustomRoleOutput) Description() pulumi.StringPtrOutput {
return o.ApplyT(func(v *IAMCustomRole) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
}
// The name of the role in the format `organizations/{{org_id}}/roles/{{role_id}}`. Like `id`, this field can be used as a reference in other resources such as IAM role bindings.
func (o IAMCustomRoleOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *IAMCustomRole) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// The numeric ID of the organization in which you want to create a custom role.
func (o IAMCustomRoleOutput) OrgId() pulumi.StringOutput {
return o.ApplyT(func(v *IAMCustomRole) pulumi.StringOutput { return v.OrgId }).(pulumi.StringOutput)
}
// The names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
func (o IAMCustomRoleOutput) Permissions() pulumi.StringArrayOutput {
return o.ApplyT(func(v *IAMCustomRole) pulumi.StringArrayOutput { return v.Permissions }).(pulumi.StringArrayOutput)
}
// The role id to use for this role.
func (o IAMCustomRoleOutput) RoleId() pulumi.StringOutput {
return o.ApplyT(func(v *IAMCustomRole) pulumi.StringOutput { return v.RoleId }).(pulumi.StringOutput)
}
// The current launch stage of the role.
// Defaults to `GA`.
// List of possible stages is [here](https://cloud.google.com/iam/reference/rest/v1/organizations.roles#Role.RoleLaunchStage).
func (o IAMCustomRoleOutput) Stage() pulumi.StringPtrOutput {
return o.ApplyT(func(v *IAMCustomRole) pulumi.StringPtrOutput { return v.Stage }).(pulumi.StringPtrOutput)
}
// A human-readable title for the role.
func (o IAMCustomRoleOutput) Title() pulumi.StringOutput {
return o.ApplyT(func(v *IAMCustomRole) pulumi.StringOutput { return v.Title }).(pulumi.StringOutput)
}
type IAMCustomRoleArrayOutput struct{ *pulumi.OutputState }
func (IAMCustomRoleArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*IAMCustomRole)(nil)).Elem()
}
func (o IAMCustomRoleArrayOutput) ToIAMCustomRoleArrayOutput() IAMCustomRoleArrayOutput {
return o
}
func (o IAMCustomRoleArrayOutput) ToIAMCustomRoleArrayOutputWithContext(ctx context.Context) IAMCustomRoleArrayOutput {
return o
}
func (o IAMCustomRoleArrayOutput) Index(i pulumi.IntInput) IAMCustomRoleOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *IAMCustomRole {
return vs[0].([]*IAMCustomRole)[vs[1].(int)]
}).(IAMCustomRoleOutput)
}
type IAMCustomRoleMapOutput struct{ *pulumi.OutputState }
func (IAMCustomRoleMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*IAMCustomRole)(nil)).Elem()
}
func (o IAMCustomRoleMapOutput) ToIAMCustomRoleMapOutput() IAMCustomRoleMapOutput {
return o
}
func (o IAMCustomRoleMapOutput) ToIAMCustomRoleMapOutputWithContext(ctx context.Context) IAMCustomRoleMapOutput {
return o
}
func (o IAMCustomRoleMapOutput) MapIndex(k pulumi.StringInput) IAMCustomRoleOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *IAMCustomRole {
return vs[0].(map[string]*IAMCustomRole)[vs[1].(string)]
}).(IAMCustomRoleOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*IAMCustomRoleInput)(nil)).Elem(), &IAMCustomRole{})
pulumi.RegisterInputType(reflect.TypeOf((*IAMCustomRoleArrayInput)(nil)).Elem(), IAMCustomRoleArray{})
pulumi.RegisterInputType(reflect.TypeOf((*IAMCustomRoleMapInput)(nil)).Elem(), IAMCustomRoleMap{})
pulumi.RegisterOutputType(IAMCustomRoleOutput{})
pulumi.RegisterOutputType(IAMCustomRoleArrayOutput{})
pulumi.RegisterOutputType(IAMCustomRoleMapOutput{})
}