You are viewing documentation for version 3 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: Aws::ElasticLoadBalancingV2::Client

Inherits:
Seahorse::Client::Base show all
Includes:
ClientStubs
Defined in:
gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb

Instance Attribute Summary

Attributes inherited from Seahorse::Client::Base

#config, #handlers

API Operations collapse

Instance Method Summary collapse

Methods included from ClientStubs

#stub_data, #stub_responses

Methods inherited from Seahorse::Client::Base

add_plugin, api, clear_plugins, define, new, #operation_names, plugins, remove_plugin, set_api, set_plugins

Methods included from Seahorse::Client::HandlerBuilder

#handle, #handle_request, #handle_response

Constructor Details

#initialize(*args) ⇒ Client

Returns a new instance of Client

Parameters:

  • options (Hash)

    a customizable set of options



142
143
144
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 142

def initialize(*args)
  super
end

Instance Method Details

#add_tags(params = {}) ⇒ Struct

Adds the specified tags to the specified resource. You can tag your Application Load Balancers and your target groups.

Each tag consists of a key and an optional value. If a resource already has a tag with the same key, AddTags updates its value.

To list the current tags for your resources, use DescribeTags. To remove tags from your resources, use RemoveTags.

Examples:

Example: To add tags to a load balancer


# This example adds the specified tags to the specified load balancer.

resp = client.add_tags({
  resource_arns: [
    "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
  ], 
  tags: [
    {
      key: "project", 
      value: "lima", 
    }, 
    {
      key: "department", 
      value: "digital-media", 
    }, 
  ], 
})

Request syntax with placeholder values


resp = client.add_tags({
  resource_arns: ["ResourceArn"], # required
  tags: [ # required
    {
      key: "TagKey", # required
      value: "TagValue",
    },
  ],
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :resource_arns (required, Array<String>)

    The Amazon Resource Name (ARN) of the resource.

  • :tags (required, Array<Types::Tag>)

    The tags. Each resource can have a maximum of 10 tags.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



202
203
204
205
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 202

def add_tags(params = {}, options = {})
  req = build_request(:add_tags, params)
  req.send_request(options)
end

#create_listener(params = {}) ⇒ Types::CreateListenerOutput

Creates a listener for the specified Application Load Balancer.

You can create up to 10 listeners per load balancer.

To update a listener, use ModifyListener. When you are finished with a listener, you can delete it using DeleteListener. If you are finished with both the listener and the load balancer, you can delete them both using DeleteLoadBalancer.

For more information, see Listeners for Your Application Load Balancers in the Application Load Balancers Guide.

Examples:

Example: To create an HTTP listener


# This example creates an HTTP listener for the specified load balancer that forwards requests to the specified target group.

resp = client.create_listener({
  default_actions: [
    {
      target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
      type: "forward", 
    }, 
  ], 
  load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
  port: 80, 
  protocol: "HTTP", 
})

resp.to_h outputs the following:
{
  listeners: [
    {
      default_actions: [
        {
          target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
          type: "forward", 
        }, 
      ], 
      listener_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2", 
      load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
      port: 80, 
      protocol: "HTTP", 
    }, 
  ], 
}

Example: 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).

resp = client.create_listener({
  certificates: [
    {
      certificate_arn: "arn:aws:iam::123456789012:server-certificate/my-server-cert", 
    }, 
  ], 
  default_actions: [
    {
      target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
      type: "forward", 
    }, 
  ], 
  load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
  port: 443, 
  protocol: "HTTPS", 
  ssl_policy: "ELBSecurityPolicy-2015-05", 
})

resp.to_h outputs the following:
{
  listeners: [
    {
      certificates: [
        {
          certificate_arn: "arn:aws:iam::123456789012:server-certificate/my-server-cert", 
        }, 
      ], 
      default_actions: [
        {
          target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
          type: "forward", 
        }, 
      ], 
      listener_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2", 
      load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
      port: 443, 
      protocol: "HTTPS", 
      ssl_policy: "ELBSecurityPolicy-2015-05", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.create_listener({
  load_balancer_arn: "LoadBalancerArn", # required
  protocol: "HTTP", # required, accepts HTTP, HTTPS
  port: 1, # required
  ssl_policy: "SslPolicyName",
  certificates: [
    {
      certificate_arn: "CertificateArn",
    },
  ],
  default_actions: [ # required
    {
      type: "forward", # required, accepts forward
      target_group_arn: "TargetGroupArn", # required
    },
  ],
})

Response structure


resp.listeners #=> Array
resp.listeners[0].listener_arn #=> String
resp.listeners[0].load_balancer_arn #=> String
resp.listeners[0].port #=> Integer
resp.listeners[0].protocol #=> String, one of "HTTP", "HTTPS"
resp.listeners[0].certificates #=> Array
resp.listeners[0].certificates[0].certificate_arn #=> String
resp.listeners[0].ssl_policy #=> String
resp.listeners[0].default_actions #=> Array
resp.listeners[0].default_actions[0].type #=> String, one of "forward"
resp.listeners[0].default_actions[0].target_group_arn #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :load_balancer_arn (required, String)

    The Amazon Resource Name (ARN) of the load balancer.

  • :protocol (required, String)

    The protocol for connections from clients to the load balancer.

  • :port (required, Integer)

    The port on which the load balancer is listening.

  • :ssl_policy (String)

    The security policy that defines which ciphers and protocols are supported. The default is the current predefined security policy.

  • :certificates (Array<Types::Certificate>)

    The SSL server certificate. You must provide exactly one certificate if the protocol is HTTPS.

  • :default_actions (required, Array<Types::Action>)

    The default action for the listener.

Returns:

See Also:



366
367
368
369
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 366

def create_listener(params = {}, options = {})
  req = build_request(:create_listener, params)
  req.send_request(options)
end

#create_load_balancer(params = {}) ⇒ Types::CreateLoadBalancerOutput

Creates an Application Load Balancer.

When you create a load balancer, you can specify security groups, subnets, IP address type, and tags. Otherwise, you could do so later using SetSecurityGroups, SetSubnets, SetIpAddressType, and AddTags.

To create listeners for your load balancer, use CreateListener. To describe your current load balancers, see DescribeLoadBalancers. When you are finished with a load balancer, you can delete it using DeleteLoadBalancer.

You can create up to 20 load balancers per region per account. You can request an increase for the number of load balancers for your account. For more information, see Limits for Your Application Load Balancer in the Application Load Balancers Guide.

For more information, see Application Load Balancers in the Application Load Balancers Guide.

Examples:

Example: To create an Internet-facing load balancer


# This example creates an Internet-facing load balancer and enables the Availability Zones for the specified subnets.

resp = client.create_load_balancer({
  name: "my-load-balancer", 
  subnets: [
    "subnet-b7d581c0", 
    "subnet-8360a9e7", 
  ], 
})

resp.to_h outputs the following:
{
  load_balancers: [
    {
      availability_zones: [
        {
          subnet_id: "subnet-8360a9e7", 
          zone_name: "us-west-2a", 
        }, 
        {
          subnet_id: "subnet-b7d581c0", 
          zone_name: "us-west-2b", 
        }, 
      ], 
      canonical_hosted_zone_id: "Z2P70J7EXAMPLE", 
      created_time: Time.parse("2016-03-25T21:26:12.920Z"), 
      dns_name: "my-load-balancer-424835706.us-west-2.elb.amazonaws.com", 
      load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
      load_balancer_name: "my-load-balancer", 
      scheme: "internet-facing", 
      security_groups: [
        "sg-5943793c", 
      ], 
      state: {
        code: "provisioning", 
      }, 
      type: "application", 
      vpc_id: "vpc-3ac0fb5f", 
    }, 
  ], 
}

Example: To create an internal load balancer


# This example creates an internal load balancer and enables the Availability Zones for the specified subnets.

resp = client.create_load_balancer({
  name: "my-internal-load-balancer", 
  scheme: "internal", 
  security_groups: [
  ], 
  subnets: [
    "subnet-b7d581c0", 
    "subnet-8360a9e7", 
  ], 
})

resp.to_h outputs the following:
{
  load_balancers: [
    {
      availability_zones: [
        {
          subnet_id: "subnet-8360a9e7", 
          zone_name: "us-west-2a", 
        }, 
        {
          subnet_id: "subnet-b7d581c0", 
          zone_name: "us-west-2b", 
        }, 
      ], 
      canonical_hosted_zone_id: "Z2P70J7EXAMPLE", 
      created_time: Time.parse("2016-03-25T21:29:48.850Z"), 
      dns_name: "internal-my-internal-load-balancer-1529930873.us-west-2.elb.amazonaws.com", 
      load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-internal-load-balancer/5b49b8d4303115c2", 
      load_balancer_name: "my-internal-load-balancer", 
      scheme: "internal", 
      security_groups: [
        "sg-5943793c", 
      ], 
      state: {
        code: "provisioning", 
      }, 
      type: "application", 
      vpc_id: "vpc-3ac0fb5f", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.create_load_balancer({
  name: "LoadBalancerName", # required
  subnets: ["SubnetId"], # required
  security_groups: ["SecurityGroupId"],
  scheme: "internet-facing", # accepts internet-facing, internal
  tags: [
    {
      key: "TagKey", # required
      value: "TagValue",
    },
  ],
  ip_address_type: "ipv4", # accepts ipv4, dualstack
})

Response structure


resp.load_balancers #=> Array
resp.load_balancers[0].load_balancer_arn #=> String
resp.load_balancers[0].dns_name #=> String
resp.load_balancers[0].canonical_hosted_zone_id #=> String
resp.load_balancers[0].created_time #=> Time
resp.load_balancers[0].load_balancer_name #=> String
resp.load_balancers[0].scheme #=> String, one of "internet-facing", "internal"
resp.load_balancers[0].vpc_id #=> String
resp.load_balancers[0].state.code #=> String, one of "active", "provisioning", "failed"
resp.load_balancers[0].state.reason #=> String
resp.load_balancers[0].type #=> String, one of "application"
resp.load_balancers[0].availability_zones #=> Array
resp.load_balancers[0].availability_zones[0].zone_name #=> String
resp.load_balancers[0].availability_zones[0].subnet_id #=> String
resp.load_balancers[0].security_groups #=> Array
resp.load_balancers[0].security_groups[0] #=> String
resp.load_balancers[0].ip_address_type #=> String, one of "ipv4", "dualstack"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :name (required, String)

    The name of the load balancer.

    This name must be unique per region per account, can have a maximum of 32 characters, must contain only alphanumeric characters or hyphens, and must not begin or end with a hyphen.

  • :subnets (required, Array<String>)

    The IDs of the subnets to attach to the load balancer. You can specify only one subnet per Availability Zone. You must specify subnets from at least two Availability Zones.

  • :security_groups (Array<String>)

    The IDs of the security groups to assign to the load balancer.

  • :scheme (String)

    The nodes of an Internet-facing load balancer have public IP addresses. The DNS name of an Internet-facing load balancer is publicly resolvable to the public IP addresses of the nodes. Therefore, Internet-facing load balancers can route requests from clients over the Internet.

    The nodes of an internal load balancer have only private IP addresses. The DNS name of an internal load balancer is publicly resolvable to the private IP addresses of the nodes. Therefore, internal load balancers can only route requests from clients with access to the VPC for the load balancer.

    The default is an Internet-facing load balancer.

  • :tags (Array<Types::Tag>)

    One or more tags to assign to the load balancer.

  • :ip_address_type (String)

    The type of IP addresses used by the subnets for your load balancer. The possible values are ipv4 (for IPv4 addresses) and dualstack (for IPv4 and IPv6 addresses). Internal load balancers must use ipv4.

Returns:

See Also:



570
571
572
573
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 570

def create_load_balancer(params = {}, options = {})
  req = build_request(:create_load_balancer, params)
  req.send_request(options)
end

#create_rule(params = {}) ⇒ Types::CreateRuleOutput

Creates a rule for the specified listener.

Each rule can have one action and one condition. Rules are evaluated in priority order, from the lowest value to the highest value. When the condition for a rule is met, the specified action is taken. If no conditions are met, the default action for the default rule is taken. For more information, see Listener Rules in the Application Load Balancers Guide.

To view your current rules, use DescribeRules. To update a rule, use ModifyRule. To set the priorities of your rules, use SetRulePriorities. To delete a rule, use DeleteRule.

Examples:

Example: To create a rule


# This example creates a rule that forwards requests to the specified target group if the URL contains the specified pattern (for example, /img/*).

resp = client.create_rule({
  actions: [
    {
      target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
      type: "forward", 
    }, 
  ], 
  conditions: [
    {
      field: "path-pattern", 
      values: [
        "/img/*", 
      ], 
    }, 
  ], 
  listener_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2", 
  priority: 10, 
})

resp.to_h outputs the following:
{
  rules: [
    {
      actions: [
        {
          target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
          type: "forward", 
        }, 
      ], 
      conditions: [
        {
          field: "path-pattern", 
          values: [
            "/img/*", 
          ], 
        }, 
      ], 
      is_default: false, 
      priority: "10", 
      rule_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.create_rule({
  listener_arn: "ListenerArn", # required
  conditions: [ # required
    {
      field: "ConditionFieldName",
      values: ["StringValue"],
    },
  ],
  priority: 1, # required
  actions: [ # required
    {
      type: "forward", # required, accepts forward
      target_group_arn: "TargetGroupArn", # required
    },
  ],
})

Response structure


resp.rules #=> Array
resp.rules[0].rule_arn #=> String
resp.rules[0].priority #=> String
resp.rules[0].conditions #=> Array
resp.rules[0].conditions[0].field #=> String
resp.rules[0].conditions[0].values #=> Array
resp.rules[0].conditions[0].values[0] #=> String
resp.rules[0].actions #=> Array
resp.rules[0].actions[0].type #=> String, one of "forward"
resp.rules[0].actions[0].target_group_arn #=> String
resp.rules[0].is_default #=> Boolean

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :listener_arn (required, String)

    The Amazon Resource Name (ARN) of the listener.

  • :conditions (required, Array<Types::RuleCondition>)

    A condition. Each condition specifies a field name and a single value.

    If the field name is host-header, you can specify a single host name (for example, my.example.com). A host name is case insensitive, can be up to 128 characters in length, and can contain any of the following characters. Note that you can include up to three wildcard characters.

    • A-Z, a-z, 0-9

    • - .

      • (matches 0 or more characters)
    • ? (matches exactly 1 character)

    If the field name is path-pattern, you can specify a single path pattern. A path pattern is case sensitive, can be up to 128 characters in length, and can contain any of the following characters. Note that you can include up to three wildcard characters.

    • A-Z, a-z, 0-9

    • _ - . $ / ~ " ' @ : +

    • & (using &amp;)

      • (matches 0 or more characters)
    • ? (matches exactly 1 character)

  • :priority (required, Integer)

    The priority for the rule. A listener can't have multiple rules with the same priority.

  • :actions (required, Array<Types::Action>)

    An action. Each action has the type forward and specifies a target group.

Returns:

See Also:



724
725
726
727
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 724

def create_rule(params = {}, options = {})
  req = build_request(:create_rule, params)
  req.send_request(options)
end

#create_target_group(params = {}) ⇒ Types::CreateTargetGroupOutput

Creates a target group.

To register targets with the target group, use RegisterTargets. To update the health check settings for the target group, use ModifyTargetGroup. To monitor the health of targets in the target group, use DescribeTargetHealth.

To route traffic to the targets in a target group, specify the target group in an action using CreateListener or CreateRule.

To delete a target group, use DeleteTargetGroup.

For more information, see Target Groups for Your Application Load Balancers in the Application Load Balancers Guide.

Examples:

Example: To create a target group


# This example creates a target group that you can use to route traffic to targets using HTTP on port 80. This target group uses the default health check configuration.

resp = client.create_target_group({
  name: "my-targets", 
  port: 80, 
  protocol: "HTTP", 
  vpc_id: "vpc-3ac0fb5f", 
})

resp.to_h outputs the following:
{
  target_groups: [
    {
      health_check_interval_seconds: 30, 
      health_check_path: "/", 
      health_check_port: "traffic-port", 
      health_check_protocol: "HTTP", 
      health_check_timeout_seconds: 5, 
      healthy_threshold_count: 5, 
      matcher: {
        http_code: "200", 
      }, 
      port: 80, 
      protocol: "HTTP", 
      target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
      target_group_name: "my-targets", 
      unhealthy_threshold_count: 2, 
      vpc_id: "vpc-3ac0fb5f", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.create_target_group({
  name: "TargetGroupName", # required
  protocol: "HTTP", # required, accepts HTTP, HTTPS
  port: 1, # required
  vpc_id: "VpcId", # required
  health_check_protocol: "HTTP", # accepts HTTP, HTTPS
  health_check_port: "HealthCheckPort",
  health_check_path: "Path",
  health_check_interval_seconds: 1,
  health_check_timeout_seconds: 1,
  healthy_threshold_count: 1,
  unhealthy_threshold_count: 1,
  matcher: {
    http_code: "HttpCode", # required
  },
})

Response structure


resp.target_groups #=> Array
resp.target_groups[0].target_group_arn #=> String
resp.target_groups[0].target_group_name #=> String
resp.target_groups[0].protocol #=> String, one of "HTTP", "HTTPS"
resp.target_groups[0].port #=> Integer
resp.target_groups[0].vpc_id #=> String
resp.target_groups[0].health_check_protocol #=> String, one of "HTTP", "HTTPS"
resp.target_groups[0].health_check_port #=> String
resp.target_groups[0].health_check_interval_seconds #=> Integer
resp.target_groups[0].health_check_timeout_seconds #=> Integer
resp.target_groups[0].healthy_threshold_count #=> Integer
resp.target_groups[0].unhealthy_threshold_count #=> Integer
resp.target_groups[0].health_check_path #=> String
resp.target_groups[0].matcher.http_code #=> String
resp.target_groups[0].load_balancer_arns #=> Array
resp.target_groups[0].load_balancer_arns[0] #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :name (required, String)

    The name of the target group.

    This name must be unique per region per account, can have a maximum of 32 characters, must contain only alphanumeric characters or hyphens, and must not begin or end with a hyphen.

  • :protocol (required, String)

    The protocol to use for routing traffic to the targets.

  • :port (required, Integer)

    The port on which the targets receive traffic. This port is used unless you specify a port override when registering the target.

  • :vpc_id (required, String)

    The identifier of the virtual private cloud (VPC).

  • :health_check_protocol (String)

    The protocol the load balancer uses when performing health checks on targets. The default is the HTTP protocol.

  • :health_check_port (String)

    The port the load balancer uses when performing health checks on targets. The default is traffic-port, which indicates the port on which each target receives traffic from the load balancer.

  • :health_check_path (String)

    The ping path that is the destination on the targets for health checks. The default is /.

  • :health_check_interval_seconds (Integer)

    The approximate amount of time, in seconds, between health checks of an individual target. The default is 30 seconds.

  • :health_check_timeout_seconds (Integer)

    The amount of time, in seconds, during which no response from a target means a failed health check. The default is 5 seconds.

  • :healthy_threshold_count (Integer)

    The number of consecutive health checks successes required before considering an unhealthy target healthy. The default is 5.

  • :unhealthy_threshold_count (Integer)

    The number of consecutive health check failures required before considering a target unhealthy. The default is 2.

  • :matcher (Types::Matcher)

    The HTTP codes to use when checking for a successful response from a target. The default is 200.

Returns:

See Also:



879
880
881
882
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 879

def create_target_group(params = {}, options = {})
  req = build_request(:create_target_group, params)
  req.send_request(options)
end

#delete_listener(params = {}) ⇒ Struct

Deletes the specified listener.

Alternatively, your listener is deleted when you delete the load balancer it is attached to using DeleteLoadBalancer.

Examples:

Example: To delete a listener


# This example deletes the specified listener.

resp = client.delete_listener({
  listener_arn: "arn:aws:elasticloadbalancing:ua-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2", 
})

Request syntax with placeholder values


resp = client.delete_listener({
  listener_arn: "ListenerArn", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :listener_arn (required, String)

    The Amazon Resource Name (ARN) of the listener.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



913
914
915
916
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 913

def delete_listener(params = {}, options = {})
  req = build_request(:delete_listener, params)
  req.send_request(options)
end

#delete_load_balancer(params = {}) ⇒ Struct

Deletes the specified Application Load Balancer and its attached listeners.

You can't delete a load balancer if deletion protection is enabled. If the load balancer does not exist or has already been deleted, the call succeeds.

Deleting a load balancer does not affect its registered targets. For example, your EC2 instances continue to run and are still registered to their target groups. If you no longer need these EC2 instances, you can stop or terminate them.

Examples:

Example: To delete a load balancer


# This example deletes the specified load balancer.

resp = client.delete_load_balancer({
  load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
})

Request syntax with placeholder values


resp = client.delete_load_balancer({
  load_balancer_arn: "LoadBalancerArn", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :load_balancer_arn (required, String)

    The Amazon Resource Name (ARN) of the load balancer.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



954
955
956
957
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 954

def delete_load_balancer(params = {}, options = {})
  req = build_request(:delete_load_balancer, params)
  req.send_request(options)
end

#delete_rule(params = {}) ⇒ Struct

Deletes the specified rule.

Examples:

Example: To delete a rule


# This example deletes the specified rule.

resp = client.delete_rule({
  rule_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/1291d13826f405c3", 
})

Request syntax with placeholder values


resp = client.delete_rule({
  rule_arn: "RuleArn", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :rule_arn (required, String)

    The Amazon Resource Name (ARN) of the rule.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



985
986
987
988
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 985

def delete_rule(params = {}, options = {})
  req = build_request(:delete_rule, params)
  req.send_request(options)
end

#delete_target_group(params = {}) ⇒ Struct

Deletes the specified target group.

You can delete a target group if it is not referenced by any actions. Deleting a target group also deletes any associated health checks.

Examples:

Example: To delete a target group


# This example deletes the specified target group.

resp = client.delete_target_group({
  target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
})

Request syntax with placeholder values


resp = client.delete_target_group({
  target_group_arn: "TargetGroupArn", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :target_group_arn (required, String)

    The Amazon Resource Name (ARN) of the target group.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



1019
1020
1021
1022
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 1019

def delete_target_group(params = {}, options = {})
  req = build_request(:delete_target_group, params)
  req.send_request(options)
end

#deregister_targets(params = {}) ⇒ Struct

Deregisters the specified targets from the specified target group. After the targets are deregistered, they no longer receive traffic from the load balancer.

Examples:

Example: To deregister a target from a target group


# This example deregisters the specified instance from the specified target group.

resp = client.deregister_targets({
  target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
  targets: [
    {
      id: "i-0f76fade", 
    }, 
  ], 
})

Request syntax with placeholder values


resp = client.deregister_targets({
  target_group_arn: "TargetGroupArn", # required
  targets: [ # required
    {
      id: "TargetId", # required
      port: 1,
    },
  ],
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :target_group_arn (required, String)

    The Amazon Resource Name (ARN) of the target group.

  • :targets (required, Array<Types::TargetDescription>)

    The targets. If you specified a port override when you registered a target, you must specify both the target ID and the port when you deregister it.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



1068
1069
1070
1071
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 1068

def deregister_targets(params = {}, options = {})
  req = build_request(:deregister_targets, params)
  req.send_request(options)
end

#describe_account_limits(params = {}) ⇒ Types::DescribeAccountLimitsOutput

Describes the current Elastic Load Balancing resource limits for your AWS account.

For more information, see Limits for Your Application Load Balancer in the Application Load Balancer Guide.

Examples:

Request syntax with placeholder values


resp = client.({
  marker: "Marker",
  page_size: 1,
})

Response structure


resp.limits #=> Array
resp.limits[0].name #=> String
resp.limits[0].max #=> String
resp.next_marker #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :marker (String)

    The marker for the next set of results. (You received this marker from a previous call.)

  • :page_size (Integer)

    The maximum number of results to return with this call.

Returns:

See Also:



1113
1114
1115
1116
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 1113

def (params = {}, options = {})
  req = build_request(:describe_account_limits, params)
  req.send_request(options)
end

#describe_listeners(params = {}) ⇒ Types::DescribeListenersOutput

Describes the specified listeners or the listeners for the specified Application Load Balancer. You must specify either a load balancer or one or more listeners.

Examples:

Example: To describe a listener


# This example describes the specified listener.

resp = client.describe_listeners({
  listener_arns: [
    "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2", 
  ], 
})

resp.to_h outputs the following:
{
  listeners: [
    {
      default_actions: [
        {
          target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
          type: "forward", 
        }, 
      ], 
      listener_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2", 
      load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
      port: 80, 
      protocol: "HTTP", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.describe_listeners({
  load_balancer_arn: "LoadBalancerArn",
  listener_arns: ["ListenerArn"],
  marker: "Marker",
  page_size: 1,
})

Response structure


resp.listeners #=> Array
resp.listeners[0].listener_arn #=> String
resp.listeners[0].load_balancer_arn #=> String
resp.listeners[0].port #=> Integer
resp.listeners[0].protocol #=> String, one of "HTTP", "HTTPS"
resp.listeners[0].certificates #=> Array
resp.listeners[0].certificates[0].certificate_arn #=> String
resp.listeners[0].ssl_policy #=> String
resp.listeners[0].default_actions #=> Array
resp.listeners[0].default_actions[0].type #=> String, one of "forward"
resp.listeners[0].default_actions[0].target_group_arn #=> String
resp.next_marker #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :load_balancer_arn (String)

    The Amazon Resource Name (ARN) of the load balancer.

  • :listener_arns (Array<String>)

    The Amazon Resource Names (ARN) of the listeners.

  • :marker (String)

    The marker for the next set of results. (You received this marker from a previous call.)

  • :page_size (Integer)

    The maximum number of results to return with this call.

Returns:

See Also:



1197
1198
1199
1200
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 1197

def describe_listeners(params = {}, options = {})
  req = build_request(:describe_listeners, params)
  req.send_request(options)
end

#describe_load_balancer_attributes(params = {}) ⇒ Types::DescribeLoadBalancerAttributesOutput

Describes the attributes for the specified Application Load Balancer.

Examples:

Example: To describe load balancer attributes


# This example describes the attributes of the specified load balancer.

resp = client.describe_load_balancer_attributes({
  load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
})

resp.to_h outputs the following:
{
  attributes: [
    {
      key: "access_logs.s3.enabled", 
      value: "false", 
    }, 
    {
      key: "idle_timeout.timeout_seconds", 
      value: "60", 
    }, 
    {
      key: "access_logs.s3.prefix", 
      value: "", 
    }, 
    {
      key: "deletion_protection.enabled", 
      value: "false", 
    }, 
    {
      key: "access_logs.s3.bucket", 
      value: "", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.describe_load_balancer_attributes({
  load_balancer_arn: "LoadBalancerArn", # required
})

Response structure


resp.attributes #=> Array
resp.attributes[0].key #=> String
resp.attributes[0].value #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :load_balancer_arn (required, String)

    The Amazon Resource Name (ARN) of the load balancer.

Returns:

See Also:



1262
1263
1264
1265
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 1262

def describe_load_balancer_attributes(params = {}, options = {})
  req = build_request(:describe_load_balancer_attributes, params)
  req.send_request(options)
end

#describe_load_balancers(params = {}) ⇒ Types::DescribeLoadBalancersOutput

Describes the specified Application Load Balancers or all of your Application Load Balancers.

To describe the listeners for a load balancer, use DescribeListeners. To describe the attributes for a load balancer, use DescribeLoadBalancerAttributes.

Examples:

Example: To describe a load balancer


# This example describes the specified load balancer.

resp = client.describe_load_balancers({
  load_balancer_arns: [
    "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
  ], 
})

resp.to_h outputs the following:
{
  load_balancers: [
    {
      availability_zones: [
        {
          subnet_id: "subnet-8360a9e7", 
          zone_name: "us-west-2a", 
        }, 
        {
          subnet_id: "subnet-b7d581c0", 
          zone_name: "us-west-2b", 
        }, 
      ], 
      canonical_hosted_zone_id: "Z2P70J7EXAMPLE", 
      created_time: Time.parse("2016-03-25T21:26:12.920Z"), 
      dns_name: "my-load-balancer-424835706.us-west-2.elb.amazonaws.com", 
      load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
      load_balancer_name: "my-load-balancer", 
      scheme: "internet-facing", 
      security_groups: [
        "sg-5943793c", 
      ], 
      state: {
        code: "active", 
      }, 
      type: "application", 
      vpc_id: "vpc-3ac0fb5f", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.describe_load_balancers({
  load_balancer_arns: ["LoadBalancerArn"],
  names: ["LoadBalancerName"],
  marker: "Marker",
  page_size: 1,
})

Response structure


resp.load_balancers #=> Array
resp.load_balancers[0].load_balancer_arn #=> String
resp.load_balancers[0].dns_name #=> String
resp.load_balancers[0].canonical_hosted_zone_id #=> String
resp.load_balancers[0].created_time #=> Time
resp.load_balancers[0].load_balancer_name #=> String
resp.load_balancers[0].scheme #=> String, one of "internet-facing", "internal"
resp.load_balancers[0].vpc_id #=> String
resp.load_balancers[0].state.code #=> String, one of "active", "provisioning", "failed"
resp.load_balancers[0].state.reason #=> String
resp.load_balancers[0].type #=> String, one of "application"
resp.load_balancers[0].availability_zones #=> Array
resp.load_balancers[0].availability_zones[0].zone_name #=> String
resp.load_balancers[0].availability_zones[0].subnet_id #=> String
resp.load_balancers[0].security_groups #=> Array
resp.load_balancers[0].security_groups[0] #=> String
resp.load_balancers[0].ip_address_type #=> String, one of "ipv4", "dualstack"
resp.next_marker #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :load_balancer_arns (Array<String>)

    The Amazon Resource Names (ARN) of the load balancers. You can specify up to 20 load balancers in a single call.

  • :names (Array<String>)

    The names of the load balancers.

  • :marker (String)

    The marker for the next set of results. (You received this marker from a previous call.)

  • :page_size (Integer)

    The maximum number of results to return with this call.

Returns:

See Also:



1370
1371
1372
1373
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 1370

def describe_load_balancers(params = {}, options = {})
  req = build_request(:describe_load_balancers, params)
  req.send_request(options)
end

#describe_rules(params = {}) ⇒ Types::DescribeRulesOutput

Describes the specified rules or the rules for the specified listener. You must specify either a listener or one or more rules.

Examples:

Example: To describe a rule


# This example describes the specified rule.

resp = client.describe_rules({
  rule_arns: [
    "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee", 
  ], 
})

resp.to_h outputs the following:
{
  rules: [
    {
      actions: [
        {
          target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
          type: "forward", 
        }, 
      ], 
      conditions: [
        {
          field: "path-pattern", 
          values: [
            "/img/*", 
          ], 
        }, 
      ], 
      is_default: false, 
      priority: "10", 
      rule_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.describe_rules({
  listener_arn: "ListenerArn",
  rule_arns: ["RuleArn"],
  marker: "Marker",
  page_size: 1,
})

Response structure


resp.rules #=> Array
resp.rules[0].rule_arn #=> String
resp.rules[0].priority #=> String
resp.rules[0].conditions #=> Array
resp.rules[0].conditions[0].field #=> String
resp.rules[0].conditions[0].values #=> Array
resp.rules[0].conditions[0].values[0] #=> String
resp.rules[0].actions #=> Array
resp.rules[0].actions[0].type #=> String, one of "forward"
resp.rules[0].actions[0].target_group_arn #=> String
resp.rules[0].is_default #=> Boolean
resp.next_marker #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :listener_arn (String)

    The Amazon Resource Name (ARN) of the listener.

  • :rule_arns (Array<String>)

    The Amazon Resource Names (ARN) of the rules.

  • :marker (String)

    The marker for the next set of results. (You received this marker from a previous call.)

  • :page_size (Integer)

    The maximum number of results to return with this call.

Returns:

See Also:



1460
1461
1462
1463
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 1460

def describe_rules(params = {}, options = {})
  req = build_request(:describe_rules, params)
  req.send_request(options)
end

#describe_ssl_policies(params = {}) ⇒ Types::DescribeSSLPoliciesOutput

Describes the specified policies or all policies used for SSL negotiation.

For more information, see Security Policies in the Application Load Balancers Guide.

Examples:

Example: To describe a policy used for SSL negotiation


# This example describes the specified policy used for SSL negotiation.

resp = client.describe_ssl_policies({
  names: [
    "ELBSecurityPolicy-2015-05", 
  ], 
})

resp.to_h outputs the following:
{
  ssl_policies: [
    {
      ciphers: [
        {
          name: "ECDHE-ECDSA-AES128-GCM-SHA256", 
          priority: 1, 
        }, 
        {
          name: "ECDHE-RSA-AES128-GCM-SHA256", 
          priority: 2, 
        }, 
        {
          name: "ECDHE-ECDSA-AES128-SHA256", 
          priority: 3, 
        }, 
        {
          name: "ECDHE-RSA-AES128-SHA256", 
          priority: 4, 
        }, 
        {
          name: "ECDHE-ECDSA-AES128-SHA", 
          priority: 5, 
        }, 
        {
          name: "ECDHE-RSA-AES128-SHA", 
          priority: 6, 
        }, 
        {
          name: "DHE-RSA-AES128-SHA", 
          priority: 7, 
        }, 
        {
          name: "ECDHE-ECDSA-AES256-GCM-SHA384", 
          priority: 8, 
        }, 
        {
          name: "ECDHE-RSA-AES256-GCM-SHA384", 
          priority: 9, 
        }, 
        {
          name: "ECDHE-ECDSA-AES256-SHA384", 
          priority: 10, 
        }, 
        {
          name: "ECDHE-RSA-AES256-SHA384", 
          priority: 11, 
        }, 
        {
          name: "ECDHE-RSA-AES256-SHA", 
          priority: 12, 
        }, 
        {
          name: "ECDHE-ECDSA-AES256-SHA", 
          priority: 13, 
        }, 
        {
          name: "AES128-GCM-SHA256", 
          priority: 14, 
        }, 
        {
          name: "AES128-SHA256", 
          priority: 15, 
        }, 
        {
          name: "AES128-SHA", 
          priority: 16, 
        }, 
        {
          name: "AES256-GCM-SHA384", 
          priority: 17, 
        }, 
        {
          name: "AES256-SHA256", 
          priority: 18, 
        }, 
        {
          name: "AES256-SHA", 
          priority: 19, 
        }, 
      ], 
      name: "ELBSecurityPolicy-2015-05", 
      ssl_protocols: [
        "TLSv1", 
        "TLSv1.1", 
        "TLSv1.2", 
      ], 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.describe_ssl_policies({
  names: ["SslPolicyName"],
  marker: "Marker",
  page_size: 1,
})

Response structure


resp.ssl_policies #=> Array
resp.ssl_policies[0].ssl_protocols #=> Array
resp.ssl_policies[0].ssl_protocols[0] #=> String
resp.ssl_policies[0].ciphers #=> Array
resp.ssl_policies[0].ciphers[0].name #=> String
resp.ssl_policies[0].ciphers[0].priority #=> Integer
resp.ssl_policies[0].name #=> String
resp.next_marker #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :names (Array<String>)

    The names of the policies.

  • :marker (String)

    The marker for the next set of results. (You received this marker from a previous call.)

  • :page_size (Integer)

    The maximum number of results to return with this call.

Returns:

See Also:



1616
1617
1618
1619
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 1616

def describe_ssl_policies(params = {}, options = {})
  req = build_request(:describe_ssl_policies, params)
  req.send_request(options)
end

#describe_tags(params = {}) ⇒ Types::DescribeTagsOutput

Describes the tags for the specified resources. You can describe the tags for one or more Application Load Balancers and target groups.

Examples:

Example: To describe the tags assigned to a load balancer


# This example describes the tags assigned to the specified load balancer.

resp = client.describe_tags({
  resource_arns: [
    "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
  ], 
})

resp.to_h outputs the following:
{
  tag_descriptions: [
    {
      resource_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
      tags: [
        {
          key: "project", 
          value: "lima", 
        }, 
        {
          key: "department", 
          value: "digital-media", 
        }, 
      ], 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.describe_tags({
  resource_arns: ["ResourceArn"], # required
})

Response structure


resp.tag_descriptions #=> Array
resp.tag_descriptions[0].resource_arn #=> String
resp.tag_descriptions[0].tags #=> Array
resp.tag_descriptions[0].tags[0].key #=> String
resp.tag_descriptions[0].tags[0].value #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :resource_arns (required, Array<String>)

    The Amazon Resource Names (ARN) of the resources.

Returns:

See Also:



1679
1680
1681
1682
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 1679

def describe_tags(params = {}, options = {})
  req = build_request(:describe_tags, params)
  req.send_request(options)
end

#describe_target_group_attributes(params = {}) ⇒ Types::DescribeTargetGroupAttributesOutput

Describes the attributes for the specified target group.

Examples:

Example: To describe target group attributes


# This example describes the attributes of the specified target group.

resp = client.describe_target_group_attributes({
  target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
})

resp.to_h outputs the following:
{
  attributes: [
    {
      key: "stickiness.enabled", 
      value: "false", 
    }, 
    {
      key: "deregistration_delay.timeout_seconds", 
      value: "300", 
    }, 
    {
      key: "stickiness.type", 
      value: "lb_cookie", 
    }, 
    {
      key: "stickiness.lb_cookie.duration_seconds", 
      value: "86400", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.describe_target_group_attributes({
  target_group_arn: "TargetGroupArn", # required
})

Response structure


resp.attributes #=> Array
resp.attributes[0].key #=> String
resp.attributes[0].value #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :target_group_arn (required, String)

    The Amazon Resource Name (ARN) of the target group.

Returns:

See Also:



1740
1741
1742
1743
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 1740

def describe_target_group_attributes(params = {}, options = {})
  req = build_request(:describe_target_group_attributes, params)
  req.send_request(options)
end

#describe_target_groups(params = {}) ⇒ Types::DescribeTargetGroupsOutput

Describes the specified target groups or all of your target groups. By default, all target groups are described. Alternatively, you can specify one of the following to filter the results: the ARN of the load balancer, the names of one or more target groups, or the ARNs of one or more target groups.

To describe the targets for a target group, use DescribeTargetHealth. To describe the attributes of a target group, use DescribeTargetGroupAttributes.

Examples:

Example: To describe a target group


# This example describes the specified target group.

resp = client.describe_target_groups({
  target_group_arns: [
    "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
  ], 
})

resp.to_h outputs the following:
{
  target_groups: [
    {
      health_check_interval_seconds: 30, 
      health_check_path: "/", 
      health_check_port: "traffic-port", 
      health_check_protocol: "HTTP", 
      health_check_timeout_seconds: 5, 
      healthy_threshold_count: 5, 
      load_balancer_arns: [
        "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
      ], 
      matcher: {
        http_code: "200", 
      }, 
      port: 80, 
      protocol: "HTTP", 
      target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
      target_group_name: "my-targets", 
      unhealthy_threshold_count: 2, 
      vpc_id: "vpc-3ac0fb5f", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.describe_target_groups({
  load_balancer_arn: "LoadBalancerArn",
  target_group_arns: ["TargetGroupArn"],
  names: ["TargetGroupName"],
  marker: "Marker",
  page_size: 1,
})

Response structure


resp.target_groups #=> Array
resp.target_groups[0].target_group_arn #=> String
resp.target_groups[0].target_group_name #=> String
resp.target_groups[0].protocol #=> String, one of "HTTP", "HTTPS"
resp.target_groups[0].port #=> Integer
resp.target_groups[0].vpc_id #=> String
resp.target_groups[0].health_check_protocol #=> String, one of "HTTP", "HTTPS"
resp.target_groups[0].health_check_port #=> String
resp.target_groups[0].health_check_interval_seconds #=> Integer
resp.target_groups[0].health_check_timeout_seconds #=> Integer
resp.target_groups[0].healthy_threshold_count #=> Integer
resp.target_groups[0].unhealthy_threshold_count #=> Integer
resp.target_groups[0].health_check_path #=> String
resp.target_groups[0].matcher.http_code #=> String
resp.target_groups[0].load_balancer_arns #=> Array
resp.target_groups[0].load_balancer_arns[0] #=> String
resp.next_marker #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :load_balancer_arn (String)

    The Amazon Resource Name (ARN) of the load balancer.

  • :target_group_arns (Array<String>)

    The Amazon Resource Names (ARN) of the target groups.

  • :names (Array<String>)

    The names of the target groups.

  • :marker (String)

    The marker for the next set of results. (You received this marker from a previous call.)

  • :page_size (Integer)

    The maximum number of results to return with this call.

Returns:

See Also:



1847
1848
1849
1850
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 1847

def describe_target_groups(params = {}, options = {})
  req = build_request(:describe_target_groups, params)
  req.send_request(options)
end

#describe_target_health(params = {}) ⇒ Types::DescribeTargetHealthOutput

Describes the health of the specified targets or all of your targets.

Examples:

Example: To describe the health of the targets for a target group


# This example describes the health of the targets for the specified target group. One target is healthy but the other is not specified in an action, so it can't receive traffic from the load balancer.

resp = client.describe_target_health({
  target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
})

resp.to_h outputs the following:
{
  target_health_descriptions: [
    {
      target: {
        id: "i-0f76fade", 
        port: 80, 
      }, 
      target_health: {
        description: "Given target group is not configured to receive traffic from ELB", 
        reason: "Target.NotInUse", 
        state: "unused", 
      }, 
    }, 
    {
      health_check_port: "80", 
      target: {
        id: "i-0f76fade", 
        port: 80, 
      }, 
      target_health: {
        state: "healthy", 
      }, 
    }, 
  ], 
}

Example: To describe the health of a target


# This example describes the health of the specified target. This target is healthy.

resp = client.describe_target_health({
  target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
  targets: [
    {
      id: "i-0f76fade", 
      port: 80, 
    }, 
  ], 
})

resp.to_h outputs the following:
{
  target_health_descriptions: [
    {
      health_check_port: "80", 
      target: {
        id: "i-0f76fade", 
        port: 80, 
      }, 
      target_health: {
        state: "healthy", 
      }, 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.describe_target_health({
  target_group_arn: "TargetGroupArn", # required
  targets: [
    {
      id: "TargetId", # required
      port: 1,
    },
  ],
})

Response structure


resp.target_health_descriptions #=> Array
resp.target_health_descriptions[0].target.id #=> String
resp.target_health_descriptions[0].target.port #=> Integer
resp.target_health_descriptions[0].health_check_port #=> String
resp.target_health_descriptions[0].target_health.state #=> String, one of "initial", "healthy", "unhealthy", "unused", "draining"
resp.target_health_descriptions[0].target_health.reason #=> String, one of "Elb.RegistrationInProgress", "Elb.InitialHealthChecking", "Target.ResponseCodeMismatch", "Target.Timeout", "Target.FailedHealthChecks", "Target.NotRegistered", "Target.NotInUse", "Target.DeregistrationInProgress", "Target.InvalidState", "Elb.InternalError"
resp.target_health_descriptions[0].target_health.description #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :target_group_arn (required, String)

    The Amazon Resource Name (ARN) of the target group.

  • :targets (Array<Types::TargetDescription>)

    The targets.

Returns:

See Also:



1956
1957
1958
1959
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 1956

def describe_target_health(params = {}, options = {})
  req = build_request(:describe_target_health, params)
  req.send_request(options)
end

#modify_listener(params = {}) ⇒ Types::ModifyListenerOutput

Modifies the specified properties of the specified listener.

Any properties that you do not specify retain their current values. However, changing the protocol from HTTPS to HTTP removes the security policy and SSL certificate properties. If you change the protocol from HTTP to HTTPS, you must add the security policy and server certificate.

Examples:

Example: To change the default action for a listener


# This example changes the default action for the specified listener.

resp = client.modify_listener({
  default_actions: [
    {
      target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-targets/2453ed029918f21f", 
      type: "forward", 
    }, 
  ], 
  listener_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2", 
})

resp.to_h outputs the following:
{
  listeners: [
    {
      default_actions: [
        {
          target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-targets/2453ed029918f21f", 
          type: "forward", 
        }, 
      ], 
      listener_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2", 
      load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
      port: 80, 
      protocol: "HTTP", 
    }, 
  ], 
}

Example: To change the server certificate


# This example changes the server certificate for the specified HTTPS listener.

resp = client.modify_listener({
  certificates: [
    {
      certificate_arn: "arn:aws:iam::123456789012:server-certificate/my-new-server-cert", 
    }, 
  ], 
  listener_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/0467ef3c8400ae65", 
})

resp.to_h outputs the following:
{
  listeners: [
    {
      certificates: [
        {
          certificate_arn: "arn:aws:iam::123456789012:server-certificate/my-new-server-cert", 
        }, 
      ], 
      default_actions: [
        {
          target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
          type: "forward", 
        }, 
      ], 
      listener_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/0467ef3c8400ae65", 
      load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
      port: 443, 
      protocol: "HTTPS", 
      ssl_policy: "ELBSecurityPolicy-2015-05", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.modify_listener({
  listener_arn: "ListenerArn", # required
  port: 1,
  protocol: "HTTP", # accepts HTTP, HTTPS
  ssl_policy: "SslPolicyName",
  certificates: [
    {
      certificate_arn: "CertificateArn",
    },
  ],
  default_actions: [
    {
      type: "forward", # required, accepts forward
      target_group_arn: "TargetGroupArn", # required
    },
  ],
})

Response structure


resp.listeners #=> Array
resp.listeners[0].listener_arn #=> String
resp.listeners[0].load_balancer_arn #=> String
resp.listeners[0].port #=> Integer
resp.listeners[0].protocol #=> String, one of "HTTP", "HTTPS"
resp.listeners[0].certificates #=> Array
resp.listeners[0].certificates[0].certificate_arn #=> String
resp.listeners[0].ssl_policy #=> String
resp.listeners[0].default_actions #=> Array
resp.listeners[0].default_actions[0].type #=> String, one of "forward"
resp.listeners[0].default_actions[0].target_group_arn #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :listener_arn (required, String)

    The Amazon Resource Name (ARN) of the listener.

  • :port (Integer)

    The port for connections from clients to the load balancer.

  • :protocol (String)

    The protocol for connections from clients to the load balancer.

  • :ssl_policy (String)

    The security policy that defines which protocols and ciphers are supported. For more information, see Security Policies in the Application Load Balancers Guide.

  • :certificates (Array<Types::Certificate>)

    The SSL server certificate.

  • :default_actions (Array<Types::Action>)

    The default actions.

Returns:

See Also:



2105
2106
2107
2108
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 2105

def modify_listener(params = {}, options = {})
  req = build_request(:modify_listener, params)
  req.send_request(options)
end

#modify_load_balancer_attributes(params = {}) ⇒ Types::ModifyLoadBalancerAttributesOutput

Modifies the specified attributes of the specified Application Load Balancer.

If any of the specified attributes can't be modified as requested, the call fails. Any existing attributes that you do not modify retain their current values.

Examples:

Example: To enable deletion protection


# This example enables deletion protection for the specified load balancer.

resp = client.modify_load_balancer_attributes({
  attributes: [
    {
      key: "deletion_protection.enabled", 
      value: "true", 
    }, 
  ], 
  load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
})

resp.to_h outputs the following:
{
  attributes: [
    {
      key: "deletion_protection.enabled", 
      value: "true", 
    }, 
    {
      key: "access_logs.s3.enabled", 
      value: "false", 
    }, 
    {
      key: "idle_timeout.timeout_seconds", 
      value: "60", 
    }, 
    {
      key: "access_logs.s3.prefix", 
      value: "", 
    }, 
    {
      key: "access_logs.s3.bucket", 
      value: "", 
    }, 
  ], 
}

Example: To change the idle timeout


# This example changes the idle timeout value for the specified load balancer.

resp = client.modify_load_balancer_attributes({
  attributes: [
    {
      key: "idle_timeout.timeout_seconds", 
      value: "30", 
    }, 
  ], 
  load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
})

resp.to_h outputs the following:
{
  attributes: [
    {
      key: "idle_timeout.timeout_seconds", 
      value: "30", 
    }, 
    {
      key: "access_logs.s3.enabled", 
      value: "false", 
    }, 
    {
      key: "access_logs.s3.prefix", 
      value: "", 
    }, 
    {
      key: "deletion_protection.enabled", 
      value: "true", 
    }, 
    {
      key: "access_logs.s3.bucket", 
      value: "", 
    }, 
  ], 
}

Example: To enable access logs


# This example enables access logs for the specified load balancer. Note that the S3 bucket must exist in the same region as the load balancer and must have a policy attached that grants access to the Elastic Load Balancing service.

resp = client.modify_load_balancer_attributes({
  attributes: [
    {
      key: "access_logs.s3.enabled", 
      value: "true", 
    }, 
    {
      key: "access_logs.s3.bucket", 
      value: "my-loadbalancer-logs", 
    }, 
    {
      key: "access_logs.s3.prefix", 
      value: "myapp", 
    }, 
  ], 
  load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
})

resp.to_h outputs the following:
{
  attributes: [
    {
      key: "access_logs.s3.enabled", 
      value: "true", 
    }, 
    {
      key: "access_logs.s3.bucket", 
      value: "my-load-balancer-logs", 
    }, 
    {
      key: "access_logs.s3.prefix", 
      value: "myapp", 
    }, 
    {
      key: "idle_timeout.timeout_seconds", 
      value: "60", 
    }, 
    {
      key: "deletion_protection.enabled", 
      value: "false", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.modify_load_balancer_attributes({
  load_balancer_arn: "LoadBalancerArn", # required
  attributes: [ # required
    {
      key: "LoadBalancerAttributeKey",
      value: "LoadBalancerAttributeValue",
    },
  ],
})

Response structure


resp.attributes #=> Array
resp.attributes[0].key #=> String
resp.attributes[0].value #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :load_balancer_arn (required, String)

    The Amazon Resource Name (ARN) of the load balancer.

  • :attributes (required, Array<Types::LoadBalancerAttribute>)

    The load balancer attributes.

Returns:

See Also:



2278
2279
2280
2281
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 2278

def modify_load_balancer_attributes(params = {}, options = {})
  req = build_request(:modify_load_balancer_attributes, params)
  req.send_request(options)
end

#modify_rule(params = {}) ⇒ Types::ModifyRuleOutput

Modifies the specified rule.

Any existing properties that you do not modify retain their current values.

To modify the default action, use ModifyListener.

Examples:

Example: To modify a rule


# This example modifies the condition for the specified rule.

resp = client.modify_rule({
  conditions: [
    {
      field: "path-pattern", 
      values: [
        "/images/*", 
      ], 
    }, 
  ], 
  rule_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee", 
})

resp.to_h outputs the following:
{
  rules: [
    {
      actions: [
        {
          target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
          type: "forward", 
        }, 
      ], 
      conditions: [
        {
          field: "path-pattern", 
          values: [
            "/images/*", 
          ], 
        }, 
      ], 
      is_default: false, 
      priority: "10", 
      rule_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.modify_rule({
  rule_arn: "RuleArn", # required
  conditions: [
    {
      field: "ConditionFieldName",
      values: ["StringValue"],
    },
  ],
  actions: [
    {
      type: "forward", # required, accepts forward
      target_group_arn: "TargetGroupArn", # required
    },
  ],
})

Response structure


resp.rules #=> Array
resp.rules[0].rule_arn #=> String
resp.rules[0].priority #=> String
resp.rules[0].conditions #=> Array
resp.rules[0].conditions[0].field #=> String
resp.rules[0].conditions[0].values #=> Array
resp.rules[0].conditions[0].values[0] #=> String
resp.rules[0].actions #=> Array
resp.rules[0].actions[0].type #=> String, one of "forward"
resp.rules[0].actions[0].target_group_arn #=> String
resp.rules[0].is_default #=> Boolean

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :rule_arn (required, String)

    The Amazon Resource Name (ARN) of the rule.

  • :conditions (Array<Types::RuleCondition>)

    The conditions.

  • :actions (Array<Types::Action>)

    The actions.

Returns:

See Also:



2381
2382
2383
2384
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 2381

def modify_rule(params = {}, options = {})
  req = build_request(:modify_rule, params)
  req.send_request(options)
end

#modify_target_group(params = {}) ⇒ Types::ModifyTargetGroupOutput

Modifies the health checks used when evaluating the health state of the targets in the specified target group.

To monitor the health of the targets, use DescribeTargetHealth.

Examples:

Example: To modify the health check configuration for a target group


# This example changes the configuration of the health checks used to evaluate the health of the targets for the specified target group.

resp = client.modify_target_group({
  health_check_port: "443", 
  health_check_protocol: "HTTPS", 
  target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-https-targets/2453ed029918f21f", 
})

resp.to_h outputs the following:
{
  target_groups: [
    {
      health_check_interval_seconds: 30, 
      health_check_port: "443", 
      health_check_protocol: "HTTPS", 
      health_check_timeout_seconds: 5, 
      healthy_threshold_count: 5, 
      load_balancer_arns: [
        "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
      ], 
      matcher: {
        http_code: "200", 
      }, 
      port: 443, 
      protocol: "HTTPS", 
      target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-https-targets/2453ed029918f21f", 
      target_group_name: "my-https-targets", 
      unhealthy_threshold_count: 2, 
      vpc_id: "vpc-3ac0fb5f", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.modify_target_group({
  target_group_arn: "TargetGroupArn", # required
  health_check_protocol: "HTTP", # accepts HTTP, HTTPS
  health_check_port: "HealthCheckPort",
  health_check_path: "Path",
  health_check_interval_seconds: 1,
  health_check_timeout_seconds: 1,
  healthy_threshold_count: 1,
  unhealthy_threshold_count: 1,
  matcher: {
    http_code: "HttpCode", # required
  },
})

Response structure


resp.target_groups #=> Array
resp.target_groups[0].target_group_arn #=> String
resp.target_groups[0].target_group_name #=> String
resp.target_groups[0].protocol #=> String, one of "HTTP", "HTTPS"
resp.target_groups[0].port #=> Integer
resp.target_groups[0].vpc_id #=> String
resp.target_groups[0].health_check_protocol #=> String, one of "HTTP", "HTTPS"
resp.target_groups[0].health_check_port #=> String
resp.target_groups[0].health_check_interval_seconds #=> Integer
resp.target_groups[0].health_check_timeout_seconds #=> Integer
resp.target_groups[0].healthy_threshold_count #=> Integer
resp.target_groups[0].unhealthy_threshold_count #=> Integer
resp.target_groups[0].health_check_path #=> String
resp.target_groups[0].matcher.http_code #=> String
resp.target_groups[0].load_balancer_arns #=> Array
resp.target_groups[0].load_balancer_arns[0] #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :target_group_arn (required, String)

    The Amazon Resource Name (ARN) of the target group.

  • :health_check_protocol (String)

    The protocol to use to connect with the target.

  • :health_check_port (String)

    The port to use to connect with the target.

  • :health_check_path (String)

    The ping path that is the destination for the health check request.

  • :health_check_interval_seconds (Integer)

    The approximate amount of time, in seconds, between health checks of an individual target.

  • :health_check_timeout_seconds (Integer)

    The amount of time, in seconds, during which no response means a failed health check.

  • :healthy_threshold_count (Integer)

    The number of consecutive health checks successes required before considering an unhealthy target healthy.

  • :unhealthy_threshold_count (Integer)

    The number of consecutive health check failures required before considering the target unhealthy.

  • :matcher (Types::Matcher)

    The HTTP codes to use when checking for a successful response from a target.

Returns:

See Also:



2502
2503
2504
2505
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 2502

def modify_target_group(params = {}, options = {})
  req = build_request(:modify_target_group, params)
  req.send_request(options)
end

#modify_target_group_attributes(params = {}) ⇒ Types::ModifyTargetGroupAttributesOutput

Modifies the specified attributes of the specified target group.

Examples:

Example: To modify the deregistration delay timeout


# This example sets the deregistration delay timeout to the specified value for the specified target group.

resp = client.modify_target_group_attributes({
  attributes: [
    {
      key: "deregistration_delay.timeout_seconds", 
      value: "600", 
    }, 
  ], 
  target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
})

resp.to_h outputs the following:
{
  attributes: [
    {
      key: "stickiness.enabled", 
      value: "false", 
    }, 
    {
      key: "deregistration_delay.timeout_seconds", 
      value: "600", 
    }, 
    {
      key: "stickiness.type", 
      value: "lb_cookie", 
    }, 
    {
      key: "stickiness.lb_cookie.duration_seconds", 
      value: "86400", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.modify_target_group_attributes({
  target_group_arn: "TargetGroupArn", # required
  attributes: [ # required
    {
      key: "TargetGroupAttributeKey",
      value: "TargetGroupAttributeValue",
    },
  ],
})

Response structure


resp.attributes #=> Array
resp.attributes[0].key #=> String
resp.attributes[0].value #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :target_group_arn (required, String)

    The Amazon Resource Name (ARN) of the target group.

  • :attributes (required, Array<Types::TargetGroupAttribute>)

    The attributes.

Returns:

See Also:



2578
2579
2580
2581
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 2578

def modify_target_group_attributes(params = {}, options = {})
  req = build_request(:modify_target_group_attributes, params)
  req.send_request(options)
end

#register_targets(params = {}) ⇒ Struct

Registers the specified targets with the specified target group.

By default, the load balancer routes requests to registered targets using the protocol and port number for the target group. Alternatively, you can override the port for a target when you register it.

The target must be in the virtual private cloud (VPC) that you specified for the target group. If the target is an EC2 instance, it must be in the running state when you register it.

To remove a target from a target group, use DeregisterTargets.

Examples:

Example: To register targets with a target group


# This example registers the specified instances with the specified target group.

resp = client.register_targets({
  target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
  targets: [
    {
      id: "i-80c8dd94", 
    }, 
    {
      id: "i-ceddcd4d", 
    }, 
  ], 
})

Example: To register targets with a target group using port overrides


# This example registers the specified instance with the specified target group using multiple ports. This enables you to register ECS containers on the same instance as targets in the target group.

resp = client.register_targets({
  target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-targets/3bb63f11dfb0faf9", 
  targets: [
    {
      id: "i-80c8dd94", 
      port: 80, 
    }, 
    {
      id: "i-80c8dd94", 
      port: 766, 
    }, 
  ], 
})

Request syntax with placeholder values


resp = client.register_targets({
  target_group_arn: "TargetGroupArn", # required
  targets: [ # required
    {
      id: "TargetId", # required
      port: 1,
    },
  ],
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :target_group_arn (required, String)

    The Amazon Resource Name (ARN) of the target group.

  • :targets (required, Array<Types::TargetDescription>)

    The targets. The default port for a target is the port for the target group. You can specify a port override. If a target is already registered, you can register it again using a different port.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



2657
2658
2659
2660
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 2657

def register_targets(params = {}, options = {})
  req = build_request(:register_targets, params)
  req.send_request(options)
end

#remove_tags(params = {}) ⇒ Struct

Removes the specified tags from the specified resource.

To list the current tags for your resources, use DescribeTags.

Examples:

Example: To remove tags from a load balancer


# This example removes the specified tags from the specified load balancer.

resp = client.remove_tags({
  resource_arns: [
    "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
  ], 
  tag_keys: [
    "project", 
    "department", 
  ], 
})

Request syntax with placeholder values


resp = client.remove_tags({
  resource_arns: ["ResourceArn"], # required
  tag_keys: ["TagKey"], # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :resource_arns (required, Array<String>)

    The Amazon Resource Name (ARN) of the resource.

  • :tag_keys (required, Array<String>)

    The tag keys for the tags to remove.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



2700
2701
2702
2703
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 2700

def remove_tags(params = {}, options = {})
  req = build_request(:remove_tags, params)
  req.send_request(options)
end

#set_ip_address_type(params = {}) ⇒ Types::SetIpAddressTypeOutput

Sets the type of IP addresses used by the subnets of the specified Application Load Balancer.

Examples:

Request syntax with placeholder values


resp = client.set_ip_address_type({
  load_balancer_arn: "LoadBalancerArn", # required
  ip_address_type: "ipv4", # required, accepts ipv4, dualstack
})

Response structure


resp.ip_address_type #=> String, one of "ipv4", "dualstack"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :load_balancer_arn (required, String)

    The Amazon Resource Name (ARN) of the load balancer.

  • :ip_address_type (required, String)

    The IP address type. The possible values are ipv4 (for IPv4 addresses) and dualstack (for IPv4 and IPv6 addresses). Internal load balancers must use ipv4.

Returns:

See Also:



2735
2736
2737
2738
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 2735

def set_ip_address_type(params = {}, options = {})
  req = build_request(:set_ip_address_type, params)
  req.send_request(options)
end

#set_rule_priorities(params = {}) ⇒ Types::SetRulePrioritiesOutput

Sets the priorities of the specified rules.

You can reorder the rules as long as there are no priority conflicts in the new order. Any existing rules that you do not specify retain their current priority.

Examples:

Example: To set the rule priority


# This example sets the priority of the specified rule.

resp = client.set_rule_priorities({
  rule_priorities: [
    {
      priority: 5, 
      rule_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/1291d13826f405c3", 
    }, 
  ], 
})

resp.to_h outputs the following:
{
  rules: [
    {
      actions: [
        {
          target_group_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", 
          type: "forward", 
        }, 
      ], 
      conditions: [
        {
          field: "path-pattern", 
          values: [
            "/img/*", 
          ], 
        }, 
      ], 
      is_default: false, 
      priority: "5", 
      rule_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/1291d13826f405c3", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.set_rule_priorities({
  rule_priorities: [ # required
    {
      rule_arn: "RuleArn",
      priority: 1,
    },
  ],
})

Response structure


resp.rules #=> Array
resp.rules[0].rule_arn #=> String
resp.rules[0].priority #=> String
resp.rules[0].conditions #=> Array
resp.rules[0].conditions[0].field #=> String
resp.rules[0].conditions[0].values #=> Array
resp.rules[0].conditions[0].values[0] #=> String
resp.rules[0].actions #=> Array
resp.rules[0].actions[0].type #=> String, one of "forward"
resp.rules[0].actions[0].target_group_arn #=> String
resp.rules[0].is_default #=> Boolean

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

Returns:

See Also:



2821
2822
2823
2824
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 2821

def set_rule_priorities(params = {}, options = {})
  req = build_request(:set_rule_priorities, params)
  req.send_request(options)
end

#set_security_groups(params = {}) ⇒ Types::SetSecurityGroupsOutput

Associates the specified security groups with the specified load balancer. The specified security groups override the previously associated security groups.

Examples:

Example: To associate a security group with a load balancer


# This example associates the specified security group with the specified load balancer.

resp = client.set_security_groups({
  load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
  security_groups: [
    "sg-5943793c", 
  ], 
})

resp.to_h outputs the following:
{
  security_group_ids: [
    "sg-5943793c", 
  ], 
}

Request syntax with placeholder values


resp = client.set_security_groups({
  load_balancer_arn: "LoadBalancerArn", # required
  security_groups: ["SecurityGroupId"], # required
})

Response structure


resp.security_group_ids #=> Array
resp.security_group_ids[0] #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :load_balancer_arn (required, String)

    The Amazon Resource Name (ARN) of the load balancer.

  • :security_groups (required, Array<String>)

    The IDs of the security groups.

Returns:

See Also:



2875
2876
2877
2878
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 2875

def set_security_groups(params = {}, options = {})
  req = build_request(:set_security_groups, params)
  req.send_request(options)
end

#set_subnets(params = {}) ⇒ Types::SetSubnetsOutput

Enables the Availability Zone for the specified subnets for the specified load balancer. The specified subnets replace the previously enabled subnets.

Examples:

Example: To enable Availability Zones for a load balancer


# This example enables the Availability Zones for the specified subnets for the specified load balancer.

resp = client.set_subnets({
  load_balancer_arn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", 
  subnets: [
    "subnet-8360a9e7", 
    "subnet-b7d581c0", 
  ], 
})

resp.to_h outputs the following:
{
  availability_zones: [
    {
      subnet_id: "subnet-8360a9e7", 
      zone_name: "us-west-2a", 
    }, 
    {
      subnet_id: "subnet-b7d581c0", 
      zone_name: "us-west-2b", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.set_subnets({
  load_balancer_arn: "LoadBalancerArn", # required
  subnets: ["SubnetId"], # required
})

Response structure


resp.availability_zones #=> Array
resp.availability_zones[0].zone_name #=> String
resp.availability_zones[0].subnet_id #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :load_balancer_arn (required, String)

    The Amazon Resource Name (ARN) of the load balancer.

  • :subnets (required, Array<String>)

    The IDs of the subnets. You must specify at least two subnets. You can add only one subnet per Availability Zone.

Returns:

See Also:



2939
2940
2941
2942
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 2939

def set_subnets(params = {}, options = {})
  req = build_request(:set_subnets, params)
  req.send_request(options)
end

#wait_until(waiter_name, params = {}, options = {}) {|w.waiter| ... } ⇒ Boolean

Polls an API operation until a resource enters a desired state.

Basic Usage

A waiter will call an API operation until:

  • It is successful
  • It enters a terminal state
  • It makes the maximum number of attempts

In between attempts, the waiter will sleep.

# polls in a loop, sleeping between attempts
client.waiter_until(waiter_name, params)

Configuration

You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. You can pass configuration as the final arguments hash.

# poll for ~25 seconds
client.wait_until(waiter_name, params, {
  max_attempts: 5,
  delay: 5,
})

Callbacks

You can be notified before each polling attempt and before each delay. If you throw :success or :failure from these callbacks, it will terminate the waiter.

started_at = Time.now
client.wait_until(waiter_name, params, {

  # disable max attempts
  max_attempts: nil,

  # poll for 1 hour, instead of a number of attempts
  before_wait: -> (attempts, response) do
    throw :failure if Time.now - started_at > 3600
  end
})

Handling Errors

When a waiter is unsuccessful, it will raise an error. All of the failure errors extend from Waiters::Errors::WaiterFailed.

begin
  client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
  # resource did not enter the desired state in time
end

Valid Waiters

The following table lists the valid waiter names, the operations they call, and the default :delay and :max_attempts values.

waiter_name params :delay :max_attempts
load_balancer_available #describe_load_balancers 15 40
load_balancer_exists #describe_load_balancers 15 40
load_balancers_deleted #describe_load_balancers 15 40
target_deregistered #describe_target_health 15 40
target_in_service #describe_target_health 15 40

Parameters:

  • waiter_name (Symbol)
  • params (Hash) (defaults to: {})

    ({})

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :max_attempts (Integer)
  • :delay (Integer)
  • :before_attempt (Proc)
  • :before_wait (Proc)

Yields:

  • (w.waiter)

Returns:

  • (Boolean)

    Returns true if the waiter was successful.

Raises:

  • (Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

  • (Errors::TooManyAttemptsError)

    Raised when the configured maximum number of attempts have been made, and the waiter is not yet successful.

  • (Errors::UnexpectedError)

    Raised when an error is encounted while polling for a resource that is not expected.

  • (Errors::NoSuchWaiterError)

    Raised when you request to wait for an unknown state.



3053
3054
3055
3056
3057
# File 'gems/aws-sdk-elasticloadbalancingv2/lib/aws-sdk-elasticloadbalancingv2/client.rb', line 3053

def wait_until(waiter_name, params = {}, options = {})
  w = waiter(waiter_name, options)
  yield(w.waiter) if block_given? # deprecated
  w.wait(params)
end