/
saslAcl.go
445 lines (392 loc) · 17.7 KB
/
saslAcl.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
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
// 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 alikafka
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides an ALIKAFKA sasl acl resource, see [What is alikafka sasl acl](https://www.alibabacloud.com/help/en/message-queue-for-apache-kafka/latest/api-alikafka-2019-09-16-createacl).
//
// > **NOTE:** Available since v1.66.0.
//
// > **NOTE:** Only the following regions support create alikafka sasl user.
// [`cn-hangzhou`,`cn-beijing`,`cn-shenzhen`,`cn-shanghai`,`cn-qingdao`,`cn-hongkong`,`cn-huhehaote`,`cn-zhangjiakou`,`cn-chengdu`,`cn-heyuan`,`ap-southeast-1`,`ap-southeast-3`,`ap-southeast-5`,`ap-northeast-1`,`eu-central-1`,`eu-west-1`,`us-west-1`,`us-east-1`]
//
// ## Example Usage
//
// # Basic Usage
//
// ```go
// package main
//
// import (
//
// "fmt"
//
// "github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
// "github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/alikafka"
// "github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
// "github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
// "github.com/pulumi/pulumi-random/sdk/v4/go/random"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// cfg := config.New(ctx, "")
// name := "tf_example"
// if param := cfg.Get("name"); param != "" {
// name = param
// }
// _default, err := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
// AvailableResourceCreation: pulumi.StringRef("VSwitch"),
// }, nil)
// if err != nil {
// return err
// }
// defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
// VpcName: pulumi.String(name),
// CidrBlock: pulumi.String("10.4.0.0/16"),
// })
// if err != nil {
// return err
// }
// defaultSwitch, err := vpc.NewSwitch(ctx, "default", &vpc.SwitchArgs{
// VswitchName: pulumi.String(name),
// CidrBlock: pulumi.String("10.4.0.0/24"),
// VpcId: defaultNetwork.ID(),
// ZoneId: pulumi.String(_default.Zones[0].Id),
// })
// if err != nil {
// return err
// }
// defaultSecurityGroup, err := ecs.NewSecurityGroup(ctx, "default", &ecs.SecurityGroupArgs{
// VpcId: defaultNetwork.ID(),
// })
// if err != nil {
// return err
// }
// defaultInteger, err := random.NewInteger(ctx, "default", &random.IntegerArgs{
// Min: 10000,
// Max: 99999,
// })
// if err != nil {
// return err
// }
// defaultInstance, err := alikafka.NewInstance(ctx, "default", &alikafka.InstanceArgs{
// Name: pulumi.String(fmt.Sprintf("%v-%v", name, defaultInteger.Result)),
// PartitionNum: pulumi.Int(50),
// DiskType: pulumi.Int(1),
// DiskSize: pulumi.Int(500),
// DeployType: pulumi.Int(5),
// IoMax: pulumi.Int(20),
// SpecType: pulumi.String("professional"),
// ServiceVersion: pulumi.String("2.2.0"),
// Config: pulumi.String("{\"enable.acl\":\"true\"}"),
// VswitchId: defaultSwitch.ID(),
// SecurityGroup: defaultSecurityGroup.ID(),
// })
// if err != nil {
// return err
// }
// defaultTopic, err := alikafka.NewTopic(ctx, "default", &alikafka.TopicArgs{
// InstanceId: defaultInstance.ID(),
// Topic: pulumi.String("example-topic"),
// Remark: pulumi.String("topic-remark"),
// })
// if err != nil {
// return err
// }
// defaultSaslUser, err := alikafka.NewSaslUser(ctx, "default", &alikafka.SaslUserArgs{
// InstanceId: defaultInstance.ID(),
// Username: pulumi.String(name),
// Password: pulumi.String("tf_example123"),
// })
// if err != nil {
// return err
// }
// _, err = alikafka.NewSaslAcl(ctx, "default", &alikafka.SaslAclArgs{
// InstanceId: defaultInstance.ID(),
// Username: defaultSaslUser.Username,
// AclResourceType: pulumi.String("Topic"),
// AclResourceName: defaultTopic.Topic,
// AclResourcePatternType: pulumi.String("LITERAL"),
// AclOperationType: pulumi.String("Write"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// ALIKAFKA GROUP can be imported using the id, e.g.
//
// ```sh
// $ pulumi import alicloud:alikafka/saslAcl:SaslAcl acl alikafka_post-cn-123455abc:username:Topic:test-topic:LITERAL:Write
// ```
type SaslAcl struct {
pulumi.CustomResourceState
// Operation type for this acl. The operation type can only be "Write" and "Read".
AclOperationType pulumi.StringOutput `pulumi:"aclOperationType"`
// Resource name for this acl. The resource name should be a topic or consumer group name.
AclResourceName pulumi.StringOutput `pulumi:"aclResourceName"`
// Resource pattern type for this acl. The resource pattern support two types "LITERAL" and "PREFIXED". "LITERAL": A literal name defines the full name of a resource. The special wildcard character "*" can be used to represent a resource with any name. "PREFIXED": A prefixed name defines a prefix for a resource.
AclResourcePatternType pulumi.StringOutput `pulumi:"aclResourcePatternType"`
// Resource type for this acl. The resource type can only be "Topic" and "Group".
AclResourceType pulumi.StringOutput `pulumi:"aclResourceType"`
// The host of the acl.
Host pulumi.StringOutput `pulumi:"host"`
// ID of the ALIKAFKA Instance that owns the groups.
InstanceId pulumi.StringOutput `pulumi:"instanceId"`
// Username for the sasl user. The length should between 1 to 64 characters. The user should be an existed sasl user.
Username pulumi.StringOutput `pulumi:"username"`
}
// NewSaslAcl registers a new resource with the given unique name, arguments, and options.
func NewSaslAcl(ctx *pulumi.Context,
name string, args *SaslAclArgs, opts ...pulumi.ResourceOption) (*SaslAcl, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.AclOperationType == nil {
return nil, errors.New("invalid value for required argument 'AclOperationType'")
}
if args.AclResourceName == nil {
return nil, errors.New("invalid value for required argument 'AclResourceName'")
}
if args.AclResourcePatternType == nil {
return nil, errors.New("invalid value for required argument 'AclResourcePatternType'")
}
if args.AclResourceType == nil {
return nil, errors.New("invalid value for required argument 'AclResourceType'")
}
if args.InstanceId == nil {
return nil, errors.New("invalid value for required argument 'InstanceId'")
}
if args.Username == nil {
return nil, errors.New("invalid value for required argument 'Username'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource SaslAcl
err := ctx.RegisterResource("alicloud:alikafka/saslAcl:SaslAcl", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetSaslAcl gets an existing SaslAcl 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 GetSaslAcl(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *SaslAclState, opts ...pulumi.ResourceOption) (*SaslAcl, error) {
var resource SaslAcl
err := ctx.ReadResource("alicloud:alikafka/saslAcl:SaslAcl", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering SaslAcl resources.
type saslAclState struct {
// Operation type for this acl. The operation type can only be "Write" and "Read".
AclOperationType *string `pulumi:"aclOperationType"`
// Resource name for this acl. The resource name should be a topic or consumer group name.
AclResourceName *string `pulumi:"aclResourceName"`
// Resource pattern type for this acl. The resource pattern support two types "LITERAL" and "PREFIXED". "LITERAL": A literal name defines the full name of a resource. The special wildcard character "*" can be used to represent a resource with any name. "PREFIXED": A prefixed name defines a prefix for a resource.
AclResourcePatternType *string `pulumi:"aclResourcePatternType"`
// Resource type for this acl. The resource type can only be "Topic" and "Group".
AclResourceType *string `pulumi:"aclResourceType"`
// The host of the acl.
Host *string `pulumi:"host"`
// ID of the ALIKAFKA Instance that owns the groups.
InstanceId *string `pulumi:"instanceId"`
// Username for the sasl user. The length should between 1 to 64 characters. The user should be an existed sasl user.
Username *string `pulumi:"username"`
}
type SaslAclState struct {
// Operation type for this acl. The operation type can only be "Write" and "Read".
AclOperationType pulumi.StringPtrInput
// Resource name for this acl. The resource name should be a topic or consumer group name.
AclResourceName pulumi.StringPtrInput
// Resource pattern type for this acl. The resource pattern support two types "LITERAL" and "PREFIXED". "LITERAL": A literal name defines the full name of a resource. The special wildcard character "*" can be used to represent a resource with any name. "PREFIXED": A prefixed name defines a prefix for a resource.
AclResourcePatternType pulumi.StringPtrInput
// Resource type for this acl. The resource type can only be "Topic" and "Group".
AclResourceType pulumi.StringPtrInput
// The host of the acl.
Host pulumi.StringPtrInput
// ID of the ALIKAFKA Instance that owns the groups.
InstanceId pulumi.StringPtrInput
// Username for the sasl user. The length should between 1 to 64 characters. The user should be an existed sasl user.
Username pulumi.StringPtrInput
}
func (SaslAclState) ElementType() reflect.Type {
return reflect.TypeOf((*saslAclState)(nil)).Elem()
}
type saslAclArgs struct {
// Operation type for this acl. The operation type can only be "Write" and "Read".
AclOperationType string `pulumi:"aclOperationType"`
// Resource name for this acl. The resource name should be a topic or consumer group name.
AclResourceName string `pulumi:"aclResourceName"`
// Resource pattern type for this acl. The resource pattern support two types "LITERAL" and "PREFIXED". "LITERAL": A literal name defines the full name of a resource. The special wildcard character "*" can be used to represent a resource with any name. "PREFIXED": A prefixed name defines a prefix for a resource.
AclResourcePatternType string `pulumi:"aclResourcePatternType"`
// Resource type for this acl. The resource type can only be "Topic" and "Group".
AclResourceType string `pulumi:"aclResourceType"`
// ID of the ALIKAFKA Instance that owns the groups.
InstanceId string `pulumi:"instanceId"`
// Username for the sasl user. The length should between 1 to 64 characters. The user should be an existed sasl user.
Username string `pulumi:"username"`
}
// The set of arguments for constructing a SaslAcl resource.
type SaslAclArgs struct {
// Operation type for this acl. The operation type can only be "Write" and "Read".
AclOperationType pulumi.StringInput
// Resource name for this acl. The resource name should be a topic or consumer group name.
AclResourceName pulumi.StringInput
// Resource pattern type for this acl. The resource pattern support two types "LITERAL" and "PREFIXED". "LITERAL": A literal name defines the full name of a resource. The special wildcard character "*" can be used to represent a resource with any name. "PREFIXED": A prefixed name defines a prefix for a resource.
AclResourcePatternType pulumi.StringInput
// Resource type for this acl. The resource type can only be "Topic" and "Group".
AclResourceType pulumi.StringInput
// ID of the ALIKAFKA Instance that owns the groups.
InstanceId pulumi.StringInput
// Username for the sasl user. The length should between 1 to 64 characters. The user should be an existed sasl user.
Username pulumi.StringInput
}
func (SaslAclArgs) ElementType() reflect.Type {
return reflect.TypeOf((*saslAclArgs)(nil)).Elem()
}
type SaslAclInput interface {
pulumi.Input
ToSaslAclOutput() SaslAclOutput
ToSaslAclOutputWithContext(ctx context.Context) SaslAclOutput
}
func (*SaslAcl) ElementType() reflect.Type {
return reflect.TypeOf((**SaslAcl)(nil)).Elem()
}
func (i *SaslAcl) ToSaslAclOutput() SaslAclOutput {
return i.ToSaslAclOutputWithContext(context.Background())
}
func (i *SaslAcl) ToSaslAclOutputWithContext(ctx context.Context) SaslAclOutput {
return pulumi.ToOutputWithContext(ctx, i).(SaslAclOutput)
}
// SaslAclArrayInput is an input type that accepts SaslAclArray and SaslAclArrayOutput values.
// You can construct a concrete instance of `SaslAclArrayInput` via:
//
// SaslAclArray{ SaslAclArgs{...} }
type SaslAclArrayInput interface {
pulumi.Input
ToSaslAclArrayOutput() SaslAclArrayOutput
ToSaslAclArrayOutputWithContext(context.Context) SaslAclArrayOutput
}
type SaslAclArray []SaslAclInput
func (SaslAclArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*SaslAcl)(nil)).Elem()
}
func (i SaslAclArray) ToSaslAclArrayOutput() SaslAclArrayOutput {
return i.ToSaslAclArrayOutputWithContext(context.Background())
}
func (i SaslAclArray) ToSaslAclArrayOutputWithContext(ctx context.Context) SaslAclArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(SaslAclArrayOutput)
}
// SaslAclMapInput is an input type that accepts SaslAclMap and SaslAclMapOutput values.
// You can construct a concrete instance of `SaslAclMapInput` via:
//
// SaslAclMap{ "key": SaslAclArgs{...} }
type SaslAclMapInput interface {
pulumi.Input
ToSaslAclMapOutput() SaslAclMapOutput
ToSaslAclMapOutputWithContext(context.Context) SaslAclMapOutput
}
type SaslAclMap map[string]SaslAclInput
func (SaslAclMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*SaslAcl)(nil)).Elem()
}
func (i SaslAclMap) ToSaslAclMapOutput() SaslAclMapOutput {
return i.ToSaslAclMapOutputWithContext(context.Background())
}
func (i SaslAclMap) ToSaslAclMapOutputWithContext(ctx context.Context) SaslAclMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(SaslAclMapOutput)
}
type SaslAclOutput struct{ *pulumi.OutputState }
func (SaslAclOutput) ElementType() reflect.Type {
return reflect.TypeOf((**SaslAcl)(nil)).Elem()
}
func (o SaslAclOutput) ToSaslAclOutput() SaslAclOutput {
return o
}
func (o SaslAclOutput) ToSaslAclOutputWithContext(ctx context.Context) SaslAclOutput {
return o
}
// Operation type for this acl. The operation type can only be "Write" and "Read".
func (o SaslAclOutput) AclOperationType() pulumi.StringOutput {
return o.ApplyT(func(v *SaslAcl) pulumi.StringOutput { return v.AclOperationType }).(pulumi.StringOutput)
}
// Resource name for this acl. The resource name should be a topic or consumer group name.
func (o SaslAclOutput) AclResourceName() pulumi.StringOutput {
return o.ApplyT(func(v *SaslAcl) pulumi.StringOutput { return v.AclResourceName }).(pulumi.StringOutput)
}
// Resource pattern type for this acl. The resource pattern support two types "LITERAL" and "PREFIXED". "LITERAL": A literal name defines the full name of a resource. The special wildcard character "*" can be used to represent a resource with any name. "PREFIXED": A prefixed name defines a prefix for a resource.
func (o SaslAclOutput) AclResourcePatternType() pulumi.StringOutput {
return o.ApplyT(func(v *SaslAcl) pulumi.StringOutput { return v.AclResourcePatternType }).(pulumi.StringOutput)
}
// Resource type for this acl. The resource type can only be "Topic" and "Group".
func (o SaslAclOutput) AclResourceType() pulumi.StringOutput {
return o.ApplyT(func(v *SaslAcl) pulumi.StringOutput { return v.AclResourceType }).(pulumi.StringOutput)
}
// The host of the acl.
func (o SaslAclOutput) Host() pulumi.StringOutput {
return o.ApplyT(func(v *SaslAcl) pulumi.StringOutput { return v.Host }).(pulumi.StringOutput)
}
// ID of the ALIKAFKA Instance that owns the groups.
func (o SaslAclOutput) InstanceId() pulumi.StringOutput {
return o.ApplyT(func(v *SaslAcl) pulumi.StringOutput { return v.InstanceId }).(pulumi.StringOutput)
}
// Username for the sasl user. The length should between 1 to 64 characters. The user should be an existed sasl user.
func (o SaslAclOutput) Username() pulumi.StringOutput {
return o.ApplyT(func(v *SaslAcl) pulumi.StringOutput { return v.Username }).(pulumi.StringOutput)
}
type SaslAclArrayOutput struct{ *pulumi.OutputState }
func (SaslAclArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*SaslAcl)(nil)).Elem()
}
func (o SaslAclArrayOutput) ToSaslAclArrayOutput() SaslAclArrayOutput {
return o
}
func (o SaslAclArrayOutput) ToSaslAclArrayOutputWithContext(ctx context.Context) SaslAclArrayOutput {
return o
}
func (o SaslAclArrayOutput) Index(i pulumi.IntInput) SaslAclOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *SaslAcl {
return vs[0].([]*SaslAcl)[vs[1].(int)]
}).(SaslAclOutput)
}
type SaslAclMapOutput struct{ *pulumi.OutputState }
func (SaslAclMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*SaslAcl)(nil)).Elem()
}
func (o SaslAclMapOutput) ToSaslAclMapOutput() SaslAclMapOutput {
return o
}
func (o SaslAclMapOutput) ToSaslAclMapOutputWithContext(ctx context.Context) SaslAclMapOutput {
return o
}
func (o SaslAclMapOutput) MapIndex(k pulumi.StringInput) SaslAclOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *SaslAcl {
return vs[0].(map[string]*SaslAcl)[vs[1].(string)]
}).(SaslAclOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*SaslAclInput)(nil)).Elem(), &SaslAcl{})
pulumi.RegisterInputType(reflect.TypeOf((*SaslAclArrayInput)(nil)).Elem(), SaslAclArray{})
pulumi.RegisterInputType(reflect.TypeOf((*SaslAclMapInput)(nil)).Elem(), SaslAclMap{})
pulumi.RegisterOutputType(SaslAclOutput{})
pulumi.RegisterOutputType(SaslAclArrayOutput{})
pulumi.RegisterOutputType(SaslAclMapOutput{})
}