Class: Jets::Rule::Task

Inherits:
Lambda::Task show all
Defined in:
lib/jets/rule/task.rb

Instance Attribute Summary collapse

Attributes inherited from Lambda::Task

#class_name, #iam_policy, #lang, #meth, #properties, #type

Instance Method Summary collapse

Methods inherited from Lambda::Task

#full_handler, #get_type, #handler_base, #handler_path, #lang_ext, #name, #poly_src_path

Constructor Details

#initialize(class_name, meth, options = {}) ⇒ Task

Returns a new instance of Task.



3
4
5
6
# File 'lib/jets/rule/task.rb', line 3

def initialize(class_name, meth, options={})
  super
  @config_rule = options[:config_rule] || {}
end

Instance Attribute Details

#config_ruleObject (readonly)

Returns the value of attribute config_rule.



2
3
4
# File 'lib/jets/rule/task.rb', line 2

def config_rule
  @config_rule
end

Instance Method Details

#config_rule_defaultsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/jets/rule/task.rb', line 23

def config_rule_defaults
  map = Jets::Cfn::TemplateMappers::ConfigRuleMapper.new(self)
  source_identifier = "!GetAtt #{map.lambda_function_logical_id}.Arn"
  {
    "ConfigRuleName" => config_rule_name,
    "Source" => {
      "Owner" => "CUSTOM_LAMBDA",
      "SourceIdentifier" => source_identifier,
      "SourceDetails" => [
          {
              "EventSource" => "aws.config",
              "MessageType" => "ConfigurationItemChangeNotification"
          },
          {
              "EventSource" => "aws.config",
              "MessageType" => "OversizedConfigurationItemChangeNotification"
          }
      ]
    }
  }
end

#config_rule_nameObject



8
9
10
# File 'lib/jets/rule/task.rb', line 8

def config_rule_name
  @properties[:config_rule_name] || conventional_config_rule_name
end

#config_rule_propertiesObject



17
18
19
20
21
# File 'lib/jets/rule/task.rb', line 17

def config_rule_properties
  props = Jets::Pascalize.pascalize(@config_rule)
  props = config_rule_defaults.merge(props)
  props
end

#conventional_config_rule_nameObject



12
13
14
15
# File 'lib/jets/rule/task.rb', line 12

def conventional_config_rule_name
  name_without_rule = @class_name.underscore.gsub(/_rule$/,'')
  "#{name_without_rule}_#{@meth}".dasherize
end