Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5 from aibou/feature/over-100-rules
Browse files Browse the repository at this point in the history
Fix a bug: can not export over 100 rules #4
  • Loading branch information
aibou authored Jun 1, 2018
2 parents 360ecf2 + 6ccacad commit cd58db1
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions lib/monosasi/exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,28 @@ def export

def export_rules
rule_by_name = {}
resp = @client.list_rules
next_token = nil
loop do
resp = @client.list_rules(next_token: next_token)

Parallel.each(resp.rules, in_threads: CONCURRENCY) do |rule|
rule = rule.to_h
rule.delete(:arn)
rule_name = rule.delete(:name)
Parallel.each(resp.rules, in_threads: CONCURRENCY) do |rule|
rule = rule.to_h
rule.delete(:arn)
rule_name = rule.delete(:name)

next unless target?(rule_name)
next unless target?(rule_name)

if rule[:event_pattern]
rule[:event_pattern] = JSON.parse(rule[:event_pattern])
end
if rule[:event_pattern]
rule[:event_pattern] = JSON.parse(rule[:event_pattern])
end

targets = export_targets(rule_name)
rule[:targets] = targets

targets = export_targets(rule_name)
rule[:targets] = targets
rule_by_name[rule_name] = rule
end

rule_by_name[rule_name] = rule
break if (next_token = resp.next_token).nil?
end

rule_by_name
Expand Down

0 comments on commit cd58db1

Please sign in to comment.