Class: DrawCloud::RDSInstance

Inherits:
Base
  • Object
show all
Defined in:
lib/draw_cloud/rds_instance.rb

Defined Under Namespace

Classes: RDSSubnetGroup

Instance Attribute Summary collapse

Attributes inherited from Base

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

Instance Method Summary collapse

Methods inherited from Base

#[], #accessor, #add_standard_properties, #create_as_group, #create_as_launch_configuration, #create_ec2_instance, #create_ec2_instance_template, #create_elastic_ip, #create_iam_access_key, #create_iam_policy, #create_iam_user, #create_mapping, #create_network_acl, #create_network_interface, #create_output, #create_parameter, #create_rds, #create_route_table, #create_security_group, #create_service, #create_sns_topic, #create_subnet, #create_vpc, #create_wait_handle, #ref

Methods included from Locations

#arn_s3

Methods included from Utilities

#desplice, #fnbase64, #fngetatt, #fnjoin, #hash_to_tag_array, #region, #resource_style, #splice, #stack_name

Constructor Details

#initialize(name, options = {}, &block) ⇒ RDSInstance



60
61
62
63
64
65
# File 'lib/draw_cloud/rds_instance.rb', line 60

def initialize(name, options={}, &block)
  @name = name
  @db_security_groups = []
  @rds_subnets = []
  super(options, &block)
end

Instance Attribute Details

#allocated_storageObject

Returns the value of attribute allocated_storage.



42
43
44
# File 'lib/draw_cloud/rds_instance.rb', line 42

def allocated_storage
  @allocated_storage
end

#auto_minor_version_upgradeObject

Returns the value of attribute auto_minor_version_upgrade.



42
43
44
# File 'lib/draw_cloud/rds_instance.rb', line 42

def auto_minor_version_upgrade
  @auto_minor_version_upgrade
end

#backup_retention_periodObject

Returns the value of attribute backup_retention_period.



42
43
44
# File 'lib/draw_cloud/rds_instance.rb', line 42

def backup_retention_period
  @backup_retention_period
end

#db_instance_classObject Also known as: instance_class

Returns the value of attribute db_instance_class.



42
43
44
# File 'lib/draw_cloud/rds_instance.rb', line 42

def db_instance_class
  @db_instance_class
end

#db_security_groupsObject

Returns the value of attribute db_security_groups.



42
43
44
# File 'lib/draw_cloud/rds_instance.rb', line 42

def db_security_groups
  @db_security_groups
end

#db_snapshot_identifierObject

Returns the value of attribute db_snapshot_identifier.



42
43
44
# File 'lib/draw_cloud/rds_instance.rb', line 42

def db_snapshot_identifier
  @db_snapshot_identifier
end

#engineObject

Returns the value of attribute engine.



42
43
44
# File 'lib/draw_cloud/rds_instance.rb', line 42

def engine
  @engine
end

#engine_versionObject

Returns the value of attribute engine_version.



42
43
44
# File 'lib/draw_cloud/rds_instance.rb', line 42

def engine_version
  @engine_version
end

#iopsObject

Returns the value of attribute iops.



42
43
44
# File 'lib/draw_cloud/rds_instance.rb', line 42

def iops
  @iops
end

#master_user_passwordObject Also known as: master_password

Returns the value of attribute master_user_password.



42
43
44
# File 'lib/draw_cloud/rds_instance.rb', line 42

def master_user_password
  @master_user_password
end

#master_usernameObject

Returns the value of attribute master_username.



42
43
44
# File 'lib/draw_cloud/rds_instance.rb', line 42

def master_username
  @master_username
end

#multi_azObject

Returns the value of attribute multi_az.



42
43
44
# File 'lib/draw_cloud/rds_instance.rb', line 42

def multi_az
  @multi_az
end

#nameObject

Returns the value of attribute name.



42
43
44
# File 'lib/draw_cloud/rds_instance.rb', line 42

def name
  @name
end

#rds_subnetsObject

Returns the value of attribute rds_subnets.



42
43
44
# File 'lib/draw_cloud/rds_instance.rb', line 42

def rds_subnets
  @rds_subnets
end

Instance Method Details

#db_security_group(name, description, options = {}, &block) ⇒ Object



88
89
90
91
92
# File 'lib/draw_cloud/rds_instance.rb', line 88

def db_security_group(name, description, options={}, &block)
  d = RDSSecurityGroup.new(name, description, options.merge(:parent => self), &block)
  db_security_groups << d
  d
end

#load_into_config(config) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/draw_cloud/rds_instance.rb', line 71

def load_into_config(config)
  config.cf_add_resource resource_name, self
  db_security_groups.each {|g| g.load_into_config(config) }
  unless rds_subnets.empty?
    config.cf_add_resource subnet_group.resource_name, subnet_group
  end
  super(config)
end

#rdsObject



67
68
69
# File 'lib/draw_cloud/rds_instance.rb', line 67

def rds
  self
end

#resource_nameObject



80
81
82
# File 'lib/draw_cloud/rds_instance.rb', line 80

def resource_name
  resource_style(name) + "RDS"
end

#subnet_groupObject



84
85
86
# File 'lib/draw_cloud/rds_instance.rb', line 84

def subnet_group
  RDSSubnetGroup.new(self, rds_subnets)
end

#to_hObject



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/draw_cloud/rds_instance.rb', line 94

def to_h
  h = {
    "Type" => "AWS::RDS::DBInstance",
    "Properties" => {
      "DBSecurityGroups" => db_security_groups.collect { |g| DrawCloud.ref(g)},
      "AllocatedStorage" => DrawCloud.ref(allocated_storage),
      "Engine" => DrawCloud.ref(engine),
      "DBInstanceClass" => DrawCloud.ref(db_instance_class),
      "MasterUsername" => DrawCloud.ref(master_username),
      "MasterUserPassword" => DrawCloud.ref(master_user_password),
    }
  }
  p = h["Properties"]
  p["DBSnapshotIdentifier"] = DrawCloud.ref(db_snapshot_identifier) if db_snapshot_identifier
  p["MultiAZ"] = multi_az unless multi_az.nil?
  p["EngineVersion"] = DrawCloud.ref(engine_version) unless engine_version.nil?
  p["Iops"] = DrawCloud.ref(iops) if iops
  p["DBSubnetGroupName"] = DrawCloud.ref(subnet_group) unless rds_subnets.empty?
  p["AutoMinorVersionUpgrade"] = DrawCloud.ref(auto_minor_version_upgrade) unless auto_minor_version_upgrade.nil?
  p["BackupRetentionPeriod"] = DrawCloud.ref(backup_retention_period) unless backup_retention_period.nil?
  add_standard_properties(h)
end