You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.
Class: Aws::ElasticLoadBalancingV2::Client
- Inherits:
-
Seahorse::Client::Base
- Object
- Seahorse::Client::Base
- Aws::ElasticLoadBalancingV2::Client
- Defined in:
- (unknown)
Overview
An API client for Elastic Load Balancing. To construct a client, you need to configure a :region
and :credentials
.
elasticloadbalancingv2 = Aws::ElasticLoadBalancingV2::Client.new(
region: region_name,
credentials: credentials,
# ...
)
See #initialize for a full list of supported configuration options.
Region
You can configure a default region in the following locations:
ENV['AWS_REGION']
Aws.config[:region]
Go here for a list of supported regions.
Credentials
Default credentials are loaded automatically from the following locations:
ENV['AWS_ACCESS_KEY_ID']
andENV['AWS_SECRET_ACCESS_KEY']
Aws.config[:credentials]
- The shared credentials ini file at
~/.aws/credentials
(more information) - From an instance profile when running on EC2
You can also construct a credentials object from one of the following classes:
Alternatively, you configure credentials with :access_key_id
and
:secret_access_key
:
# load credentials from disk
creds = YAML.load(File.read('/path/to/secrets'))
Aws::ElasticLoadBalancingV2::Client.new(
access_key_id: creds['access_key_id'],
secret_access_key: creds['secret_access_key']
)
Always load your credentials from outside your application. Avoid configuring credentials statically and never commit them to source control.
Instance Attribute Summary
Attributes inherited from Seahorse::Client::Base
Constructor collapse
-
#initialize(options = {}) ⇒ Aws::ElasticLoadBalancingV2::Client
constructor
Constructs an API client.
API Operations collapse
-
#add_listener_certificates(options = {}) ⇒ Types::AddListenerCertificatesOutput
Adds the specified SSL server certificate to the certificate list for the specified HTTPS or TLS listener.
If the certificate in already in the certificate list, the call is successful but the certificate is not added again.
For more information, see HTTPS listeners in the Application Load Balancers Guide or TLS listeners in the Network Load Balancers Guide.
. -
#add_tags(options = {}) ⇒ Struct
Adds the specified tags to the specified Elastic Load Balancing resource.
-
#create_listener(options = {}) ⇒ Types::CreateListenerOutput
Creates a listener for the specified Application Load Balancer, Network Load Balancer.
-
#create_load_balancer(options = {}) ⇒ Types::CreateLoadBalancerOutput
Creates an Application Load Balancer, Network Load Balancer, or Gateway Load Balancer.
For more information, see the following:
This operation is idempotent, which means that it completes at most one time.
-
#create_rule(options = {}) ⇒ Types::CreateRuleOutput
Creates a rule for the specified listener.
-
#create_target_group(options = {}) ⇒ Types::CreateTargetGroupOutput
Creates a target group.
For more information, see the following:
This operation is idempotent, which means that it completes at most one time.
-
#delete_listener(options = {}) ⇒ Struct
Deletes the specified listener.
Alternatively, your listener is deleted when you delete the load balancer to which it is attached.
. -
#delete_load_balancer(options = {}) ⇒ Struct
Deletes the specified Application Load Balancer, Network Load Balancer, or Gateway Load Balancer.
-
#delete_rule(options = {}) ⇒ Struct
Deletes the specified rule.
You can't delete the default rule.
. -
#delete_target_group(options = {}) ⇒ Struct
Deletes the specified target group.
You can delete a target group if it is not referenced by any actions.
-
#deregister_targets(options = {}) ⇒ Struct
Deregisters the specified targets from the specified target group.
-
#describe_account_limits(options = {}) ⇒ Types::DescribeAccountLimitsOutput
Describes the current Elastic Load Balancing resource limits for your AWS account.
For more information, see the following:
. -
#describe_listener_certificates(options = {}) ⇒ Types::DescribeListenerCertificatesOutput
Describes the default certificate and the certificate list for the specified HTTPS or TLS listener.
If the default certificate is also in the certificate list, it appears twice in the results (once with
IsDefault
set to true and once withIsDefault
set to false).For more information, see SSL certificates in the Application Load Balancers Guide or Server certificates in the Network Load Balancers Guide.
. -
#describe_listeners(options = {}) ⇒ Types::DescribeListenersOutput
Describes the specified listeners or the listeners for the specified Application Load Balancer, Network Load Balancer, or Gateway Load Balancer.
-
#describe_load_balancer_attributes(options = {}) ⇒ Types::DescribeLoadBalancerAttributesOutput
Describes the attributes for the specified Application Load Balancer, Network Load Balancer, or Gateway Load Balancer.
For more information, see the following:
-
Load balancer attributes in the Application Load Balancers Guide
-
Load balancer attributes in the Network Load Balancers Guide
-
Load balancer attributes in the Gateway Load Balancers Guide
-
-
#describe_load_balancers(options = {}) ⇒ Types::DescribeLoadBalancersOutput
Describes the specified load balancers or all of your load balancers.
.
-
#describe_rules(options = {}) ⇒ Types::DescribeRulesOutput
Describes the specified rules or the rules for the specified listener.
-
#describe_ssl_policies(options = {}) ⇒ 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 or Security policies in the Network Load Balancers Guide.
. -
#describe_tags(options = {}) ⇒ Types::DescribeTagsOutput
Describes the tags for the specified Elastic Load Balancing resources.
-
#describe_target_group_attributes(options = {}) ⇒ Types::DescribeTargetGroupAttributesOutput
Describes the attributes for the specified target group.
For more information, see the following:
-
Target group attributes in the Application Load Balancers Guide
-
Target group attributes in the Network Load Balancers Guide
-
Target group attributes in the Gateway Load Balancers Guide
-
-
#describe_target_groups(options = {}) ⇒ Types::DescribeTargetGroupsOutput
Describes the specified target groups or all of your target groups.
-
#describe_target_health(options = {}) ⇒ Types::DescribeTargetHealthOutput
Describes the health of the specified targets or all of your targets.
.
-
#modify_listener(options = {}) ⇒ Types::ModifyListenerOutput
Replaces the specified properties of the specified listener.
-
#modify_load_balancer_attributes(options = {}) ⇒ Types::ModifyLoadBalancerAttributesOutput
Modifies the specified attributes of the specified Application Load Balancer, Network Load Balancer, or Gateway Load Balancer.
If any of the specified attributes can't be modified as requested, the call fails.
-
#modify_rule(options = {}) ⇒ Types::ModifyRuleOutput
Replaces the specified properties of the specified rule.
-
#modify_target_group(options = {}) ⇒ Types::ModifyTargetGroupOutput
Modifies the health checks used when evaluating the health state of the targets in the specified target group.
.
-
#modify_target_group_attributes(options = {}) ⇒ Types::ModifyTargetGroupAttributesOutput
Modifies the specified attributes of the specified target group.
.
-
#register_targets(options = {}) ⇒ Struct
Registers the specified targets with the specified target group.
If the target is an EC2 instance, it must be in the
running
state when you register it.By default, the load balancer routes requests to registered targets using the protocol and port for the target group.
-
#remove_listener_certificates(options = {}) ⇒ Struct
Removes the specified certificate from the certificate list for the specified HTTPS or TLS listener.
.
-
#remove_tags(options = {}) ⇒ Struct
Removes the specified tags from the specified Elastic Load Balancing resources.
-
#set_ip_address_type(options = {}) ⇒ Types::SetIpAddressTypeOutput
Sets the type of IP addresses used by the subnets of the specified Application Load Balancer or Network Load Balancer.
.
-
#set_rule_priorities(options = {}) ⇒ 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.
-
#set_security_groups(options = {}) ⇒ Types::SetSecurityGroupsOutput
Associates the specified security groups with the specified Application Load Balancer.
-
#set_subnets(options = {}) ⇒ Types::SetSubnetsOutput
Enables the Availability Zones for the specified public subnets for the specified Application Load Balancer or Network Load Balancer.
Instance Method Summary collapse
-
#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean
Waiters polls an API operation until a resource enters a desired state.
-
#waiter_names ⇒ Array<Symbol>
Returns the list of supported waiters.
Methods inherited from Seahorse::Client::Base
add_plugin, api, #build_request, clear_plugins, define, new, #operation, #operation_names, plugins, remove_plugin, set_api, set_plugins
Methods included from Seahorse::Client::HandlerBuilder
#handle, #handle_request, #handle_response
Constructor Details
#initialize(options = {}) ⇒ Aws::ElasticLoadBalancingV2::Client
Constructs an API client.
Instance Method Details
#add_listener_certificates(options = {}) ⇒ Types::AddListenerCertificatesOutput
Adds the specified SSL server certificate to the certificate list for the specified HTTPS or TLS listener.
If the certificate in already in the certificate list, the call is successful but the certificate is not added again.
For more information, see HTTPS listeners in the Application Load Balancers Guide or TLS listeners in the Network Load Balancers Guide.
#add_tags(options = {}) ⇒ Struct
Adds the specified tags to the specified Elastic Load Balancing resource. You can tag your Application Load Balancers, Network Load Balancers, Gateway Load Balancers, target groups, listeners, and rules.
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.
#create_listener(options = {}) ⇒ Types::CreateListenerOutput
Creates a listener for the specified Application Load Balancer, Network Load Balancer. or Gateway Load Balancer.
For more information, see the following:
This operation is idempotent, which means that it completes at most one time. If you attempt to create multiple listeners with the same settings, each call succeeds.
#create_load_balancer(options = {}) ⇒ Types::CreateLoadBalancerOutput
Creates an Application Load Balancer, Network Load Balancer, or Gateway Load Balancer.
For more information, see the following:
This operation is idempotent, which means that it completes at most one time. If you attempt to create multiple load balancers with the same settings, each call succeeds.
#create_rule(options = {}) ⇒ Types::CreateRuleOutput
Creates a rule for the specified listener. The listener must be associated with an Application Load Balancer.
Each rule consists of a priority, one or more actions, and one or more conditions. Rules are evaluated in priority order, from the lowest value to the highest value. When the conditions for a rule are met, its actions are performed. If the conditions for no rules are met, the actions for the default rule are performed. For more information, see Listener rules in the Application Load Balancers Guide.
#create_target_group(options = {}) ⇒ Types::CreateTargetGroupOutput
Creates a target group.
For more information, see the following:
This operation is idempotent, which means that it completes at most one time. If you attempt to create multiple target groups with the same settings, each call succeeds.
#delete_listener(options = {}) ⇒ Struct
Deletes the specified listener.
Alternatively, your listener is deleted when you delete the load balancer to which it is attached.
#delete_load_balancer(options = {}) ⇒ Struct
Deletes the specified Application Load Balancer, Network Load Balancer, or Gateway Load Balancer. Deleting a load balancer also deletes its 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.
#delete_rule(options = {}) ⇒ Struct
Deletes the specified rule.
You can't delete the default rule.
#delete_target_group(options = {}) ⇒ 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. Deleting a target group does not affect its registered targets. For example, any EC2 instances continue to run until you stop or terminate them.
#deregister_targets(options = {}) ⇒ Struct
Deregisters the specified targets from the specified target group. After the targets are deregistered, they no longer receive traffic from the load balancer.
#describe_account_limits(options = {}) ⇒ Types::DescribeAccountLimitsOutput
Describes the current Elastic Load Balancing resource limits for your AWS account.
For more information, see the following:
#describe_listener_certificates(options = {}) ⇒ Types::DescribeListenerCertificatesOutput
Describes the default certificate and the certificate list for the specified HTTPS or TLS listener.
If the default certificate is also in the certificate list, it appears twice in the results (once with IsDefault
set to true and once with IsDefault
set to false).
For more information, see SSL certificates in the Application Load Balancers Guide or Server certificates in the Network Load Balancers Guide.
#describe_listeners(options = {}) ⇒ Types::DescribeListenersOutput
Describes the specified listeners or the listeners for the specified Application Load Balancer, Network Load Balancer, or Gateway Load Balancer. You must specify either a load balancer or one or more listeners.
#describe_load_balancer_attributes(options = {}) ⇒ Types::DescribeLoadBalancerAttributesOutput
Describes the attributes for the specified Application Load Balancer, Network Load Balancer, or Gateway Load Balancer.
For more information, see the following:
-
Load balancer attributes in the Application Load Balancers Guide
-
Load balancer attributes in the Network Load Balancers Guide
-
Load balancer attributes in the Gateway Load Balancers Guide
#describe_load_balancers(options = {}) ⇒ Types::DescribeLoadBalancersOutput
Describes the specified load balancers or all of your load balancers.
#describe_rules(options = {}) ⇒ Types::DescribeRulesOutput
Describes the specified rules or the rules for the specified listener. You must specify either a listener or one or more rules.
#describe_ssl_policies(options = {}) ⇒ 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 or Security policies in the Network Load Balancers Guide.
#describe_tags(options = {}) ⇒ Types::DescribeTagsOutput
Describes the tags for the specified Elastic Load Balancing resources. You can describe the tags for one or more Application Load Balancers, Network Load Balancers, Gateway Load Balancers, target groups, listeners, or rules.
#describe_target_group_attributes(options = {}) ⇒ Types::DescribeTargetGroupAttributesOutput
Describes the attributes for the specified target group.
For more information, see the following:
-
Target group attributes in the Application Load Balancers Guide
-
Target group attributes in the Network Load Balancers Guide
-
Target group attributes in the Gateway Load Balancers Guide
#describe_target_groups(options = {}) ⇒ 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.
#describe_target_health(options = {}) ⇒ Types::DescribeTargetHealthOutput
Describes the health of the specified targets or all of your targets.
#modify_listener(options = {}) ⇒ Types::ModifyListenerOutput
Replaces the specified properties of the specified listener. Any properties that you do not specify remain unchanged.
Changing the protocol from HTTPS to HTTP, or from TLS to TCP, removes the security policy and default certificate properties. If you change the protocol from HTTP to HTTPS, or from TCP to TLS, you must add the security policy and default certificate properties.
To add an item to a list, remove an item from a list, or update an item in a list, you must provide the entire list. For example, to add an action, specify a list with the current actions plus the new action.
#modify_load_balancer_attributes(options = {}) ⇒ Types::ModifyLoadBalancerAttributesOutput
Modifies the specified attributes of the specified Application Load Balancer, Network Load Balancer, or Gateway 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.
#modify_rule(options = {}) ⇒ Types::ModifyRuleOutput
Replaces the specified properties of the specified rule. Any properties that you do not specify are unchanged.
To add an item to a list, remove an item from a list, or update an item in a list, you must provide the entire list. For example, to add an action, specify a list with the current actions plus the new action.
#modify_target_group(options = {}) ⇒ Types::ModifyTargetGroupOutput
Modifies the health checks used when evaluating the health state of the targets in the specified target group.
#modify_target_group_attributes(options = {}) ⇒ Types::ModifyTargetGroupAttributesOutput
Modifies the specified attributes of the specified target group.
#register_targets(options = {}) ⇒ Struct
Registers the specified targets with the specified target group.
If the target is an EC2 instance, it must be in the running
state when you register it.
By default, the load balancer routes requests to registered targets using the protocol and port for the target group. Alternatively, you can override the port for a target when you register it. You can register each EC2 instance or IP address with the same target group multiple times using different ports.
With a Network Load Balancer, you cannot register instances by instance ID if they have the following instance types: C1, CC1, CC2, CG1, CG2, CR1, CS1, G1, G2, HI1, HS1, M1, M2, M3, and T1. You can register instances of these types by IP address.
#remove_listener_certificates(options = {}) ⇒ Struct
Removes the specified certificate from the certificate list for the specified HTTPS or TLS listener.
#remove_tags(options = {}) ⇒ Struct
Removes the specified tags from the specified Elastic Load Balancing resources. You can remove the tags for one or more Application Load Balancers, Network Load Balancers, Gateway Load Balancers, target groups, listeners, or rules.
#set_ip_address_type(options = {}) ⇒ Types::SetIpAddressTypeOutput
Sets the type of IP addresses used by the subnets of the specified Application Load Balancer or Network Load Balancer.
#set_rule_priorities(options = {}) ⇒ 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.
#set_security_groups(options = {}) ⇒ Types::SetSecurityGroupsOutput
Associates the specified security groups with the specified Application Load Balancer. The specified security groups override the previously associated security groups.
You can't specify a security group for a Network Load Balancer or Gateway Load Balancer.
#set_subnets(options = {}) ⇒ Types::SetSubnetsOutput
Enables the Availability Zones for the specified public subnets for the specified Application Load Balancer or Network Load Balancer. The specified subnets replace the previously enabled subnets.
When you specify subnets for a Network Load Balancer, you must include all subnets that were enabled previously, with their existing configurations, plus any additional subnets.
#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean
Waiters polls an API operation until a resource enters a desired state.
Basic Usage
Waiters will poll until they are succesful, they fail by entering a terminal state, or until a maximum number of attempts are made.
# 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 configure waiters by passing a block to #wait_until:
# poll for ~25 seconds
client.wait_until(...) do |w|
w.max_attempts = 5
w.delay = 5
end
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(...) do |w|
# disable max attempts
w.max_attempts = nil
# poll for 1 hour, instead of a number of attempts
w.before_wait do |attempts, response|
throw :failure if Time.now - started_at > 3600
end
end
Handling Errors
When a waiter is successful, it returns true
. When a waiter
fails, it raises an error. All errors raised extend from
Waiters::Errors::WaiterFailed.
begin
client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
# resource did not enter the desired state in time
end
#waiter_names ⇒ Array<Symbol>
Returns the list of supported waiters. The following table lists the supported waiters and the client method they call:
Waiter Name | Client Method | Default Delay: | Default 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 |