Skip to content

Commit

Permalink
Added support for instance tag constraints in EC2 Discovery
Browse files Browse the repository at this point in the history
The `aws` data bag can now have a structure at `discovery.ec2.tag` that contains EC2 instance tag
values keyed by tag name. Any tag specified will be required for an EC2 instance to
be discoverable by the plugin.

Closes #66
  • Loading branch information
JustinTArthur authored and karmi committed Feb 27, 2013
1 parent 2122ab0 commit 71dc02b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions attributes/aws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@
default.elasticsearch[:cloud][:aws][:region] = ( aws['cloud']['aws']['region'] rescue nil )
default.elasticsearch[:cloud][:ec2][:endpoint] = ( aws['cloud']['ec2']['endpoint'] rescue nil )

discovery_tags = ( aws['discovery']['ec2']['tag'] rescue [] )
discovery_tags.each do |tag_name, tag_value|
default.elasticsearch[:discovery][:ec2][:tag][tag_name] = tag_value
end

default.elasticsearch[:cloud][:node][:auto_attributes] = true
4 changes: 3 additions & 1 deletion templates/default/elasticsearch.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
<%= print_value 'discovery.zen.ping.unicast.hosts' -%>

<%- if node.elasticsearch[:cloud] -%>
# AWS Discovery
<%= print_value 'cloud.node.auto_attributes' -%>
<%= print_value 'cloud.aws.access_key' %>
<%= print_value 'cloud.aws.secret_key' %>
Expand All @@ -97,6 +96,9 @@
<%= print_value 'discovery.ec2.availability_zones' -%>
<%= print_value 'discovery.ec2.any_group' -%>
<%= print_value 'discovery.ec2.ping_timeout' -%>
<%- node.elasticsearch[:discovery][:ec2][:tag].sort.each do |key, value| -%>
discovery.ec2.tag.<%= key %>: <%= value %>
<%- end unless node.elasticsearch[:discovery][:ec2][:tag].keys.empty? rescue false -%>
<%- end -%>

################################## Slow Log ###################################
Expand Down

0 comments on commit 71dc02b

Please sign in to comment.