Class: CfnGuardian::Resource::InternalSFTP

Inherits:
Base
  • Object
show all
Defined in:
lib/cfnguardian/resources/internal_sftp.rb

Instance Method Summary collapse

Methods inherited from Base

#default_event_subscriptions, #default_metric_filters, #get_alarms, #get_checks, #get_cost, #get_event_subscriptions, #get_events, #get_metric_filters, #resource_exists?

Methods included from Logging

colors, included, logger, #logger, logger=

Constructor Details

#initialize(resource, override_group = nil) ⇒ InternalSFTP

Returns a new instance of InternalSFTP.



4
5
6
7
8
# File 'lib/cfnguardian/resources/internal_sftp.rb', line 4

def initialize(resource, override_group = nil)
  super(resource, override_group)
  @resource_list = resource['Hosts']
  @environment = resource['Environment']
end

Instance Method Details

#default_alarmsObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cfnguardian/resources/internal_sftp.rb', line 10

def default_alarms
  @resource_list.each do |host|
    alarm = CfnGuardian::Models::InternalSFTPAlarm.new(host)
    alarm.name = 'Available'
    alarm.metric_name = 'Available'
    @alarms.push(alarm)
    
    alarm = CfnGuardian::Models::InternalSFTPAlarm.new(host)
    alarm.name = 'ConnectionTime'
    alarm.metric_name = 'ConnectionTime'
    alarm.comparison_operator = 'GreaterThanThreshold'
    alarm.statistic = 'Minimum'
    alarm.threshold = 1000
    @alarms.push(alarm)
    
    if host.has_key?('File')
      alarm = CfnGuardian::Models::InternalSFTPAlarm.new(host)
      alarm.name = 'FileExists'
      alarm.metric_name = 'FileExists'
      @alarms.push(alarm)
    
      alarm = CfnGuardian::Models::InternalSFTPAlarm.new(host)
      alarm.name = 'FileGetTime'
      alarm.metric_name = 'FileGetTime'
      alarm.comparison_operator = 'GreaterThanThreshold'
      alarm.statistic = 'Minimum'
      alarm.threshold = 1000
      @alarms.push(alarm)
      
      if host.has_key?('FileBodyMatch')
        alarm = CfnGuardian::Models::InternalSFTPAlarm.new(host)
        alarm.name = 'FileBodyMatch'
        alarm.metric_name = 'FileBodyMatch'
        @alarms.push(alarm)
      end
    end
  end
end

#default_checksObject



53
54
55
# File 'lib/cfnguardian/resources/internal_sftp.rb', line 53

def default_checks
  @checks.push(CfnGuardian::Models::InternalSFTPCheck.new(@resource))
end

#default_eventsObject



49
50
51
# File 'lib/cfnguardian/resources/internal_sftp.rb', line 49

def default_events
  @resource_list.each {|host| @events.push(CfnGuardian::Models::InternalSFTPEvent.new(host,@environment)) }
end