class DrawCloud::Base

Attributes

as_groups[RW]
as_launch_configurations[RW]
deletion_policy[RW]
depends_on[RW]
ec2_instances[RW]
elastic_ips[RW]
gateways[RW]
iam_access_keys[RW]
iam_policies[RW]
iam_users[RW]
mappings[RW]
metadata[RW]
network_acls[RW]
network_interfaces[RW]
outputs[RW]
parameters[RW]
parent[RW]
rdses[RW]
resources[RW]
route_tables[RW]
security_groups[RW]
sns_topics[RW]
subnets[RW]
vpcs[RW]
wait_handles[RW]

Public Class Methods

new(options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 57
def initialize(options={}, &block)
  @mappings = {}
  @parameters = {}
  @resources = {}
  @outputs = {}

  @subnets = []
  @route_tables = []
  @network_acls = []
  @security_groups = []
  @iam_users = []
  @iam_policies = []
  @iam_access_keys = []
  @gateways = []
  @rdses = []
  @ec2_instances = []
  @as_launch_configurations = []
  @as_groups = []
  @elastic_ips = []
  @network_interfaces = []
  @wait_handles = []
  @vpcs = []
  @sns_topics = []

  @parent = options.fetch(:parent, nil)

  self.instance_exec(self, &block) if block
end

Public Instance Methods

[](attribute) click to toggle source
# File lib/draw_cloud/base.rb, line 112
def [](attribute)
  fngetatt(self, attribute)
end
add_standard_properties(hash) click to toggle source
# File lib/draw_cloud/base.rb, line 101
def add_standard_properties(hash)
  hash["DependsOn"] = DrawCloud.resource_name(depends_on) if depends_on
  hash["DeletionPolicy"] = DrawCloud.resource_style(deletion_policy) if deletion_policy
  hash["Metadata"] = DrawCloud.ref(metadata) unless metadata.nil?
  hash
end
create_as_group(name, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 217
def create_as_group(name, options={}, &block)
  asg = ASGroup.new(name, options.merge(:parent => self), &block)
  as_groups << asg
  asg
end
create_as_launch_configuration(name, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 211
def create_as_launch_configuration(name, options={}, &block)
  lc = ASLaunchConfiguration.new(name, options.merge(:parent => self), &block)
  as_launch_configurations << lc
  lc
end
create_ec2_instance(name, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 205
def create_ec2_instance(name, options={}, &block)
  e = EC2Instance.new(name, options.merge(:parent => self), &block)
  ec2_instances << e
  e
end
create_ec2_instance_template(name, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 201
def create_ec2_instance_template(name, options={}, &block)
  EC2InstanceTemplate.new(name, options.merge(:parent => self), &block)
end
create_elastic_ip(name, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 229
def create_elastic_ip(name, options={}, &block)
  eip = ElasticIp.new(name, options.merge(:parent => self), &block)
  elastic_ips << eip
  eip
end
create_iam_access_key(name, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 189
def create_iam_access_key(name, options={}, &block)
  a = IAMAccessKey.new(name, options.merge(:parent => self), &block)
  iam_access_keys << a
  a
end
create_iam_policy(name, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 183
def create_iam_policy(name, options={}, &block)
  p = IAMPolicy.new(name, options.merge(:parent => self), &block)
  iam_policies << p
  p
end
create_iam_user(name, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 177
def create_iam_user(name, options={}, &block)
  u = IAMUser.new(name, options.merge(:parent => self), &block)
  iam_users << u
  u
end
create_mapping(name, map_by_function, values={}) click to toggle source

Definers

# File lib/draw_cloud/base.rb, line 118
def create_mapping(name, map_by_function, values={})
  m = Map.new(name, map_by_function, {:parent => self}, values)
  mappings[m.resource_name] = m
  m
end
create_network_acl(name, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 165
def create_network_acl(name, options={}, &block)
  a = NetworkAcl.new(name, options.merge(:parent => self), &block)
  network_acls << a
  a
end
create_network_interface(name, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 235
def create_network_interface(name, options={}, &block)
  eni = NetworkInterface.new(name, options.merge(:parent => self), &block)
  network_interfaces << eni
  eni
end
create_output(name, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 124
def create_output(name, options={}, &block)
  o = Output.new(name, options.merge(:parent => self), &block)
  outputs[o.resource_name] = o
  o
end
create_parameter(name, type, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 130
def create_parameter(name, type, options={}, &block)
  p = Parameter.new(name, type, options.merge(:parent => self), &block)
  parameters[p.resource_name] = p
  p
end
create_rds(name, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 195
def create_rds(name, options={}, &block)
  r = RDSInstance.new(name, options.merge(:parent => self), &block)
  rdses << r
  r
end
create_route_table(name, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 159
def create_route_table(name, options={}, &block)
  r = RouteTable.new(name, options.merge(:parent => self), &block)
  route_tables << r
  r
end
create_security_group(name, description=nil, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 171
def create_security_group(name, description=nil, options={}, &block)
  g = SecurityGroup.new(name, description, options.merge(:parent => self), &block)
  security_groups << g
  g
end
create_service(name, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 136
def create_service(name, options={}, &block)
  # NOOP
end
create_sns_topic(name, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 146
def create_sns_topic(name, options={}, &block)
  s = SNSTopic.new(name, options.merge(:parent => self), &block)
  sns_topics << s
  s
end
create_subnet(name, cidr, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 152
def create_subnet(name, cidr, options={}, &block)
  # collisioncheck
  s = Subnet.new(name, cidr, options.merge(:parent => self), &block)
  subnets << s
  s
end
create_vpc(name, cidr, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 140
def create_vpc(name, cidr, options={}, &block)
  v = Vpc.new(name, cidr, options.merge(:parent => self), &block)
  vpcs << v
  v
end
create_wait_handle(name, timeout=nil, options={}, &block) click to toggle source
# File lib/draw_cloud/base.rb, line 223
def create_wait_handle(name, timeout=nil, options={}, &block)
  h = WaitHandle.new(name, timeout, options.merge(:parent => self), &block)
  wait_handles << h
  h
end
load_into_config(config) click to toggle source
# File lib/draw_cloud/base.rb, line 86
def load_into_config(config)
  [@mappings, @parameters, @resources, @outputs].each do |i|
    i.each {|k,v| v.load_into_config(config)}
  end

  [@gateways, @subnets, @route_tables, @network_acls, @security_groups, @iam_users, @iam_policies, @iam_access_keys,
   @rdses, @ec2_instances, @as_launch_configurations, @as_groups, @elastic_ips, @network_interfaces, @wait_handles, @vpcs, @sns_topics].each do |a|
    a.each {|g| g.load_into_config(config) }
  end
end
ref() click to toggle source
# File lib/draw_cloud/base.rb, line 108
def ref
  {"Ref" => resource_name}
end
resource_name() click to toggle source
# File lib/draw_cloud/base.rb, line 97
def resource_name
  resource_style(name)
end