From cc16d406d85d3fec7709f2e1b5a97465871e263e Mon Sep 17 00:00:00 2001 From: Iristyle Date: Tue, 17 Mar 2015 19:12:01 -0700 Subject: [PATCH] (maint) Improve security_group create error msg - Share count amongst multiple spots, emit the number of matching groups for a given name --- lib/puppet/provider/ec2_securitygroup/v2.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/ec2_securitygroup/v2.rb b/lib/puppet/provider/ec2_securitygroup/v2.rb index 6c6943cf..414167e5 100644 --- a/lib/puppet/provider/ec2_securitygroup/v2.rb +++ b/lib/puppet/provider/ec2_securitygroup/v2.rb @@ -138,9 +138,10 @@ def authorize_ingress(new_rules, existing_rules=[]) filters.push( {name: 'vpc-id', values: [vpc_id]} ) end group_response = ec2.describe_security_groups(filters: filters) - fail("No groups found called #{source_group_name}") if group_response.data.security_groups.count == 0 + match_count = group_response.data.security_groups.count + fail("No groups found called #{source_group_name}") if match_count == 0 source_group_id = group_response.data.security_groups.first.group_id - Puppet.warning "Multiple groups found called #{source_group_name}, using #{source_group_id}" if group_response.data.security_groups.count > 1 + Puppet.warning "#{match_count} groups found called #{source_group_name}, using #{source_group_id}" if match_count > 1 permissions = ['tcp', 'udp', 'icmp'].collect do |protocol| {