Class: CfnModel

Inherits:
Object
  • Object
show all
Defined in:
lib/model/cfn_model.rb

Overview

consider a canonical form for template too… always transform optional things into more general forms.… although referencing violations becomes tricky then (a la c preprocessor)

Instance Method Summary collapse

Constructor Details

#initializeCfnModel

Returns a new instance of CfnModel.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/model/cfn_model.rb', line 10

def initialize
  @parser_registry = {
    'AWS::EC2::SecurityGroup' => SecurityGroupParser,
    'AWS::EC2::SecurityGroupIngress' => SecurityGroupXgressParser,
    'AWS::EC2::SecurityGroupEgress' => SecurityGroupXgressParser,
    'AWS::IAM::User' => IamUserParser,
    'AWS::IAM::UserToGroupAddition' => IamUserToGroupAdditionParser
  }
  @dangling_ingress_or_egress_rules = []
  @dangler = Object.new
end

Instance Method Details

#dangling_ingress_or_egress_rulesObject



35
36
37
38
# File 'lib/model/cfn_model.rb', line 35

def dangling_ingress_or_egress_rules
  fail 'must call parse first' unless @json_hash
  @dangling_ingress_or_egress_rules
end

#iam_usersObject



40
41
42
43
44
45
# File 'lib/model/cfn_model.rb', line 40

def iam_users
  fail 'must call parse first' unless @json_hash
  iam_users_hash = resources_by_type('AWS::IAM::User')
  wire_user_to_group_additions_to_users(iam_users_hash)
  iam_users_hash.values
end

#parse(cfn_json_string) ⇒ Object



22
23
24
25
# File 'lib/model/cfn_model.rb', line 22

def parse(cfn_json_string)
  @json_hash = JSON.load cfn_json_string
  self
end

#security_groupsObject



27
28
29
30
31
32
33
# File 'lib/model/cfn_model.rb', line 27

def security_groups
  fail 'must call parse first' unless @json_hash
  security_groups_hash = resources_by_type('AWS::EC2::SecurityGroup')
  wire_ingress_rules_to_security_groups(security_groups_hash)
  wire_egress_rules_to_security_groups(security_groups_hash)
  security_groups_hash.values
end