class Fog::AWS::ELBV2::Real

Public Class Methods

new(options={}) click to toggle source
Calls superclass method Fog::AWS::ELB::Real::new
# File lib/fog/aws/elbv2.rb, line 16
def initialize(options={})
  @version = '2015-12-01'

  super(options)
end

Public Instance Methods

add_tags(resource_arn, tags) click to toggle source

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

Parameters

  • resource_arn <~String> - The Amazon Resource Name (ARN) of the resource

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

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

# File lib/fog/aws/requests/elbv2/add_tags.rb, line 15
def add_tags(resource_arn, tags)
  keys    = tags.keys.sort
  values  = keys.map {|key| tags[key]}
  request({
      'Action'                     => 'AddTags',
      'ResourceArns.member.1'      => resource_arn,
      :parser                      => Fog::Parsers::AWS::ELBV2::Empty.new,
    }.merge(Fog::AWS.indexed_param('Tags.member.%d.Key', keys))
     .merge(Fog::AWS.indexed_param('Tags.member.%d.Value', values)))
end
create_load_balancer(name, options = {}) click to toggle source

Create a new Elastic Load Balancer

Parameters

  • name<~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,
      must not begin or end with a hyphen, and must not begin with "internal-".
    - Required: Yes
  • options<~Hash>:

    • ip_address_type<~String> - [Application Load Balancers] 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.
      - Required: No
    • scheme<~String> - The default is an Internet-facing load balancer. Valid Values: internet-facing | internal

      - Required: No
    • security_groups<~Array> - The IDs of the security groups for the load balancer.

      - Required: No
    • subnet_mappings<~Array> - The IDs of the public subnets. You can specify only one subnet per Availability Zone. You must specify either subnets or subnet mappings.

      - [Application Load Balancers] You must specify subnets from at least two Availability Zones.
        You cannot specify Elastic IP addresses for your subnets.
      - [Network Load Balancers] You can specify subnets from one or more Availability Zones.
        You can specify one Elastic IP address per subnet if you need static IP addresses for your internet-facing load balancer.
        For internal load balancers, you can specify one private IP address per subnet from the IPv4 range of the subnet.
      - Required: No
    • subnets<~Array> - The IDs of the public subnets. You can specify only one subnet per Availability Zone. You must specify either subnets or subnet mappings.

      - [Application Load Balancers] You must specify subnets from at least two Availability Zones.
      - [Network Load Balancers] You can specify subnets from one or more Availability Zones.
      - Required: No
    • tags<~Hash> - One or more tags to assign to the load balancer.

      - Required: No
    • type<~String> - The type of load balancer. The default is application. Valid Values: application | network

      - Required: No

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'ResponseMetadata'<~Hash>:

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

      • 'CreateLoadBalancerResult'<~Hash>:

        • 'LoadBalancers'<~Array>

          • 'AvailabilityZones'<~Array>:

            • 'SubnetId'<~String> - ID of the subnet

            • 'ZoneName'<~String> - Name of the Availability Zone

            • 'LoadBalancerAddresses'<~Array>:

              • 'IpAddress'<~String> - IP address

              • 'AllocationId'<~String> - ID of the AWS allocation

          • '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

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

          • 'SecurityGroups'<~Array> - array of security group id

# File lib/fog/aws/requests/elbv2/create_load_balancer.rb, line 57
def create_load_balancer(name, options = {})
  params = {}
  params.merge!(Fog::AWS.indexed_param('Subnets.member.%d', options[:subnets]))
  params.merge!(Fog::AWS.indexed_param('SecurityGroups.member.%d', options[:security_groups]))
  params.merge!(Fog::AWS.serialize_keys('Scheme', options[:scheme]))
  params.merge!(Fog::AWS.serialize_keys('Type', options[:type]))
  params.merge!(Fog::AWS.serialize_keys('IpAddressType', options[:ip_address_type]))


  unless options[:tags].nil?
    tag_keys   = options[:tags].keys.sort
    tag_values = tag_keys.map { |key| options[:tags][key] }
    params.merge!(Fog::AWS.indexed_param('Tags.member.%d.Key', tag_keys))
    params.merge!(Fog::AWS.indexed_param('Tags.member.%d.Value', tag_values))
  end

  unless options[:subnet_mappings].nil?
    subnet_ids = []
    allocation_ids = []
    private_ipv4_address = []
    options[:subnet_mappings].each do |subnet_mapping|
      subnet_ids.push(subnet_mapping[:subnet_id])
      allocation_ids.push(subnet_mapping[:allocation_id])
      private_ipv4_address.push(subnet_mapping[:private_ipv4_address])
    end
    params.merge!(Fog::AWS.indexed_param('SubnetMappings.member.%d.SubnetId', subnet_ids))
    params.merge!(Fog::AWS.indexed_param('SubnetMappings.member.%d.AllocationId', allocation_ids))
    params.merge!(Fog::AWS.indexed_param('SubnetMappings.member.%d.PrivateIPv4Address', private_ipv4_address))
  end


  request({
    'Action'           => 'CreateLoadBalancer',
    'Name' => name,
    :parser            => Fog::Parsers::AWS::ELBV2::CreateLoadBalancer.new
  }.merge!(params))
end
describe_listeners(load_balancer_arn, options = {}) click to toggle source

Describe all or specified load balancers

Parameters

  • 'LoadBalancerArn'<~String> - The Amazon Resource Name (ARN) of the load balancer

  • options<~Hash>

    • '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

      • 'DescribeListenersResult'<~Hash>:

        • 'Listeners'<~Array>

          • 'LoadBalancerArn'<~String> - The Amazon Resource Name (ARN) of the load balancer

          • 'Protocol'<~String> - The protocol for connections from clients to the load balancer

          • 'Port'<~String> - The port on which the load balancer is listening

          • 'DefaultActions'<~Array> - The default actions for the listener

            • 'Type'<~String> - The type of action

            • 'TargetGroupArn'<~String> - The Amazon Resource Name (ARN) of the target group. Specify only when Type is forward

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

# File lib/fog/aws/requests/elbv2/describe_listeners.rb, line 28
def describe_listeners(load_balancer_arn, options = {})
  request({
    'Action'  => 'DescribeListeners',
    'LoadBalancerArn' => load_balancer_arn,
    :parser   => Fog::Parsers::AWS::ELBV2::DescribeListeners.new
  }.merge!(options))
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>:

        • 'LoadBalancers'<~Array>

          • 'AvailabilityZones'<~Array>:

            • 'SubnetId'<~String> - ID of the subnet

            • 'ZoneName'<~String> - Name of the Availability Zone

            • 'LoadBalancerAddresses'<~Array>:

              • 'IpAddress'<~String> - IP address

              • 'AllocationId'<~String> - ID of the AWS allocation

          • '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

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

          • 'SecurityGroups'<~Array> - array of security group id

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

# File lib/fog/aws/requests/elbv2/describe_load_balancers.rb, line 34
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::ELBV2::DescribeLoadBalancers.new
  }.merge!(options))
end
describe_tags(resource_arns) click to toggle source

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

Parameters

  • resource_arns <~Array> - ARN(s) of the ELB instance whose tags are to be retrieved

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

# File lib/fog/aws/requests/elbv2/describe_tags.rb, line 14
def describe_tags(resource_arns)
  request({
      'Action' => 'DescribeTags',
      :parser  => Fog::Parsers::AWS::ELBV2::DescribeTags.new
    }.merge!(Fog::AWS.indexed_param('ResourceArns.member.%d', [*resource_arns]))
  )
end
remove_tags(resource_arn, keys) click to toggle source

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

Parameters

  • resource_arn <~String> - ARN 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/elbv2/remove_tags.rb, line 15
def remove_tags(resource_arn, keys)
  request(
    { 'Action'                      => 'RemoveTags',
      'ResourceArns.member.1'  => resource_arn,
      :parser => Fog::Parsers::AWS::ELBV2::Empty.new,
    }.merge(Fog::AWS.indexed_param('TagKeys.member.%d', keys))
  )
end