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

Bug fixes for federated vpns #6

Merged
merged 1 commit into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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