Skip to content

Instantly share code, notes, and snippets.

@lukedemi
Created February 2, 2017 21:26
Show Gist options
  • Save lukedemi/cb79c396596998b604d13384a453b4bc to your computer and use it in GitHub Desktop.
Save lukedemi/cb79c396596998b604d13384a453b4bc to your computer and use it in GitHub Desktop.
def validate_statement_ip_restrictions(statement)
errors = []
if statement.ip_restrictions.empty?
errors << "IPAddress Condition aws:SourceIP must contain cidr blocks"
else
for cidr_block in statement.ip_restrictions
if !valid_cidr?(cidr_block)
errors << "#{cidr_block} is not included in the valid_cidr array for this environment"
end
end
end
errors
end
def valid_cidr?(cidr_block)
return true if env.valid_cidr_blocks.flatten.include?(cidr_block)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment