From e0856a601131b44addf2719d0d2d39486c82709c Mon Sep 17 00:00:00 2001 From: Samseppiol Date: Mon, 11 Jan 2021 14:16:01 +1100 Subject: [PATCH] Pass saml_arn to config, fix logger commands, set default dns servers as empty array to avoid nil class error when using .any --- lib/cfnvpn/actions/init.rb | 7 ++++--- lib/cfnvpn/templates/vpn.rb | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/cfnvpn/actions/init.rb b/lib/cfnvpn/actions/init.rb index 8441fe3..17ebb39 100644 --- a/lib/cfnvpn/actions/init.rb +++ b/lib/cfnvpn/actions/init.rb @@ -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' @@ -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 diff --git a/lib/cfnvpn/templates/vpn.rb b/lib/cfnvpn/templates/vpn.rb index 6fe1188..b9ee97b 100644 --- a/lib/cfnvpn/templates/vpn.rb +++ b/lib/cfnvpn/templates/vpn.rb @@ -11,7 +11,6 @@ def initialize def render(name, config) Description "cfnvpn #{name} AWS Client-VPN" - Parameter(:AssociateSubnets) { Type 'String' Default 'true' @@ -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' @@ -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: [