Class: AWS::RDS::DBSnapshot

Inherits:
Core::Resource
  • Object
show all
Defined in:
lib/aws/rds/db_snapshot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db_snapshot_id, options = {}) ⇒ DBSnapshot

Returns a new instance of DBSnapshot.

Parameters:

  • db_snapshot_id (String)
  • options (Hash) (defaults to: {})


47
48
49
50
# File 'lib/aws/rds/db_snapshot.rb', line 47

def initialize db_snapshot_id, options = {}
  @db_snapshot_identifier = db_snapshot_id
  super
end

Instance Attribute Details

#allocated_storageInteger (readonly)

Returns the current value of allocated_storage.

Returns:

  • (Integer)

    the current value of allocated_storage



43
44
45
# File 'lib/aws/rds/db_snapshot.rb', line 43

def allocated_storage
  @allocated_storage
end

#availability_zone_nameString (readonly)

Returns the current value of availability_zone_name.

Returns:

  • (String)

    the current value of availability_zone_name



43
44
45
# File 'lib/aws/rds/db_snapshot.rb', line 43

def availability_zone_name
  @availability_zone_name
end

#created_atTime (readonly)

Returns the current value of created_at.

Returns:

  • (Time)

    the current value of created_at



43
44
45
# File 'lib/aws/rds/db_snapshot.rb', line 43

def created_at
  @created_at
end

#db_instance_idString (readonly)

Returns the current value of db_instance_id.

Returns:

  • (String)

    the current value of db_instance_id



43
44
45
# File 'lib/aws/rds/db_snapshot.rb', line 43

def db_instance_id
  @db_instance_id
end

#db_snapshot_identifierString (readonly) Also known as: id, db_snapshot_id

Returns:

  • (String)


53
54
55
# File 'lib/aws/rds/db_snapshot.rb', line 53

def db_snapshot_identifier
  @db_snapshot_identifier
end

#engineString (readonly)

Returns the current value of engine.

Returns:

  • (String)

    the current value of engine



43
44
45
# File 'lib/aws/rds/db_snapshot.rb', line 43

def engine
  @engine
end

#engine_versionString (readonly)

Returns the current value of engine_version.

Returns:

  • (String)

    the current value of engine_version



43
44
45
# File 'lib/aws/rds/db_snapshot.rb', line 43

def engine_version
  @engine_version
end

#instance_create_timeTime (readonly)

Returns the current value of instance_create_time.

Returns:

  • (Time)

    the current value of instance_create_time



43
44
45
# File 'lib/aws/rds/db_snapshot.rb', line 43

def instance_create_time
  @instance_create_time
end

#license_modelString (readonly)

Returns the current value of license_model.

Returns:

  • (String)

    the current value of license_model



43
44
45
# File 'lib/aws/rds/db_snapshot.rb', line 43

def license_model
  @license_model
end

#master_usernameString (readonly)

Returns the current value of master_username.

Returns:

  • (String)

    the current value of master_username



43
44
45
# File 'lib/aws/rds/db_snapshot.rb', line 43

def master_username
  @master_username
end

#portString (readonly)

Returns the current value of port.

Returns:

  • (String)

    the current value of port



43
44
45
# File 'lib/aws/rds/db_snapshot.rb', line 43

def port
  @port
end

#snapshot_typeString (readonly)

Returns the current value of snapshot_type.

Returns:

  • (String)

    the current value of snapshot_type



43
44
45
# File 'lib/aws/rds/db_snapshot.rb', line 43

def snapshot_type
  @snapshot_type
end

#statusString (readonly)

Returns the current value of status.

Returns:

  • (String)

    the current value of status



43
44
45
# File 'lib/aws/rds/db_snapshot.rb', line 43

def status
  @status
end

#vpc_idInteger (readonly)

Returns the current value of vpc_id.

Returns:

  • (Integer)

    the current value of vpc_id



43
44
45
# File 'lib/aws/rds/db_snapshot.rb', line 43

def vpc_id
  @vpc_id
end

Instance Method Details

#copy(new_snapshot_id) ⇒ DBSnapshot

Copies this database snapshot.

Parameters:

  • new_snapshot_id (String)

Returns:



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/aws/rds/db_snapshot.rb', line 108

def copy new_snapshot_id

  options = {}
  options[:source_db_snapshot_identifier] = id
  options[:target_db_snapshot_identifier] = new_snapshot_id
  resp = client.copy_db_snapshot(options)

  DBSnapshot.new_from(:copy_db_snapshot, resp,
    resp[:db_snapshot_identifier], :config => config)

end

#db_instanceDBInstance

Returns:



101
102
103
# File 'lib/aws/rds/db_snapshot.rb', line 101

def db_instance
  DBInstance.new(db_instance_id, :config => config)
end

#deletenil

Deletes this database snapshot.

Returns:

  • (nil)


122
123
124
125
# File 'lib/aws/rds/db_snapshot.rb', line 122

def delete
  client.delete_db_snapshot(:db_snapshot_identifier => db_snapshot_identifier)
  nil
end

#exists?Boolean

Returns true if the db snapshot exists.

Returns:

  • (Boolean)

    Returns true if the db snapshot exists.



140
141
142
143
144
145
146
147
# File 'lib/aws/rds/db_snapshot.rb', line 140

def exists?
  begin
    get_resource
    true
  rescue AWS::RDS::Errors::DBSnapshotNotFound
    false
  end
end

#restore_instance(options = {}) ⇒ Object

Restores the database instance from this snapshot. You may optionally specify the db instance id if you wish to restore to a different db.

Parameters:

  • options (Hash) (defaults to: {})
    • :db_instance_identifier - required - (String) The identifier for the DB Snapshot to restore from.

    • :db_snapshot_identifier - required - (String) Name of the DB Instance to create from the DB Snapshot. This parameter isn’t case sensitive.

    • :db_instance_class - (String) The compute and memory capacity of the Amazon RDS DB instance.

    • :port - (Integer) The port number on which the database accepts connections.

    • :availability_zone - (String) The EC2 Availability Zone that the database instance will be created in.

    • :db_subnet_group_name - (String) The DB Subnet Group name to use for the new instance.

    • :multi_az - (Boolean) Specifies if the DB Instance is a Multi-AZ deployment. Constraint: You cannot specify the AvailabilityZone parameter if the MultiAZ parameter is set to true .

    • :auto_minor_version_upgrade - (Boolean) Indicates that minor version upgrades will be applied automatically to the DB Instance during the maintenance window.

    • :license_model - (String) License model information for the restored DB Instance. Default: Same as source. Valid values: license-included | bring-your-own-license | general-public-license

    • :db_name - (String) The database name for the restored DB Instance. This parameter doesn’t apply to the MySQL engine.

    • :engine - (String) The database engine to use for the new instance. Default: The same as source Constraint: Must be compatible with the engine of the source Example: oracle-ee

    • :iops - (Integer) The amount of Provisioned IOPS (input/output operations per second) to be initially allocated for the DB Instance. Constraints: Must be an integer greater than 1000.

    • :option_group_name - (String)



132
133
134
135
136
137
# File 'lib/aws/rds/db_snapshot.rb', line 132

def restore_instance options = {}
  options[:db_snapshot_identifier] = db_snapshot_identifier
  options[:db_instance_identifier] ||= db_instance_id
  client.restore_db_instance_from_db_snapshot(options)
  nil
end