class DrawCloud::ASGroup

Constants

ALL_ACTIVITY
ALL_ERRORS
ALL_NOTIFICATIONS
NOTIFY_EC2_INSTANCE_LAUNCH
NOTIFY_EC2_INSTANCE_LAUNCH_ERROR
NOTIFY_EC2_INSTANCE_TERMINATE
NOTIFY_EC2_INSTANCE_TERMINATE_ERROR
NOTIFY_EC2_TEST_NOTIFICATION

Attributes

availability_zones[RW]
cooldown[RW]
desired_capacity[RW]
launch_configuration[RW]
launch_configuration=[RW]
launch_configuration_name[RW]
max_size[RW]
min_size[RW]
name[RW]
notification_configuration[RW]
subnets[RW]
tags[RW]
vpc_zone_identifier[RW]

Public Class Methods

new(name, options={}, &block) click to toggle source
Calls superclass method
# File lib/draw_cloud/as_group.rb, line 41
def initialize(name, options={}, &block)
  @name = name
  @availability_zones = options.fetch(:availability_zones, [])
  @cooldown = options.fetch(:cooldown, nil)
  @launch_configuration_name = options.fetch(:launch_configuration_name, nil)
  @max_size = options.fetch(:max_size, nil)
  @min_size = options.fetch(:min_size, nil)
  @notification_configuration = options.fetch(:notification_configuration, nil)
  @desired_capacity = options.fetch(:desired_capacity, nil)
  @tags = options.fetch(:tags, [])
  @vpc_zone_identifier = options.fetch(:vpc_zone_identifier, nil)
  super(options, &block)
end

Public Instance Methods

as_group() click to toggle source
# File lib/draw_cloud/as_group.rb, line 55
def as_group
  self
end
load_into_config(config) click to toggle source
Calls superclass method
# File lib/draw_cloud/as_group.rb, line 71
def load_into_config(config)
  config.cf_add_resource resource_name, self
  super(config)
end
notify(topic_arn, notification_types) click to toggle source
# File lib/draw_cloud/as_group.rb, line 59
def notify(topic_arn, notification_types)
  self.notification_configuration = {:arn => topic_arn, :types => notification_types}
end
resource_name() click to toggle source
# File lib/draw_cloud/as_group.rb, line 76
def resource_name
  resource_style(name) + "AS"
end
subnets=(subnets)
to_h() click to toggle source
# File lib/draw_cloud/as_group.rb, line 80
def to_h
  h = {
    "Type" => "AWS::AutoScaling::AutoScalingGroup",
    "Properties" => {
      "AvailabilityZones" => availability_zones.collect {|g| DrawCloud.ref(g) },
      "LaunchConfigurationName" => DrawCloud.ref(launch_configuration_name),
      "MaxSize" => max_size,
      "MinSize" => min_size,
      "Tags" => [], # FIXME
    }
  }
  p = h["Properties"]
  p["AvailabilityZones"] = DrawCloud.ref(availability_zones) if cooldown
  p["Cooldown"] = DrawCloud.ref(cooldown) if cooldown
  p["DesiredCapacity"] = DrawCloud.ref(desired_capacity) if desired_capacity
  p["VPCZoneIdentifier"] = vpc_zone_identifier.collect {|z| DrawCloud.ref(z) }
  p["NotificationConfiguration"] = {
    "TopicARN" => DrawCloud.ref(self.notification_configuration[:arn]),
    "NotificationTypes" => self.notification_configuration[:types],
  } if self.notification_configuration

  add_standard_properties(h)
end
vpc_zone_identifier=(subnets) click to toggle source
# File lib/draw_cloud/as_group.rb, line 63
def vpc_zone_identifier=(subnets)
  if subnets.all? {|s| s.respond_to? :availability_zone }
    self.availability_zones = subnets.collect(&:availability_zone)
  end
  @vpc_zone_identifier = subnets
end
Also aliased as: subnets=