class AWS::EC2::Snapshot

Represents an Amazon EBS snapshot.

@example Taking a snapshot from a volume

snapshot = volume.create_snapshot("Database Backup 12/21/2010")
sleep 1 until [:completed, :error].include?(snapshot.status)

@example Managing snapshot permissions

unless snapshot.public?
  snapshot.permissions.add("12345678901")
end

@attr_reader [String] volume_id The ID of the volume this

snapshot was created from.

@attr_reader [Symbol] status The status of the snapshot.

Possible values:

* +:pending+
* +:completed+
* +:error+

@attr_reader [Time] start_time The time at which the snapshot

was initiated.

@attr_reader [Integer] progress The progress of the snapshot

as a percentage.

@attr_reader [String] owner_id The AWS account ID of the

snapshot owner.

@attr_reader [Integer] volume_size The size of the volume from

which the snapshot was created.

@attr_reader [String] description The description of the

snapshot provided at snapshot initiation.

Attributes

id[R]

@return [String] Returns the snapshot’s ID.

Public Class Methods

new(id, options = {}) click to toggle source

@private

# File lib/aws/ec2/snapshot.rb, line 58
def initialize id, options = {}
  @id = id
  super(options)
end

Public Instance Methods

__permissions_attribute__() click to toggle source

@private

# File lib/aws/ec2/snapshot.rb, line 136
def __permissions_attribute__
  "createVolumePermission"
end
create_volume(availability_zone, options = {}) click to toggle source

Creates a volume from the snapshot.

@param [AvailabilityZone or String] availability_zone The

Availability Zone in which to create the new volume. See
{EC2#availability_zones} for how to get a list of
availability zones.

@param [Hash] options Additional options for creating the volume

@option options [Integer] size The desired size (in gigabytes)

for the volume.

@return [Volume] The newly created volume

# File lib/aws/ec2/snapshot.rb, line 114
def create_volume availability_zone, options = {}
  volumes = VolumeCollection.new(:config => config)
  volumes.create(options.merge(
    :availability_zone => availability_zone,
    :snapshot => self
  ))
end
delete() click to toggle source

Deletes the snapshot. @return [nil]

# File lib/aws/ec2/snapshot.rb, line 96
def delete
  client.delete_snapshot(:snapshot_id => id)
  nil
end
exists?() click to toggle source

@return [Boolean] True if the snapshot exists.

# File lib/aws/ec2/snapshot.rb, line 123
def exists?
  resp =
    client.describe_snapshots(:filters => [{ :name => 'snapshot-id',
                                             :values => [id] }]) and
    !resp.snapshot_set.empty?
end
volume() click to toggle source

@return [Volume] The volume this snapshot was created from.

# File lib/aws/ec2/snapshot.rb, line 131
def volume
  Volume.new(volume_id, :config => config) if volume_id
end