Class: CfnModel
- Inherits:
-
Object
show all
- Defined in:
- lib/cfn-model/model/cfn_model.rb,
lib/cfn-model/transforms/serverless.rb,
lib/cfn-model/parser/transform_registry.rb,
lib/cfn-model/parser/transform_registry.rb
Defined Under Namespace
Classes: TransformRegistry, Transforms
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of CfnModel.
12
13
14
15
16
|
# File 'lib/cfn-model/model/cfn_model.rb', line 12
def initialize
@parameters = {}
@resources = {}
@raw_model = nil
end
|
Instance Attribute Details
#parameters ⇒ Object
Returns the value of attribute parameters.
4
5
6
|
# File 'lib/cfn-model/model/cfn_model.rb', line 4
def parameters
@parameters
end
|
#raw_model ⇒ Object
if you really want it, here it is - the raw Hash from YAML.load. you’ll have to mess with structural nits of CloudFormation and deal with variations between yaml/json refs and all that
10
11
12
|
# File 'lib/cfn-model/model/cfn_model.rb', line 10
def raw_model
@raw_model
end
|
#resources ⇒ Object
Returns the value of attribute resources.
4
5
6
|
# File 'lib/cfn-model/model/cfn_model.rb', line 4
def resources
@resources
end
|
Instance Method Details
#copy ⇒ Object
A new instance of CfnModel with a copy of the raw_model and and resources. The resource objects themselves aren’t cloned but the Hash is a clone
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/cfn-model/model/cfn_model.rb', line 22
def copy
new_cfn_model = CfnModel.new
@parameters.each do |k,v|
new_cfn_model.parameters[k] = v
end
@resources.each do |k, v|
new_cfn_model.resources[k] = v
end
new_cfn_model.raw_model = @raw_model.dup unless @raw_model.nil?
new_cfn_model
end
|
#find_security_group_by_group_id(security_group_reference) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/cfn-model/model/cfn_model.rb', line 60
def find_security_group_by_group_id(security_group_reference)
security_group_id = References.resolve_security_group_id(security_group_reference)
if security_group_id.nil?
security_group_reference
else
matched_security_group = security_groups.find do |security_group|
security_group.logical_resource_id == security_group_id
end
if matched_security_group.nil?
security_group_reference
else
matched_security_group
end
end
end
|
#iam_users ⇒ Object
38
39
40
|
# File 'lib/cfn-model/model/cfn_model.rb', line 38
def iam_users
resources_by_type 'AWS::IAM::User'
end
|
#resources_by_type(resource_type) ⇒ Object
56
57
58
|
# File 'lib/cfn-model/model/cfn_model.rb', line 56
def resources_by_type(resource_type)
@resources.values.select { |resource| resource.resource_type == resource_type }
end
|
#security_groups ⇒ Object
34
35
36
|
# File 'lib/cfn-model/model/cfn_model.rb', line 34
def security_groups
resources_by_type 'AWS::EC2::SecurityGroup'
end
|
#standalone_egress ⇒ Object
49
50
51
52
53
54
|
# File 'lib/cfn-model/model/cfn_model.rb', line 49
def standalone_egress
security_group_egresses = resources_by_type 'AWS::EC2::SecurityGroupEgress'
security_group_egresses.select do |security_group_egress|
References.is_security_group_id_external(security_group_egress.groupId)
end
end
|
#standalone_ingress ⇒ Object
42
43
44
45
46
47
|
# File 'lib/cfn-model/model/cfn_model.rb', line 42
def standalone_ingress
security_group_ingresses = resources_by_type 'AWS::EC2::SecurityGroupIngress'
security_group_ingresses.select do |security_group_ingress|
References.is_security_group_id_external(security_group_ingress.groupId)
end
end
|
#to_s ⇒ Object
78
79
80
|
# File 'lib/cfn-model/model/cfn_model.rb', line 78
def to_s
@resources.to_s
end
|