Skip to content
Browse files

Add an AWS Elastic LB provider.

  • Loading branch information...
1 parent 34861f7 commit ee6f1d4a09f5d592fcc71cd3d31066176009b8e1 @jjhuff jjhuff committed with jtimberman Dec 9, 2011
Showing with 54 additions and 1 deletion.
  1. +29 −1 aws/README.md
  2. +20 −0 aws/providers/elastic_lb.rb
  3. +5 −0 aws/resources/elastic_lb.rb
View
30 aws/README.md
@@ -5,6 +5,7 @@ This cookbook provides libraries, resources and providers to configure and manag
* EBS Volumes (`ebs_volume`)
* Elastic IPs (`elastic_ip`)
+* Elastic Load Balancer (`elastic_lb`)
Requirements
============
@@ -105,6 +106,18 @@ Attribute Parameters:
* `ip` - the IP address.
* `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
=====
@@ -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.
+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
==================
Author:: Chris Walters (<cw@opscode.com>)
Author:: AJ Christensen (<aj@opscode.com>)
+Author:: Justin Huff (<jjhuff@mspin.net>)
Copyright 2009-2010, Opscode, Inc.
@@ -198,4 +226,4 @@ Changes
* [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-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
View
20 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
+
View
5 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 ee6f1d4

Please sign in to comment.
Something went wrong with that request. Please try again.