Skip to content

Commit

Permalink
Merge pull request #6 from Samseppiol/master
Browse files Browse the repository at this point in the history
Bug fixes for federated vpns
  • Loading branch information
Guslington authored Jan 18, 2021
2 parents b218c67 + e0856a6 commit 6c7fc8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 4 additions & 3 deletions lib/cfnvpn/actions/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Init < Thor::Group

class_option :subnet_ids, required: true, type: :array, desc: 'subnet id to associate your vpn with'
class_option :cidr, default: '10.250.0.0/16', desc: 'cidr from which to assign client IP addresses'
class_option :dns_servers, type: :array, desc: 'DNS Servers to push to clients.'
class_option :dns_servers, default: [], type: :array, desc: 'DNS Servers to push to clients.'

class_option :split_tunnel, type: :boolean, default: true, desc: 'only push routes to the client on the vpn endpoint'
class_option :internet_route, type: :string, desc: '[subnet-id] create a default route to the internet through a subnet'
Expand Down Expand Up @@ -60,19 +60,20 @@ def initialize_config
protocol: @options['protocol'],
start: @options['start'],
stop: @options['stop'],
saml_arn: @options['saml_arn'],
routes: []
}
end

def set_type
@config[:type] = @options['saml_arn'] ? 'federated' : 'certificate'
Log.logger.info "intialising #{@config[:type]} client vpn"
CfnVpn::Log.logger.info "initialising #{@config[:type]} client vpn"
end

def conditional_options_check
if @config[:type] == 'certificate'
if !@options['bucket']
Log.logger.error "--bucket option must be specified if creating a client vpn with certificate based authentication"
CfnVpn::Log.logger.error "--bucket option must be specified if creating a client vpn with certificate based authentication"
exit 1
end
end
Expand Down
5 changes: 2 additions & 3 deletions lib/cfnvpn/templates/vpn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def initialize

def render(name, config)
Description "cfnvpn #{name} AWS Client-VPN"

Parameter(:AssociateSubnets) {
Type 'String'
Default 'true'
Expand All @@ -32,7 +31,7 @@ def render(name, config)
if config[:type] == 'federated'
{
FederatedAuthentication: {
SAMLProviderArn: config[:federated],
SAMLProviderArn: config[:saml_arn],
SelfServiceSAMLProviderArn: config[:saml_arn]
},
Type: 'federated-authentication'
Expand All @@ -52,7 +51,7 @@ def render(name, config)
CloudwatchLogGroup: Ref(:ClientVpnLogGroup),
Enabled: true
})
DnsServers config.fetch(:dns_servers, []).any? ? config[:dns_servers] : Ref('AWS::NoValue')
DnsServers config[:dns_servers].any? ? config[:dns_servers] : Ref('AWS::NoValue')
TagSpecifications([{
ResourceType: "client-vpn-endpoint",
Tags: [
Expand Down

0 comments on commit 6c7fc8e

Please sign in to comment.