Class: CfnParser
- Inherits:
-
Object
- Object
- CfnParser
- Defined in:
- lib/cfn-model/parser/cfn_parser.rb
Overview
This class is the heart of the matter. It will take a CloudFormation template and return a CfnModel object to represent the underlying document in a way that is hopefully more convenient for (cfn-nag rule) developers to work with
Instance Method Summary collapse
-
#parse(cloudformation_yml, parameter_values_json = nil) ⇒ Object
Given raw json/yml CloudFormation template, returns a CfnModel object or raise ParserErrors if something is amiss with the format.
Instance Method Details
#parse(cloudformation_yml, parameter_values_json = nil) ⇒ Object
Given raw json/yml CloudFormation template, returns a CfnModel object or raise ParserErrors if something is amiss with the format
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/cfn-model/parser/cfn_parser.rb', line 34 def parse(cloudformation_yml, parameter_values_json=nil) pre_validate_model cloudformation_yml cfn_hash = YAML.load cloudformation_yml # Transform raw resources in template as performed by # transforms CfnModel::TransformRegistry.instance.perform_transforms cfn_hash validate_references cfn_hash cfn_model = CfnModel.new cfn_model.raw_model = cfn_hash # pass 1: wire properties into ModelElement objects transform_hash_into_model_elements cfn_hash, cfn_model transform_hash_into_parameters cfn_hash, cfn_model # pass 2: tie together separate resources only where necessary to make life easier for rule logic post_process_resource_model_elements cfn_model apply_parameter_values(cfn_model, parameter_values_json) cfn_model end |