generated from pulumi/pulumi-tf-provider-boilerplate
/
groupRuleSet.go
379 lines (329 loc) · 13.9 KB
/
groupRuleSet.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
// 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 security
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a resource to create security group rule. This resource is similar with tencentcloud_security_group_lite_rule, rules can be ordered and configure descriptions.
//
// > **NOTE:** This resource must exclusive in one security group, do not declare additional rule resources of this security group elsewhere.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-tencentcloud/sdk/go/tencentcloud/Security"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// "github.com/tencentcloudstack/pulumi-tencentcloud/sdk/go/tencentcloud/Address"
// "github.com/tencentcloudstack/pulumi-tencentcloud/sdk/go/tencentcloud/Security"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// baseGroup, err := Security.NewGroup(ctx, "baseGroup", &Security.GroupArgs{
// Description: pulumi.String("Testing Rule Set Security"),
// })
// if err != nil {
// return err
// }
// relative, err := Security.NewGroup(ctx, "relative", &Security.GroupArgs{
// Description: pulumi.String("Used for attach security policy"),
// })
// if err != nil {
// return err
// }
// fooTemplate, err := Address.NewTemplate(ctx, "fooTemplate", &Address.TemplateArgs{
// Addresses: pulumi.StringArray{
// pulumi.String("10.0.0.1"),
// pulumi.String("10.0.1.0/24"),
// pulumi.String("10.0.0.1-10.0.0.100"),
// },
// })
// if err != nil {
// return err
// }
// fooTemplateGroup, err := Address.NewTemplateGroup(ctx, "fooTemplateGroup", &Address.TemplateGroupArgs{
// TemplateIds: pulumi.StringArray{
// fooTemplate.ID(),
// },
// })
// if err != nil {
// return err
// }
// _, err = Security.NewGroupRuleSet(ctx, "baseGroupRuleSet", &Security.GroupRuleSetArgs{
// SecurityGroupId: baseGroup.ID(),
// Ingresses: security.GroupRuleSetIngressArray{
// &security.GroupRuleSetIngressArgs{
// Action: pulumi.String("ACCEPT"),
// CidrBlock: pulumi.String("10.0.0.0/22"),
// Protocol: pulumi.String("TCP"),
// Port: pulumi.String("80-90"),
// Description: pulumi.String("A:Allow Ips and 80-90"),
// },
// &security.GroupRuleSetIngressArgs{
// Action: pulumi.String("ACCEPT"),
// CidrBlock: pulumi.String("10.0.2.1"),
// Protocol: pulumi.String("UDP"),
// Port: pulumi.String("8080"),
// Description: pulumi.String("B:Allow UDP 8080"),
// },
// &security.GroupRuleSetIngressArgs{
// Action: pulumi.String("ACCEPT"),
// CidrBlock: pulumi.String("10.0.2.1"),
// Protocol: pulumi.String("UDP"),
// Port: pulumi.String("8080"),
// Description: pulumi.String("C:Allow UDP 8080"),
// },
// &security.GroupRuleSetIngressArgs{
// Action: pulumi.String("ACCEPT"),
// CidrBlock: pulumi.String("172.18.1.2"),
// Protocol: pulumi.String("ALL"),
// Port: pulumi.String("ALL"),
// Description: pulumi.String("D:Allow ALL"),
// },
// &security.GroupRuleSetIngressArgs{
// Action: pulumi.String("DROP"),
// Protocol: pulumi.String("TCP"),
// Port: pulumi.String("80"),
// SourceSecurityId: relative.ID(),
// Description: pulumi.String("E:Block relative"),
// },
// },
// Egresses: security.GroupRuleSetEgressArray{
// &security.GroupRuleSetEgressArgs{
// Action: pulumi.String("DROP"),
// CidrBlock: pulumi.String("10.0.0.0/16"),
// Protocol: pulumi.String("ICMP"),
// Description: pulumi.String("A:Block ping3"),
// },
// &security.GroupRuleSetEgressArgs{
// Action: pulumi.String("DROP"),
// AddressTemplateId: fooTemplate.ID(),
// Description: pulumi.String("B:Allow template"),
// },
// &security.GroupRuleSetEgressArgs{
// Action: pulumi.String("DROP"),
// AddressTemplateGroup: fooTemplateGroup.ID(),
// Description: pulumi.String("C:DROP template group"),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Resource tencentcloud_security_group_rule_set can be imported by passing security grou id
//
// ```sh
// $ pulumi import tencentcloud:Security/groupRuleSet:GroupRuleSet sglab_1 sg-xxxxxxxx
// ```
type GroupRuleSet struct {
pulumi.CustomResourceState
// List of egress rule. NOTE: this block is ordered, the first rule has the highest priority.
Egresses GroupRuleSetEgressArrayOutput `pulumi:"egresses"`
// List of ingress rule. NOTE: this block is ordered, the first rule has the highest priority.
Ingresses GroupRuleSetIngressArrayOutput `pulumi:"ingresses"`
// ID of the security group to be queried.
SecurityGroupId pulumi.StringOutput `pulumi:"securityGroupId"`
// Security policies version, auto increment for every update.
Version pulumi.StringOutput `pulumi:"version"`
}
// NewGroupRuleSet registers a new resource with the given unique name, arguments, and options.
func NewGroupRuleSet(ctx *pulumi.Context,
name string, args *GroupRuleSetArgs, opts ...pulumi.ResourceOption) (*GroupRuleSet, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.SecurityGroupId == nil {
return nil, errors.New("invalid value for required argument 'SecurityGroupId'")
}
opts = pkgResourceDefaultOpts(opts)
var resource GroupRuleSet
err := ctx.RegisterResource("tencentcloud:Security/groupRuleSet:GroupRuleSet", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetGroupRuleSet gets an existing GroupRuleSet 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 GetGroupRuleSet(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *GroupRuleSetState, opts ...pulumi.ResourceOption) (*GroupRuleSet, error) {
var resource GroupRuleSet
err := ctx.ReadResource("tencentcloud:Security/groupRuleSet:GroupRuleSet", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering GroupRuleSet resources.
type groupRuleSetState struct {
// List of egress rule. NOTE: this block is ordered, the first rule has the highest priority.
Egresses []GroupRuleSetEgress `pulumi:"egresses"`
// List of ingress rule. NOTE: this block is ordered, the first rule has the highest priority.
Ingresses []GroupRuleSetIngress `pulumi:"ingresses"`
// ID of the security group to be queried.
SecurityGroupId *string `pulumi:"securityGroupId"`
// Security policies version, auto increment for every update.
Version *string `pulumi:"version"`
}
type GroupRuleSetState struct {
// List of egress rule. NOTE: this block is ordered, the first rule has the highest priority.
Egresses GroupRuleSetEgressArrayInput
// List of ingress rule. NOTE: this block is ordered, the first rule has the highest priority.
Ingresses GroupRuleSetIngressArrayInput
// ID of the security group to be queried.
SecurityGroupId pulumi.StringPtrInput
// Security policies version, auto increment for every update.
Version pulumi.StringPtrInput
}
func (GroupRuleSetState) ElementType() reflect.Type {
return reflect.TypeOf((*groupRuleSetState)(nil)).Elem()
}
type groupRuleSetArgs struct {
// List of egress rule. NOTE: this block is ordered, the first rule has the highest priority.
Egresses []GroupRuleSetEgress `pulumi:"egresses"`
// List of ingress rule. NOTE: this block is ordered, the first rule has the highest priority.
Ingresses []GroupRuleSetIngress `pulumi:"ingresses"`
// ID of the security group to be queried.
SecurityGroupId string `pulumi:"securityGroupId"`
}
// The set of arguments for constructing a GroupRuleSet resource.
type GroupRuleSetArgs struct {
// List of egress rule. NOTE: this block is ordered, the first rule has the highest priority.
Egresses GroupRuleSetEgressArrayInput
// List of ingress rule. NOTE: this block is ordered, the first rule has the highest priority.
Ingresses GroupRuleSetIngressArrayInput
// ID of the security group to be queried.
SecurityGroupId pulumi.StringInput
}
func (GroupRuleSetArgs) ElementType() reflect.Type {
return reflect.TypeOf((*groupRuleSetArgs)(nil)).Elem()
}
type GroupRuleSetInput interface {
pulumi.Input
ToGroupRuleSetOutput() GroupRuleSetOutput
ToGroupRuleSetOutputWithContext(ctx context.Context) GroupRuleSetOutput
}
func (*GroupRuleSet) ElementType() reflect.Type {
return reflect.TypeOf((**GroupRuleSet)(nil)).Elem()
}
func (i *GroupRuleSet) ToGroupRuleSetOutput() GroupRuleSetOutput {
return i.ToGroupRuleSetOutputWithContext(context.Background())
}
func (i *GroupRuleSet) ToGroupRuleSetOutputWithContext(ctx context.Context) GroupRuleSetOutput {
return pulumi.ToOutputWithContext(ctx, i).(GroupRuleSetOutput)
}
// GroupRuleSetArrayInput is an input type that accepts GroupRuleSetArray and GroupRuleSetArrayOutput values.
// You can construct a concrete instance of `GroupRuleSetArrayInput` via:
//
// GroupRuleSetArray{ GroupRuleSetArgs{...} }
type GroupRuleSetArrayInput interface {
pulumi.Input
ToGroupRuleSetArrayOutput() GroupRuleSetArrayOutput
ToGroupRuleSetArrayOutputWithContext(context.Context) GroupRuleSetArrayOutput
}
type GroupRuleSetArray []GroupRuleSetInput
func (GroupRuleSetArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*GroupRuleSet)(nil)).Elem()
}
func (i GroupRuleSetArray) ToGroupRuleSetArrayOutput() GroupRuleSetArrayOutput {
return i.ToGroupRuleSetArrayOutputWithContext(context.Background())
}
func (i GroupRuleSetArray) ToGroupRuleSetArrayOutputWithContext(ctx context.Context) GroupRuleSetArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(GroupRuleSetArrayOutput)
}
// GroupRuleSetMapInput is an input type that accepts GroupRuleSetMap and GroupRuleSetMapOutput values.
// You can construct a concrete instance of `GroupRuleSetMapInput` via:
//
// GroupRuleSetMap{ "key": GroupRuleSetArgs{...} }
type GroupRuleSetMapInput interface {
pulumi.Input
ToGroupRuleSetMapOutput() GroupRuleSetMapOutput
ToGroupRuleSetMapOutputWithContext(context.Context) GroupRuleSetMapOutput
}
type GroupRuleSetMap map[string]GroupRuleSetInput
func (GroupRuleSetMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*GroupRuleSet)(nil)).Elem()
}
func (i GroupRuleSetMap) ToGroupRuleSetMapOutput() GroupRuleSetMapOutput {
return i.ToGroupRuleSetMapOutputWithContext(context.Background())
}
func (i GroupRuleSetMap) ToGroupRuleSetMapOutputWithContext(ctx context.Context) GroupRuleSetMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(GroupRuleSetMapOutput)
}
type GroupRuleSetOutput struct{ *pulumi.OutputState }
func (GroupRuleSetOutput) ElementType() reflect.Type {
return reflect.TypeOf((**GroupRuleSet)(nil)).Elem()
}
func (o GroupRuleSetOutput) ToGroupRuleSetOutput() GroupRuleSetOutput {
return o
}
func (o GroupRuleSetOutput) ToGroupRuleSetOutputWithContext(ctx context.Context) GroupRuleSetOutput {
return o
}
// List of egress rule. NOTE: this block is ordered, the first rule has the highest priority.
func (o GroupRuleSetOutput) Egresses() GroupRuleSetEgressArrayOutput {
return o.ApplyT(func(v *GroupRuleSet) GroupRuleSetEgressArrayOutput { return v.Egresses }).(GroupRuleSetEgressArrayOutput)
}
// List of ingress rule. NOTE: this block is ordered, the first rule has the highest priority.
func (o GroupRuleSetOutput) Ingresses() GroupRuleSetIngressArrayOutput {
return o.ApplyT(func(v *GroupRuleSet) GroupRuleSetIngressArrayOutput { return v.Ingresses }).(GroupRuleSetIngressArrayOutput)
}
// ID of the security group to be queried.
func (o GroupRuleSetOutput) SecurityGroupId() pulumi.StringOutput {
return o.ApplyT(func(v *GroupRuleSet) pulumi.StringOutput { return v.SecurityGroupId }).(pulumi.StringOutput)
}
// Security policies version, auto increment for every update.
func (o GroupRuleSetOutput) Version() pulumi.StringOutput {
return o.ApplyT(func(v *GroupRuleSet) pulumi.StringOutput { return v.Version }).(pulumi.StringOutput)
}
type GroupRuleSetArrayOutput struct{ *pulumi.OutputState }
func (GroupRuleSetArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*GroupRuleSet)(nil)).Elem()
}
func (o GroupRuleSetArrayOutput) ToGroupRuleSetArrayOutput() GroupRuleSetArrayOutput {
return o
}
func (o GroupRuleSetArrayOutput) ToGroupRuleSetArrayOutputWithContext(ctx context.Context) GroupRuleSetArrayOutput {
return o
}
func (o GroupRuleSetArrayOutput) Index(i pulumi.IntInput) GroupRuleSetOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *GroupRuleSet {
return vs[0].([]*GroupRuleSet)[vs[1].(int)]
}).(GroupRuleSetOutput)
}
type GroupRuleSetMapOutput struct{ *pulumi.OutputState }
func (GroupRuleSetMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*GroupRuleSet)(nil)).Elem()
}
func (o GroupRuleSetMapOutput) ToGroupRuleSetMapOutput() GroupRuleSetMapOutput {
return o
}
func (o GroupRuleSetMapOutput) ToGroupRuleSetMapOutputWithContext(ctx context.Context) GroupRuleSetMapOutput {
return o
}
func (o GroupRuleSetMapOutput) MapIndex(k pulumi.StringInput) GroupRuleSetOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *GroupRuleSet {
return vs[0].(map[string]*GroupRuleSet)[vs[1].(string)]
}).(GroupRuleSetOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*GroupRuleSetInput)(nil)).Elem(), &GroupRuleSet{})
pulumi.RegisterInputType(reflect.TypeOf((*GroupRuleSetArrayInput)(nil)).Elem(), GroupRuleSetArray{})
pulumi.RegisterInputType(reflect.TypeOf((*GroupRuleSetMapInput)(nil)).Elem(), GroupRuleSetMap{})
pulumi.RegisterOutputType(GroupRuleSetOutput{})
pulumi.RegisterOutputType(GroupRuleSetArrayOutput{})
pulumi.RegisterOutputType(GroupRuleSetMapOutput{})
}