load_balancer#

State module for managing Amazon Elastic Load Balancing.

async idem_aws.states.aws.elb.load_balancer.present(hub, ctx, name: str, listeners: ~typing.List[~types.Information about a listener.Listener], availability_zones: ~typing.List[str] = None, subnets: ~typing.List[str] = None, security_groups: ~typing.List[str] = None, scheme: str = None, instances: ~typing.List[~types.The ID of an EC2 instance.Instance] = None, load_balancer_attributes: ~types.LoadBalancerAttributes = None, tags: ~typing.Dict[str, str] = None, resource_id: str = None) Dict[str, Any][source]#

Create an Elastic Load Balancer in AWS.

Creates a Classic Load Balancer. You can add listeners, security groups, subnets, and tags when you create your load balancer, or you can add them later using this present function with a resource_id.

You can create up to 20 load balancers per region per account.

Parameters:
  • name (str) – The name of the load balancer. This name must be unique within your set of load balancers for the region, must have a maximum of 32 characters, must contain only alphanumeric characters or hyphens, and cannot begin or end with a hyphen.

  • listeners (list[dict[str, Any]]) –

    Information about a listener.

    • Protocol (str):

      The load balancer transport protocol to use for routing: HTTP, HTTPS, TCP, or SSL.

    • LoadBalancerPort (int):

      The port on which the load balancer is listening. On EC2-VPC, you can specify any port from the range 1-65535. On EC2-Classic, you can specify any port from the following list: 25, 80, 443, 465, 587, 1024-65535.

    • InstanceProtocol (str, Optional):

      1. The protocol to use for routing traffic to instance: HTTP, HTTPS, TCP, or SSL. If the front-end protocol is TCP or SSL, the back-end protocol must be TCP or SSL. If the front-end protocol is HTTP or HTTPS, the back-end protocol must be HTTP or HTTPS.

      2. If there is another listener with the same InstancePort whose InstanceProtocol is secure, (HTTPS or SSL), the listener’s InstanceProtocol must also be secure.

      3. If there is another listener with the same InstancePort whose InstanceProtocol is HTTP or TCP, the listener’s InstanceProtocol must be HTTP or TCP.

    • InstancePort (int):

      The port on which the instance is listening.

    • SSLCertificateId (str, Optional):

      The Amazon Resource Name (ARN) of the server certificate.

  • availability_zones (list, Optional) – One or more Availability Zones from the same region as the load balancer. You must specify at least one Availability Zone. You can add more Availability Zones after you create the load balancer using EnableAvailabilityZonesForLoadBalancer.

  • subnets (list, Optional) – The IDs of the subnets in your VPC to attach to the load balancer. Specify one subnet per Availability Zone specified in AvailabilityZones.

  • security_groups (list, Optional) – The IDs of the security groups to assign to the load balancer.

  • scheme (str, Optional) – Given load balance type. Valid only for load balancers in a VPC.

  • instances (list, Optional) –

    The IDs of the instances.
    • (dict): The ID of an EC2 instance.

  • load_balancer_attributes (dict, Optional) –

    The attributes for the load balancer.
    • CrossZoneLoadBalancing(dict): If enabled, the load balancer routes the request traffic evenly across all instances regardless of the Availability Zones. Enabled (bool): Specifies whether cross-zone load balancing is enabled for the load balancer.

    • AccessLog(dict, Optional): If enabled, the load balancer captures detailed information of all requests and delivers the information to the Amazon S3 bucket that you specify.
      • Enabled(bool): Specifies whether access logs are enabled for the load balancer.

      • S3BucketName(str, Optional): The name of the Amazon S3 bucket where the access logs are stored.

      • EmitInterval(int, Optional): The interval for publishing the access logs. You can specify an interval of either 5 minutes or 60 minutes. Default: 60 minutes

      • S3BucketPrefix(str, Optional): The logical hierarchy you created for your Amazon S3 bucket, for example my-bucket-prefix/prod . If the prefix is not provided, the log is placed at the root level of the bucket.

    • ConnectionDraining(dict[int, bool], Optional): If enabled, the load balancer allows existing requests to complete before the load balancer shifts traffic away from a deregistered or unhealthy instance.
      • Enabled(bool): Specifies whether connection draining is enabled for the load balancer.

      • Timeout(int, Optional): The maximum time, in seconds, to keep the existing connections open before unregistering the instances.

      • ConnectionSettings(dict): If enabled, the load balancer allows the connections to remain idle (no data is sent over the connection) for the specified duration.

      • IdleTimeout(int): The time, in seconds, that the connection is allowed to be idle (no data has been sent over the connection) before it is closed by the load balancer.

    • AdditionalAttributes (list[dict[str, Any]], Optional): Any additional attributes.
      Information about additional load balancer attributes.
      • Key (str): The name of the attribute. The following attribute is supported.

        elb.http.desyncmitigationmode - Determines how the load balancer handles requests that might pose a security risk to your application. The possible values are monitor, defensive, and strictest . The default is defensive.

      • Value (str, Optional): This value of the attribute.

  • tags (dict[str, str], Optional) –

    The tags to assign to the load balancer.
    • Key (str): The key of the tag.

    • Value (str, Optional): The value of the tag.

  • resource_id (str, Optional) – AWS ELB load balancer name.

Examples:

Using in a state:

test_load-balancer_name:
    aws.elb.load_balancer.present
    - name: my-load-balancer
    - resource_id: my-load-balancer
    - listeners:
      - InstancePort: 80
      - InstanceProtocol: HTTP
      - LoadBalancerPort: 80
      - Protocol: HTTP
    - tags:
        name: my-load-balancer
    - availability_zones:
      - us-west-2a
    - subnets:
      - subnet-15aaab61
    - security_groups:
      - sg-a61988c378fgtyu
    - scheme: internal
    - instances:
      - i-d6f6f34tyu78ae3
      - i-207d9vbty56u717
      - i-afefvbu90ipb49b
    - load_balancer_attributes:
        CrossZoneLoadBalancing:
            - Enabled: True
async idem_aws.states.aws.elb.load_balancer.absent(hub, ctx, name: str, resource_id: str = None) Dict[str, Any][source]#

Deletes the specified load balancer.

If the load balancer does not exist or has already been deleted, the call still succeeds.

Parameters:
  • name (str) – Idem name of the load balancer.

  • resource_id (str, Optional) – AWS ELB load balancer name. Idem automatically considers this resource being absent if this field is not specified.

Examples:

Using in a state:

test_load-balancer_name:
    aws.elb.load_balancer.absent:
        - name: my-load-balancer
        - resource_id: my-load-balancer
async idem_aws.states.aws.elb.load_balancer.describe(hub, ctx) Dict[str, Dict[str, Any]][source]#

Describe the resource in a way that can be recreated/managed with the corresponding “present” function. This call describes all of your load balancers.

Examples:

$ idem describe aws.elb.load_balancer