diff --git a/lib/puppet/provider/ec2_instance/v2.rb b/lib/puppet/provider/ec2_instance/v2.rb index f9e18375..45ef0b9d 100644 --- a/lib/puppet/provider/ec2_instance/v2.rb +++ b/lib/puppet/provider/ec2_instance/v2.rb @@ -16,7 +16,7 @@ def self.instances response.data.reservations.each do |reservation| reservation.instances.each do |instance| hash = instance_to_hash(region, instance) - instances << new(hash) if (hash[:name] and ! hash[:name].empty?) + instances << new(hash) if has_name?(hash) end end end diff --git a/lib/puppet/provider/ec2_vpc/v2.rb b/lib/puppet/provider/ec2_vpc/v2.rb index 9fc778f1..f52bebf1 100644 --- a/lib/puppet/provider/ec2_vpc/v2.rb +++ b/lib/puppet/provider/ec2_vpc/v2.rb @@ -13,7 +13,7 @@ def self.instances vpcs = [] response.data.vpcs.each do |vpc| hash = vpc_to_hash(region, vpc) - vpcs << new(hash) if hash[:name] + vpcs << new(hash) if has_name?(hash) end vpcs end.flatten diff --git a/lib/puppet/provider/ec2_vpc_dhcp_options/v2.rb b/lib/puppet/provider/ec2_vpc_dhcp_options/v2.rb index ebefeac1..e6c15689 100644 --- a/lib/puppet/provider/ec2_vpc_dhcp_options/v2.rb +++ b/lib/puppet/provider/ec2_vpc_dhcp_options/v2.rb @@ -13,7 +13,7 @@ def self.instances ec2_client(region).describe_dhcp_options.collect do |response| response.data.dhcp_options.each do |item| hash = dhcp_option_to_hash(region, item) - options << new(hash) if hash[:name] + options << new(hash) if has_name?(hash) end end options diff --git a/lib/puppet/provider/ec2_vpc_internet_gateway/v2.rb b/lib/puppet/provider/ec2_vpc_internet_gateway/v2.rb index a7ed6d6a..0a8b170e 100644 --- a/lib/puppet/provider/ec2_vpc_internet_gateway/v2.rb +++ b/lib/puppet/provider/ec2_vpc_internet_gateway/v2.rb @@ -13,7 +13,7 @@ def self.instances gateways = [] response.data.internet_gateways.each do |gateway| hash = gateway_to_hash(region, gateway) - gateways << new(hash) if hash[:name] + gateways << new(hash) if has_name?(hash) end gateways end.flatten diff --git a/lib/puppet/provider/ec2_vpc_routetable/v2.rb b/lib/puppet/provider/ec2_vpc_routetable/v2.rb index e7df98d2..74376fe4 100644 --- a/lib/puppet/provider/ec2_vpc_routetable/v2.rb +++ b/lib/puppet/provider/ec2_vpc_routetable/v2.rb @@ -13,7 +13,7 @@ def self.instances tables = [] response.data.route_tables.each do |table| hash = route_table_to_hash(region, table) - tables << new(hash) if hash[:name] + tables << new(hash) if has_name?(hash) end tables end.flatten diff --git a/lib/puppet/provider/ec2_vpc_subnet/v2.rb b/lib/puppet/provider/ec2_vpc_subnet/v2.rb index b6b7b1fa..666b5cff 100644 --- a/lib/puppet/provider/ec2_vpc_subnet/v2.rb +++ b/lib/puppet/provider/ec2_vpc_subnet/v2.rb @@ -13,7 +13,7 @@ def self.instances subnets = [] response.data.subnets.each do |subnet| hash = subnet_to_hash(region, subnet) - subnets << new(hash) if hash[:name] + subnets << new(hash) if has_name?(hash) end subnets end.flatten diff --git a/lib/puppet/provider/ec2_vpc_vpn/v2.rb b/lib/puppet/provider/ec2_vpc_vpn/v2.rb index 108a6ab8..e2907f18 100644 --- a/lib/puppet/provider/ec2_vpc_vpn/v2.rb +++ b/lib/puppet/provider/ec2_vpc_vpn/v2.rb @@ -15,7 +15,7 @@ def self.instances() ]).each do |response| response.data.vpn_connections.each do |connection| hash = connection_to_hash(region, connection) - connections << new(hash) if hash[:name] + connections << new(hash) if has_name?(hash) end end connections diff --git a/lib/puppet/provider/ec2_vpc_vpn_gateway/v2.rb b/lib/puppet/provider/ec2_vpc_vpn_gateway/v2.rb index 04f74d06..c8410dac 100644 --- a/lib/puppet/provider/ec2_vpc_vpn_gateway/v2.rb +++ b/lib/puppet/provider/ec2_vpc_vpn_gateway/v2.rb @@ -15,9 +15,7 @@ def self.instances() ]).each do |response| response.data.vpn_gateways.each do |gateway| hash = gateway_to_hash(region, gateway) - if hash[:name] - gateways << new(hash) - end + gateways << new(hash) if has_name?(hash) end end gateways diff --git a/lib/puppet_x/puppetlabs/aws.rb b/lib/puppet_x/puppetlabs/aws.rb index 9bb66ecc..b6e4b48a 100644 --- a/lib/puppet_x/puppetlabs/aws.rb +++ b/lib/puppet_x/puppetlabs/aws.rb @@ -110,6 +110,10 @@ def tags=(value) ) unless missing_tags.empty? end + def self.has_name?(hash) + !hash[:name].nil? && !hash[:name].empty? + end + end end end