<gh_stars>0// *** 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! ***

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;

namespace Pulumi.AliCloud.Vpc
{
    /// <summary>
    /// Provides a VPC Traffic Mirror Session resource.
    /// 
    /// For information about VPC Traffic Mirror Session and how to use it, see [What is Traffic Mirror Session](https://www.alibabacloud.com/help/en/doc-detail/261364.htm).
    /// 
    /// &gt; **NOTE:** Available in v1.142.0+.
    /// 
    /// ## Example Usage
    /// 
    /// Basic Usage
    /// 
    /// ```csharp
    /// using System.Collections.Generic;
    /// using System.Linq;
    /// using Pulumi;
    /// using AliCloud = Pulumi.AliCloud;
    /// 
    /// return await Deployment.RunAsync(() =&gt; 
    /// {
    ///     var defaultInstanceTypes = AliCloud.Ecs.GetInstanceTypes.Invoke(new()
    ///     {
    ///         InstanceTypeFamily = "ecs.g7",
    ///     });
    /// 
    ///     var defaultZones = AliCloud.GetZones.Invoke(new()
    ///     {
    ///         AvailableResourceCreation = "Instance",
    ///         AvailableInstanceType = defaultInstanceTypes.Apply(getInstanceTypesResult =&gt; getInstanceTypesResult.InstanceTypes[0]?.Id),
    ///     });
    /// 
    ///     var defaultNetworks = AliCloud.Vpc.GetNetworks.Invoke(new()
    ///     {
    ///         NameRegex = "default-NODELETING",
    ///     });
    /// 
    ///     var defaultSwitches = AliCloud.Vpc.GetSwitches.Invoke(new()
    ///     {
    ///         VpcId = defaultNetworks.Apply(getNetworksResult =&gt; getNetworksResult.Ids[0]),
    ///         ZoneId = defaultZones.Apply(getZonesResult =&gt; getZonesResult.Zones[0]?.Id),
    ///     });
    /// 
    ///     var vswitchId = defaultSwitches.Apply(getSwitchesResult =&gt; getSwitchesResult.Ids[0]);
    /// 
    ///     var defaultSecurityGroup = new AliCloud.Ecs.SecurityGroup("defaultSecurityGroup", new()
    ///     {
    ///         Description = "New security group",
    ///         VpcId = defaultNetworks.Apply(getNetworksResult =&gt; getNetworksResult.Ids[0]),
    ///     });
    /// 
    ///     var defaultImages = AliCloud.Ecs.GetImages.Invoke(new()
    ///     {
    ///         NameRegex = "^ubuntu_[0-9]+_[0-9]+_x64*",
    ///         MostRecent = true,
    ///         Owners = "system",
    ///     });
    /// 
    ///     var defaultInstance = new List&lt;AliCloud.Ecs.Instance&gt;();
    ///     for (var rangeIndex = 0; rangeIndex &lt; 2; rangeIndex++)
    ///     {
    ///         var range = new { Value = rangeIndex };
    ///         defaultInstance.Add(new AliCloud.Ecs.Instance($"defaultInstance-{range.Value}", new()
    ///         {
    ///             AvailabilityZone = defaultZones.Apply(getZonesResult =&gt; getZonesResult.Zones[0]?.Id),
    ///             InstanceName = "example_value",
    ///             HostName = "tf-testAcc",
    ///             ImageId = defaultImages.Apply(getImagesResult =&gt; getImagesResult.Images[0]?.Id),
    ///             InstanceType = defaultInstanceTypes.Apply(getInstanceTypesResult =&gt; getInstanceTypesResult.InstanceTypes[0]?.Id),
    ///             SecurityGroups = new[]
    ///             {
    ///                 defaultSecurityGroup.Id,
    ///             },
    ///             VswitchId = vswitchId,
    ///             SystemDiskCategory = "cloud_essd",
    ///         }));
    ///     }
    ///     var defaultEcsNetworkInterface = new List&lt;AliCloud.Ecs.EcsNetworkInterface&gt;();
    ///     for (var rangeIndex = 0; rangeIndex &lt; 2; rangeIndex++)
    ///     {
    ///         var range = new { Value = rangeIndex };
    ///         defaultEcsNetworkInterface.Add(new AliCloud.Ecs.EcsNetworkInterface($"defaultEcsNetworkInterface-{range.Value}", new()
    ///         {
    ///             NetworkInterfaceName = "example_value",
    ///             VswitchId = vswitchId,
    ///             SecurityGroupIds = new[]
    ///             {
    ///                 defaultSecurityGroup.Id,
    ///             },
    ///         }));
    ///     }
    ///     var defaultEcsNetworkInterfaceAttachment = new List&lt;AliCloud.Ecs.EcsNetworkInterfaceAttachment&gt;();
    ///     for (var rangeIndex = 0; rangeIndex &lt; 2; rangeIndex++)
    ///     {
    ///         var range = new { Value = rangeIndex };
    ///         defaultEcsNetworkInterfaceAttachment.Add(new AliCloud.Ecs.EcsNetworkInterfaceAttachment($"defaultEcsNetworkInterfaceAttachment-{range.Value}", new()
    ///         {
    ///             InstanceId = defaultInstance.Select(__item =&gt; __item.Id).ToList()[range.Value],
    ///             NetworkInterfaceId = defaultEcsNetworkInterface.Select(__item =&gt; __item.Id).ToList()[range.Value],
    ///         }));
    ///     }
    ///     var defaultTrafficMirrorFilter = new AliCloud.Vpc.TrafficMirrorFilter("defaultTrafficMirrorFilter", new()
    ///     {
    ///         TrafficMirrorFilterName = "example_value",
    ///         TrafficMirrorFilterDescription = "example_value",
    ///     });
    /// 
    ///     var defaultTrafficMirrorSession = new AliCloud.Vpc.TrafficMirrorSession("defaultTrafficMirrorSession", new()
    ///     {
    ///         Priority = 1,
    ///         VirtualNetworkId = 10,
    ///         TrafficMirrorSessionDescription = "example_value",
    ///         TrafficMirrorSessionName = "example_value",
    ///         TrafficMirrorTargetId = defaultEcsNetworkInterfaceAttachment[0].NetworkInterfaceId,
    ///         TrafficMirrorSourceIds = new[]
    ///         {
    ///             defaultEcsNetworkInterfaceAttachment[1].NetworkInterfaceId,
    ///         },
    ///         TrafficMirrorFilterId = defaultTrafficMirrorFilter.Id,
    ///         TrafficMirrorTargetType = "NetworkInterface",
    ///     });
    /// 
    /// });
    /// ```
    /// 
    /// ## Import
    /// 
    /// VPC Traffic Mirror Session can be imported using the id, e.g.
    /// 
    /// ```sh
    ///  $ pulumi import alicloud:vpc/trafficMirrorSession:TrafficMirrorSession example &lt;id&gt;
    /// ```
    /// </summary>
    [AliCloudResourceType("alicloud:vpc/trafficMirrorSession:TrafficMirrorSession")]
    public partial class TrafficMirrorSession : global::Pulumi.CustomResource
    {
        /// <summary>
        /// The dry run.
        /// </summary>
        [Output("dryRun")]
        public Output<bool?> DryRun { get; private set; } = null!;

        /// <summary>
        /// Specifies whether to enable traffic mirror sessions. default to `false`.
        /// </summary>
        [Output("enabled")]
        public Output<bool?> Enabled { get; private set; } = null!;

        /// <summary>
        /// The priority of the traffic mirror session. Valid values: `1` to `32766`. A smaller value indicates a higher priority. You cannot specify the same priority for traffic mirror sessions that are created in the same region with the same Alibaba Cloud account.
        /// </summary>
        [Output("priority")]
        public Output<int> Priority { get; private set; } = null!;

        /// <summary>
        /// The state of the traffic mirror session. Valid values: `Creating`, `Created`, `Modifying` and `Deleting`.
        /// </summary>
        [Output("status")]
        public Output<string> Status { get; private set; } = null!;

        /// <summary>
        /// The ID of the filter.
        /// </summary>
        [Output("trafficMirrorFilterId")]
        public Output<string> TrafficMirrorFilterId { get; private set; } = null!;

        /// <summary>
        /// The description of the traffic mirror session. The description must be `2` to `256` characters in length and cannot start with `http://` or `https://`.
        /// </summary>
        [Output("trafficMirrorSessionDescription")]
        public Output<string?> TrafficMirrorSessionDescription { get; private set; } = null!;

        /// <summary>
        /// The name of the traffic mirror session. The name must be `2` to `128` characters in length and can contain digits, underscores (_), and hyphens (-). It must start with a letter.
        /// </summary>
        [Output("trafficMirrorSessionName")]
        public Output<string?> TrafficMirrorSessionName { get; private set; } = null!;

        /// <summary>
        /// The ID of the mirror source. You can specify only an elastic network interface (ENI) as the mirror source. **NOTE:** Only one mirror source can be added to a traffic mirror session.
        /// </summary>
        [Output("trafficMirrorSourceIds")]
        public Output<ImmutableArray<string>> TrafficMirrorSourceIds { get; private set; } = null!;

        /// <summary>
        /// The ID of the mirror destination. You can specify only an ENI or a Server Load Balancer (SLB) instance as a mirror destination.
        /// </summary>
        [Output("trafficMirrorTargetId")]
        public Output<string> TrafficMirrorTargetId { get; private set; } = null!;

        /// <summary>
        /// The type of the mirror destination. Valid values: `NetworkInterface` or `SLB`. `NetworkInterface`: an ENI. `SLB`: an internal-facing SLB instance
        /// </summary>
        [Output("trafficMirrorTargetType")]
        public Output<string> TrafficMirrorTargetType { get; private set; } = null!;

        /// <summary>
        /// The VXLAN network identifier (VNI) that is used to distinguish different mirrored traffic. Valid values: `0` to `16777215`. You can specify VNIs for the traffic mirror destination to identify mirrored traffic from different sessions. If you do not specify a VNI, the system randomly allocates a VNI. If you want the system to randomly allocate a VNI, ignore this parameter.
        /// </summary>
        [Output("virtualNetworkId")]
        public Output<int> VirtualNetworkId { get; private set; } = null!;


        /// <summary>
        /// Create a TrafficMirrorSession resource with the given unique name, arguments, and options.
        /// </summary>
        ///
        /// <param name="name">The unique name of the resource</param>
        /// <param name="args">The arguments used to populate this resource's properties</param>
        /// <param name="options">A bag of options that control this resource's behavior</param>
        public TrafficMirrorSession(string name, TrafficMirrorSessionArgs args, CustomResourceOptions? options = null)
            : base("alicloud:vpc/trafficMirrorSession:TrafficMirrorSession", name, args ?? new TrafficMirrorSessionArgs(), MakeResourceOptions(options, ""))
        {
        }

        private TrafficMirrorSession(string name, Input<string> id, TrafficMirrorSessionState? state = null, CustomResourceOptions? options = null)
            : base("alicloud:vpc/trafficMirrorSession:TrafficMirrorSession", name, state, MakeResourceOptions(options, id))
        {
        }

        private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? options, Input<string>? id)
        {
            var defaultOptions = new CustomResourceOptions
            {
                Version = Utilities.Version,
                PluginDownloadURL = "github://api.github.com/rhysmdnz/pulumi-alicloud",
            };
            var merged = CustomResourceOptions.Merge(defaultOptions, options);
            // Override the ID if one was specified for consistency with other language SDKs.
            merged.Id = id ?? merged.Id;
            return merged;
        }
        /// <summary>
        /// Get an existing TrafficMirrorSession resource's state with the given name, ID, and optional extra
        /// properties used to qualify the lookup.
        /// </summary>
        ///
        /// <param name="name">The unique name of the resulting resource.</param>
        /// <param name="id">The unique provider ID of the resource to lookup.</param>
        /// <param name="state">Any extra arguments used during the lookup.</param>
        /// <param name="options">A bag of options that control this resource's behavior</param>
        public static TrafficMirrorSession Get(string name, Input<string> id, TrafficMirrorSessionState? state = null, CustomResourceOptions? options = null)
        {
            return new TrafficMirrorSession(name, id, state, options);
        }
    }

    public sealed class TrafficMirrorSessionArgs : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// The dry run.
        /// </summary>
        [Input("dryRun")]
        public Input<bool>? DryRun { get; set; }

        /// <summary>
        /// Specifies whether to enable traffic mirror sessions. default to `false`.
        /// </summary>
        [Input("enabled")]
        public Input<bool>? Enabled { get; set; }

        /// <summary>
        /// The priority of the traffic mirror session. Valid values: `1` to `32766`. A smaller value indicates a higher priority. You cannot specify the same priority for traffic mirror sessions that are created in the same region with the same Alibaba Cloud account.
        /// </summary>
        [Input("priority", required: true)]
        public Input<int> Priority { get; set; } = null!;

        /// <summary>
        /// The ID of the filter.
        /// </summary>
        [Input("trafficMirrorFilterId", required: true)]
        public Input<string> TrafficMirrorFilterId { get; set; } = null!;

        /// <summary>
        /// The description of the traffic mirror session. The description must be `2` to `256` characters in length and cannot start with `http://` or `https://`.
        /// </summary>
        [Input("trafficMirrorSessionDescription")]
        public Input<string>? TrafficMirrorSessionDescription { get; set; }

        /// <summary>
        /// The name of the traffic mirror session. The name must be `2` to `128` characters in length and can contain digits, underscores (_), and hyphens (-). It must start with a letter.
        /// </summary>
        [Input("trafficMirrorSessionName")]
        public Input<string>? TrafficMirrorSessionName { get; set; }

        [Input("trafficMirrorSourceIds", required: true)]
        private InputList<string>? _trafficMirrorSourceIds;

        /// <summary>
        /// The ID of the mirror source. You can specify only an elastic network interface (ENI) as the mirror source. **NOTE:** Only one mirror source can be added to a traffic mirror session.
        /// </summary>
        public InputList<string> TrafficMirrorSourceIds
        {
            get => _trafficMirrorSourceIds ?? (_trafficMirrorSourceIds = new InputList<string>());
            set => _trafficMirrorSourceIds = value;
        }

        /// <summary>
        /// The ID of the mirror destination. You can specify only an ENI or a Server Load Balancer (SLB) instance as a mirror destination.
        /// </summary>
        [Input("trafficMirrorTargetId", required: true)]
        public Input<string> TrafficMirrorTargetId { get; set; } = null!;

        /// <summary>
        /// The type of the mirror destination. Valid values: `NetworkInterface` or `SLB`. `NetworkInterface`: an ENI. `SLB`: an internal-facing SLB instance
        /// </summary>
        [Input("trafficMirrorTargetType", required: true)]
        public Input<string> TrafficMirrorTargetType { get; set; } = null!;

        /// <summary>
        /// The VXLAN network identifier (VNI) that is used to distinguish different mirrored traffic. Valid values: `0` to `16777215`. You can specify VNIs for the traffic mirror destination to identify mirrored traffic from different sessions. If you do not specify a VNI, the system randomly allocates a VNI. If you want the system to randomly allocate a VNI, ignore this parameter.
        /// </summary>
        [Input("virtualNetworkId")]
        public Input<int>? VirtualNetworkId { get; set; }

        public TrafficMirrorSessionArgs()
        {
        }
        public static new TrafficMirrorSessionArgs Empty => new TrafficMirrorSessionArgs();
    }

    public sealed class TrafficMirrorSessionState : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// The dry run.
        /// </summary>
        [Input("dryRun")]
        public Input<bool>? DryRun { get; set; }

        /// <summary>
        /// Specifies whether to enable traffic mirror sessions. default to `false`.
        /// </summary>
        [Input("enabled")]
        public Input<bool>? Enabled { get; set; }

        /// <summary>
        /// The priority of the traffic mirror session. Valid values: `1` to `32766`. A smaller value indicates a higher priority. You cannot specify the same priority for traffic mirror sessions that are created in the same region with the same Alibaba Cloud account.
        /// </summary>
        [Input("priority")]
        public Input<int>? Priority { get; set; }

        /// <summary>
        /// The state of the traffic mirror session. Valid values: `Creating`, `Created`, `Modifying` and `Deleting`.
        /// </summary>
        [Input("status")]
        public Input<string>? Status { get; set; }

        /// <summary>
        /// The ID of the filter.
        /// </summary>
        [Input("trafficMirrorFilterId")]
        public Input<string>? TrafficMirrorFilterId { get; set; }

        /// <summary>
        /// The description of the traffic mirror session. The description must be `2` to `256` characters in length and cannot start with `http://` or `https://`.
        /// </summary>
        [Input("trafficMirrorSessionDescription")]
        public Input<string>? TrafficMirrorSessionDescription { get; set; }

        /// <summary>
        /// The name of the traffic mirror session. The name must be `2` to `128` characters in length and can contain digits, underscores (_), and hyphens (-). It must start with a letter.
        /// </summary>
        [Input("trafficMirrorSessionName")]
        public Input<string>? TrafficMirrorSessionName { get; set; }

        [Input("trafficMirrorSourceIds")]
        private InputList<string>? _trafficMirrorSourceIds;

        /// <summary>
        /// The ID of the mirror source. You can specify only an elastic network interface (ENI) as the mirror source. **NOTE:** Only one mirror source can be added to a traffic mirror session.
        /// </summary>
        public InputList<string> TrafficMirrorSourceIds
        {
            get => _trafficMirrorSourceIds ?? (_trafficMirrorSourceIds = new InputList<string>());
            set => _trafficMirrorSourceIds = value;
        }

        /// <summary>
        /// The ID of the mirror destination. You can specify only an ENI or a Server Load Balancer (SLB) instance as a mirror destination.
        /// </summary>
        [Input("trafficMirrorTargetId")]
        public Input<string>? TrafficMirrorTargetId { get; set; }

        /// <summary>
        /// The type of the mirror destination. Valid values: `NetworkInterface` or `SLB`. `NetworkInterface`: an ENI. `SLB`: an internal-facing SLB instance
        /// </summary>
        [Input("trafficMirrorTargetType")]
        public Input<string>? TrafficMirrorTargetType { get; set; }

        /// <summary>
        /// The VXLAN network identifier (VNI) that is used to distinguish different mirrored traffic. Valid values: `0` to `16777215`. You can specify VNIs for the traffic mirror destination to identify mirrored traffic from different sessions. If you do not specify a VNI, the system randomly allocates a VNI. If you want the system to randomly allocate a VNI, ignore this parameter.
        /// </summary>
        [Input("virtualNetworkId")]
        public Input<int>? VirtualNetworkId { get; set; }

        public TrafficMirrorSessionState()
        {
        }
        public static new TrafficMirrorSessionState Empty => new TrafficMirrorSessionState();
    }
}
