Class: Ufo::Cfn::Stack::Builder::Base

Inherits:
Base show all
Defined in:
lib/ufo/cfn/stack/builder/base.rb

Instance Attribute Summary collapse

Attributes inherited from Ufo::CLI::Base

#task_definition

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Ufo::Concerns

#build, #deploy, #info, #ps

Methods included from Ufo::Concerns::Names

#names

Methods included from AwsServices

#acm, #applicationautoscaling, #aws_options, #cloudformation, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb, #find_stack, #ssm_client, #stack_resources, #status, #task_definition_arns

Methods included from Utils::Sure

#sure?

Methods included from Utils::Pretty

#pretty_home, #pretty_path, #pretty_time

Methods included from Utils::Logging

#logger

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



4
5
6
7
# File 'lib/ufo/cfn/stack/builder/base.rb', line 4

def initialize(options={})
  super
  @vars = options[:vars]
end

Instance Attribute Details

#varsObject (readonly)

Returns the value of attribute vars.



3
4
5
# File 'lib/ufo/cfn/stack/builder/base.rb', line 3

def vars
  @vars
end

Class Method Details

.build(options = {}) ⇒ Object



39
40
41
# File 'lib/ufo/cfn/stack/builder/base.rb', line 39

def self.build(options={})
  new(options).build
end

Instance Method Details

#managed_security_group(type) ⇒ Object



29
30
31
32
# File 'lib/ufo/cfn/stack/builder/base.rb', line 29

def managed_security_group(type)
  logical_id = managed_security_groups? ? "#{type.camelize}SecurityGroup" : "AWS::NoValue"
  {Ref: logical_id}
end

#managed_security_groups?Boolean

Returns:

  • (Boolean)


34
35
36
37
# File 'lib/ufo/cfn/stack/builder/base.rb', line 34

def managed_security_groups?
  managed = Ufo.config.vpc.security_groups.managed
  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.



18
19
20
21
22
23
24
25
26
27
# File 'lib/ufo/cfn/stack/builder/base.rb', line 18

def security_groups(type)
  group_ids = Ufo.config.vpc.security_groups[type] || []
  # 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