Class: Ufo::Stack::Builder::Base
- Inherits:
-
Object
- Object
- Ufo::Stack::Builder::Base
- Includes:
- Ufo::Settings
- Defined in:
- lib/ufo/stack/builder/base.rb
Direct Known Subclasses
Conditions, Outputs, Parameters, Resources, Resources::Base, Resources::Dns, Resources::Ecs, Resources::Elb, Resources::Roles::Base, Resources::SecurityGroup::Base
Class Method Summary collapse
Instance Method Summary collapse
-
#copy_instance_variables ⇒ Object
Copy the instance variables from TemplateScope Stack Builder classes.
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #managed_security_group(type) ⇒ Object
- #managed_security_groups? ⇒ Boolean
-
#security_groups(type) ⇒ Object
type: elb or ecs NOTE: Application ELBs always seem to need a security group even though the docs say its not required However, there’s a case where no ELB is created for a worker tier and if the settings are all blank CloudFormation fails to resolve and splits out this error:.
Methods included from Ufo::Settings
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
5 6 7 |
# File 'lib/ufo/stack/builder/base.rb', line 5 def initialize copy_instance_variables end |
Class Method Details
.build ⇒ Object
19 20 21 |
# File 'lib/ufo/stack/builder/base.rb', line 19 def self.build new.build end |
Instance Method Details
#copy_instance_variables ⇒ Object
Copy the instance variables from TemplateScope Stack Builder classes
10 11 12 13 14 15 16 17 |
# File 'lib/ufo/stack/builder/base.rb', line 10 def copy_instance_variables context = Ufo::Stack::Builder.context scope = context.scope scope.instance_variables.each do |var| val = scope.instance_variable_get(var) instance_variable_set(var, val) end end |
#managed_security_group(type) ⇒ Object
44 45 46 47 |
# File 'lib/ufo/stack/builder/base.rb', line 44 def managed_security_group(type) logical_id = managed_security_groups? ? "#{type.camelize}SecurityGroup" : "AWS::NoValue" {Ref: logical_id} end |
#managed_security_groups? ⇒ Boolean
49 50 51 52 |
# File 'lib/ufo/stack/builder/base.rb', line 49 def managed_security_groups? managed = settings[:managed_security_groups] managed.nil? ? true : managed end |
#security_groups(type) ⇒ Object
type: elb or ecs NOTE: Application ELBs always seem to need a security group even though the docs say its not required However, there’s a case where no ELB is created for a worker tier and if the settings are all blank CloudFormation fails to resolve and splits out this error:
Template error: every Fn::Split object requires two parameters
So we will not assign security groups at all for case of workers with no security groups at all.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ufo/stack/builder/base.rb', line 32 def security_groups(type) settings_key = "#{type}_security_groups".to_sym group_ids = Ufo::Setting::SecurityGroups.new(@service, settings_key).load # no security groups at all return if !managed_security_groups? && group_ids.blank? groups = [] groups += group_ids groups += [managed_security_group(type.to_s.camelize)] if managed_security_groups? groups end |