Browse Source

handle hanging subnets

Chris Mague 7 years ago
parent
commit
5c43c9e697
1 changed files with 7 additions and 1 deletions
  1. 7 1
      lib/neoinfra/vpcs.rb

+ 7 - 1
lib/neoinfra/vpcs.rb

@@ -75,7 +75,13 @@ module NeoInfra
             )
             )
             sn.save
             sn.save
             VpcSubnet.create(from_node: sn, to_node: Vpc.where(vpc_id: subnet.vpc_id).first)
             VpcSubnet.create(from_node: sn, to_node: Vpc.where(vpc_id: subnet.vpc_id).first)
-            SubnetAz.create(from_node: sn, to_node: Az.where(az: subnet.availability_zone).first)
+            begin
+              SubnetAz.create(from_node: sn, to_node: Az.where(az: subnet.availability_zone).first)
+            rescue
+              #  Handle the case of hanging subnets
+              puts "Account #{account[:name]} couldn't load the following subnet:"
+              p subnet
+            end
           end
           end
         end
         end
       end
       end