/
trafficMirrorSession.go
417 lines (356 loc) · 18.7 KB
/
trafficMirrorSession.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
// *** 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 ec2
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides an Traffic mirror session.\
// Read [limits and considerations](https://docs.aws.amazon.com/vpc/latest/mirroring/traffic-mirroring-considerations.html) for traffic mirroring
//
// ## Example Usage
//
// To create a basic traffic mirror session
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// filter, err := ec2.NewTrafficMirrorFilter(ctx, "filter", &ec2.TrafficMirrorFilterArgs{
// Description: pulumi.String("traffic mirror filter - example"),
// NetworkServices: pulumi.StringArray{
// pulumi.String("amazon-dns"),
// },
// })
// if err != nil {
// return err
// }
// target, err := ec2.NewTrafficMirrorTarget(ctx, "target", &ec2.TrafficMirrorTargetArgs{
// NetworkLoadBalancerArn: pulumi.Any(aws_lb.Lb.Arn),
// })
// if err != nil {
// return err
// }
// _, err = ec2.NewTrafficMirrorSession(ctx, "session", &ec2.TrafficMirrorSessionArgs{
// Description: pulumi.String("traffic mirror session - example"),
// NetworkInterfaceId: pulumi.Any(aws_instance.Test.Primary_network_interface_id),
// SessionNumber: pulumi.Int(1),
// TrafficMirrorFilterId: filter.ID(),
// TrafficMirrorTargetId: target.ID(),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Traffic mirror sessions can be imported using the `id`, e.g.
//
// ```sh
// $ pulumi import aws:ec2/trafficMirrorSession:TrafficMirrorSession session tms-0d8aa3ca35897b82e
// ```
type TrafficMirrorSession struct {
pulumi.CustomResourceState
// The ARN of the traffic mirror session.
Arn pulumi.StringOutput `pulumi:"arn"`
// A description of the traffic mirror session.
Description pulumi.StringPtrOutput `pulumi:"description"`
// ID of the source network interface. Not all network interfaces are eligible as mirror sources. On EC2 instances only nitro based instances support mirroring.
NetworkInterfaceId pulumi.StringOutput `pulumi:"networkInterfaceId"`
// The AWS account ID of the session owner.
OwnerId pulumi.StringOutput `pulumi:"ownerId"`
// The number of bytes in each packet to mirror. These are bytes after the VXLAN header. Do not specify this parameter when you want to mirror the entire packet. To mirror a subset of the packet, set this to the length (in bytes) that you want to mirror.
PacketLength pulumi.IntPtrOutput `pulumi:"packetLength"`
// - The session number determines the order in which sessions are evaluated when an interface is used by multiple sessions. The first session with a matching filter is the one that mirrors the packets.
SessionNumber pulumi.IntOutput `pulumi:"sessionNumber"`
Tags pulumi.StringMapOutput `pulumi:"tags"`
TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
// ID of the traffic mirror filter to be used
TrafficMirrorFilterId pulumi.StringOutput `pulumi:"trafficMirrorFilterId"`
// ID of the traffic mirror target to be used
TrafficMirrorTargetId pulumi.StringOutput `pulumi:"trafficMirrorTargetId"`
// - The VXLAN ID for the Traffic Mirror session. For more information about the VXLAN protocol, see RFC 7348. If you do not specify a VirtualNetworkId, an account-wide unique id is chosen at random.
VirtualNetworkId pulumi.IntOutput `pulumi:"virtualNetworkId"`
}
// NewTrafficMirrorSession registers a new resource with the given unique name, arguments, and options.
func NewTrafficMirrorSession(ctx *pulumi.Context,
name string, args *TrafficMirrorSessionArgs, opts ...pulumi.ResourceOption) (*TrafficMirrorSession, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.NetworkInterfaceId == nil {
return nil, errors.New("invalid value for required argument 'NetworkInterfaceId'")
}
if args.SessionNumber == nil {
return nil, errors.New("invalid value for required argument 'SessionNumber'")
}
if args.TrafficMirrorFilterId == nil {
return nil, errors.New("invalid value for required argument 'TrafficMirrorFilterId'")
}
if args.TrafficMirrorTargetId == nil {
return nil, errors.New("invalid value for required argument 'TrafficMirrorTargetId'")
}
var resource TrafficMirrorSession
err := ctx.RegisterResource("aws:ec2/trafficMirrorSession:TrafficMirrorSession", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetTrafficMirrorSession gets an existing TrafficMirrorSession 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 GetTrafficMirrorSession(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *TrafficMirrorSessionState, opts ...pulumi.ResourceOption) (*TrafficMirrorSession, error) {
var resource TrafficMirrorSession
err := ctx.ReadResource("aws:ec2/trafficMirrorSession:TrafficMirrorSession", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering TrafficMirrorSession resources.
type trafficMirrorSessionState struct {
// The ARN of the traffic mirror session.
Arn *string `pulumi:"arn"`
// A description of the traffic mirror session.
Description *string `pulumi:"description"`
// ID of the source network interface. Not all network interfaces are eligible as mirror sources. On EC2 instances only nitro based instances support mirroring.
NetworkInterfaceId *string `pulumi:"networkInterfaceId"`
// The AWS account ID of the session owner.
OwnerId *string `pulumi:"ownerId"`
// The number of bytes in each packet to mirror. These are bytes after the VXLAN header. Do not specify this parameter when you want to mirror the entire packet. To mirror a subset of the packet, set this to the length (in bytes) that you want to mirror.
PacketLength *int `pulumi:"packetLength"`
// - The session number determines the order in which sessions are evaluated when an interface is used by multiple sessions. The first session with a matching filter is the one that mirrors the packets.
SessionNumber *int `pulumi:"sessionNumber"`
Tags map[string]string `pulumi:"tags"`
TagsAll map[string]string `pulumi:"tagsAll"`
// ID of the traffic mirror filter to be used
TrafficMirrorFilterId *string `pulumi:"trafficMirrorFilterId"`
// ID of the traffic mirror target to be used
TrafficMirrorTargetId *string `pulumi:"trafficMirrorTargetId"`
// - The VXLAN ID for the Traffic Mirror session. For more information about the VXLAN protocol, see RFC 7348. If you do not specify a VirtualNetworkId, an account-wide unique id is chosen at random.
VirtualNetworkId *int `pulumi:"virtualNetworkId"`
}
type TrafficMirrorSessionState struct {
// The ARN of the traffic mirror session.
Arn pulumi.StringPtrInput
// A description of the traffic mirror session.
Description pulumi.StringPtrInput
// ID of the source network interface. Not all network interfaces are eligible as mirror sources. On EC2 instances only nitro based instances support mirroring.
NetworkInterfaceId pulumi.StringPtrInput
// The AWS account ID of the session owner.
OwnerId pulumi.StringPtrInput
// The number of bytes in each packet to mirror. These are bytes after the VXLAN header. Do not specify this parameter when you want to mirror the entire packet. To mirror a subset of the packet, set this to the length (in bytes) that you want to mirror.
PacketLength pulumi.IntPtrInput
// - The session number determines the order in which sessions are evaluated when an interface is used by multiple sessions. The first session with a matching filter is the one that mirrors the packets.
SessionNumber pulumi.IntPtrInput
Tags pulumi.StringMapInput
TagsAll pulumi.StringMapInput
// ID of the traffic mirror filter to be used
TrafficMirrorFilterId pulumi.StringPtrInput
// ID of the traffic mirror target to be used
TrafficMirrorTargetId pulumi.StringPtrInput
// - The VXLAN ID for the Traffic Mirror session. For more information about the VXLAN protocol, see RFC 7348. If you do not specify a VirtualNetworkId, an account-wide unique id is chosen at random.
VirtualNetworkId pulumi.IntPtrInput
}
func (TrafficMirrorSessionState) ElementType() reflect.Type {
return reflect.TypeOf((*trafficMirrorSessionState)(nil)).Elem()
}
type trafficMirrorSessionArgs struct {
// A description of the traffic mirror session.
Description *string `pulumi:"description"`
// ID of the source network interface. Not all network interfaces are eligible as mirror sources. On EC2 instances only nitro based instances support mirroring.
NetworkInterfaceId string `pulumi:"networkInterfaceId"`
// The number of bytes in each packet to mirror. These are bytes after the VXLAN header. Do not specify this parameter when you want to mirror the entire packet. To mirror a subset of the packet, set this to the length (in bytes) that you want to mirror.
PacketLength *int `pulumi:"packetLength"`
// - The session number determines the order in which sessions are evaluated when an interface is used by multiple sessions. The first session with a matching filter is the one that mirrors the packets.
SessionNumber int `pulumi:"sessionNumber"`
Tags map[string]string `pulumi:"tags"`
TagsAll map[string]string `pulumi:"tagsAll"`
// ID of the traffic mirror filter to be used
TrafficMirrorFilterId string `pulumi:"trafficMirrorFilterId"`
// ID of the traffic mirror target to be used
TrafficMirrorTargetId string `pulumi:"trafficMirrorTargetId"`
// - The VXLAN ID for the Traffic Mirror session. For more information about the VXLAN protocol, see RFC 7348. If you do not specify a VirtualNetworkId, an account-wide unique id is chosen at random.
VirtualNetworkId *int `pulumi:"virtualNetworkId"`
}
// The set of arguments for constructing a TrafficMirrorSession resource.
type TrafficMirrorSessionArgs struct {
// A description of the traffic mirror session.
Description pulumi.StringPtrInput
// ID of the source network interface. Not all network interfaces are eligible as mirror sources. On EC2 instances only nitro based instances support mirroring.
NetworkInterfaceId pulumi.StringInput
// The number of bytes in each packet to mirror. These are bytes after the VXLAN header. Do not specify this parameter when you want to mirror the entire packet. To mirror a subset of the packet, set this to the length (in bytes) that you want to mirror.
PacketLength pulumi.IntPtrInput
// - The session number determines the order in which sessions are evaluated when an interface is used by multiple sessions. The first session with a matching filter is the one that mirrors the packets.
SessionNumber pulumi.IntInput
Tags pulumi.StringMapInput
TagsAll pulumi.StringMapInput
// ID of the traffic mirror filter to be used
TrafficMirrorFilterId pulumi.StringInput
// ID of the traffic mirror target to be used
TrafficMirrorTargetId pulumi.StringInput
// - The VXLAN ID for the Traffic Mirror session. For more information about the VXLAN protocol, see RFC 7348. If you do not specify a VirtualNetworkId, an account-wide unique id is chosen at random.
VirtualNetworkId pulumi.IntPtrInput
}
func (TrafficMirrorSessionArgs) ElementType() reflect.Type {
return reflect.TypeOf((*trafficMirrorSessionArgs)(nil)).Elem()
}
type TrafficMirrorSessionInput interface {
pulumi.Input
ToTrafficMirrorSessionOutput() TrafficMirrorSessionOutput
ToTrafficMirrorSessionOutputWithContext(ctx context.Context) TrafficMirrorSessionOutput
}
func (*TrafficMirrorSession) ElementType() reflect.Type {
return reflect.TypeOf((*TrafficMirrorSession)(nil))
}
func (i *TrafficMirrorSession) ToTrafficMirrorSessionOutput() TrafficMirrorSessionOutput {
return i.ToTrafficMirrorSessionOutputWithContext(context.Background())
}
func (i *TrafficMirrorSession) ToTrafficMirrorSessionOutputWithContext(ctx context.Context) TrafficMirrorSessionOutput {
return pulumi.ToOutputWithContext(ctx, i).(TrafficMirrorSessionOutput)
}
func (i *TrafficMirrorSession) ToTrafficMirrorSessionPtrOutput() TrafficMirrorSessionPtrOutput {
return i.ToTrafficMirrorSessionPtrOutputWithContext(context.Background())
}
func (i *TrafficMirrorSession) ToTrafficMirrorSessionPtrOutputWithContext(ctx context.Context) TrafficMirrorSessionPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(TrafficMirrorSessionPtrOutput)
}
type TrafficMirrorSessionPtrInput interface {
pulumi.Input
ToTrafficMirrorSessionPtrOutput() TrafficMirrorSessionPtrOutput
ToTrafficMirrorSessionPtrOutputWithContext(ctx context.Context) TrafficMirrorSessionPtrOutput
}
type trafficMirrorSessionPtrType TrafficMirrorSessionArgs
func (*trafficMirrorSessionPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**TrafficMirrorSession)(nil))
}
func (i *trafficMirrorSessionPtrType) ToTrafficMirrorSessionPtrOutput() TrafficMirrorSessionPtrOutput {
return i.ToTrafficMirrorSessionPtrOutputWithContext(context.Background())
}
func (i *trafficMirrorSessionPtrType) ToTrafficMirrorSessionPtrOutputWithContext(ctx context.Context) TrafficMirrorSessionPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(TrafficMirrorSessionPtrOutput)
}
// TrafficMirrorSessionArrayInput is an input type that accepts TrafficMirrorSessionArray and TrafficMirrorSessionArrayOutput values.
// You can construct a concrete instance of `TrafficMirrorSessionArrayInput` via:
//
// TrafficMirrorSessionArray{ TrafficMirrorSessionArgs{...} }
type TrafficMirrorSessionArrayInput interface {
pulumi.Input
ToTrafficMirrorSessionArrayOutput() TrafficMirrorSessionArrayOutput
ToTrafficMirrorSessionArrayOutputWithContext(context.Context) TrafficMirrorSessionArrayOutput
}
type TrafficMirrorSessionArray []TrafficMirrorSessionInput
func (TrafficMirrorSessionArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*TrafficMirrorSession)(nil)).Elem()
}
func (i TrafficMirrorSessionArray) ToTrafficMirrorSessionArrayOutput() TrafficMirrorSessionArrayOutput {
return i.ToTrafficMirrorSessionArrayOutputWithContext(context.Background())
}
func (i TrafficMirrorSessionArray) ToTrafficMirrorSessionArrayOutputWithContext(ctx context.Context) TrafficMirrorSessionArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(TrafficMirrorSessionArrayOutput)
}
// TrafficMirrorSessionMapInput is an input type that accepts TrafficMirrorSessionMap and TrafficMirrorSessionMapOutput values.
// You can construct a concrete instance of `TrafficMirrorSessionMapInput` via:
//
// TrafficMirrorSessionMap{ "key": TrafficMirrorSessionArgs{...} }
type TrafficMirrorSessionMapInput interface {
pulumi.Input
ToTrafficMirrorSessionMapOutput() TrafficMirrorSessionMapOutput
ToTrafficMirrorSessionMapOutputWithContext(context.Context) TrafficMirrorSessionMapOutput
}
type TrafficMirrorSessionMap map[string]TrafficMirrorSessionInput
func (TrafficMirrorSessionMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*TrafficMirrorSession)(nil)).Elem()
}
func (i TrafficMirrorSessionMap) ToTrafficMirrorSessionMapOutput() TrafficMirrorSessionMapOutput {
return i.ToTrafficMirrorSessionMapOutputWithContext(context.Background())
}
func (i TrafficMirrorSessionMap) ToTrafficMirrorSessionMapOutputWithContext(ctx context.Context) TrafficMirrorSessionMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(TrafficMirrorSessionMapOutput)
}
type TrafficMirrorSessionOutput struct{ *pulumi.OutputState }
func (TrafficMirrorSessionOutput) ElementType() reflect.Type {
return reflect.TypeOf((*TrafficMirrorSession)(nil))
}
func (o TrafficMirrorSessionOutput) ToTrafficMirrorSessionOutput() TrafficMirrorSessionOutput {
return o
}
func (o TrafficMirrorSessionOutput) ToTrafficMirrorSessionOutputWithContext(ctx context.Context) TrafficMirrorSessionOutput {
return o
}
func (o TrafficMirrorSessionOutput) ToTrafficMirrorSessionPtrOutput() TrafficMirrorSessionPtrOutput {
return o.ToTrafficMirrorSessionPtrOutputWithContext(context.Background())
}
func (o TrafficMirrorSessionOutput) ToTrafficMirrorSessionPtrOutputWithContext(ctx context.Context) TrafficMirrorSessionPtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v TrafficMirrorSession) *TrafficMirrorSession {
return &v
}).(TrafficMirrorSessionPtrOutput)
}
type TrafficMirrorSessionPtrOutput struct{ *pulumi.OutputState }
func (TrafficMirrorSessionPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**TrafficMirrorSession)(nil))
}
func (o TrafficMirrorSessionPtrOutput) ToTrafficMirrorSessionPtrOutput() TrafficMirrorSessionPtrOutput {
return o
}
func (o TrafficMirrorSessionPtrOutput) ToTrafficMirrorSessionPtrOutputWithContext(ctx context.Context) TrafficMirrorSessionPtrOutput {
return o
}
func (o TrafficMirrorSessionPtrOutput) Elem() TrafficMirrorSessionOutput {
return o.ApplyT(func(v *TrafficMirrorSession) TrafficMirrorSession {
if v != nil {
return *v
}
var ret TrafficMirrorSession
return ret
}).(TrafficMirrorSessionOutput)
}
type TrafficMirrorSessionArrayOutput struct{ *pulumi.OutputState }
func (TrafficMirrorSessionArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]TrafficMirrorSession)(nil))
}
func (o TrafficMirrorSessionArrayOutput) ToTrafficMirrorSessionArrayOutput() TrafficMirrorSessionArrayOutput {
return o
}
func (o TrafficMirrorSessionArrayOutput) ToTrafficMirrorSessionArrayOutputWithContext(ctx context.Context) TrafficMirrorSessionArrayOutput {
return o
}
func (o TrafficMirrorSessionArrayOutput) Index(i pulumi.IntInput) TrafficMirrorSessionOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) TrafficMirrorSession {
return vs[0].([]TrafficMirrorSession)[vs[1].(int)]
}).(TrafficMirrorSessionOutput)
}
type TrafficMirrorSessionMapOutput struct{ *pulumi.OutputState }
func (TrafficMirrorSessionMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]TrafficMirrorSession)(nil))
}
func (o TrafficMirrorSessionMapOutput) ToTrafficMirrorSessionMapOutput() TrafficMirrorSessionMapOutput {
return o
}
func (o TrafficMirrorSessionMapOutput) ToTrafficMirrorSessionMapOutputWithContext(ctx context.Context) TrafficMirrorSessionMapOutput {
return o
}
func (o TrafficMirrorSessionMapOutput) MapIndex(k pulumi.StringInput) TrafficMirrorSessionOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) TrafficMirrorSession {
return vs[0].(map[string]TrafficMirrorSession)[vs[1].(string)]
}).(TrafficMirrorSessionOutput)
}
func init() {
pulumi.RegisterOutputType(TrafficMirrorSessionOutput{})
pulumi.RegisterOutputType(TrafficMirrorSessionPtrOutput{})
pulumi.RegisterOutputType(TrafficMirrorSessionArrayOutput{})
pulumi.RegisterOutputType(TrafficMirrorSessionMapOutput{})
}