-
Notifications
You must be signed in to change notification settings - Fork 151
/
permissions.go
382 lines (322 loc) · 18 KB
/
permissions.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
// *** 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 lakeformation
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Grants permissions to the principal to access metadata in the Data Catalog and data organized in underlying data storage such as Amazon S3. Permissions are granted to a principal, in a Data Catalog, relative to a Lake Formation resource, which includes the Data Catalog, databases, and tables. For more information, see [Security and Access Control to Metadata and Data in Lake Formation](https://docs.aws.amazon.com/lake-formation/latest/dg/security-data-access.html).
//
// > **NOTE:** Lake Formation grants implicit permissions to data lake administrators, database creators, and table creators. These implicit permissions cannot be revoked _per se_. If this resource reads implicit permissions, it will attempt to revoke them, which causes an error when the resource is destroyed. There are two ways to avoid these errors. First, grant explicit permissions (and `permissionsWithGrantOption`) to "overwrite" a principal's implicit permissions, which you can then revoke with this resource. Second, avoid using this resource with principals that have implicit permissions. For more information, see [Implicit Lake Formation Permissions](https://docs.aws.amazon.com/lake-formation/latest/dg/implicit-permissions.html).
//
// ## Example Usage
// ### Grant Permissions For A Lake Formation S3 Resource
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/lakeformation"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := lakeformation.NewPermissions(ctx, "test", &lakeformation.PermissionsArgs{
// Principal: pulumi.Any(aws_iam_role.Workflow_role.Arn),
// Permissions: pulumi.StringArray{
// pulumi.String("ALL"),
// },
// DataLocation: &lakeformation.PermissionsDataLocationArgs{
// Arn: pulumi.Any(aws_lakeformation_resource.Test.Arn),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
type Permissions struct {
pulumi.CustomResourceState
// Identifier for the Data Catalog. By default, it is the account ID of the caller.
CatalogId pulumi.StringPtrOutput `pulumi:"catalogId"`
// Whether the permissions are to be granted for the Data Catalog. Defaults to `false`.
CatalogResource pulumi.BoolPtrOutput `pulumi:"catalogResource"`
// Configuration block for a data location resource. Detailed below.
DataLocation PermissionsDataLocationOutput `pulumi:"dataLocation"`
// Configuration block for a database resource. Detailed below.
Database PermissionsDatabaseOutput `pulumi:"database"`
// List of permissions granted to the principal. Valid values may include `ALL`, `ALTER`, `CREATE_DATABASE`, `CREATE_TABLE`, `DATA_LOCATION_ACCESS`, `DELETE`, `DESCRIBE`, `DROP`, `INSERT`, and `SELECT`. For details on each permission, see [Lake Formation Permissions Reference](https://docs.aws.amazon.com/lake-formation/latest/dg/lf-permissions-reference.html).
Permissions pulumi.StringArrayOutput `pulumi:"permissions"`
// Subset of `permissions` which the principal can pass.
PermissionsWithGrantOptions pulumi.StringArrayOutput `pulumi:"permissionsWithGrantOptions"`
// Principal to be granted the permissions on the resource. Supported principals include IAM roles, users, groups, SAML groups and users, QuickSight groups, OUs, and organizations as well as AWS account IDs for cross-account permissions. For more information, see [Lake Formation Permissions Reference](https://docs.aws.amazon.com/lake-formation/latest/dg/lf-permissions-reference.html).
Principal pulumi.StringOutput `pulumi:"principal"`
// Configuration block for a table resource. Detailed below.
Table PermissionsTableOutput `pulumi:"table"`
// Configuration block for a table with columns resource. Detailed below.
TableWithColumns PermissionsTableWithColumnsOutput `pulumi:"tableWithColumns"`
}
// NewPermissions registers a new resource with the given unique name, arguments, and options.
func NewPermissions(ctx *pulumi.Context,
name string, args *PermissionsArgs, opts ...pulumi.ResourceOption) (*Permissions, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Permissions == nil {
return nil, errors.New("invalid value for required argument 'Permissions'")
}
if args.Principal == nil {
return nil, errors.New("invalid value for required argument 'Principal'")
}
var resource Permissions
err := ctx.RegisterResource("aws:lakeformation/permissions:Permissions", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetPermissions gets an existing Permissions 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 GetPermissions(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *PermissionsState, opts ...pulumi.ResourceOption) (*Permissions, error) {
var resource Permissions
err := ctx.ReadResource("aws:lakeformation/permissions:Permissions", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Permissions resources.
type permissionsState struct {
// Identifier for the Data Catalog. By default, it is the account ID of the caller.
CatalogId *string `pulumi:"catalogId"`
// Whether the permissions are to be granted for the Data Catalog. Defaults to `false`.
CatalogResource *bool `pulumi:"catalogResource"`
// Configuration block for a data location resource. Detailed below.
DataLocation *PermissionsDataLocation `pulumi:"dataLocation"`
// Configuration block for a database resource. Detailed below.
Database *PermissionsDatabase `pulumi:"database"`
// List of permissions granted to the principal. Valid values may include `ALL`, `ALTER`, `CREATE_DATABASE`, `CREATE_TABLE`, `DATA_LOCATION_ACCESS`, `DELETE`, `DESCRIBE`, `DROP`, `INSERT`, and `SELECT`. For details on each permission, see [Lake Formation Permissions Reference](https://docs.aws.amazon.com/lake-formation/latest/dg/lf-permissions-reference.html).
Permissions []string `pulumi:"permissions"`
// Subset of `permissions` which the principal can pass.
PermissionsWithGrantOptions []string `pulumi:"permissionsWithGrantOptions"`
// Principal to be granted the permissions on the resource. Supported principals include IAM roles, users, groups, SAML groups and users, QuickSight groups, OUs, and organizations as well as AWS account IDs for cross-account permissions. For more information, see [Lake Formation Permissions Reference](https://docs.aws.amazon.com/lake-formation/latest/dg/lf-permissions-reference.html).
Principal *string `pulumi:"principal"`
// Configuration block for a table resource. Detailed below.
Table *PermissionsTable `pulumi:"table"`
// Configuration block for a table with columns resource. Detailed below.
TableWithColumns *PermissionsTableWithColumns `pulumi:"tableWithColumns"`
}
type PermissionsState struct {
// Identifier for the Data Catalog. By default, it is the account ID of the caller.
CatalogId pulumi.StringPtrInput
// Whether the permissions are to be granted for the Data Catalog. Defaults to `false`.
CatalogResource pulumi.BoolPtrInput
// Configuration block for a data location resource. Detailed below.
DataLocation PermissionsDataLocationPtrInput
// Configuration block for a database resource. Detailed below.
Database PermissionsDatabasePtrInput
// List of permissions granted to the principal. Valid values may include `ALL`, `ALTER`, `CREATE_DATABASE`, `CREATE_TABLE`, `DATA_LOCATION_ACCESS`, `DELETE`, `DESCRIBE`, `DROP`, `INSERT`, and `SELECT`. For details on each permission, see [Lake Formation Permissions Reference](https://docs.aws.amazon.com/lake-formation/latest/dg/lf-permissions-reference.html).
Permissions pulumi.StringArrayInput
// Subset of `permissions` which the principal can pass.
PermissionsWithGrantOptions pulumi.StringArrayInput
// Principal to be granted the permissions on the resource. Supported principals include IAM roles, users, groups, SAML groups and users, QuickSight groups, OUs, and organizations as well as AWS account IDs for cross-account permissions. For more information, see [Lake Formation Permissions Reference](https://docs.aws.amazon.com/lake-formation/latest/dg/lf-permissions-reference.html).
Principal pulumi.StringPtrInput
// Configuration block for a table resource. Detailed below.
Table PermissionsTablePtrInput
// Configuration block for a table with columns resource. Detailed below.
TableWithColumns PermissionsTableWithColumnsPtrInput
}
func (PermissionsState) ElementType() reflect.Type {
return reflect.TypeOf((*permissionsState)(nil)).Elem()
}
type permissionsArgs struct {
// Identifier for the Data Catalog. By default, it is the account ID of the caller.
CatalogId *string `pulumi:"catalogId"`
// Whether the permissions are to be granted for the Data Catalog. Defaults to `false`.
CatalogResource *bool `pulumi:"catalogResource"`
// Configuration block for a data location resource. Detailed below.
DataLocation *PermissionsDataLocation `pulumi:"dataLocation"`
// Configuration block for a database resource. Detailed below.
Database *PermissionsDatabase `pulumi:"database"`
// List of permissions granted to the principal. Valid values may include `ALL`, `ALTER`, `CREATE_DATABASE`, `CREATE_TABLE`, `DATA_LOCATION_ACCESS`, `DELETE`, `DESCRIBE`, `DROP`, `INSERT`, and `SELECT`. For details on each permission, see [Lake Formation Permissions Reference](https://docs.aws.amazon.com/lake-formation/latest/dg/lf-permissions-reference.html).
Permissions []string `pulumi:"permissions"`
// Subset of `permissions` which the principal can pass.
PermissionsWithGrantOptions []string `pulumi:"permissionsWithGrantOptions"`
// Principal to be granted the permissions on the resource. Supported principals include IAM roles, users, groups, SAML groups and users, QuickSight groups, OUs, and organizations as well as AWS account IDs for cross-account permissions. For more information, see [Lake Formation Permissions Reference](https://docs.aws.amazon.com/lake-formation/latest/dg/lf-permissions-reference.html).
Principal string `pulumi:"principal"`
// Configuration block for a table resource. Detailed below.
Table *PermissionsTable `pulumi:"table"`
// Configuration block for a table with columns resource. Detailed below.
TableWithColumns *PermissionsTableWithColumns `pulumi:"tableWithColumns"`
}
// The set of arguments for constructing a Permissions resource.
type PermissionsArgs struct {
// Identifier for the Data Catalog. By default, it is the account ID of the caller.
CatalogId pulumi.StringPtrInput
// Whether the permissions are to be granted for the Data Catalog. Defaults to `false`.
CatalogResource pulumi.BoolPtrInput
// Configuration block for a data location resource. Detailed below.
DataLocation PermissionsDataLocationPtrInput
// Configuration block for a database resource. Detailed below.
Database PermissionsDatabasePtrInput
// List of permissions granted to the principal. Valid values may include `ALL`, `ALTER`, `CREATE_DATABASE`, `CREATE_TABLE`, `DATA_LOCATION_ACCESS`, `DELETE`, `DESCRIBE`, `DROP`, `INSERT`, and `SELECT`. For details on each permission, see [Lake Formation Permissions Reference](https://docs.aws.amazon.com/lake-formation/latest/dg/lf-permissions-reference.html).
Permissions pulumi.StringArrayInput
// Subset of `permissions` which the principal can pass.
PermissionsWithGrantOptions pulumi.StringArrayInput
// Principal to be granted the permissions on the resource. Supported principals include IAM roles, users, groups, SAML groups and users, QuickSight groups, OUs, and organizations as well as AWS account IDs for cross-account permissions. For more information, see [Lake Formation Permissions Reference](https://docs.aws.amazon.com/lake-formation/latest/dg/lf-permissions-reference.html).
Principal pulumi.StringInput
// Configuration block for a table resource. Detailed below.
Table PermissionsTablePtrInput
// Configuration block for a table with columns resource. Detailed below.
TableWithColumns PermissionsTableWithColumnsPtrInput
}
func (PermissionsArgs) ElementType() reflect.Type {
return reflect.TypeOf((*permissionsArgs)(nil)).Elem()
}
type PermissionsInput interface {
pulumi.Input
ToPermissionsOutput() PermissionsOutput
ToPermissionsOutputWithContext(ctx context.Context) PermissionsOutput
}
func (*Permissions) ElementType() reflect.Type {
return reflect.TypeOf((*Permissions)(nil))
}
func (i *Permissions) ToPermissionsOutput() PermissionsOutput {
return i.ToPermissionsOutputWithContext(context.Background())
}
func (i *Permissions) ToPermissionsOutputWithContext(ctx context.Context) PermissionsOutput {
return pulumi.ToOutputWithContext(ctx, i).(PermissionsOutput)
}
func (i *Permissions) ToPermissionsPtrOutput() PermissionsPtrOutput {
return i.ToPermissionsPtrOutputWithContext(context.Background())
}
func (i *Permissions) ToPermissionsPtrOutputWithContext(ctx context.Context) PermissionsPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(PermissionsPtrOutput)
}
type PermissionsPtrInput interface {
pulumi.Input
ToPermissionsPtrOutput() PermissionsPtrOutput
ToPermissionsPtrOutputWithContext(ctx context.Context) PermissionsPtrOutput
}
type permissionsPtrType PermissionsArgs
func (*permissionsPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**Permissions)(nil))
}
func (i *permissionsPtrType) ToPermissionsPtrOutput() PermissionsPtrOutput {
return i.ToPermissionsPtrOutputWithContext(context.Background())
}
func (i *permissionsPtrType) ToPermissionsPtrOutputWithContext(ctx context.Context) PermissionsPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(PermissionsPtrOutput)
}
// PermissionsArrayInput is an input type that accepts PermissionsArray and PermissionsArrayOutput values.
// You can construct a concrete instance of `PermissionsArrayInput` via:
//
// PermissionsArray{ PermissionsArgs{...} }
type PermissionsArrayInput interface {
pulumi.Input
ToPermissionsArrayOutput() PermissionsArrayOutput
ToPermissionsArrayOutputWithContext(context.Context) PermissionsArrayOutput
}
type PermissionsArray []PermissionsInput
func (PermissionsArray) ElementType() reflect.Type {
return reflect.TypeOf(([]*Permissions)(nil))
}
func (i PermissionsArray) ToPermissionsArrayOutput() PermissionsArrayOutput {
return i.ToPermissionsArrayOutputWithContext(context.Background())
}
func (i PermissionsArray) ToPermissionsArrayOutputWithContext(ctx context.Context) PermissionsArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(PermissionsArrayOutput)
}
// PermissionsMapInput is an input type that accepts PermissionsMap and PermissionsMapOutput values.
// You can construct a concrete instance of `PermissionsMapInput` via:
//
// PermissionsMap{ "key": PermissionsArgs{...} }
type PermissionsMapInput interface {
pulumi.Input
ToPermissionsMapOutput() PermissionsMapOutput
ToPermissionsMapOutputWithContext(context.Context) PermissionsMapOutput
}
type PermissionsMap map[string]PermissionsInput
func (PermissionsMap) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*Permissions)(nil))
}
func (i PermissionsMap) ToPermissionsMapOutput() PermissionsMapOutput {
return i.ToPermissionsMapOutputWithContext(context.Background())
}
func (i PermissionsMap) ToPermissionsMapOutputWithContext(ctx context.Context) PermissionsMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(PermissionsMapOutput)
}
type PermissionsOutput struct {
*pulumi.OutputState
}
func (PermissionsOutput) ElementType() reflect.Type {
return reflect.TypeOf((*Permissions)(nil))
}
func (o PermissionsOutput) ToPermissionsOutput() PermissionsOutput {
return o
}
func (o PermissionsOutput) ToPermissionsOutputWithContext(ctx context.Context) PermissionsOutput {
return o
}
func (o PermissionsOutput) ToPermissionsPtrOutput() PermissionsPtrOutput {
return o.ToPermissionsPtrOutputWithContext(context.Background())
}
func (o PermissionsOutput) ToPermissionsPtrOutputWithContext(ctx context.Context) PermissionsPtrOutput {
return o.ApplyT(func(v Permissions) *Permissions {
return &v
}).(PermissionsPtrOutput)
}
type PermissionsPtrOutput struct {
*pulumi.OutputState
}
func (PermissionsPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Permissions)(nil))
}
func (o PermissionsPtrOutput) ToPermissionsPtrOutput() PermissionsPtrOutput {
return o
}
func (o PermissionsPtrOutput) ToPermissionsPtrOutputWithContext(ctx context.Context) PermissionsPtrOutput {
return o
}
type PermissionsArrayOutput struct{ *pulumi.OutputState }
func (PermissionsArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]Permissions)(nil))
}
func (o PermissionsArrayOutput) ToPermissionsArrayOutput() PermissionsArrayOutput {
return o
}
func (o PermissionsArrayOutput) ToPermissionsArrayOutputWithContext(ctx context.Context) PermissionsArrayOutput {
return o
}
func (o PermissionsArrayOutput) Index(i pulumi.IntInput) PermissionsOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) Permissions {
return vs[0].([]Permissions)[vs[1].(int)]
}).(PermissionsOutput)
}
type PermissionsMapOutput struct{ *pulumi.OutputState }
func (PermissionsMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]Permissions)(nil))
}
func (o PermissionsMapOutput) ToPermissionsMapOutput() PermissionsMapOutput {
return o
}
func (o PermissionsMapOutput) ToPermissionsMapOutputWithContext(ctx context.Context) PermissionsMapOutput {
return o
}
func (o PermissionsMapOutput) MapIndex(k pulumi.StringInput) PermissionsOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) Permissions {
return vs[0].(map[string]Permissions)[vs[1].(string)]
}).(PermissionsOutput)
}
func init() {
pulumi.RegisterOutputType(PermissionsOutput{})
pulumi.RegisterOutputType(PermissionsPtrOutput{})
pulumi.RegisterOutputType(PermissionsArrayOutput{})
pulumi.RegisterOutputType(PermissionsMapOutput{})
}