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

EC2 Security Group Rule Automation #32

Open
wants to merge 38 commits into
base: master
Choose a base branch
from

Conversation

citruspi
Copy link
Contributor

@citruspi citruspi commented May 5, 2015

This adds support for automating the addition of inbound rules to EC2 security groups. The modifications are append only, rules are not deleted.

It supports the re-use of a security group definition across multiple environments and groups through the use of regular expression rules and string formatting.

Sample definitions for Cache servers, MongoDB servers, and the Management and Chef-Nodes groups are included. These definitions have been used to successfully recreate the test environment security group for Cache servers from scratch and to spin up a MongoDB replica set in the stage environment for a new group without any work on the user's part.

The rule source can be expressed as the name of a security group, an IPv4 address, or a CIDR IP. Security Group ID's are not supported.

citruspi added 30 commits May 3, 2015 20:27
@citruspi citruspi self-assigned this May 5, 2015
@citruspi citruspi added this to the VPC Migration milestone May 5, 2015
'rules': [
{
'port': 22,
'source': 'p-ops-vpn'
Copy link
Contributor

Choose a reason for hiding this comment

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

Why have this in chef-nodes also? It's in management already

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I was just looking at the rules in chef-nodes and I didn't look for duplicate rules. I'll remove that.

'source': [
'p-ops-vpn',
'216.229.9.101/32',
'76.84.137.182/32',
Copy link
Contributor

Choose a reason for hiding this comment

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

could we add all offices to all of these rules?

citruspi added 6 commits May 20, 2015 15:59
* master: (62 commits)
  Added the missing subnet_id argument to replace_server
  Specified the private key paths when establishing SSH connections
  Updated the old DNS entry with the private DNS name
  Replaced use of the public DNS name with the private DNS name
  Added an argument for a accessible address when adding an instance
  Added an option to block on the route call until the DNS propagates
  Established the connection property using the private DNS name
  Fixed support for the subnet_id argument when spinning up the new node
  Set the default group to None
  removing documentation changes
  removing documentation changes
  removing documentation changes
  updating /etc/hosts entry to include localhost
  Added support for the dns_zones argument to the Nginx server
  Added the subnet_id argument to the MongoDB replacement module
  Fixed the placement of the subnet_id argument
  Changed the DNS record formatting parameter 'id' to 'instance_id'
  add vpc support to nginx spin up
  Removed log statements with the new node's properties
  Set the default arguments for node creation for MongoDB replacement to None
  ...

Conflicts:
	tyr/servers/server.py
@citruspi
Copy link
Contributor Author

I've added support for constants, which are basically variables, so I'm not sure why I named them constants.

Anyway, they allow you to define values for strings which are then substituted in. constants always start with @. So, instead of having a rule

{
    'port': 22,
    'source': [
        'p-ops-vpn',
        '216.229.9.101/32',
    ]
}

where you're not sure what 216.229.9.101/32 is for, you can now have a rule like

{
    'port': 22,
    'source': [
        'p-ops-vpn',
        '@hudl-lincoln-east',
    ]
}

The value 216.229.9.101/32 will then be inserted when the rule is being compiled.

For what it's worth, I'm not sure why you'd want to do this, but the values can be anything - you could map a value to another security group.

},
{
'rule': '[ts]-.+-cache',
'value': '@hudl-boston'
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be cool to have an option of an values array to supply multiple.. It'd clean up a few of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I thought of that yesterday. I just wasn't sure how much time I should spend on this pull request, but it shouldn't take too long to get that in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants