class CfnVpn::Actions::Subnets

Public Instance Methods

associate() click to toggle source
# File lib/cfnvpn/actions/subnets.rb, line 34
def associate
  if @options[:associate]
    if !@associated
      CfnVpn::Log.logger.info "Associating subnets ..."
      change_set, change_set_type = @deployer.create_change_set(parameters: {"AssociateSubnets" => 'true'})
      @deployer.wait_for_changeset(change_set.id)
      @deployer.execute_change_set(change_set.id)
      @deployer.wait_for_execute(change_set_type)
      CfnVpn::Log.logger.info "Association complete"
    else
      CfnVpn::Log.logger.warn "Client-VPN #{name} subnets are already associated"
    end
  end
end
associated?() click to toggle source
# File lib/cfnvpn/actions/subnets.rb, line 30
def associated?
  @associated = @deployer.get_parameter_value('AssociateSubnets') == 'true'
end
associations() click to toggle source
# File lib/cfnvpn/actions/subnets.rb, line 69
def associations
  associations = @vpn.get_associations(@endpoint_id)
  table = Terminal::Table.new(
    :headings => ['ID', 'Subnet', 'Status', 'CIDR', 'AZ', 'Groups'],
    :rows => associations.map {|ass| ass.values})
  puts table
end
disassociate() click to toggle source
# File lib/cfnvpn/actions/subnets.rb, line 49
def disassociate
  if @options[:disassociate]
    if @associated
      CfnVpn::Log.logger.info "Disassociating subnets ..."
      change_set, change_set_type = @deployer.create_change_set(parameters: {"AssociateSubnets" => 'false'})
      @deployer.wait_for_changeset(change_set.id)
      @deployer.execute_change_set(change_set.id)
      @deployer.wait_for_execute(change_set_type)
      CfnVpn::Log.logger.info "Disassociation complete"
    else
      CfnVpn::Log.logger.warn "Client-VPN #{name} subnets are already disassociated"
    end
  end
end
get_endpoint() click to toggle source
# File lib/cfnvpn/actions/subnets.rb, line 64
def get_endpoint
  @vpn = CfnVpn::ClientVpn.new(@name,@options['region'])
  @endpoint_id = @vpn.get_endpoint_id()
end
set_loglevel() click to toggle source
# File lib/cfnvpn/actions/subnets.rb, line 18
def set_loglevel
  CfnVpn::Log.logger.level = Logger::DEBUG if @options['verbose']
end
stack_exist() click to toggle source
# File lib/cfnvpn/actions/subnets.rb, line 22
def stack_exist
  @deployer = CfnVpn::Deployer.new(@options['region'],@name)
  if !@deployer.does_cf_stack_exist()
    CfnVpn::Log.logger.error "#{@name}-cfnvpn stack doesn't exists in this account and region #{@options['region']}"
    exit 1
  end
end