Skip to content
This repository was archived by the owner on Oct 7, 2022. It is now read-only.

WARNING over 50 rules per securitygroup. #26

Open
wants to merge 1 commit into
base: 0.3.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion lib/piculet/dsl/security-group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Piculet
class DSL
class EC2
class SecurityGroup
include Logger::ClientHelper
include Piculet::TemplateHelper

def initialize(context, name, vpc, &block)
Expand Down Expand Up @@ -51,6 +52,15 @@ def ingress(&block)
end

@result.ingress = Permissions.new(@context, @name, :ingress, &block).result
rule_cnt = @result.ingress.reduce(0) {
|sum , o|
sum +
(o.ip_ranges.nil? ? 0 : o.ip_ranges.length()) +
(o.groups.nil? ? 0 : o.groups.length())
}
if rule_cnt > 50
log(:warn, "`#{@vpc}.#{@name}`: ingress too many #{rule_cnt} " , :yellow)
end
@ingress_is_defined = true
end

Expand All @@ -64,7 +74,15 @@ def egress(&block)
end

@result.egress = Permissions.new(@context, @name, :egress, &block).result

rule_cnt = @result.egress.reduce(0) {
|sum , o|
sum +
(o.ip_ranges.nil? ? 0 : o.ip_ranges.length()) +
(o.groups.nil? ? 0 : o.groups.length())
}
if rule_cnt > 50
log(:warn, "`#{@vpc}.#{@name}`: egress too many #{rule_cnt} " , :yellow)
end
@egress_is_defined = true
end
end # SecurityGroup
Expand Down