Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable configuration of ELB health check parameters. #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ search:
action :create
end

You can configure the `health check` parameters from the defaults by specifying
the `health_check` attribute with a hash:

elb_load_balancer "ap-tcp-frontend" do
aws_access_key aws['aws_access_key_id']
aws_secret_access_key aws['aws_secret_access_key']
instances ['i-xxxxx', 'i-xxxxx']
region 'ap-southeast-1'
listeners [{"InstancePort" => 1234, "Protocol" => "TCP", "LoadBalancerPort" => 1234}]
health_check [{"HealthyThreshold" => 10, "Interval" => 30, "Target" => "HTTP:80/ping", "Timeout" => 5, "UnhealthyThreshold" =>2}]
action :create
end

You can also do SSL, but it's a little funky.

First, you have to [upload your cert](http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/DeveloperGuide/index.html?US_SettingUpLoadBalancerHTTPSIntegrated.html).
Expand Down
15 changes: 15 additions & 0 deletions providers/load_balancer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ def load_current_resource
end
new_resource.updated_by_last_action(true)

configure_successful = false
ruby_block "Configure ELB #{new_resource.lb_name}" do
block do
response = elb.configure_health_check(new_resource.lb_name, new_resource.health_check.first)
if response.status != 200
Chef::Log::fatal!("Configuring load balancer health check returned " << response.status.to_s)
else
Chef::Log::debug("Configure load balancer health check succeeded: \n" << response.body.to_s)
configure_successful = true
end
end
action :create
end
new_resource.updated_by_last_action(configure_successful)

instances_to_add = new_resource.instances - current_resource.instances
instances_to_delete = current_resource.instances - new_resource.instances

Expand Down
3 changes: 2 additions & 1 deletion resources/load_balancer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
attribute :listeners, :kind_of => Array, :default => [{"InstancePort" => 80, "Protocol" => "HTTP", "LoadBalancerPort" => 80}]
attribute :instances, :kind_of => Array
attribute :search_query, :kind_of => String
attribute :timeout, :default => 60
attribute :timeout, :default => 60
attribute :health_check, :kind_of => Array, :default => [{"HealthyThreshold" => 10, "Interval" => 30, "Target" => "HTTP:80/", "Timeout" => 5, "UnhealthyThreshold" => 2}]