瀏覽代碼

setup relationships has a todo

Chris Mague 7 年之前
父節點
當前提交
1d111684ba
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      lib/neoinfra/aws.rb

+ 12 - 0
lib/neoinfra/aws.rb

@@ -172,6 +172,18 @@ module NeoInfra
                       )
                       rl.save
                     end
+                    # TODO: remove duplicate Relationships
+                    SecurityGroupsIpRules.create(
+                      from_node: SecurityGroup.where(sg_id: grp.group_id).first,
+                      to_node: IpRules.where(
+                        cidr_block: r['cidrIp'],
+                        direction: 'ingress',
+                        proto: iprule['ipProtocol'],
+                        to_port: to_port,
+                        from_port: from_port,
+                        private: RFC_1918.any? { |rfc| rfc.include?(IPAddr.new(r['cidrIp']))}
+                      ).first
+                    )
                   end
                 end
               end