Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

Commit

Permalink
Add an AWS Elastic LB provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjhuff authored and jtimberman committed Dec 15, 2011
1 parent 85325c9 commit 6530891
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
30 changes: 29 additions & 1 deletion aws/README.md
Expand Up @@ -5,6 +5,7 @@ This cookbook provides libraries, resources and providers to configure and manag


* EBS Volumes (`ebs_volume`) * EBS Volumes (`ebs_volume`)
* Elastic IPs (`elastic_ip`) * Elastic IPs (`elastic_ip`)
* Elastic Load Balancer (`elastic_lb`)


Requirements Requirements
============ ============
Expand Down Expand Up @@ -105,6 +106,18 @@ Attribute Parameters:
* `ip` - the IP address. * `ip` - the IP address.
* `timeout` - connection timeout for EC2 API. * `timeout` - connection timeout for EC2 API.


`elastic_lb.rb`
-------------

Actions:

* `register` - Add this instance to the LB
* `deregister` - Remove this instance from the LB

Attribute Parameters:

* `aws_secret_access_key`, `aws_access_key` - passed to `Opscode::AWS:Ec2` to authenticate, required.
* `name` - the name of the LB, required.


Usage Usage
===== =====
Expand Down Expand Up @@ -168,11 +181,26 @@ This will use the loaded `aws` and `ip_info` databags to pass the required value


You can also store this in a role as an attribute or assign to the node directly, if preferred. You can also store this in a role as an attribute or assign to the node directly, if preferred.


aws_elastic_lb
---------

`elastic_lb` opererates similar to `elastic_ip'. Make sure that you've created the ELB and enabled your instances' availability zones prior to using this provider.

For example, to register the node in the 'QA' ELB:
aws_elastic_lb "elb_qa" do
aws_access_key aws['aws_access_key_id']
aws_secret_access_key aws['aws_secret_access_key']
name "QA"
action :register
end


License and Author License and Author
================== ==================


Author:: Chris Walters (<cw@opscode.com>) Author:: Chris Walters (<cw@opscode.com>)
Author:: AJ Christensen (<aj@opscode.com>) Author:: AJ Christensen (<aj@opscode.com>)
Author:: Justin Huff (<jjhuff@mspin.net>)


Copyright 2009-2010, Opscode, Inc. Copyright 2009-2010, Opscode, Inc.


Expand All @@ -198,4 +226,4 @@ Changes
* [COOK-601] - in aws cookbook :prune action keeps 1 less snapshot than snapshots_to_keep * [COOK-601] - in aws cookbook :prune action keeps 1 less snapshot than snapshots_to_keep
* [COOK-610] - Create Snapshot action in aws cookbook should allow description attribute * [COOK-610] - Create Snapshot action in aws cookbook should allow description attribute
* [COOK-819] - fix documentation bug in aws readme * [COOK-819] - fix documentation bug in aws readme
* [COOK-829] - AWS cookbook does not work with most recent right_aws gem but no version is locked in the recipe * [COOK-829] - AWS cookbook does not work with most recent right_aws gem but no version is locked in the recipe
20 changes: 20 additions & 0 deletions aws/providers/elastic_lb.rb
@@ -0,0 +1,20 @@
include Opscode::Aws::Ec2

action :register do
elb.register_instances_with_load_balancer(new_resource.name, instance_id)
new_resource.updated_by_last_action(true)
Chef::Log.info("Added node to ELB #{new_resource.name}")
end

action :deregister do
Chef::Log.info("Removing node from ELB #{new_resource.name}")
elb.deregister_instances_with_load_balancer(new_resource.name, instance_id)
new_resource.updated_by_last_action(true)
end

private

def elb
@@elb ||= RightAws::ElbInterface.new(new_resource.aws_access_key, new_resource.aws_secret_access_key, { :logger => Chef::Log })
end

5 changes: 5 additions & 0 deletions aws/resources/elastic_lb.rb
@@ -0,0 +1,5 @@
actions :register, :deregister

attribute :aws_access_key, :kind_of => String
attribute :aws_secret_access_key, :kind_of => String
attribute :name, :kind_of => String

0 comments on commit 6530891

Please sign in to comment.