Пример #1
0
 public Task <CreateListenerResponse> CreateListenerAsync(
     int port,
     ProtocolEnum protocol,
     string loadBalancerArn,
     string targetGroupArn,
     ActionTypeEnum actionTypeEnum,
     IEnumerable <Certificate> certificates = null,
     string sslPolicy = null,
     CancellationToken cancellationToken = default(CancellationToken))
 => _clientV2.CreateListenerAsync(
     new CreateListenerRequest()
 {
     Port            = port,
     Protocol        = protocol,
     LoadBalancerArn = loadBalancerArn,
     DefaultActions  = new List <Action>()
     {
         new Action()
         {
             TargetGroupArn = targetGroupArn,
             Type           = actionTypeEnum
         }
     },
     Certificates = certificates?.ToList(),
     SslPolicy    = sslPolicy
 }
     , cancellationToken).EnsureSuccessAsync();
Пример #2
0
        public async Task <SA_Listener> CreatListener(
            string loadBalancerArn, string targetGroupArn,
            string strProtocol, int port, string certificateArn = "")
        {
            var actions = new List <Amazon.ElasticLoadBalancingV2.Model.Action>();
            var action  = new Amazon.ElasticLoadBalancingV2.Model.Action();

            action.Type           = ActionTypeEnum.Forward;
            action.TargetGroupArn = targetGroupArn;
            actions.Add(action);
            var protocol = new ProtocolEnum(strProtocol);
            var request  = new CreateListenerRequest
            {
                DefaultActions  = actions,
                Protocol        = protocol,
                Port            = port,
                LoadBalancerArn = loadBalancerArn,
            };

            if (!string.IsNullOrEmpty(certificateArn))
            {
                var certificate = new Certificate();
                certificate.CertificateArn = certificateArn;
                //certificate.IsDefault = true;
                request.Certificates = new List <Certificate>()
                {
                    certificate
                };
            }

            var response = await client.CreateListenerAsync(request);

            var listener = response.Listeners[0];

            return(ConvertListener(response.Listeners[0]));
        }