Class: Ufo::Cfn::Stack::Builder
- Inherits:
-
Base
- Object
- Ufo::CLI::Base
- Base
- Ufo::Cfn::Stack::Builder
- Includes:
- Utils::Logging
- Defined in:
- lib/ufo/cfn/stack/builder.rb,
lib/ufo/cfn/stack/builder/base.rb,
lib/ufo/cfn/stack/builder/outputs.rb,
lib/ufo/cfn/stack/builder/resources.rb,
lib/ufo/cfn/stack/builder/conditions.rb,
lib/ufo/cfn/stack/builder/parameters.rb
Defined Under Namespace
Classes: Base, Conditions, Outputs, Parameters, Resources
Instance Attribute Summary
Attributes inherited from Ufo::CLI::Base
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(options = {}) ⇒ Builder
constructor
A new instance of Builder.
- #write(template) ⇒ Object
Methods included from Utils::Logging
Methods included from Ufo::Concerns
Methods included from Ufo::Concerns::Names
Methods included from AwsServices
#acm, #applicationautoscaling, #aws_options, #cfn, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb, #s3, #ssm_client, #waf_client
Methods included from AwsServices::Concerns
#find_stack, #find_stack_resources, #stack_resources, #status, #task_definition_arns
Methods included from Utils::Sure
Methods included from Utils::Pretty
#pretty_home, #pretty_path, #pretty_time
Constructor Details
#initialize(options = {}) ⇒ Builder
Returns a new instance of Builder.
5 6 7 8 9 |
# File 'lib/ufo/cfn/stack/builder.rb', line 5 def initialize(={}) super @vars = [:vars] @template = {Description: "UFO ECS stack #{@vars[:stack_name]}"} end |
Instance Method Details
#build ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ufo/cfn/stack/builder.rb', line 11 def build logger.info "Building template" @template[:Parameters] = Parameters.build(@options) @template[:Conditions] = Conditions.build(@options) @template[:Resources] = Resources.build(@options) @template[:Outputs] = Outputs.build(@options) @template.deep_stringify_keys! @template = Ufo::Utils::Squeezer.new(@template).squeeze @template = CustomProperties.new(@template, @vars[:stack_name]).apply write(@template) end |
#write(template) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ufo/cfn/stack/builder.rb', line 23 def write(template) text = YAML.dump(template) path = ".ufo/output/template.yml" IO.write("#{Ufo.root}/#{path}", text) logger.info " #{path}" # Only basic YAML validation. Doesnt check for everything CloudFormation checks. # For CloudFormation checks handled with an exception handler in Cfn::Stack#print_code(exception) Ufo::Yaml.validate!(path) text end |