Skip to content
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

Merged
merged 13 commits into from
Jun 11, 2019

Conversation

smcavallo
Copy link
Contributor

Description

Adds the ability to manage security groups

Issues Resolved

#184

Check List

README.md Show resolved Hide resolved
@majormoses
Copy link
Contributor

@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.

@@ -0,0 +1,36 @@
class Hash
# Removes empty values from a hash
def remove_empty
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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'
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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: []
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alias added, thanks

@majormoses
Copy link
Contributor

@smcavallo a friendly reminder this is waiting on you to respond to my comments 😉

@smcavallo
Copy link
Contributor Author

@majormoses - thanks for staying on top of this. I went in and made some changes based on your feedback.

Copy link
Contributor

@majormoses majormoses left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@majormoses majormoses merged commit b4779af into sous-chefs:master Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants