Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
(maint) Improve security_group create error msg
Browse files Browse the repository at this point in the history
 - Share count amongst multiple spots, emit the number of matching
   groups for a given name
  • Loading branch information
Iristyle committed Mar 18, 2015
1 parent 9c4ff92 commit cc16d40
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/puppet/provider/ec2_securitygroup/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
{
Expand Down

0 comments on commit cc16d40

Please sign in to comment.