/
userPolicyAttachment.go
346 lines (286 loc) · 13.7 KB
/
userPolicyAttachment.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
// *** 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 ram
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// Provides a RAM User Policy attachment resource.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "fmt"
//
// "github.com/pulumi/pulumi-alicloud/sdk/v2/go/alicloud/ram"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// user, err := ram.NewUser(ctx, "user", &ram.UserArgs{
// DisplayName: pulumi.String("user_display_name"),
// Mobile: pulumi.String("86-18688888888"),
// Email: pulumi.String("hello.uuu@aaa.com"),
// Comments: pulumi.String("yoyoyo"),
// Force: pulumi.Bool(true),
// })
// if err != nil {
// return err
// }
// policy, err := ram.NewPolicy(ctx, "policy", &ram.PolicyArgs{
// Document: pulumi.String(fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v", " {\n", " \"Statement\": [\n", " {\n", " \"Action\": [\n", " \"oss:ListObjects\",\n", " \"oss:GetObject\"\n", " ],\n", " \"Effect\": \"Allow\",\n", " \"Resource\": [\n", " \"acs:oss:*:*:mybucket\",\n", " \"acs:oss:*:*:mybucket/*\"\n", " ]\n", " }\n", " ],\n", " \"Version\": \"1\"\n", " }\n")),
// Description: pulumi.String("this is a policy test"),
// Force: pulumi.Bool(true),
// })
// if err != nil {
// return err
// }
// _, err = ram.NewUserPolicyAttachment(ctx, "attach", &ram.UserPolicyAttachmentArgs{
// PolicyName: policy.Name,
// PolicyType: policy.Type,
// UserName: user.Name,
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// RAM User Policy attachment can be imported using the id, e.g.
//
// ```sh
// $ pulumi import alicloud:ram/userPolicyAttachment:UserPolicyAttachment example user:my-policy:Custom:my-user
// ```
type UserPolicyAttachment struct {
pulumi.CustomResourceState
// Name of the RAM policy. This name can have a string of 1 to 128 characters, must contain only alphanumeric characters or hyphen "-", and must not begin with a hyphen.
PolicyName pulumi.StringOutput `pulumi:"policyName"`
// Type of the RAM policy. It must be `Custom` or `System`.
PolicyType pulumi.StringOutput `pulumi:"policyType"`
// Name of the RAM user. This name can have a string of 1 to 64 characters, must contain only alphanumeric characters or hyphens, such as "-",".","_", and must not begin with a hyphen.
UserName pulumi.StringOutput `pulumi:"userName"`
}
// NewUserPolicyAttachment registers a new resource with the given unique name, arguments, and options.
func NewUserPolicyAttachment(ctx *pulumi.Context,
name string, args *UserPolicyAttachmentArgs, opts ...pulumi.ResourceOption) (*UserPolicyAttachment, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.PolicyName == nil {
return nil, errors.New("invalid value for required argument 'PolicyName'")
}
if args.PolicyType == nil {
return nil, errors.New("invalid value for required argument 'PolicyType'")
}
if args.UserName == nil {
return nil, errors.New("invalid value for required argument 'UserName'")
}
var resource UserPolicyAttachment
err := ctx.RegisterResource("alicloud:ram/userPolicyAttachment:UserPolicyAttachment", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetUserPolicyAttachment gets an existing UserPolicyAttachment 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 GetUserPolicyAttachment(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *UserPolicyAttachmentState, opts ...pulumi.ResourceOption) (*UserPolicyAttachment, error) {
var resource UserPolicyAttachment
err := ctx.ReadResource("alicloud:ram/userPolicyAttachment:UserPolicyAttachment", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering UserPolicyAttachment resources.
type userPolicyAttachmentState struct {
// Name of the RAM policy. This name can have a string of 1 to 128 characters, must contain only alphanumeric characters or hyphen "-", and must not begin with a hyphen.
PolicyName *string `pulumi:"policyName"`
// Type of the RAM policy. It must be `Custom` or `System`.
PolicyType *string `pulumi:"policyType"`
// Name of the RAM user. This name can have a string of 1 to 64 characters, must contain only alphanumeric characters or hyphens, such as "-",".","_", and must not begin with a hyphen.
UserName *string `pulumi:"userName"`
}
type UserPolicyAttachmentState struct {
// Name of the RAM policy. This name can have a string of 1 to 128 characters, must contain only alphanumeric characters or hyphen "-", and must not begin with a hyphen.
PolicyName pulumi.StringPtrInput
// Type of the RAM policy. It must be `Custom` or `System`.
PolicyType pulumi.StringPtrInput
// Name of the RAM user. This name can have a string of 1 to 64 characters, must contain only alphanumeric characters or hyphens, such as "-",".","_", and must not begin with a hyphen.
UserName pulumi.StringPtrInput
}
func (UserPolicyAttachmentState) ElementType() reflect.Type {
return reflect.TypeOf((*userPolicyAttachmentState)(nil)).Elem()
}
type userPolicyAttachmentArgs struct {
// Name of the RAM policy. This name can have a string of 1 to 128 characters, must contain only alphanumeric characters or hyphen "-", and must not begin with a hyphen.
PolicyName string `pulumi:"policyName"`
// Type of the RAM policy. It must be `Custom` or `System`.
PolicyType string `pulumi:"policyType"`
// Name of the RAM user. This name can have a string of 1 to 64 characters, must contain only alphanumeric characters or hyphens, such as "-",".","_", and must not begin with a hyphen.
UserName string `pulumi:"userName"`
}
// The set of arguments for constructing a UserPolicyAttachment resource.
type UserPolicyAttachmentArgs struct {
// Name of the RAM policy. This name can have a string of 1 to 128 characters, must contain only alphanumeric characters or hyphen "-", and must not begin with a hyphen.
PolicyName pulumi.StringInput
// Type of the RAM policy. It must be `Custom` or `System`.
PolicyType pulumi.StringInput
// Name of the RAM user. This name can have a string of 1 to 64 characters, must contain only alphanumeric characters or hyphens, such as "-",".","_", and must not begin with a hyphen.
UserName pulumi.StringInput
}
func (UserPolicyAttachmentArgs) ElementType() reflect.Type {
return reflect.TypeOf((*userPolicyAttachmentArgs)(nil)).Elem()
}
type UserPolicyAttachmentInput interface {
pulumi.Input
ToUserPolicyAttachmentOutput() UserPolicyAttachmentOutput
ToUserPolicyAttachmentOutputWithContext(ctx context.Context) UserPolicyAttachmentOutput
}
func (*UserPolicyAttachment) ElementType() reflect.Type {
return reflect.TypeOf((*UserPolicyAttachment)(nil))
}
func (i *UserPolicyAttachment) ToUserPolicyAttachmentOutput() UserPolicyAttachmentOutput {
return i.ToUserPolicyAttachmentOutputWithContext(context.Background())
}
func (i *UserPolicyAttachment) ToUserPolicyAttachmentOutputWithContext(ctx context.Context) UserPolicyAttachmentOutput {
return pulumi.ToOutputWithContext(ctx, i).(UserPolicyAttachmentOutput)
}
func (i *UserPolicyAttachment) ToUserPolicyAttachmentPtrOutput() UserPolicyAttachmentPtrOutput {
return i.ToUserPolicyAttachmentPtrOutputWithContext(context.Background())
}
func (i *UserPolicyAttachment) ToUserPolicyAttachmentPtrOutputWithContext(ctx context.Context) UserPolicyAttachmentPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(UserPolicyAttachmentPtrOutput)
}
type UserPolicyAttachmentPtrInput interface {
pulumi.Input
ToUserPolicyAttachmentPtrOutput() UserPolicyAttachmentPtrOutput
ToUserPolicyAttachmentPtrOutputWithContext(ctx context.Context) UserPolicyAttachmentPtrOutput
}
type userPolicyAttachmentPtrType UserPolicyAttachmentArgs
func (*userPolicyAttachmentPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**UserPolicyAttachment)(nil))
}
func (i *userPolicyAttachmentPtrType) ToUserPolicyAttachmentPtrOutput() UserPolicyAttachmentPtrOutput {
return i.ToUserPolicyAttachmentPtrOutputWithContext(context.Background())
}
func (i *userPolicyAttachmentPtrType) ToUserPolicyAttachmentPtrOutputWithContext(ctx context.Context) UserPolicyAttachmentPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(UserPolicyAttachmentPtrOutput)
}
// UserPolicyAttachmentArrayInput is an input type that accepts UserPolicyAttachmentArray and UserPolicyAttachmentArrayOutput values.
// You can construct a concrete instance of `UserPolicyAttachmentArrayInput` via:
//
// UserPolicyAttachmentArray{ UserPolicyAttachmentArgs{...} }
type UserPolicyAttachmentArrayInput interface {
pulumi.Input
ToUserPolicyAttachmentArrayOutput() UserPolicyAttachmentArrayOutput
ToUserPolicyAttachmentArrayOutputWithContext(context.Context) UserPolicyAttachmentArrayOutput
}
type UserPolicyAttachmentArray []UserPolicyAttachmentInput
func (UserPolicyAttachmentArray) ElementType() reflect.Type {
return reflect.TypeOf(([]*UserPolicyAttachment)(nil))
}
func (i UserPolicyAttachmentArray) ToUserPolicyAttachmentArrayOutput() UserPolicyAttachmentArrayOutput {
return i.ToUserPolicyAttachmentArrayOutputWithContext(context.Background())
}
func (i UserPolicyAttachmentArray) ToUserPolicyAttachmentArrayOutputWithContext(ctx context.Context) UserPolicyAttachmentArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(UserPolicyAttachmentArrayOutput)
}
// UserPolicyAttachmentMapInput is an input type that accepts UserPolicyAttachmentMap and UserPolicyAttachmentMapOutput values.
// You can construct a concrete instance of `UserPolicyAttachmentMapInput` via:
//
// UserPolicyAttachmentMap{ "key": UserPolicyAttachmentArgs{...} }
type UserPolicyAttachmentMapInput interface {
pulumi.Input
ToUserPolicyAttachmentMapOutput() UserPolicyAttachmentMapOutput
ToUserPolicyAttachmentMapOutputWithContext(context.Context) UserPolicyAttachmentMapOutput
}
type UserPolicyAttachmentMap map[string]UserPolicyAttachmentInput
func (UserPolicyAttachmentMap) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*UserPolicyAttachment)(nil))
}
func (i UserPolicyAttachmentMap) ToUserPolicyAttachmentMapOutput() UserPolicyAttachmentMapOutput {
return i.ToUserPolicyAttachmentMapOutputWithContext(context.Background())
}
func (i UserPolicyAttachmentMap) ToUserPolicyAttachmentMapOutputWithContext(ctx context.Context) UserPolicyAttachmentMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(UserPolicyAttachmentMapOutput)
}
type UserPolicyAttachmentOutput struct {
*pulumi.OutputState
}
func (UserPolicyAttachmentOutput) ElementType() reflect.Type {
return reflect.TypeOf((*UserPolicyAttachment)(nil))
}
func (o UserPolicyAttachmentOutput) ToUserPolicyAttachmentOutput() UserPolicyAttachmentOutput {
return o
}
func (o UserPolicyAttachmentOutput) ToUserPolicyAttachmentOutputWithContext(ctx context.Context) UserPolicyAttachmentOutput {
return o
}
func (o UserPolicyAttachmentOutput) ToUserPolicyAttachmentPtrOutput() UserPolicyAttachmentPtrOutput {
return o.ToUserPolicyAttachmentPtrOutputWithContext(context.Background())
}
func (o UserPolicyAttachmentOutput) ToUserPolicyAttachmentPtrOutputWithContext(ctx context.Context) UserPolicyAttachmentPtrOutput {
return o.ApplyT(func(v UserPolicyAttachment) *UserPolicyAttachment {
return &v
}).(UserPolicyAttachmentPtrOutput)
}
type UserPolicyAttachmentPtrOutput struct {
*pulumi.OutputState
}
func (UserPolicyAttachmentPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**UserPolicyAttachment)(nil))
}
func (o UserPolicyAttachmentPtrOutput) ToUserPolicyAttachmentPtrOutput() UserPolicyAttachmentPtrOutput {
return o
}
func (o UserPolicyAttachmentPtrOutput) ToUserPolicyAttachmentPtrOutputWithContext(ctx context.Context) UserPolicyAttachmentPtrOutput {
return o
}
type UserPolicyAttachmentArrayOutput struct{ *pulumi.OutputState }
func (UserPolicyAttachmentArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]UserPolicyAttachment)(nil))
}
func (o UserPolicyAttachmentArrayOutput) ToUserPolicyAttachmentArrayOutput() UserPolicyAttachmentArrayOutput {
return o
}
func (o UserPolicyAttachmentArrayOutput) ToUserPolicyAttachmentArrayOutputWithContext(ctx context.Context) UserPolicyAttachmentArrayOutput {
return o
}
func (o UserPolicyAttachmentArrayOutput) Index(i pulumi.IntInput) UserPolicyAttachmentOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) UserPolicyAttachment {
return vs[0].([]UserPolicyAttachment)[vs[1].(int)]
}).(UserPolicyAttachmentOutput)
}
type UserPolicyAttachmentMapOutput struct{ *pulumi.OutputState }
func (UserPolicyAttachmentMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]UserPolicyAttachment)(nil))
}
func (o UserPolicyAttachmentMapOutput) ToUserPolicyAttachmentMapOutput() UserPolicyAttachmentMapOutput {
return o
}
func (o UserPolicyAttachmentMapOutput) ToUserPolicyAttachmentMapOutputWithContext(ctx context.Context) UserPolicyAttachmentMapOutput {
return o
}
func (o UserPolicyAttachmentMapOutput) MapIndex(k pulumi.StringInput) UserPolicyAttachmentOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) UserPolicyAttachment {
return vs[0].(map[string]UserPolicyAttachment)[vs[1].(string)]
}).(UserPolicyAttachmentOutput)
}
func init() {
pulumi.RegisterOutputType(UserPolicyAttachmentOutput{})
pulumi.RegisterOutputType(UserPolicyAttachmentPtrOutput{})
pulumi.RegisterOutputType(UserPolicyAttachmentArrayOutput{})
pulumi.RegisterOutputType(UserPolicyAttachmentMapOutput{})
}