create_listener
async
¶
create_listener(
*,
config_overrides: Optional[AsyncElasticLoadBalancingv2ClientConfig] = None,
load_balancer_arn: Optional[LoadBalancerArn] = None,
protocol: Optional[ProtocolEnum] = None,
port: Optional[Port] = None,
ssl_policy: Optional[SslPolicyName] = None,
certificates: Optional[CertificateList] = None,
default_actions: Optional[Actions] = None,
alpn_policy: Optional[AlpnPolicyName] = None,
tags: Optional[TagList] = None,
mutual_authentication: Optional[MutualAuthenticationAttributes] = None,
) -> CreateListenerOutput
Creates a listener for the specified Application Load Balancer, Network Load Balancer, or Gateway Load Balancer.
For more information, see the following:
This operation is idempotent, which means that it completes at most one time. If you attempt to create multiple listeners with the same settings, each call succeeds.
Parameters:
-
load_balancer_arn(Optional[LoadBalancerArn], default:None) –The Amazon Resource Name (ARN) of the load balancer.
-
protocol(Optional[ProtocolEnum], default:None) –The protocol for connections from clients to the load balancer. For Application Load Balancers, the supported protocols are HTTP and HTTPS. For Network Load Balancers, the supported protocols are TCP, TLS, UDP, TCP_UDP, QUIC, and TCP_QUIC. You can’t specify the UDP, TCP_UDP, QUIC, or TCP_QUIC protocol if dual-stack mode is enabled. You can't specify a protocol for a Gateway Load Balancer.
-
port(Optional[Port], default:None) –The port on which the load balancer is listening. You can't specify a port for a Gateway Load Balancer.
-
ssl_policy(Optional[SslPolicyName], default:None) –[HTTPS and TLS listeners] The security policy that defines which protocols and ciphers are supported.
For more information, see Security policies in the Application Load Balancers Guide and Security policies in the Network Load Balancers Guide.
-
certificates(Optional[CertificateList], default:None) –[HTTPS and TLS listeners] The default certificate for the listener. You must provide exactly one certificate. Set
CertificateArnto the certificate ARN but do not setIsDefault. -
default_actions(Optional[Actions], default:None) –The actions for the default rule.
-
alpn_policy(Optional[AlpnPolicyName], default:None) –[TLS listeners] The name of the Application-Layer Protocol Negotiation (ALPN) policy. You can specify one policy name. The following are the possible values:
-
HTTP1Only -
HTTP2Only -
HTTP2Optional -
HTTP2Preferred -
None
For more information, see ALPN policies in the Network Load Balancers Guide.
-
-
tags(Optional[TagList], default:None) –The tags to assign to the listener.
-
mutual_authentication(Optional[MutualAuthenticationAttributes], default:None) –[HTTPS listeners] The mutual authentication configuration information.
Raises:
-
ALPNPolicyNotSupportedException–The specified ALPN policy is not supported.
-
CertificateNotFoundException–The specified certificate does not exist.
-
DuplicateListenerException–A listener with the specified port already exists.
-
IncompatibleProtocolsException–The specified configuration is not valid with this protocol.
-
InvalidConfigurationRequestException–The requested configuration is not valid.
-
InvalidLoadBalancerActionException–The requested action is not valid.
-
LoadBalancerNotFoundException–The specified load balancer does not exist.
-
SSLPolicyNotFoundException–The specified SSL policy does not exist.
-
TargetGroupAssociationLimitException–You've reached the limit on the number of load balancers per target group.
-
TargetGroupNotFoundException–The specified target group does not exist.
-
TooManyActionsException–You've reached the limit on the number of actions per rule.
-
TooManyCertificatesException–You've reached the limit on the number of certificates per load balancer.
-
TooManyListenersException–You've reached the limit on the number of listeners per load balancer.
-
TooManyRegistrationsForTargetIdException–You've reached the limit on the number of times a target can be registered with a load balancer.
-
TooManyTagsException–You've reached the limit on the number of tags for this resource.
-
TooManyTargetsException–You've reached the limit on the number of targets.
-
TooManyUniqueTargetGroupsPerLoadBalancerException–You've reached the limit on the number of unique target groups per load balancer across all listeners. If a target group is used by multiple actions for a load balancer, it is counted as only one use.
-
TrustStoreNotFoundException–The specified trust store does not exist.
-
TrustStoreNotReadyException–The specified trust store is not active.
-
UnsupportedProtocolException–The specified protocol is not supported.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To create an HTTP listener This example creates an HTTP listener for the specified load balancer that forwards requests to the specified target group.
>>> await client.create_listener(load_balancer_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188', protocol='HTTP', port=80, default_actions=[{'Type': 'forward', 'TargetGroupArn': 'arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067'}])
To create an HTTPS listener
This example creates an HTTPS listener for the specified load balancer that forwards requests to the specified target group. Note that you must specify an SSL certificate for an HTTPS listener. You can create and manage certificates using AWS Certificate Manager (ACM). Alternatively, you can create a certificate using SSL/TLS tools, get the certificate signed by a certificate authority (CA), and upload the certificate to AWS Identity and Access Management (IAM).
>>> await client.create_listener(load_balancer_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188', protocol='HTTPS', port=443, ssl_policy='ELBSecurityPolicy-2015-05', certificates=[{'CertificateArn': 'arn:aws:iam::123456789012:server-certificate/my-server-cert'}], default_actions=[{'Type': 'forward', 'TargetGroupArn': 'arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067'}])
Source code in docs_src/capo_elastic_load_balancing_v2/_services/async_elastic_load_balancingv2.py
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 | |