class Fog::AWS::ELB::Real

Attributes

region[R]

Public Class Methods

new(options={}) click to toggle source

Initialize connection to ELB

Notes

options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection

Examples

elb = ELB.new(
 :aws_access_key_id => your_aws_access_key_id,
 :aws_secret_access_key => your_aws_secret_access_key
)

Parameters

  • options<~Hash> - config arguments for connection. Defaults to {}.

    • region<~String> - optional region to use. For instance, 'eu-west-1', 'us-east-1', etc.

Returns

  • ELB object with connection to AWS.

# File lib/fog/aws/elb.rb, line 130
def initialize(options={})

  @use_iam_profile = options[:use_iam_profile]
  @connection_options     = options[:connection_options] || {}
  @instrumentor           = options[:instrumentor]
  @instrumentor_name      = options[:instrumentor_name] || 'fog.aws.elb'

  options[:region] ||= 'us-east-1'
  @region = options[:region]
  @host = options[:host] || "elasticloadbalancing.#{@region}.amazonaws.com"
  @path       = options[:path]        || '/'
  @persistent = options[:persistent]  || false
  @port       = options[:port]        || 443
  @scheme     = options[:scheme]      || 'https'
  @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
  @version ||= options[:version] || '2012-06-01'

  setup_credentials(options)
end

Public Instance Methods

add_tags(elb_id, tags) click to toggle source

adds tags to a load balancer instance docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_AddTags.html

Parameters

  • elb_id <~String> - name of the ELB instance to be tagged

  • tags <~Hash> A Hash of (String) key-value pairs

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

# File lib/fog/aws/requests/elb/add_tags.rb, line 14
def add_tags(elb_id, tags)
  keys    = tags.keys.sort
  values  = keys.map {|key| tags[key]}
  request({
      'Action'                     => 'AddTags',
      'LoadBalancerNames.member.1' => elb_id,
      :parser                      => Fog::Parsers::AWS::ELB::Empty.new,
    }.merge(Fog::AWS.indexed_param('Tags.member.%d.Key', keys)).
      merge(Fog::AWS.indexed_param('Tags.member.%d.Value', values)))
end
apply_security_groups(security_group_ids, lb_name)
apply_security_groups_to_load_balancer(security_group_ids, lb_name) click to toggle source

Sets the security groups for an ELB in VPC

Parameters

  • security_group_ids<~Array> - List of security group ids to enable on ELB

  • lb_name<~String> - Load balancer to disable availability zones on

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

      • 'ApplySecurityGroupsToLoadBalancer'<~Hash>:

        • 'SecurityGroups'<~Array> - array of strings describing the security group ids currently enabled

# File lib/fog/aws/requests/elb/apply_security_groups_to_load_balancer.rb, line 20
def apply_security_groups_to_load_balancer(security_group_ids, lb_name)
  params = Fog::AWS.indexed_param('SecurityGroups.member', [*security_group_ids])
  request({
    'Action'           => 'ApplySecurityGroupsToLoadBalancer',
    'LoadBalancerName' => lb_name,
    :parser            => Fog::Parsers::AWS::ELB::ApplySecurityGroupsToLoadBalancer.new
  }.merge!(params))
end
Also aliased as: apply_security_groups
attach_load_balancer_to_subnets(subnet_ids, lb_name) click to toggle source

Enable a subnet for an existing ELB

Parameters

  • subnet_ids<~Array> - List of subnet ids to enable on ELB

  • lb_name<~String> - Load balancer to enable availability zones on

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

      • 'AttachLoadBalancerToSubnetsResult'<~Hash>:

        • 'Subnets'<~Array> - array of strings describing the subnet ids currently enabled

# File lib/fog/aws/requests/elb/attach_load_balancer_to_subnets.rb, line 20
def attach_load_balancer_to_subnets(subnet_ids, lb_name)
  params = Fog::AWS.indexed_param('Subnets.member', [*subnet_ids])
  request({
    'Action'           => 'AttachLoadBalancerToSubnets',
    'LoadBalancerName' => lb_name,
    :parser            => Fog::Parsers::AWS::ELB::AttachLoadBalancerToSubnets.new
  }.merge!(params))
end
Also aliased as: enable_subnets
configure_health_check(lb_name, health_check) click to toggle source

Enables the client to define an application healthcheck for the instances. See docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/index.html?API_ConfigureHealthCheck.html

Parameters

  • lb_name<~String> - Name of the ELB

  • health_check<~Hash> - A hash of parameters describing the health check

    • 'HealthyThreshold'<~Integer> - Specifies the number of consecutive health probe successes required before moving the instance to the Healthy state.

    • 'Interval'<~Integer> - Specifies the approximate interval, in seconds, between health checks of an individual instance.

    • 'Target'<~String> - Specifies the instance being checked. The protocol is either TCP or HTTP. The range of valid ports is one (1) through 65535.

    • 'Timeout'<~Integer> - Specifies the amount of time, in seconds,

    during which no response means a failed health probe.

    • 'UnhealthyThreshold'<~Integer> - Specifies the number of consecutive health probe failures required before moving the instance to the Unhealthy state.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

# File lib/fog/aws/requests/elb/configure_health_check.rb, line 27
def configure_health_check(lb_name, health_check)
  params = {'LoadBalancerName' => lb_name}
  health_check.each {|key, value| params["HealthCheck.#{key}"] = value }

  request({
    'Action'           => 'ConfigureHealthCheck',
    :parser            => Fog::Parsers::AWS::ELB::ConfigureHealthCheck.new
  }.merge!(params))
end
create_load_balancer(availability_zones, lb_name, listeners, options = {}) click to toggle source

Create a new Elastic Load Balancer

Parameters

  • availability_zones<~Array> - List of availability zones for the ELB

  • lb_name<~String> - Name for the new ELB – must be unique

  • listeners<~Array> - Array of Hashes describing ELB listeners to assign to the ELB

    • 'Protocol'<~String> - Protocol to use. Either HTTP, HTTPS, TCP or SSL.

    • 'LoadBalancerPort'<~Integer> - The port that the ELB will listen to for outside traffic

    • 'InstancePort'<~Integer> - The port on the instance that the ELB will forward traffic to

    • 'InstanceProtocol'<~String> - Protocol for sending traffic to an instance. Either HTTP, HTTPS, TCP or SSL.

    • 'SSLCertificateId'<~String> - ARN of the server certificate

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

      • 'CreateLoadBalancerResult'<~Hash>:

        • 'DNSName'<~String> - DNS name for the newly created ELB

# File lib/fog/aws/requests/elb/create_load_balancer.rb, line 25
def create_load_balancer(availability_zones, lb_name, listeners, options = {})
  params = Fog::AWS.indexed_param('AvailabilityZones.member', [*availability_zones])
  params.merge!(Fog::AWS.indexed_param('Subnets.member.%d', options[:subnet_ids]))
  params.merge!(Fog::AWS.serialize_keys('Scheme', options[:scheme]))
  params.merge!(Fog::AWS.indexed_param('SecurityGroups.member.%d', options[:security_groups]))

  listener_protocol = []
  listener_lb_port = []
  listener_instance_port = []
  listener_instance_protocol = []
  listener_ssl_certificate_id = []
  listeners.each do |listener|
    listener_protocol.push(listener['Protocol'])
    listener_lb_port.push(listener['LoadBalancerPort'])
    listener_instance_port.push(listener['InstancePort'])
    listener_instance_protocol.push(listener['InstanceProtocol'])
    listener_ssl_certificate_id.push(listener['SSLCertificateId'])
  end

  params.merge!(Fog::AWS.indexed_param('Listeners.member.%d.Protocol', listener_protocol))
  params.merge!(Fog::AWS.indexed_param('Listeners.member.%d.LoadBalancerPort', listener_lb_port))
  params.merge!(Fog::AWS.indexed_param('Listeners.member.%d.InstancePort', listener_instance_port))
  params.merge!(Fog::AWS.indexed_param('Listeners.member.%d.InstanceProtocol', listener_instance_protocol))
  params.merge!(Fog::AWS.indexed_param('Listeners.member.%d.SSLCertificateId', listener_ssl_certificate_id))

  request({
    'Action'           => 'CreateLoadBalancer',
    'LoadBalancerName' => lb_name,
    :parser            => Fog::Parsers::AWS::ELB::CreateLoadBalancer.new
  }.merge!(params))
end
create_load_balancer_listeners(lb_name, listeners) click to toggle source

Create Elastic Load Balancer Listeners

Parameters

  • lb_name<~String> - Name for the new ELB – must be unique

  • listeners<~Array> - Array of Hashes describing ELB listeners to add to the ELB

    • 'Protocol'<~String> - Protocol to use. Either HTTP, HTTPS, TCP or SSL.

    • 'LoadBalancerPort'<~Integer> - The port that the ELB will listen to for outside traffic

    • 'InstancePort'<~Integer> - The port on the instance that the ELB will forward traffic to

    • 'InstanceProtocol'<~String> - Protocol for sending traffic to an instance. Either HTTP, HTTPS, TCP or SSL.

    • 'SSLCertificateId'<~String> - ARN of the server certificate

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

# File lib/fog/aws/requests/elb/create_load_balancer_listeners.rb, line 22
def create_load_balancer_listeners(lb_name, listeners)
  params = {}

  listener_protocol = []
  listener_lb_port = []
  listener_instance_port = []
  listener_instance_protocol = []
  listener_ssl_certificate_id = []
  listeners.each do |listener|
    listener_protocol.push(listener['Protocol'])
    listener_lb_port.push(listener['LoadBalancerPort'])
    listener_instance_port.push(listener['InstancePort'])
    listener_instance_protocol.push(listener['InstanceProtocol'])
    listener_ssl_certificate_id.push(listener['SSLCertificateId'])
  end

  params.merge!(Fog::AWS.indexed_param('Listeners.member.%d.Protocol', listener_protocol))
  params.merge!(Fog::AWS.indexed_param('Listeners.member.%d.LoadBalancerPort', listener_lb_port))
  params.merge!(Fog::AWS.indexed_param('Listeners.member.%d.InstancePort', listener_instance_port))
  params.merge!(Fog::AWS.indexed_param('Listeners.member.%d.InstanceProtocol', listener_instance_protocol))
  params.merge!(Fog::AWS.indexed_param('Listeners.member.%d.SSLCertificateId', listener_ssl_certificate_id))

  request({
    'Action'           => 'CreateLoadBalancerListeners',
    'LoadBalancerName' => lb_name,
    :parser            => Fog::Parsers::AWS::ELB::Empty.new
  }.merge!(params))
end
create_load_balancer_policy(lb_name, name, type_name, attributes = {}) click to toggle source

Create Elastic Load Balancer Policy

Parameters

  • lb_name<~String> - The name associated with the LoadBalancer for which the policy is being created. This name must be unique within the client AWS account.

  • attributes<~Hash> - A list of attributes associated with the policy being created.

    • 'AttributeName'<~String> - The name of the attribute associated with the policy.

    • 'AttributeValue'<~String> - The value of the attribute associated with the policy.

  • name<~String> - The name of the LoadBalancer policy being created. The name must be unique within the set of policies for this LoadBalancer.

  • type_name<~String> - The name of the base policy type being used to create this policy. To get the list of policy types, use the DescribeLoadBalancerPolicyTypes action.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

# File lib/fog/aws/requests/elb/create_load_balancer_policy.rb, line 21
def create_load_balancer_policy(lb_name, name, type_name, attributes = {})
  params = {}

  attribute_name = []
  attribute_value = []
  attributes.each do |name, value|
    attribute_name.push(name)
    attribute_value.push(value)
  end

  params.merge!(Fog::AWS.indexed_param('PolicyAttributes.member.%d.AttributeName', attribute_name))
  params.merge!(Fog::AWS.indexed_param('PolicyAttributes.member.%d.AttributeValue', attribute_value))

  request({
            'Action'           => 'CreateLoadBalancerPolicy',
            'LoadBalancerName' => lb_name,
            'PolicyName'       => name,
            'PolicyTypeName'   => type_name,
            :parser            => Fog::Parsers::AWS::ELB::Empty.new
          }.merge!(params))
end
delete_load_balancer(lb_name) click to toggle source

Delete an existing Elastic Load Balancer

Note that this API call, as defined by Amazon, is idempotent. That is, it will not return an error if you try to delete an ELB that does not exist.

Parameters

  • lb_name<~String> - Name of the ELB to be deleted

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'DeleteLoadBalancerResponse'<~nil>

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

# File lib/fog/aws/requests/elb/delete_load_balancer.rb, line 21
def delete_load_balancer(lb_name)
  request({
    'Action'           => 'DeleteLoadBalancer',
    'LoadBalancerName' => lb_name,
    :parser            => Fog::Parsers::AWS::ELB::DeleteLoadBalancer.new
  })
end
delete_load_balancer_listeners(lb_name, load_balancer_ports) click to toggle source

Delet Elastic Load Balancer Listeners

Parameters

  • lb_name<~String> - Name for the new ELB – must be unique

  • load_balancer_ports<~Array> - Array of client port numbers of the LoadBalancerListeners to remove

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

# File lib/fog/aws/requests/elb/delete_load_balancer_listeners.rb, line 17
def delete_load_balancer_listeners(lb_name, load_balancer_ports)
  params = Fog::AWS.indexed_param('LoadBalancerPorts.member.%d', load_balancer_ports)

  request({
    'Action'           => 'DeleteLoadBalancerListeners',
    'LoadBalancerName' => lb_name,
    :parser            => Fog::Parsers::AWS::ELB::Empty.new
  }.merge!(params))
end
delete_load_balancer_policy(lb_name, policy_name) click to toggle source

Delete a Load Balancer Stickiness Policy

Parameters

  • lb_name<~String> - Name of the ELB

  • policy_name<~String> - The name of the policy to delete

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

# File lib/fog/aws/requests/elb/delete_load_balancer_policy.rb, line 17
def delete_load_balancer_policy(lb_name, policy_name)
  params = {'PolicyName' => policy_name}

  request({
    'Action'           => 'DeleteLoadBalancerPolicy',
    'LoadBalancerName' => lb_name,
    :parser            => Fog::Parsers::AWS::ELB::Empty.new
  }.merge!(params))
end
deregister_instances(instance_ids, lb_name)
deregister_instances_from_load_balancer(instance_ids, lb_name) click to toggle source

Deregister an instance from an existing ELB

Parameters

  • instance_ids<~Array> - List of instance IDs to remove from ELB

  • lb_name<~String> - Load balancer to remove instances from

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

      • 'DeregisterInstancesFromLoadBalancerResult'<~Hash>:

        • 'Instances'<~Array> - array of hashes describing instances currently enabled

          • 'InstanceId'<~String>

# File lib/fog/aws/requests/elb/deregister_instances_from_load_balancer.rb, line 21
def deregister_instances_from_load_balancer(instance_ids, lb_name)
  params = Fog::AWS.indexed_param('Instances.member.%d.InstanceId', [*instance_ids])
  request({
    'Action'           => 'DeregisterInstancesFromLoadBalancer',
    'LoadBalancerName' => lb_name,
    :parser            => Fog::Parsers::AWS::ELB::DeregisterInstancesFromLoadBalancer.new
  }.merge!(params))
end
Also aliased as: deregister_instances
describe_instance_health(lb_name, instance_ids = []) click to toggle source

Get health status for one or more instances on an existing ELB

Parameters

  • lb_name<~String> - Load balancer to check instances health on

  • instance_ids<~Array> - Optional list of instance IDs to check

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

      • 'DescribeInstanceHealthResult'<~Hash>:

        • 'InstanceStates'<~Array> - array of hashes describing instance health

          • 'Description'<~String>

          • 'State'<~String>

          • 'InstanceId'<~String>

          • 'ReasonCode'<~String>

# File lib/fog/aws/requests/elb/describe_instance_health.rb, line 24
def describe_instance_health(lb_name, instance_ids = [])
  params = Fog::AWS.indexed_param('Instances.member.%d.InstanceId', [*instance_ids])
  request({
    'Action'           => 'DescribeInstanceHealth',
    'LoadBalancerName' => lb_name,
    :parser            => Fog::Parsers::AWS::ELB::DescribeInstanceHealth.new
  }.merge!(params))
end
describe_load_balancer_attributes(lb_name) click to toggle source

Describe the load balancer attributes docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_DescribeLoadBalancerAttributes.html

Parameters

  • lb_name<~String> - The mnemonic name associated with the LoadBalancer.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

      • 'DescribeLoadBalancerAttributesResult'<~Hash>:

        • 'LoadBalancerAttributes'<~Hash>

          • 'ConnectionDraining'<~Hash>

            • 'Enabled'<~Boolean> - whether connection draining is enabled

            • 'Timeout'<~Integer> - max time (in seconds) to keep existing conns open before deregistering instances.

          • 'CrossZoneLoadBalancing'<~Hash>

            • 'Enabled'<~Boolean> - whether crosszone load balancing is enabled

          • 'ConnectionSettings'<~Hash>

            • 'IdleTimeout'<~Integer> - time (in seconds) the connection is allowed to be idle (no data has been sent over the connection) before it is closed by the load balancer.

# File lib/fog/aws/requests/elb/describe_load_balancer_attributes.rb, line 27
def describe_load_balancer_attributes(lb_name)
  request({
    'Action'  => 'DescribeLoadBalancerAttributes',
    'LoadBalancerName' => lb_name,
    :parser   => Fog::Parsers::AWS::ELB::DescribeLoadBalancerAttributes.new
  })
end
describe_load_balancer_policies(lb_name = nil, names = []) click to toggle source

Describe all or specified load balancer policies

Parameters

  • lb_name<~String> - The mnemonic name associated with the LoadBalancer. If no name is specified, the operation returns the attributes of either all the sample policies pre-defined by Elastic Load Balancing or the specified sample polices.

  • names<~Array> - The names of LoadBalancer policies you've created or Elastic Load Balancing sample policy names.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

      • 'DescribeLoadBalancerPoliciesResult'<~Hash>:

        • 'PolicyDescriptions'<~Array>

          • 'PolicyAttributeDescriptions'<~Array>

            • 'AttributeName'<~String> - The name of the attribute associated with the policy.

            • 'AttributeValue'<~String> - The value of the attribute associated with the policy.

          • 'PolicyName'<~String> - The name mof the policy associated with the LoadBalancer.

          • 'PolicyTypeName'<~String> - The name of the policy type.

# File lib/fog/aws/requests/elb/describe_load_balancer_policies.rb, line 25
def describe_load_balancer_policies(lb_name = nil, names = [])
  params = Fog::AWS.indexed_param('PolicyNames.member', [*names])
  request({
    'Action'  => 'DescribeLoadBalancerPolicies',
    'LoadBalancerName' => lb_name,
    :parser   => Fog::Parsers::AWS::ELB::DescribeLoadBalancerPolicies.new
  }.merge!(params))
end
describe_load_balancer_policy_types(type_names = []) click to toggle source

Describe all or specified load balancer policy types

Parameters

  • type_name<~Array> - Specifies the name of the policy types. If no names are specified, returns the description of all the policy types defined by Elastic Load Balancing service.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

      • 'DescribeLoadBalancerPolicyTypesResult'<~Hash>:

        • 'PolicyTypeDescriptions'<~Array>

          • 'Description'<~String> - A human-readable description of the policy type.

          • 'PolicyAttributeTypeDescriptions'<~Array>

            • 'AttributeName'<~String> - The name of the attribute associated with the policy type.

            • 'AttributeValue'<~String> - The type of attribute. For example, Boolean, Integer, etc.

            • 'Cardinality'<~String> - The cardinality of the attribute.

            • 'DefaultValue'<~String> - The default value of the attribute, if applicable.

            • 'Description'<~String> - A human-readable description of the attribute.

          • 'PolicyTypeName'<~String> - The name of the policy type.

# File lib/fog/aws/requests/elb/describe_load_balancer_policy_types.rb, line 27
def describe_load_balancer_policy_types(type_names = [])
  params = Fog::AWS.indexed_param('PolicyTypeNames.member', [*type_names])
  request({
    'Action'  => 'DescribeLoadBalancerPolicyTypes',
    :parser   => Fog::Parsers::AWS::ELB::DescribeLoadBalancerPolicyTypes.new
  }.merge!(params))
end
describe_load_balancers(options = {}) click to toggle source

Describe all or specified load balancers

Parameters

  • options<~Hash>

    • 'LoadBalancerNames'<~Array> - List of load balancer names to describe, defaults to all

    • 'Marker'<String> - Indicates where to begin in your list of load balancers

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

      • 'DescribeLoadBalancersResult'<~Hash>:

        • 'LoadBalancerDescriptions'<~Array>

          • 'AvailabilityZones'<~Array> - list of availability zones covered by this load balancer

          • 'BackendServerDescriptions'<~Array>:

            • 'InstancePort'<~Integer> - the port on which the back-end server is listening

            • 'PolicyNames'<~Array> - list of policy names enabled for the back-end server

          • 'CanonicalHostedZoneName'<~String> - name of the Route 53 hosted zone associated with the load balancer

          • 'CanonicalHostedZoneNameID'<~String> - ID of the Route 53 hosted zone associated with the load balancer

          • 'CreatedTime'<~Time> - time load balancer was created

          • 'DNSName'<~String> - external DNS name of load balancer

          • 'HealthCheck'<~Hash>:

            • 'HealthyThreshold'<~Integer> - number of consecutive health probe successes required before moving the instance to the Healthy state

            • 'Timeout'<~Integer> - number of seconds after which no response means a failed health probe

            • 'Interval'<~Integer> - interval (in seconds) between health checks of an individual instance

            • 'UnhealthyThreshold'<~Integer> - number of consecutive health probe failures that move the instance to the unhealthy state

            • 'Target'<~String> - string describing protocol type, port and URL to check

          • 'Instances'<~Array> - list of instances that the load balancer balances between

          • 'ListenerDescriptions'<~Array>

            • 'PolicyNames'<~Array> - list of policies enabled

            • 'Listener'<~Hash>:

              • 'InstancePort'<~Integer> - port on instance that requests are sent to

              • 'Protocol'<~String> - transport protocol used for routing in [TCP, HTTP]

              • 'LoadBalancerPort'<~Integer> - port that load balancer listens on for requests

          • 'LoadBalancerName'<~String> - name of load balancer

          • 'Policies'<~Hash>:

            • 'LBCookieStickinessPolicies'<~Array> - list of Load Balancer Generated Cookie Stickiness policies for the LoadBalancer

            • 'AppCookieStickinessPolicies'<~Array> - list of Application Generated Cookie Stickiness policies for the LoadBalancer

            • 'OtherPolicies'<~Array> - list of policy names other than the stickiness policies

          • 'SourceSecurityGroup'<~Hash>:

            • 'GroupName'<~String> - Name of the source security group to use with inbound security group rules

            • 'OwnerAlias'<~String> - Owner of the source security group

          • 'NextMarker'<~String> - Marker to specify for next page

# File lib/fog/aws/requests/elb/describe_load_balancers.rb, line 51
def describe_load_balancers(options = {})
  unless options.is_a?(Hash)
    Fog::Logger.deprecation("describe_load_balancers with #{options.class} is deprecated, use all('LoadBalancerNames' => []) instead [light_black](#{caller.first})[/]")
    options = { 'LoadBalancerNames' => [options].flatten }
  end

  if names = options.delete('LoadBalancerNames')
    options.update(Fog::AWS.indexed_param('LoadBalancerNames.member', [*names]))
  end

  request({
    'Action'  => 'DescribeLoadBalancers',
    :parser   => Fog::Parsers::AWS::ELB::DescribeLoadBalancers.new
  }.merge!(options))
end
describe_tags(elb_ids) click to toggle source

returns a Hash of tags for a load balancer docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_DescribeTags.html

Parameters

  • elb_id <~String> - name(s) of the ELB instance whose tags are to be retrieved (allows 1-20 of them)

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

# File lib/fog/aws/requests/elb/describe_tags.rb, line 15
def describe_tags(elb_ids)
  request({
      'Action' => 'DescribeTags',
      :parser  => Fog::Parsers::AWS::ELB::TagListParser.new
    }.merge(Fog::AWS.indexed_param('LoadBalancerNames.member.%d', elb_ids))
  )
end
detach_load_balancer_from_subnets(subnet_ids, lb_name) click to toggle source

Disable a subnet for an existing ELB

Parameters

  • subnet_ids<~Array> - List of subnet ids to enable on ELB

  • lb_name<~String> - Load balancer to disable availability zones on

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

      • 'DetachLoadBalancerFromSubnetsResult'<~Hash>:

        • 'Subnets'<~Array> - array of strings describing the subnet ids currently enabled

# File lib/fog/aws/requests/elb/detach_load_balancer_from_subnets.rb, line 20
def detach_load_balancer_from_subnets(subnet_ids, lb_name)
  params = Fog::AWS.indexed_param('Subnets.member', [*subnet_ids])
  request({
    'Action'           => 'DetachLoadBalancerFromSubnets',
    'LoadBalancerName' => lb_name,
    :parser            => Fog::Parsers::AWS::ELB::DetachLoadBalancerFromSubnets.new
  }.merge!(params))
end
Also aliased as: disable_subnets
disable_availability_zones_for_load_balancer(availability_zones, lb_name) click to toggle source

Disable an availability zone for an existing ELB

Parameters

  • availability_zones<~Array> - List of availability zones to disable on ELB

  • lb_name<~String> - Load balancer to disable availability zones on

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

      • 'DisableAvailabilityZonesForLoadBalancerResult'<~Hash>:

        • 'AvailabilityZones'<~Array> - A list of updated Availability Zones for the LoadBalancer.

# File lib/fog/aws/requests/elb/disable_availability_zones_for_load_balancer.rb, line 20
def disable_availability_zones_for_load_balancer(availability_zones, lb_name)
  params = Fog::AWS.indexed_param('AvailabilityZones.member', [*availability_zones])
  request({
    'Action'           => 'DisableAvailabilityZonesForLoadBalancer',
    'LoadBalancerName' => lb_name,
    :parser            => Fog::Parsers::AWS::ELB::DisableAvailabilityZonesForLoadBalancer.new
  }.merge!(params))
end
Also aliased as: disable_zones
disable_subnets(subnet_ids, lb_name)
disable_zones(availability_zones, lb_name)
enable_availability_zones_for_load_balancer(availability_zones, lb_name) click to toggle source

Enable an availability zone for an existing ELB

Parameters

  • availability_zones<~Array> - List of availability zones to enable on ELB

  • lb_name<~String> - Load balancer to enable availability zones on

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

      • 'EnableAvailabilityZonesForLoadBalancerResult'<~Hash>:

        • 'AvailabilityZones'<~Array> - array of strings describing instances currently enabled

# File lib/fog/aws/requests/elb/enable_availability_zones_for_load_balancer.rb, line 20
def enable_availability_zones_for_load_balancer(availability_zones, lb_name)
  params = Fog::AWS.indexed_param('AvailabilityZones.member', [*availability_zones])
  request({
    'Action'           => 'EnableAvailabilityZonesForLoadBalancer',
    'LoadBalancerName' => lb_name,
    :parser            => Fog::Parsers::AWS::ELB::EnableAvailabilityZonesForLoadBalancer.new
  }.merge!(params))
end
Also aliased as: enable_zones
enable_subnets(subnet_ids, lb_name)
enable_zones(availability_zones, lb_name)
modify_load_balancer_attributes(lb_name, options) click to toggle source

Sets attributes of the load balancer

The following attributes can be set:

  • CrossZoneLoadBalancing (enable/disable)

  • ConnectionDraining (enable/disable and timeout)

  • Idle Connection Timeouts

Still requires: AccessLog configuration

docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_ModifyLoadBalancerAttributes.html

Parameters

  • lb_name<~String> - Name of the ELB

  • options<~Hash>

    • 'ConnectionDraining'<~Hash>:

      • 'Enabled'<~Boolean> whether to enable connection draining

      • 'Timeout'<~Integer> max time to keep existing conns open before deregistering instances

    • 'CrossZoneLoadBalancing'<~Hash>:

      • 'Enabled'<~Boolean> whether to enable cross zone load balancing

    • 'ConnectionSettings'<~Hash>:

      • 'IdleTimeout'<~Integer> time (in seconds) the connection is allowed to be idle (no data has been sent over the connection) before it is closed by the load balancer.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

# File lib/fog/aws/requests/elb/modify_load_balancer_attributes.rb, line 33
def modify_load_balancer_attributes(lb_name, options)
  attributes = Fog::AWS.serialize_keys 'LoadBalancerAttributes', options
  request(attributes.merge(
    'Action'           => 'ModifyLoadBalancerAttributes',
    'LoadBalancerName' => lb_name,
    :parser            => Fog::Parsers::AWS::ELB::Empty.new
  ))
end
register_instances(instance_ids, lb_name)
register_instances_with_load_balancer(instance_ids, lb_name) click to toggle source

Register an instance with an existing ELB

Parameters

  • instance_ids<~Array> - List of instance IDs to associate with ELB

  • lb_name<~String> - Load balancer to assign instances to

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

      • 'RegisterInstancesWithLoadBalancerResult'<~Hash>:

        • 'Instances'<~Array> - array of hashes describing instances currently enabled

          • 'InstanceId'<~String>

# File lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb, line 21
def register_instances_with_load_balancer(instance_ids, lb_name)
  params = Fog::AWS.indexed_param('Instances.member.%d.InstanceId', [*instance_ids])
  request({
    'Action'           => 'RegisterInstancesWithLoadBalancer',
    'LoadBalancerName' => lb_name,
    :parser            => Fog::Parsers::AWS::ELB::RegisterInstancesWithLoadBalancer.new
  }.merge!(params))
end
Also aliased as: register_instances
reload() click to toggle source
# File lib/fog/aws/elb.rb, line 152
def reload
  @connection.reset
end
remove_tags(elb_id, keys) click to toggle source

removes tags from an elastic load balancer instance docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_RemoveTags.html

Parameters

  • elb_id <~String> - name of the ELB instance whose tags are to be retrieved

  • keys <~Array> A list of String keys for the tags to remove

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

# File lib/fog/aws/requests/elb/remove_tags.rb, line 14
def remove_tags(elb_id, keys)
  request(
    { 'Action'                      => 'RemoveTags',
      # Note: there is a discrepancy in the API docs in the ID parameter name between the write-up and the example.
      # Who knows which way the fix will go, if any is ever made? In any case, this works.
      'LoadBalancerNames.member.1'  => elb_id,
      :parser => Fog::Parsers::AWS::ELB::Empty.new,
    }.merge(Fog::AWS.indexed_param('Tags.member.%d.Key', keys))
  )
end
set_load_balancer_listener_ssl_certificate(lb_name, load_balancer_port, ssl_certificate_id) click to toggle source

Sets the certificate that terminates the specified listener's SSL connections. The specified certificate replaces any prior certificate that was used on the same LoadBalancer and port.

Parameters

  • lb_name<~String> - Name of the ELB

  • load_balancer_port<~Integer> - The external port of the LoadBalancer with which this policy has to be associated.

  • ssl_certificate_id<~String> - ID of the SSL certificate chain to use example: arn:aws:iam::322191361670:server-certificate/newCert

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

# File lib/fog/aws/requests/elb/set_load_balancer_listener_ssl_certificate.rb, line 23
def set_load_balancer_listener_ssl_certificate(lb_name, load_balancer_port, ssl_certificate_id)
  request({
    'Action'           => 'SetLoadBalancerListenerSSLCertificate',
    'LoadBalancerName' => lb_name,
    'LoadBalancerPort' => load_balancer_port,
    'SSLCertificateId' => ssl_certificate_id,
    :parser            => Fog::Parsers::AWS::ELB::Empty.new
  })
end
set_load_balancer_policies_for_backend_server(lb_name, instance_port, policy_names) click to toggle source

Replaces the current set of policies associated with a port on which the back-end server is listening with a new set of policies. After the policies have been created using CreateLoadBalancerPolicy, they can be applied here as a list.

Parameters

  • lb_name<~String> - Name of the ELB

  • instance_port<~Integer> - The port on the instance that the ELB will forward traffic to

  • policy_names<~Array> - Array of Strings listing the policies to set for the backend port

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

# File lib/fog/aws/requests/elb/set_load_balancer_policies_for_backend_server.rb, line 19
def set_load_balancer_policies_for_backend_server(lb_name, instance_port, policy_names)
  params = {'InstancePort' => instance_port}
  if policy_names.any?
    params.merge!(Fog::AWS.indexed_param('PolicyNames.member', policy_names))
  else
    params['PolicyNames'] = ''
  end

  request({ 'Action' => 'SetLoadBalancerPoliciesForBackendServer',
            'LoadBalancerName' => lb_name,
            :parser => Fog::Parsers::AWS::ELB::Empty.new
          }.merge!(params))
end
set_load_balancer_policies_of_listener(lb_name, load_balancer_port, policy_names) click to toggle source
  • policy_names<~Array> - List of policies to be associated with the listener. Currently this list can have at most one policy. If the list is empty, the current policy is removed from the listener.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

        • 'RequestId'<~String> - Id of request

# File lib/fog/aws/requests/elb/set_load_balancer_policies_of_listener.rb, line 24
def set_load_balancer_policies_of_listener(lb_name, load_balancer_port, policy_names)
  params = {'LoadBalancerPort' => load_balancer_port}
  if policy_names.any?
    params.merge!(Fog::AWS.indexed_param('PolicyNames.member', policy_names))
  else
    params['PolicyNames'] = ''
  end

  request({
    'Action'           => 'SetLoadBalancerPoliciesOfListener',
    'LoadBalancerName' => lb_name,
    :parser            => Fog::Parsers::AWS::ELB::Empty.new
  }.merge!(params))
end

Private Instance Methods

_request(body, headers, idempotent, parser) click to toggle source
# File lib/fog/aws/elb.rb, line 196
def _request(body, headers, idempotent, parser)
  @connection.request({
    :body       => body,
    :expects    => 200,
    :headers    => headers,
    :idempotent => idempotent,
    :method     => 'POST',
    :parser     => parser
  })
rescue Excon::Errors::HTTPStatusError => error
  match = Fog::AWS::Errors.match_error(error)
  raise if match.empty?
  raise case match[:code]
        when 'CertificateNotFound'
          Fog::AWS::IAM::NotFound.slurp(error, match[:message])
        when 'DuplicateLoadBalancerName'
          Fog::AWS::ELB::IdentifierTaken.slurp(error, match[:message])
        when 'DuplicatePolicyName'
          Fog::AWS::ELB::DuplicatePolicyName.slurp(error, match[:message])
        when 'InvalidInstance'
          Fog::AWS::ELB::InvalidInstance.slurp(error, match[:message])
        when 'InvalidConfigurationRequest'
          # when do they fucking use this shit?
          Fog::AWS::ELB::InvalidConfigurationRequest.slurp(error, match[:message])
        when 'LoadBalancerNotFound'
          Fog::AWS::ELB::NotFound.slurp(error, match[:message])
        when 'PolicyNotFound'
          Fog::AWS::ELB::PolicyNotFound.slurp(error, match[:message])
        when 'PolicyTypeNotFound'
          Fog::AWS::ELB::PolicyTypeNotFound.slurp(error, match[:message])
        when 'Throttling'
          Fog::AWS::ELB::Throttled.slurp(error, match[:message])
        when 'TooManyPolicies'
          Fog::AWS::ELB::TooManyPolicies.slurp(error, match[:message])
        when 'ValidationError'
          Fog::AWS::ELB::ValidationError.slurp(error, match[:message])
        else
          Fog::AWS::ELB::Error.slurp(error, "#{match[:code]} => #{match[:message]}")
        end
end
request(params) click to toggle source
# File lib/fog/aws/elb.rb, line 167
def request(params)
  refresh_credentials_if_expired

  idempotent  = params.delete(:idempotent)
  parser      = params.delete(:parser)

  body, headers = Fog::AWS.signed_params_v4(
    params,
    { 'Content-Type' => 'application/x-www-form-urlencoded' },
    {
      :aws_session_token  => @aws_session_token,
      :signer             => @signer,
      :host               => @host,
      :path               => @path,
      :port               => @port,
      :version            => @version,
      :method             => 'POST'
  }
  )

  if @instrumentor
    @instrumentor.instrument("#{@instrumentor_name}.request", params) do
      _request(body, headers, idempotent, parser)
    end
  else
    _request(body, headers, idempotent, parser)
  end
end
setup_credentials(options={}) click to toggle source
# File lib/fog/aws/elb.rb, line 158
def setup_credentials(options={})
  @aws_access_key_id         = options[:aws_access_key_id]
  @aws_secret_access_key     = options[:aws_secret_access_key]
  @aws_session_token         = options[:aws_session_token]
  @aws_credentials_expire_at = options[:aws_credentials_expire_at]

  @signer = Fog::AWS::SignatureV4.new(@aws_access_key_id, @aws_secret_access_key, @region, 'elasticloadbalancing')
end