def egress_opts args
ensure_vpc do
last = args.last
if last.is_a?(Hash) and (last.key?(:protocol) or last.key?(:ports))
options = args.pop
else
options = {}
end
opts = {}
opts[:ip_protocol] = [nil,:any, '-1'].include?(options[:protocol]) ?
'-1' : options[:protocol].to_s.downcase
if options[:ports]
if options[:ports].is_a?(Range)
ports = options[:ports]
else
ports = Array(options[:ports])
end
opts[:from_port] = ports.first.to_i
opts[:to_port] = ports.last.to_i
end
ips, groups = parse_sources(args)
opts[:ip_ranges] = ips unless ips.empty?
opts[:user_id_group_pairs] = groups unless groups.empty?
opts
end
end