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

support creating routes for multiple subnets #15

Merged
merged 1 commit into from
Dec 15, 2021

Conversation

Guslington
Copy link
Contributor

@Guslington Guslington commented Dec 10, 2021

  • When creating routes (dns and static) change the default behavior of creating a route with single subnet when multiple subnets have been assigned to the vpn to creating routes for all subnets assigned to the vpn.
  • reduce the amount of api calls to the AWS API to retrieve the vpn endpoint id when the initializer will do this by exposing the endpoint_id attribute
  • automatically change routes to create routes all assigned subnets when updating

@Guslington Guslington force-pushed the feature/ha-route-populator branch from 732e2d9 to 5475bb4 Compare December 10, 2021 00:21
Copy link
Contributor

@Samseppiol Samseppiol left a comment

Choose a reason for hiding this comment

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

few questions @Guslington

end

def get_groups_for_route(endpoint, cidr)
def get_auth_rules(dns_route=nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

is dns route the correct variable here and in the ensuing loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dns_route variable is used here because the value is the dns endpoint that is used to generate the routes. This function searches for authorisation rules with the value of dns_route in the description.

@@ -42,9 +42,8 @@ def revoke_certificate

def apply_rekocation_list
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming this should be revocation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol v and k and not even close on the keyboard, i'll resolve this in a separate PR

@@ -163,27 +163,31 @@ def deploy_vpn
end
end

def get_routes
@vpn = CfnVpn::ClientVpn.new(@name, @options['region'])
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this supposed to exist? And if so what does it do? I can see @vpn gets used below in other code, not sure of the connection to this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a Thor Actions implementation include Thor::Actions https://github.com/rails/thor/wiki/Actions

Thor doco is not great but it's basically executing each of these methods in the class from top to bottom. The method name is poorly worded it should be def setup. What it's doing is setting an instance of the ClientVpn class which can then be consumed further down the line.

@@ -29,20 +29,19 @@ def set_directory
@build_dir = "#{CfnVpn.cfnvpn_path}/#{@name}"
end

def get_endpoint
def setup
Copy link
Contributor

Choose a reason for hiding this comment

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

same thing here, is this a thor thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see above

})
return resp.client_configuration
end

def get_rekove_list(endpoint_id)
def get_rekove_list()
Copy link
Contributor

Choose a reason for hiding this comment

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

revoke

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will fix this name in a separate PR. This repo needs a going over with my new found spell checker

}
# to aide in the migration from single to HA routes if the vpn is HA
if route[:subnets]
target_subnets = route[:subnets]
Copy link
Contributor

Choose a reason for hiding this comment

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

This comes across a little confusing with the naming 'target_subnets', at first I thought it was a duplication of the changes above but it appears to be different functionality. Maybe worth changing the naming or am I being pedantic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's the same thing but implemented in a different way.

  • dns_routes are auto generated by the lambda route populator
  • cidr_routes are static routes which can be created through cloudformation

Client vpn routes are created by routing a cidr to what AWS refer to as a "Target Subnet" which is just a subnet in a vpc

EC2_ClientVpnRoute(...) {
  DestinationCidrBlock ...
  TargetVpcSubnetId ...
}

Copy link
Contributor

@Samseppiol Samseppiol left a comment

Choose a reason for hiding this comment

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

lgtm

@Guslington Guslington merged commit 743db8f into master Dec 15, 2021
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.

Auto route populator create HA routes if multiple subnets are provided
2 participants