From 94d7c7bf657d0b4c0b6d59e0cd09bf1ff5654f12 Mon Sep 17 00:00:00 2001 From: Nathaniel Eliot Date: Thu, 12 Apr 2012 17:57:51 -0500 Subject: [PATCH] Downcase all group names to force case-insensitive matching of security groups, fixes #86 --- lib/ironfan/security_group.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ironfan/security_group.rb b/lib/ironfan/security_group.rb index 03047254..a1541a67 100644 --- a/lib/ironfan/security_group.rb +++ b/lib/ironfan/security_group.rb @@ -28,7 +28,10 @@ def self.all def self.get_all groups_list = Ironfan.fog_connection.security_groups.all @@all = groups_list.inject(Mash.new) do |hsh, fog_group| - hsh[fog_group.name] = fog_group ; hsh + # AWS security_groups are strangely case sensitive, allowing upper-case but colliding regardless + # of the case. This forces all names to lowercase, and matches against that below. + # See https://github.com/infochimps-labs/ironfan/pull/86 for more details. + hsh[fog_group.name.downcase] = fog_group ; hsh end end @@ -37,6 +40,7 @@ def get end def self.get_or_create(group_name, description) + group_name = group_name.to_s.downcase # FIXME: the '|| Ironfan.fog' part is probably unnecessary fog_group = all[group_name] || Ironfan.fog_connection.security_groups.get(group_name) unless fog_group