Class: CloudShaped::TemplateBuilder
- Inherits:
-
Object
- Object
- CloudShaped::TemplateBuilder
- Includes:
- DSL
- Defined in:
- lib/cloud_shaped/template_builder.rb
Overview
A builder for CloudFormation templates.
Instance Method Summary collapse
-
#def_output(name, value) ⇒ Object
Declares an Output.
-
#def_parameter(name, options = {}) ⇒ Object
Declares a Parameter.
-
#def_resource(name, type, *args, &block) ⇒ Object
Declares a Resource.
-
#initialize(settings = {}) ⇒ TemplateBuilder
constructor
A new instance of TemplateBuilder.
-
#template ⇒ Hash
A CloudFormation template as Ruby data.
Methods included from SnsMethods
Methods included from CoreMethods
#output, #parameter, #ref, #resource, #tag, #tags
Methods included from FunctionMethods
Constructor Details
#initialize(settings = {}) ⇒ TemplateBuilder
Returns a new instance of TemplateBuilder.
9 10 11 12 13 |
# File 'lib/cloud_shaped/template_builder.rb', line 9 def initialize(settings = {}) @parameters = {} @resources = {} @outputs = {} end |
Instance Method Details
#def_output(name, value) ⇒ Object
Declares an Output.
66 67 68 |
# File 'lib/cloud_shaped/template_builder.rb', line 66 def def_output(name, value) outputs[name] = output(value) end |
#def_parameter(name, options = {}) ⇒ Object
Declares a Parameter.
39 40 41 |
# File 'lib/cloud_shaped/template_builder.rb', line 39 def def_parameter(name, = {}) parameters[name] = parameter() end |
#def_resource(name, type, *args, &block) ⇒ Object
Declares a Resource.
49 50 51 52 53 54 55 56 |
# File 'lib/cloud_shaped/template_builder.rb', line 49 def def_resource(name, type, *args, &block) definition = if type.is_a?(Symbol) send(type, *args, &block) else resource(type, *args, &block) end resources[name] = definition if definition end |
#template ⇒ Hash
Returns a CloudFormation template as Ruby data.
17 18 19 20 21 22 23 24 |
# File 'lib/cloud_shaped/template_builder.rb', line 17 def template { "AWSTemplateFormatVersion" => '2010-09-09', "Parameters" => parameters, "Resources" => resources, "Outputs" => outputs } end |