class CfnModel
Attributes
conditions[R]
globals[R]
line_numbers[R]
mappings[R]
parameters[R]
raw_model[RW]
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
resources[R]
Public Class Methods
new()
click to toggle source
# File lib/cfn-model/model/cfn_model.rb, line 14 def initialize @parameters = {} @resources = {} @conditions = {} @globals = {} @mappings = {} @raw_model = nil @line_numbers = {} end
Public Instance Methods
copy()
click to toggle source
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
# File lib/cfn-model/model/cfn_model.rb, line 28 def copy new_cfn_model = CfnModel.new @conditions.each do |k,v| new_cfn_model.conditions[k] = v end @globals.each do |k,v| new_cfn_model.globals[k] = v end @parameters.each do |k,v| new_cfn_model.parameters[k] = v end @resources.each do |k, v| new_cfn_model.resources[k] = v end @mappings.each do |k, v| new_cfn_model.mappings[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)
click to toggle source
# File lib/cfn-model/model/cfn_model.rb, line 92 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? # leave it alone since external ref or something we don't grok 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? # leave it alone since external ref or something we don't grok security_group_reference else matched_security_group end end end
iam_users()
click to toggle source
# File lib/cfn-model/model/cfn_model.rb, line 53 def iam_users resources_by_type 'AWS::IAM::User' end
resource_by_id(resource_id)
click to toggle source
# File lib/cfn-model/model/cfn_model.rb, line 71 def resource_by_id(resource_id) @resources.values.find { |resource| resource.logical_resource_id == resource_id } end
resource_by_ref(reference, attr = nil)
click to toggle source
# File lib/cfn-model/model/cfn_model.rb, line 79 def resource_by_ref(reference, attr = nil) # If reference is a String, look for a matching object as is (best effort) # Although, the caller could just use resource_by_id on this value, since it # would be the logical_resource_id. logical_resource_id = reference if reference.is_a? String # Otherwise, obtain logical_resource_id from References class logical_resource_id ||= References.resolve_resource_id reference, attr # Search resources for a matching ID resource_by_id logical_resource_id end
resources_by_type(resource_type)
click to toggle source
# File lib/cfn-model/model/cfn_model.rb, line 75 def resources_by_type(resource_type) @resources.values.select { |resource| resource.resource_type == resource_type } end
security_groups()
click to toggle source
# File lib/cfn-model/model/cfn_model.rb, line 49 def security_groups resources_by_type 'AWS::EC2::SecurityGroup' end
standalone_egress()
click to toggle source
# File lib/cfn-model/model/cfn_model.rb, line 64 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()
click to toggle source
# File lib/cfn-model/model/cfn_model.rb, line 57 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()
click to toggle source
# File lib/cfn-model/model/cfn_model.rb, line 110 def to_s @resources.to_s end