-
-
Notifications
You must be signed in to change notification settings - Fork 554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Security group functionality #379
Conversation
Signed-off-by: S.Cavallo <[email protected]>
Signed-off-by: S.Cavallo <[email protected]>
Signed-off-by: S.Cavallo <[email protected]>
Signed-off-by: S.Cavallo <[email protected]>
Signed-off-by: S.Cavallo <[email protected]>
…ocop warnings Signed-off-by: S.Cavallo <[email protected]>
Signed-off-by: S.Cavallo <[email protected]>
… 8 (not 6) Signed-off-by: S.Cavallo <[email protected]>
…efine a property named 'name' Signed-off-by: S.Cavallo <[email protected]>
…uild Signed-off-by: S.Cavallo <[email protected]>
@smcavallo I left some comments #184 (comment) I'd like to hear more about how this looks from a user story/experience. I am worried that this encourages poor security posture with aws as it would need to be overly permissive to be useful. |
Signed-off-by: S.Cavallo <[email protected]>
@@ -0,0 +1,36 @@ | |||
class Hash | |||
# Removes empty values from a hash | |||
def remove_empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be more clearly written. Here is an (untested) example inspired from rails source:
# Returns a true if an object is nil or empty
# empty_array = []
# empty_hash = {}
# array = [0,1,2]
# hash = { one: 1, two: 2, tree: 3}
# blank?(empty_array) => true
# blank?(empty_hash} => true
# blank?(array) => false
# blank?(hash) => false
# hash.each_pair do |k,v|
# blank?(k) || blank?(v) => false
# end
# empty_hash.each_pair do |k,v|
# blank?(k) || blank?(v) => true
# end
def blank?(obj)
return true if obj.nil? || obj.respond_to(:'empty?') && obj.empty?
false
end
# Replaces the hash without the empty key/values.
# hash = { a: true, b: false, c: nil}
# array = [0, '1', nil]
# remove_blank!(hash) # => { a: true, b: false}
# hash # => { a: true, b: false }
# remove_blank!(array) # => [0, '1']
# array # => [0, '1']
def remove_blanks!(obj)
case obj.class
when 'Hash'
obj.each_pair do |k, v|
delete(key) if blank?(k) || blank?(v)
end
when 'Array'
obj.each do |elem|
delete(elem) if blank?(elem)
end
end
obj
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried those and several variations without any luck. what's the objection with what is in the PR? that it is patching the Hash class? lack of comments? It's 8 lines of code so very small and the usage is very limited - I wasn't too concerned with it however I can make changes if necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No real objection just thought it could be simpler for someone who is not very familiar with ruby development to read. Using &block
and *splat
operators are not intuitive to new ruby developers.
|
||
# => Define the Resource Properties | ||
property :security_group_name, String, name_property: true | ||
property :description, String, default: 'created by chef' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we default to have something that includes the security group name in it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@majormoses - a better option might be to make this a required field with no default. what do you think? it's a required field in aws. I was thinking of adding some code to add the name into the description and it seemed like added code and complexity when we could just ask users to set a description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If aws requires it then I think we should as well. From what I recall these are immutable so its important to get it right the first time.
property :vpc_id, String, required: true | ||
|
||
# Ingress/Egress rules | ||
property :ip_permissions, Array, default: [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add an alias for ip_permissions_ingress
? I get this matches the aws sdk and we should follow that but we should probably make it so that implementers can opt for more explicit and readable code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alias added, thanks
@smcavallo a friendly reminder this is waiting on you to respond to my comments 😉 |
Signed-off-by: S.Cavallo <[email protected]>
@majormoses - thanks for staying on top of this. I went in and made some changes based on your feedback. |
# Conflicts: # .travis.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Adds the ability to manage security groups
Issues Resolved
#184
Check List