Class: Fog::AWS::Compute::Real

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/compute/aws.rb,
lib/fog/compute/requests/aws/create_tags.rb,
lib/fog/compute/requests/aws/delete_tags.rb,
lib/fog/compute/requests/aws/create_image.rb,
lib/fog/compute/requests/aws/attach_volume.rb,
lib/fog/compute/requests/aws/create_volume.rb,
lib/fog/compute/requests/aws/delete_volume.rb,
lib/fog/compute/requests/aws/describe_tags.rb,
lib/fog/compute/requests/aws/detach_volume.rb,
lib/fog/compute/requests/aws/run_instances.rb,
lib/fog/compute/requests/aws/register_image.rb,
lib/fog/compute/requests/aws/stop_instances.rb,
lib/fog/compute/requests/aws/create_key_pair.rb,
lib/fog/compute/requests/aws/create_snapshot.rb,
lib/fog/compute/requests/aws/delete_key_pair.rb,
lib/fog/compute/requests/aws/delete_snapshot.rb,
lib/fog/compute/requests/aws/describe_images.rb,
lib/fog/compute/requests/aws/import_key_pair.rb,
lib/fog/compute/requests/aws/release_address.rb,
lib/fog/compute/requests/aws/start_instances.rb,
lib/fog/compute/requests/aws/allocate_address.rb,
lib/fog/compute/requests/aws/deregister_image.rb,
lib/fog/compute/requests/aws/describe_regions.rb,
lib/fog/compute/requests/aws/describe_volumes.rb,
lib/fog/compute/requests/aws/reboot_instances.rb,
lib/fog/compute/requests/aws/associate_address.rb,
lib/fog/compute/requests/aws/monitor_instances.rb,
lib/fog/compute/requests/aws/describe_addresses.rb,
lib/fog/compute/requests/aws/describe_instances.rb,
lib/fog/compute/requests/aws/describe_key_pairs.rb,
lib/fog/compute/requests/aws/describe_snapshots.rb,
lib/fog/compute/requests/aws/get_console_output.rb,
lib/fog/compute/requests/aws/terminate_instances.rb,
lib/fog/compute/requests/aws/unmonitor_instances.rb,
lib/fog/compute/requests/aws/disassociate_address.rb,
lib/fog/compute/requests/aws/create_security_group.rb,
lib/fog/compute/requests/aws/delete_security_group.rb,
lib/fog/compute/requests/aws/modify_image_attributes.rb,
lib/fog/compute/requests/aws/describe_security_groups.rb,
lib/fog/compute/requests/aws/modify_snapshot_attribute.rb,
lib/fog/compute/requests/aws/describe_availability_zones.rb,
lib/fog/compute/requests/aws/describe_reserved_instances.rb,
lib/fog/compute/requests/aws/revoke_security_group_ingress.rb,
lib/fog/compute/requests/aws/authorize_security_group_ingress.rb,
lib/fog/compute/requests/aws/describe_reserved_instances_offerings.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Real

Initialize connection to EC2

Notes

options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection

Examples

sdb = SimpleDB.new(
 :aws_access_key_id => your_aws_access_key_id,
 :aws_secret_access_key => your_aws_secret_access_key
)

Parameters

  • options<~Hash> - config arguments for connection. Defaults to {}.

    • region<~String> - optional region to use, in [‘eu-west-1’, ‘us-east-1’, ‘us-west-1’]

Returns

  • EC2 object with connection to aws.



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/fog/compute/aws.rb', line 171

def initialize(options={})
  unless options.delete(:provider)
    location = caller.first
    warning = "[yellow][WARN] Fog::AWS::Compute.new is deprecated, use Fog::Compute.new(:provider => 'AWS') instead[/]"
    warning << " [light_black](" << location << ")[/] "
    Formatador.display_line(warning)
  end

  require 'fog/core/parser'

  @aws_access_key_id      = options[:aws_access_key_id]
  @aws_secret_access_key  = options[:aws_secret_access_key]
  @hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
  if @endpoint = options[:endpoint]
    endpoint = URI.parse(@endpoint)
    @host = endpoint.host
    @path = endpoint.path
    @port = endpoint.port
    @scheme = endpoint.scheme
  else
    options[:region] ||= 'us-east-1'
    @host = options[:host] || case options[:region]
    when 'ap-northeast-1'
      'ec2.ap-northeast-1.amazonaws.com'
    when 'ap-southeast-1'
      'ec2.ap-southeast-1.amazonaws.com'
    when 'eu-west-1'
      'ec2.eu-west-1.amazonaws.com'
    when 'us-east-1'
      'ec2.us-east-1.amazonaws.com'
    when 'us-west-1'
      'ec2.us-west-1.amazonaws.com'
    else
      raise ArgumentError, "Unknown region: #{options[:region].inspect}"
    end
    @path   = options[:path]      || '/'
    @port   = options[:port]      || 443
    @scheme = options[:scheme]    || 'https'
  end
  @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
end

Instance Method Details

#allocate_addressObject

Acquire an elastic IP address.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘publicIp’<~String> - The acquired address

      • ‘requestId’<~String> - Id of the request



15
16
17
18
19
20
# File 'lib/fog/compute/requests/aws/allocate_address.rb', line 15

def allocate_address
  request(
    'Action'  => 'AllocateAddress',
    :parser   => Fog::Parsers::AWS::Compute::AllocateAddress.new
  )
end

#associate_address(instance_id, public_ip) ⇒ Object

Associate an elastic IP address with an instance

Parameters

  • instance_id<~String> - Id of instance to associate address with

  • public_ip<~String> - Public ip to assign to instance

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘return’<~Boolean> - success?



19
20
21
22
23
24
25
26
27
# File 'lib/fog/compute/requests/aws/associate_address.rb', line 19

def associate_address(instance_id, public_ip)
  request(
    'Action'      => 'AssociateAddress',
    'InstanceId'  => instance_id,
    'PublicIp'    => public_ip,
    :idempotent   => true,
    :parser       => Fog::Parsers::AWS::Compute::Basic.new
  )
end

#attach_volume(instance_id, volume_id, device) ⇒ Object

Attach an Amazon EBS volume with a running instance, exposing as specified device

Parameters

  • instance_id<~String> - Id of instance to associate volume with

  • volume_id<~String> - Id of amazon EBS volume to associate with instance

  • device<~String> - Specifies how the device is exposed to the instance (e.g. “/dev/sdh”)

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘attachTime’<~Time> - Time of attachment was initiated at

      • ‘device’<~String> - Device as it is exposed to the instance

      • ‘instanceId’<~String> - Id of instance for volume

      • ‘requestId’<~String> - Id of request

      • ‘status’<~String> - Status of volume

      • ‘volumeId’<~String> - Reference to volume



24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/compute/requests/aws/attach_volume.rb', line 24

def attach_volume(instance_id, volume_id, device)
  request(
    'Action'      => 'AttachVolume',
    'VolumeId'    => volume_id,
    'InstanceId'  => instance_id,
    'Device'      => device,
    :idempotent   => true,
    :parser       => Fog::Parsers::AWS::Compute::AttachVolume.new
  )
end

#authorize_security_group_ingress(group_name, options = {}) ⇒ Object

Add permissions to a security group

Parameters

  • group_name<~String> - Name of group

  • options<~Hash>:

    • ‘SourceSecurityGroupName’<~String> - Name of security group to authorize

    • ‘SourceSecurityGroupOwnerId’<~String> - Name of owner to authorize

    or

    • ‘CidrIp’ - CIDR range

    • ‘FromPort’ - Start of port range (or -1 for ICMP wildcard)

    • ‘GroupName’ - Name of group to modify

    • ‘IpProtocol’ - Ip protocol, must be in [‘tcp’, ‘udp’, ‘icmp’]

    • ‘ToPort’ - End of port range (or -1 for ICMP wildcard)

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘return’<~Boolean> - success?



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/compute/requests/aws/authorize_security_group_ingress.rb', line 27

def authorize_security_group_ingress(group_name, options = {})
  if group_name.is_a?(Hash)
    location = caller.first
    warning = "[yellow][WARN] Fog::AWS::Compute#authorize_security_group_ingress now requires the 'group_name' parameter. Only specifying an options hash is now deprecated"
    warning << " [light_black](" << location << ")[/] "
    Formatador.display_line(warning)
    options = group_name
    group_name = options['GroupName']
  end
  request({
    'Action'    => 'AuthorizeSecurityGroupIngress',
    'GroupName' => group_name,
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::Basic.new
  }.merge!(options))
end

#create_image(instance_id, name, description, no_reboot = false) ⇒ Object

Create a bootable EBS volume AMI

Parameters

  • instance_id<~String> - Instance used to create image.

  • name<~Name> - Name to give image.

  • description<~Name> - Description of image.

  • no_reboot<~Boolean> - Optional, whether or not to reboot the image when making the snapshot

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘imageId’<~String> - The ID of the created AMI.

      • ‘requestId’<~String> - Id of request.



22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/compute/requests/aws/create_image.rb', line 22

def create_image(instance_id, name, description, no_reboot = false)
  request(
    'Action'            => 'CreateImage',
    'InstanceId'        => instance_id,
    'Name'              => name,
    'Description'       => description,
    'NoReboot'          => no_reboot.to_s,
    :parser             => Fog::Parsers::AWS::Compute::CreateImage.new
  )
end

#create_key_pair(key_name) ⇒ Object

Create a new key pair

Parameters

  • key_name<~String> - Unique name for key pair.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘keyFingerprint’<~String> - SHA-1 digest of DER encoded private key

      • ‘keyMaterial’<~String> - Unencrypted encoded PEM private key

      • ‘keyName’<~String> - Name of key

      • ‘requestId’<~String> - Id of request



20
21
22
23
24
25
26
# File 'lib/fog/compute/requests/aws/create_key_pair.rb', line 20

def create_key_pair(key_name)
  request(
    'Action'  => 'CreateKeyPair',
    'KeyName' => key_name,
    :parser   => Fog::Parsers::AWS::Compute::CreateKeyPair.new
  )
end

#create_security_group(name, description) ⇒ Object

Create a new security group

Parameters

  • group_name<~String> - Name of the security group.

  • group_description<~String> - Description of group.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘return’<~Boolean> - success?



19
20
21
22
23
24
25
26
# File 'lib/fog/compute/requests/aws/create_security_group.rb', line 19

def create_security_group(name, description)
  request(
    'Action'            => 'CreateSecurityGroup',
    'GroupName'         => name,
    'GroupDescription'  => CGI.escape(description),
    :parser             => Fog::Parsers::AWS::Compute::Basic.new
  )
end

#create_snapshot(volume_id, description = nil) ⇒ Object

Create a snapshot of an EBS volume and store it in S3

Parameters

  • volume_id<~String> - Id of EBS volume to snapshot

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘progress’<~String> - The percentage progress of the snapshot

      • ‘requestId’<~String> - id of request

      • ‘snapshotId’<~String> - id of snapshot

      • ‘startTime’<~Time> - timestamp when snapshot was initiated

      • ‘status’<~String> - state of snapshot

      • ‘volumeId’<~String> - id of volume snapshot targets



22
23
24
25
26
27
28
29
# File 'lib/fog/compute/requests/aws/create_snapshot.rb', line 22

def create_snapshot(volume_id, description = nil)
  request(
    'Action'      => 'CreateSnapshot',
    'Description' => description,
    'VolumeId'    => volume_id,
    :parser       => Fog::Parsers::AWS::Compute::CreateSnapshot.new
  )
end

#create_tags(resources, tags) ⇒ Object

Adds tags to resources

Parameters

  • resources<~String> - One or more resources to tag

  • tags<~String> - hash of key value tag pairs to assign

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘return’<~Boolean> - success?



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/compute/requests/aws/create_tags.rb', line 19

def create_tags(resources, tags)
  resources = [*resources]
  for key, value in tags
    if value.nil?
      tags[key] = ''
    end
  end
  params = {}
  params.merge!(AWS.indexed_param('ResourceId', resources))
  params.merge!(AWS.indexed_param('Tag.%d.Key', tags.keys))
  params.merge!(AWS.indexed_param('Tag.%d.Value', tags.values))
  request({
    'Action'            => 'CreateTags',
    :parser             => Fog::Parsers::AWS::Compute::Basic.new
  }.merge!(params))
end

#create_volume(availability_zone, size, snapshot_id = nil) ⇒ Object

Create an EBS volume

Parameters

  • availability_zone<~String> - availability zone to create volume in

  • size<~Integer> - Size in GiBs for volume. Must be between 1 and 1024.

  • snapshot_id<~String> - Optional, snapshot to create volume from

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘availabilityZone’<~String> - Availability zone for volume

      • ‘createTime’<~Time> - Timestamp for creation

      • ‘size’<~Integer> - Size in GiBs for volume

      • ‘snapshotId’<~String> - Snapshot volume was created from, if any

      • ‘status’s<~String> - State of volume

      • ‘volumeId’<~String> - Reference to volume



24
25
26
27
28
29
30
31
32
# File 'lib/fog/compute/requests/aws/create_volume.rb', line 24

def create_volume(availability_zone, size, snapshot_id = nil)
  request(
    'Action'            => 'CreateVolume',
    'AvailabilityZone'  => availability_zone,
    'Size'              => size,
    'SnapshotId'        => snapshot_id,
    :parser             => Fog::Parsers::AWS::Compute::CreateVolume.new
  )
end

#delete_key_pair(key_name) ⇒ Object

Delete a key pair that you own

Parameters

  • key_name<~String> - Name of the key pair.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> id of request

      • ‘return’<~Boolean> - success?



18
19
20
21
22
23
24
25
# File 'lib/fog/compute/requests/aws/delete_key_pair.rb', line 18

def delete_key_pair(key_name)
  request(
    'Action'    => 'DeleteKeyPair',
    'KeyName'   => key_name,
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::Basic.new
  )
end

#delete_security_group(name) ⇒ Object

Delete a security group that you own

Parameters

  • group_name<~String> - Name of the security group.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘return’<~Boolean> - success?



18
19
20
21
22
23
24
25
# File 'lib/fog/compute/requests/aws/delete_security_group.rb', line 18

def delete_security_group(name)
  request(
    'Action'    => 'DeleteSecurityGroup',
    'GroupName' => name,
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::Basic.new
  )
end

#delete_snapshot(snapshot_id) ⇒ Object

Delete a snapshot of an EBS volume that you own

Parameters

  • snapshot_id<~String> - ID of snapshot to delete

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘return’<~Boolean> - success?



18
19
20
21
22
23
24
25
# File 'lib/fog/compute/requests/aws/delete_snapshot.rb', line 18

def delete_snapshot(snapshot_id)
  request(
    'Action'      => 'DeleteSnapshot',
    'SnapshotId'  => snapshot_id,
    :idempotent   => true,
    :parser       => Fog::Parsers::AWS::Compute::Basic.new
  )
end

#delete_tags(resources, tags) ⇒ Object

Remove tags from resources

Parameters

  • resources<~String> - One or more resources to remove tags from

  • tags<~String> - hash of key value tag pairs to remove

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘return’<~Boolean> - success?



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/compute/requests/aws/delete_tags.rb', line 19

def delete_tags(resources, tags)
  resources = [*resources]
  params = {}
  params.merge!(AWS.indexed_param('ResourceId', resources))

  # can not rely on indexed_param because nil values should be omitted
  tags.keys.each_with_index do |key, index|
    index += 1 # should start at 1 instead of 0
    params.merge!("Tag.#{index}.Key" => key)
    unless tags[key].nil?
      params.merge("Tag.#{index}.Value" => tags[key])
    end
  end

  request({
    'Action'            => 'DeleteTags',
    :parser             => Fog::Parsers::AWS::Compute::Basic.new
  }.merge!(params))
end

#delete_volume(volume_id) ⇒ Object

Delete an EBS volume

Parameters

  • volume_id<~String> - Id of volume to delete.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘return’<~Boolean> - success?



18
19
20
21
22
23
24
25
# File 'lib/fog/compute/requests/aws/delete_volume.rb', line 18

def delete_volume(volume_id)
  request(
    'Action'    => 'DeleteVolume',
    'VolumeId'  => volume_id,
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::Basic.new
  )
end

#deregister_image(image_id) ⇒ Object

deregister an image

Parameters

  • image_id<~String> - Id of image to deregister

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘return’<~Boolean> - Returns true if deregistration succeeded

      • ‘requestId’<~String> - Id of request



18
19
20
21
22
23
24
# File 'lib/fog/compute/requests/aws/deregister_image.rb', line 18

def deregister_image(image_id)
  request(
    'Action'      => 'DeregisterImage',
    'ImageId'     => image_id,
    :parser       => Fog::Parsers::AWS::Compute::DeregisterImage.new
  )
end

#describe_addresses(filters = {}) ⇒ Object

Describe all or specified IP addresses.

Parameters

  • filters<~Hash> - List of filters to limit results with

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘addressesSet’<~Array>:

        • ‘instanceId’<~String> - instance for ip address

        • ‘publicIp’<~String> - ip address for instance



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/compute/requests/aws/describe_addresses.rb', line 20

def describe_addresses(filters = {})
  unless filters.is_a?(Hash)
    Formatador.display_line("[yellow][WARN] describe_addresses with #{filters.class} param is deprecated, use describe_addresses('public-ip' => []) instead[/] [light_black](#{caller.first})[/]")
    filters = {'public-ip' => [*filters]}
  end
  params = AWS.indexed_filters(filters)
  request({
    'Action'    => 'DescribeAddresses',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::DescribeAddresses.new
  }.merge!(params))
end

#describe_availability_zones(filters = {}) ⇒ Object

Describe all or specified availability zones

Params

  • filters<~Hash> - List of filters to limit results with

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘availabilityZoneInfo’<~Array>:

        • ‘regionName’<~String> - Name of region

        • ‘zoneName’<~String> - Name of zone

        • ‘zoneState’<~String> - State of zone



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/compute/requests/aws/describe_availability_zones.rb', line 21

def describe_availability_zones(filters = {})
  unless filters.is_a?(Hash)
    Formatador.display_line("[yellow][WARN] describe_availability_zones with #{filters.class} param is deprecated, use describe_availability_zones('zone-name' => []) instead[/] [light_black](#{caller.first})[/]")
    filters = {'public-ip' => [*filters]}
  end
  params = AWS.indexed_filters(filters)
  request({
    'Action'    => 'DescribeAvailabilityZones',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::DescribeAvailabilityZones.new
  }.merge!(params))
end

#describe_images(filters = {}) ⇒ Object

Describe all or specified images.

Params

  • filters<~Hash> - List of filters to limit results with

    • filters and/or the following

    • ‘ExecutableBy’<~String> - Only return images that the executable_by user has explicit permission to launch

    • ‘ImageId’<~Array> - Ids of images to describe

    • ‘Owner’<~String> - Only return images belonging to owner.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘imagesSet’<~Array>:

        • ‘architecture’<~String> - Architecture of the image

        • ‘blockDeviceMapping’<~Array> - An array of mapped block devices

        • ‘description’<~String> - Description of image

        • ‘imageId’<~String> - Id of the image

        • ‘imageLocation’<~String> - Location of the image

        • ‘imageOwnerId’<~String> - Id of the owner of the image

        • ‘imageState’<~String> - State of the image

        • ‘imageType’<~String> - Type of the image

        • ‘isPublic’<~Boolean> - Whether or not the image is public

        • ‘kernelId’<~String> - Kernel id associated with image, if any

        • ‘platform’<~String> - Operating platform of the image

        • ‘productCodes’<~Array> - Product codes for the image

        • ‘ramdiskId’<~String> - Ramdisk id associated with image, if any

        • ‘rootDeviceName’<~String> - Root device name, e.g. /dev/sda1

        • ‘rootDeviceType’<~String> - Root device type, ebs or instance-store

        • ‘virtualizationType’<~String> - Type of virtualization



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/compute/requests/aws/describe_images.rb', line 39

def describe_images(filters = {})
  options = {}
  for key in ['ExecutableBy', 'ImageId', 'Owner']
    if filters.is_a?(Hash) && filters.key?(key)
      options[key] = filters.delete(key)
    end
  end
  params = AWS.indexed_filters(filters).merge!(options)
  request({
    'Action'    => 'DescribeImages',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::DescribeImages.new
  }.merge!(params))
end

#describe_instances(filters = {}) ⇒ Object

Describe all or specified instances

Parameters

  • filters<~Hash> - List of filters to limit results with

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘reservationSet’<~Array>:

        • ‘groupSet’<~Array> - Group names for reservation

        • ‘ownerId’<~String> - AWS Access Key ID of reservation owner

        • ‘reservationId’<~String> - Id of the reservation

        • ‘instancesSet’<~Array>:

          • instance<~Hash>:

            • ‘architecture’<~String> - architecture of image in [i386, x86_64]

            • ‘amiLaunchIndex’<~Integer> - reference to instance in launch group

            • ‘blockDeviceMapping’<~Array>

              • ‘attachTime’<~Time> - time of volume attachment

              • ‘deleteOnTermination’<~Boolean> - whether or not to delete volume on termination

              • ‘deviceName’<~String> - specifies how volume is exposed to instance

              • ‘status’<~String> - status of attached volume

              • ‘volumeId’<~String> - Id of attached volume

            • ‘dnsName’<~String> - public dns name, blank until instance is running

            • ‘imageId’<~String> - image id of ami used to launch instance

            • ‘instanceId’<~String> - id of the instance

            • ‘instanceState’<~Hash>:

              • ‘code’<~Integer> - current status code

              • ‘name’<~String> - current status name

            • ‘instanceType’<~String> - type of instance

            • ‘ipAddress’<~String> - public ip address assigned to instance

            • ‘kernelId’<~String> - id of kernel used to launch instance

            • ‘keyName’<~String> - name of key used launch instances or blank

            • ‘launchTime’<~Time> - time instance was launched

            • ‘monitoring’<~Hash>:

              • ‘state’<~Boolean - state of monitoring

            • ‘placement’<~Hash>:

              • ‘availabilityZone’<~String> - Availability zone of the instance

            • ‘productCodes’<~Array> - Product codes for the instance

            • ‘privateDnsName’<~String> - private dns name, blank until instance is running

            • ‘privateIpAddress’<~String> - private ip address assigned to instance

            • ‘rootDeviceName’<~String> - specifies how the root device is exposed to the instance

            • ‘rootDeviceType’<~String> - root device type used by AMI in [ebs, instance-store]

            • ‘ramdiskId’<~String> - Id of ramdisk used to launch instance

            • ‘reason’<~String> - reason for most recent state transition, or blank



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fog/compute/requests/aws/describe_instances.rb', line 53

def describe_instances(filters = {})
  unless filters.is_a?(Hash)
    Formatador.display_line("[yellow][WARN] describe_instances with #{filters.class} param is deprecated, use describe_instances('instance-id' => []) instead[/] [light_black](#{caller.first})[/]")
    filters = {'instance-id' => [*filters]}
  end
  params = AWS.indexed_filters(filters)

  request({
    'Action'    => 'DescribeInstances',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::DescribeInstances.new
  }.merge!(params))
end

#describe_key_pairs(filters = {}) ⇒ Object

Describe all or specified key pairs

Parameters

  • filters<~Hash> - List of filters to limit results with

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘keySet’<~Array>:

        • ‘keyName’<~String> - Name of key

        • ‘keyFingerprint’<~String> - Fingerprint of key



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/compute/requests/aws/describe_key_pairs.rb', line 20

def describe_key_pairs(filters = {})
  unless filters.is_a?(Hash)
    Formatador.display_line("[yellow][WARN] describe_key_pairs with #{filters.class} param is deprecated, use describe_key_pairs('key-name' => []) instead[/] [light_black](#{caller.first})[/]")
    filters = {'key-name' => [*filters]}
  end
  params = AWS.indexed_filters(filters)
  request({
    'Action'    => 'DescribeKeyPairs',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::DescribeKeyPairs.new
  }.merge!(params))
end

#describe_regions(filters = {}) ⇒ Object

Describe all or specified regions

Params

  • filters<~Hash> - List of filters to limit results with

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘regionInfo’<~Array>:

        • ‘regionName’<~String> - Name of region

        • ‘regionEndpoint’<~String> - Service endpoint for region



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/compute/requests/aws/describe_regions.rb', line 20

def describe_regions(filters = {})
  unless filters.is_a?(Hash)
    Formatador.display_line("[yellow][WARN] describe_regions with #{filters.class} param is deprecated, use describe_regions('region-name' => []) instead[/] [light_black](#{caller.first})[/]")
    filters = {'region-name' => [*filters]}
  end
  params = AWS.indexed_filters(filters)
  request({
    'Action'    => 'DescribeRegions',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::DescribeRegions.new
  }.merge!(params))
end

#describe_reserved_instances(filters = {}) ⇒ Object

Describe all or specified reserved instances

Parameters

  • filters<~Hash> - List of filters to limit results with

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘reservedInstancesSet’<~Array>:

        • ‘availabilityZone’<~String> - availability zone of the instance

        • ‘duration’<~Integer> - duration of reservation, in seconds

        • ‘fixedPrice’<~Float> - purchase price of reserved instance

        • ‘instanceType’<~String> - type of instance

        • ‘instanceCount’<~Integer> - number of reserved instances

        • ‘productDescription’<~String> - reserved instance description

        • ‘reservedInstancesId’<~String> - id of the instance

        • ‘start’<~Time> - start time for reservation

        • ‘state’<~String> - state of reserved instance purchase, in .[pending-payment, active, payment-failed, retired]

        • ‘usagePrice“<~Float> - usage price of reserved instances, per hour



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/compute/requests/aws/describe_reserved_instances.rb', line 28

def describe_reserved_instances(filters = {})
  unless filters.is_a?(Hash)
    Formatador.display_line("[yellow][WARN] describe_reserved_instances with #{filters.class} param is deprecated, use describe_reserved_instances('reserved-instances-id' => []) instead[/] [light_black](#{caller.first})[/]")
    filters = {'reserved-instances-id' => [*filters]}
  end
  params = AWS.indexed_filters(filters)
  request({
    'Action'    => 'DescribeReservedInstances',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::DescribeReservedInstances.new
  }.merge!(params))
end

#describe_reserved_instances_offerings(filters = {}) ⇒ Object

Describe all or specified reserved instances offerings

Parameters

  • filters<~Hash> - List of filters to limit results with

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘reservedInstancesOfferingsSet’<~Array>:

        • ‘availabilityZone’<~String> - availability zone of offering

        • ‘duration’<~Integer> - duration, in seconds, of offering

        • ‘fixedPrice’<~Float> - purchase price of offering

        • ‘instanceType’<~String> - instance type of offering

        • ‘productDescription’<~String> - description of offering

        • ‘reservedInstancesOfferingId’<~String> - id of offering

        • ‘usagePrice’<~Float> - usage price of offering, per hour



25
26
27
28
29
30
31
32
# File 'lib/fog/compute/requests/aws/describe_reserved_instances_offerings.rb', line 25

def describe_reserved_instances_offerings(filters = {})
  params = AWS.indexed_filters(filters)
  request({
    'Action'    => 'DescribeReservedInstancesOfferings',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::DescribeReservedInstancesOfferings.new
  }.merge!(params))
end

#describe_security_groups(filters = {}) ⇒ Object

Describe all or specified security groups

Parameters

  • filters<~Hash> - List of filters to limit results with

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘securityGroupInfo’<~Array>:

        • ‘groupDescription’<~String> - Description of security group

        • ‘groupName’<~String> - Name of security group

        • ‘ipPermissions’<~Array>:

          • ‘fromPort’<~Integer> - Start of port range (or -1 for ICMP wildcard)

          • ‘groups’<~Array>:

            • ‘groupName’<~String> - Name of security group

            • ‘userId’<~String> - AWS User Id of account

          • ‘ipProtocol’<~String> - Ip protocol, must be in [‘tcp’, ‘udp’, ‘icmp’]

          • ‘ipRanges’<~Array>:

            • ‘cidrIp’<~String> - CIDR range

          • ‘toPort’<~Integer> - End of port range (or -1 for ICMP wildcard)

        • ‘ownerId’<~String> - AWS Access Key Id of the owner of the security group



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/compute/requests/aws/describe_security_groups.rb', line 30

def describe_security_groups(filters = {})
  unless filters.is_a?(Hash)
    Formatador.display_line("[yellow][WARN] describe_security_groups with #{filters.class} param is deprecated, use describe_security_groups('group-name' => []) instead[/] [light_black](#{caller.first})[/]")
    filters = {'group-name' => [*filters]}
  end
  params = AWS.indexed_filters(filters)
  request({
    'Action'    => 'DescribeSecurityGroups',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::DescribeSecurityGroups.new
  }.merge!(params))
end

#describe_snapshots(filters = {}, options = {}) ⇒ Object

Describe all or specified snapshots

Parameters

  • filters<~Hash> - List of filters to limit results with

  • options<~Hash>:

    • ‘Owner’<~String> - Owner of snapshot in [‘self’, ‘amazon’, account_id]

    • ‘RestorableBy’<~String> - Account id of user who can create volumes from this snapshot

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘snapshotSet’<~Array>:

        • ‘progress’<~String>: The percentage progress of the snapshot

        • ‘snapshotId’<~String>: Id of the snapshot

        • ‘startTime’<~Time>: Timestamp of when snapshot was initiated

        • ‘status’<~String>: Snapshot state, in [‘pending’, ‘completed’]

        • ‘volumeId’<~String>: Id of volume that snapshot contains



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/compute/requests/aws/describe_snapshots.rb', line 26

def describe_snapshots(filters = {}, options = {})
  unless filters.is_a?(Hash)
    Formatador.display_line("[yellow][WARN] describe_snapshots with #{filters.class} param is deprecated, use describe_snapshots('snapshot-id' => []) instead[/] [light_black](#{caller.first})[/]")
    filters = {'snapshot-id' => [*filters]}
  end
  unless options.empty?
    Formatador.display_line("[yellow][WARN] describe_snapshots with a second param is deprecated, use describe_snapshots(options) instead[/] [light_black](#{caller.first})[/]")
  end

  for key in ['ExecutableBy', 'ImageId', 'Owner', 'RestorableBy']
    if filters.has_key?(key)
      options[key] = filters.delete(key)
    end
  end
  options['RestorableBy'] ||= 'self'
  params = AWS.indexed_filters(filters).merge!(options)
  request({
    'Action'    => 'DescribeSnapshots',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::DescribeSnapshots.new
  }.merge!(params))
end

#describe_tags(filters = {}) ⇒ Object

Describe all or specified tags

Parameters

  • filters<~Hash> - List of filters to limit results with

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘tagSet’<~Array>:

        • ‘resourceId’<~String> - id of resource tag belongs to

        • ‘resourceType’<~String> - type of resource tag belongs to

        • ‘key’<~String> - Tag’s key

        • ‘value’<~String> - Tag’s value



22
23
24
25
26
27
28
29
# File 'lib/fog/compute/requests/aws/describe_tags.rb', line 22

def describe_tags(filters = {})
  params = AWS.indexed_filters(filters)
  request({
    'Action'    => 'DescribeTags',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::DescribeTags.new
  }.merge!(params))
end

#describe_volumes(filters = {}) ⇒ Object

Describe all or specified volumes.

Parameters

  • filters<~Hash> - List of filters to limit results with

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘volumeSet’<~Array>:

        • ‘availabilityZone’<~String> - Availability zone for volume

        • ‘createTime’<~Time> - Timestamp for creation

        • ‘size’<~Integer> - Size in GiBs for volume

        • ‘snapshotId’<~String> - Snapshot volume was created from, if any

        • ‘status’<~String> - State of volume

        • ‘volumeId’<~String> - Reference to volume

        • ‘attachmentSet’<~Array>:

          • ‘attachmentTime’<~Time> - Timestamp for attachment

          • ‘deleteOnTermination’<~Boolean> - Whether or not to delete volume on instance termination

          • ‘device’<~String> - How value is exposed to instance

          • ‘instanceId’<~String> - Reference to attached instance

          • ‘status’<~String> - Attachment state

          • ‘volumeId’<~String> - Reference to volume



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/compute/requests/aws/describe_volumes.rb', line 30

def describe_volumes(filters = {})
  unless filters.is_a?(Hash)
    Formatador.display_line("[yellow][WARN] describe_volumes with #{filters.class} param is deprecated, use describe_volumes('volume-id' => []) instead[/] [light_black](#{caller.first})[/]")
    filters = {'volume-id' => [*filters]}
  end
  params = AWS.indexed_filters(filters)
  request({
    'Action'    => 'DescribeVolumes',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::DescribeVolumes.new
  }.merge!(params))
end

#detach_volume(volume_id, options = {}) ⇒ Object

Detach an Amazon EBS volume from a running instance

Parameters

  • volume_id<~String> - Id of amazon EBS volume to associate with instance

  • options<~Hash>:

    • ‘Device’<~String> - Specifies how the device is exposed to the instance (e.g. “/dev/sdh”)

    • ‘Force’<~Boolean> - If true forces detach, can cause data loss/corruption

    • ‘InstanceId’<~String> - Id of instance to associate volume with

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘attachTime’<~Time> - Time of attachment was initiated at

      • ‘device’<~String> - Device as it is exposed to the instance

      • ‘instanceId’<~String> - Id of instance for volume

      • ‘requestId’<~String> - Id of request

      • ‘status’<~String> - Status of volume

      • ‘volumeId’<~String> - Reference to volume



26
27
28
29
30
31
32
33
# File 'lib/fog/compute/requests/aws/detach_volume.rb', line 26

def detach_volume(volume_id, options = {})
  request({
    'Action'    => 'DetachVolume',
    'VolumeId'  => volume_id,
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::DetachVolume.new
  }.merge!(options))
end

#disassociate_address(public_ip) ⇒ Object

Disassociate an elastic IP address from its instance (if any)

Parameters

  • public_ip<~String> - Public ip to assign to instance

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘return’<~Boolean> - success?



18
19
20
21
22
23
24
25
# File 'lib/fog/compute/requests/aws/disassociate_address.rb', line 18

def disassociate_address(public_ip)
  request(
    'Action'    => 'DisassociateAddress',
    'PublicIp'  => public_ip,
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::Basic.new
  )
end

#get_console_output(instance_id) ⇒ Object

Retrieve console output for specified instance

Parameters

  • instance_id<~String> - Id of instance to get console output from

Returns

# * response<~Excon::Response>:

* body<~Hash>:
  * 'instanceId'<~String> - Id of instance
  * 'output'<~String> - Console output
  * 'requestId'<~String> - Id of request
  * 'timestamp'<~Time> - Timestamp of last update to output


20
21
22
23
24
25
26
27
# File 'lib/fog/compute/requests/aws/get_console_output.rb', line 20

def get_console_output(instance_id)
  request(
    'Action'      => 'GetConsoleOutput',
    'InstanceId'  => instance_id,
    :idempotent   => true,
    :parser       => Fog::Parsers::AWS::Compute::GetConsoleOutput.new
  )
end

#import_key_pair(key_name, public_key_material) ⇒ Object

Import an existing public key to create a new key pair

Parameters

  • key_name<~String> - Unique name for key pair.

  • public_key_material<~String> - RSA public key

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘keyFingerprint’<~String> - SHA-1 digest of DER encoded private key

      • ‘keyName’<~String> - Name of key

      • ‘requestId’<~String> - Id of request



20
21
22
23
24
25
26
27
# File 'lib/fog/compute/requests/aws/import_key_pair.rb', line 20

def import_key_pair(key_name, public_key_material)
  request(
    'Action'  => 'ImportKeyPair',
    'KeyName' => key_name,
    'PublicKeyMaterial' => Base64::encode64(public_key_material),
    :parser   => Fog::Parsers::AWS::Compute::ImportKeyPair.new
  )
end

#modify_image_attributes(image_id, attribute, operation_type, options = {}) ⇒ Object

Modify image attributes

Parameters

  • image_id<~String> - Id of machine image to modify

  • attribute<~String> - Attribute to modify, in [‘launchPermission’, ‘productCodes’]

  • operation_type<~String> - Operation to perform on attribute, in [‘add’, ‘remove’]



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fog/compute/requests/aws/modify_image_attributes.rb', line 15

def modify_image_attributes(image_id, attribute, operation_type, options = {})
  params = {}
  params.merge!(AWS.indexed_param('UserId', options['UserId']))
  params.merge!(AWS.indexed_param('UserGroup', options['UserGroup']))
  params.merge!(AWS.indexed_param('ProductCode', options['ProductCode']))
  request({
    'Action'        => 'ModifyImageAttribute',
    'Attribute'     => attribute,
    'ImageId'       => image_id,
    'OperationType' => operation_type,
    :idempotent     => true,
    :parser         => Fog::Parsers::AWS::Compute::Basic.new
  }.merge!(params))
end

#modify_snapshot_attribute(snapshot_id, attribute, operation_type, options = {}) ⇒ Object

Modify snapshot attributes

Parameters

  • snapshot_id<~String> - Id of snapshot to modify

  • attribute<~String> - Attribute to modify, in [‘createVolumePermission’]

  • operation_type<~String> - Operation to perform on attribute, in [‘add’, ‘remove’]



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/compute/requests/aws/modify_snapshot_attribute.rb', line 15

def modify_snapshot_attribute(snapshot_id, attribute, operation_type, options = {})
  params = {}
  params.merge!(AWS.indexed_param('UserId', options['UserId']))
  params.merge!(AWS.indexed_param('UserGroup', options['UserGroup']))
  request({
    'Action'        => 'ModifySnapshotAttribute',
    'Attribute'     => attribute,
    'SnapshotId'    => snapshot_id,
    'OperationType' => operation_type,
    :idempotent     => true,
    :parser         => Fog::Parsers::AWS::Compute::Basic.new
  }.merge!(params))
end

#monitor_instances(instance_ids) ⇒ Object

Monitor specified instance docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-MonitorInstances.html

Parameters

  • instance_ids<~Array> - Arrays of instances Ids to monitor

Returns



20
21
22
23
24
25
26
27
# File 'lib/fog/compute/requests/aws/monitor_instances.rb', line 20

def monitor_instances(instance_ids)
  params = AWS.indexed_param('InstanceId', instance_ids)
  request({
                  'Action' => 'MonitorInstances',
                  :idempotent => true,
                  :parser => Fog::Parsers::AWS::Compute::MonitorUnmonitorInstances.new
          }.merge!(params))
end

#reboot_instances(instance_id = []) ⇒ Object

Reboot specified instances

Parameters

  • instance_id<~Array> - Ids of instances to reboot

Returns

# * response<~Excon::Response>:

* body<~Hash>:
  * 'requestId'<~String> - Id of request
  * 'return'<~Boolean> - success?


18
19
20
21
22
23
24
25
# File 'lib/fog/compute/requests/aws/reboot_instances.rb', line 18

def reboot_instances(instance_id = [])
  params = AWS.indexed_param('InstanceId', instance_id)
  request({
    'Action'    => 'RebootInstances',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::Basic.new
  }.merge!(params))
end

#register_image(name, description, location, block_devices = [], options = {}) ⇒ Object

register an image

Parameters

  • Name<~String> - Name of the AMI to be registered

  • Description<~String> - AMI description

  • Location<~String> - S3 manifest location (for S3 backed AMIs)

or

  • RootDeviceName<~String> - Name of Root Device (for EBS snapshot backed AMIs)

  • BlockDevices<~Array>:

    • BlockDeviceOptions<~Hash>:

      • DeviceName<~String> - Name of the Block Device

      • VirtualName<~String> - Name of the Virtual Device

      • SnapshotId<~String> - id of the EBS Snapshot

      • VolumeSize<~Integer> - Size of the snapshot (optional)

      • NoDevice<~Boolean> - Do not use an ebs device (def: true)

      • DeleteOnTermation<~Boolean> - Delete EBS volume on instance term (def: true)

  • Options<~Hash>:

    • Architecture<~String> - i386 or x86_64

    • KernelId<~String> - kernelId

    • RamdiskId<~String> - ramdiskId

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘imageId’<~String> - Id of newly created AMI



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fog/compute/requests/aws/register_image.rb', line 34

def register_image(name, description, location, block_devices=[], options={})
  common_options = {
    'Action'      => 'RegisterImage',
    'Name'        => name,
    'Description' => description,
    :parser       => Fog::Parsers::AWS::Compute::RegisterImage.new
  }

  # This determines if we are doing a snapshot or a S3 backed AMI.
  if(location =~ /^\/dev\/sd[a-p]\d{0,2}$/)
    common_options['RootDeviceName'] = location
  else
    common_options['ImageLocation'] = location
  end

  bdi = 0
  block_devices.each do |bd|
    bdi += 1
    ["DeviceName","VirtualName"].each do |n|
      common_options["BlockDeviceMapping.#{bdi}.#{n}"] = bd["#{n}"] if bd["#{n}"]
    end
    ["SnapshotId","VolumeSize","NoDevice","DeleteOnTermination"].each do |n|
      common_options["BlockDeviceMapping.#{bdi}.Ebs.#{n}"] = bd["#{n}"] if bd["#{n}"]
    end

  end

  request(common_options.merge!(options))
end

#release_address(public_ip) ⇒ Object

Release an elastic IP address.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘return’<~Boolean> - success?



15
16
17
18
19
20
21
22
# File 'lib/fog/compute/requests/aws/release_address.rb', line 15

def release_address(public_ip)
  request(
    'Action'    => 'ReleaseAddress',
    'PublicIp'  => public_ip,
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::Basic.new
  )
end

#reloadObject



213
214
215
# File 'lib/fog/compute/aws.rb', line 213

def reload
  @connection.reset
end

#revoke_security_group_ingress(group_name, options = {}) ⇒ Object

Remove permissions from a security group

Parameters

  • ‘GroupName’<~String> - Name of group

  • options<~Hash>:

    • ‘SourceSecurityGroupName’<~String> - Name of security group to authorize

    • ‘SourceSecurityGroupOwnerId’<~String> - Name of owner to authorize

    or

    • ‘CidrIp’ - CIDR range

    • ‘FromPort’ - Start of port range (or -1 for ICMP wildcard)

    • ‘IpProtocol’ - Ip protocol, must be in [‘tcp’, ‘udp’, ‘icmp’]

    • ‘ToPort’ - End of port range (or -1 for ICMP wildcard)

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘return’<~Boolean> - success?



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/compute/requests/aws/revoke_security_group_ingress.rb', line 26

def revoke_security_group_ingress(group_name, options = {})
  if group_name.is_a?(Hash)
    location = caller.first
    warning = "[yellow][WARN] Fog::AWS::Compute#revoke_security_group_ingress now requires the 'group_name' parameter. Only specifying an options hash is now deprecated"
    warning << " [light_black](" << location << ")[/] "
    Formatador.display_line(warning)
    options = group_name
    group_name = options['GroupName']
  end
  request({
    'Action'    => 'RevokeSecurityGroupIngress',
    'GroupName' => group_name,
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::Basic.new
  }.merge!(options))
end

#run_instances(image_id, min_count, max_count, options = {}) ⇒ Object

Launch specified instances

Parameters

  • image_id<~String> - Id of machine image to load on instances

  • min_count<~Integer> - Minimum number of instances to launch. If this exceeds the count of available instances, no instances will be launched. Must be between 1 and maximum allowed for your account (by default the maximum for an account is 20)

  • max_count<~Integer> - Maximum number of instances to launch. If this exceeds the number of available instances, the largest possible number of instances above min_count will be launched instead. Must be between 1 and maximum allowed for you account (by default the maximum for an account is 20)

  • options<~Hash>:

    • ‘Placement.AvailabilityZone’<~String> - Placement constraint for instances

    • ‘BlockDeviceMapping’<~Array>: array of hashes

      • ‘DeviceName’<~String> - where the volume will be exposed to instance

      • ‘VirtualName’<~String> - volume virtual device name

      • ‘Ebs.SnapshotId’<~String> - id of snapshot to boot volume from

      • ‘Ebs.VolumeSize’<~String> - size of volume in GiBs required unless snapshot is specified

      • ‘Ebs.DeleteOnTermination’<~String> - specifies whether or not to delete the volume on instance termination

    • ‘ClientToken’<~String> - unique case-sensitive token for ensuring idempotency

    • ‘SecurityGroup’<~Array> or <~String> - Name of security group(s) for instances (you must omit this parameter if using Virtual Private Clouds)

    • ‘InstanceInitiatedShutdownBehaviour’<~String> - specifies whether volumes are stopped or terminated when instance is shutdown, in [stop, terminate]

    • ‘InstanceType’<~String> - Type of instance to boot. Valid options in [‘m1.small’, ‘m1.large’, ‘m1.xlarge’, ‘c1.medium’, ‘c1.xlarge’, ‘m2.2xlarge’, ‘m2.4xlarge’] default is ‘m1.small’

    • ‘KernelId’<~String> - Id of kernel with which to launch

    • ‘KeyName’<~String> - Name of a keypair to add to booting instances

    • ‘Monitoring.Enabled’<~Boolean> - Enables monitoring, defaults to disabled

    • ‘RamdiskId’<~String> - Id of ramdisk with which to launch

    • ‘UserData’<~String> - Additional data to provide to booting instances

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘groupSet’<~Array>: groups the instances are members in

        • ‘groupName’<~String> - Name of group

      • ‘instancesSet’<~Array>: returned instances

        • instance<~Hash>:

          • ‘amiLaunchIndex’<~Integer> - reference to instance in launch group

          • ‘architecture’<~String> - architecture of image in [i386, x86_64]

          • ‘blockDeviceMapping’<~Array>

            • ‘attachTime’<~Time> - time of volume attachment

            • ‘deleteOnTermination’<~Boolean> - whether or not to delete volume on termination

            • ‘deviceName’<~String> - specifies how volume is exposed to instance

            • ‘status’<~String> - status of attached volume

            • ‘volumeId’<~String> - Id of attached volume

          • ‘dnsName’<~String> - public dns name, blank until instance is running

          • ‘imageId’<~String> - image id of ami used to launch instance

          • ‘instanceId’<~String> - id of the instance

          • ‘instanceState’<~Hash>:

            • ‘code’<~Integer> - current status code

            • ‘name’<~String> - current status name

          • ‘instanceType’<~String> - type of instance

          • ‘ipAddress’<~String> - public ip address assigned to instance

          • ‘kernelId’<~String> - Id of kernel used to launch instance

          • ‘keyName’<~String> - name of key used launch instances or blank

          • ‘launchTime’<~Time> - time instance was launched

          • ‘monitoring’<~Hash>:

            • ‘state’<~Boolean - state of monitoring

          • ‘placement’<~Hash>:

            • ‘availabilityZone’<~String> - Availability zone of the instance

          • ‘privateDnsName’<~String> - private dns name, blank until instance is running

          • ‘privateIpAddress’<~String> - private ip address assigned to instance

          • ‘productCodes’<~Array> - Product codes for the instance

          • ‘ramdiskId’<~String> - Id of ramdisk used to launch instance

          • ‘reason’<~String> - reason for most recent state transition, or blank

          • ‘rootDeviceName’<~String> - specifies how the root device is exposed to the instance

          • ‘rootDeviceType’<~String> - root device type used by AMI in [ebs, instance-store]

      • ‘ownerId’<~String> - Id of owner

      • ‘requestId’<~String> - Id of request

      • ‘reservationId’<~String> - Id of reservation



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/fog/compute/requests/aws/run_instances.rb', line 82

def run_instances(image_id, min_count, max_count, options = {})
  if block_device_mapping = options.delete('BlockDeviceMapping')
    block_device_mapping.each_with_index do |mapping, index|
      for key, value in mapping
        options.merge!({ format("BlockDeviceMapping.%d.#{key}", index) => value })
      end
    end
  end
  if security_groups = options.delete('SecurityGroup')
    options.merge!(AWS.indexed_param('SecurityGroup', [*security_groups]))
  end
  if options['UserData']
    options['UserData'] = Base64.encode64(options['UserData'])
  end

  idempotent = !(options['ClientToken'].nil? || options['ClientToken'].empty?)

  request({
    'Action'    => 'RunInstances',
    'ImageId'   => image_id,
    'MinCount'  => min_count,
    'MaxCount'  => max_count,
    :idempotent => idempotent,
    :parser     => Fog::Parsers::AWS::Compute::RunInstances.new
  }.merge!(options))
end

#start_instances(instance_id) ⇒ Object

Start specified instance

Parameters

  • instance_id<~Array> - Id of instance to start

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • TODO: fill in the blanks



18
19
20
21
22
23
24
25
# File 'lib/fog/compute/requests/aws/start_instances.rb', line 18

def start_instances(instance_id)
  params = AWS.indexed_param('InstanceId', instance_id)
  request({
    'Action'    => 'StartInstances',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::StartStopInstances.new
  }.merge!(params))
end

#stop_instances(instance_id) ⇒ Object

Stop specified instance

Parameters

  • instance_id<~Array> - Id of instance to start

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • TODO: fill in the blanks



18
19
20
21
22
23
24
25
# File 'lib/fog/compute/requests/aws/stop_instances.rb', line 18

def stop_instances(instance_id)
  params = AWS.indexed_param('InstanceId', instance_id)
  request({
    'Action'    => 'StopInstances',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::StartStopInstances.new
  }.merge!(params))
end

#terminate_instances(instance_id) ⇒ Object

Terminate specified instances

Parameters

  • instance_id<~Array> - Ids of instances to terminates

Returns

# * response<~Excon::Response>:

* body<~Hash>:
  * 'requestId'<~String> - Id of request
  * 'instancesSet'<~Array>:
    * 'instanceId'<~String> - id of the terminated instance
    * 'previousState'<~Hash>: previous state of instance
      * 'code'<~Integer> - previous status code
      * 'name'<~String> - name of previous state
    * 'shutdownState'<~Hash>: shutdown state of instance
      * 'code'<~Integer> - current status code
      * 'name'<~String> - name of current state


25
26
27
28
29
30
31
32
# File 'lib/fog/compute/requests/aws/terminate_instances.rb', line 25

def terminate_instances(instance_id)
  params = AWS.indexed_param('InstanceId', instance_id)
  request({
    'Action'    => 'TerminateInstances',
    :idempotent => true,
    :parser     => Fog::Parsers::AWS::Compute::TerminateInstances.new
  }.merge!(params))
end

#unmonitor_instances(instance_ids) ⇒ Object

UnMonitor specified instance docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-UnmonitorInstances.html

Parameters

  • instance_ids<~Array> - Arrays of instances Ids to monitor

Returns



20
21
22
23
24
25
26
27
# File 'lib/fog/compute/requests/aws/unmonitor_instances.rb', line 20

def unmonitor_instances(instance_ids)
  params = AWS.indexed_param('InstanceId', instance_ids)
  request({
                  'Action' => 'UnmonitorInstances',
                  :idempotent => true,
                  :parser => Fog::Parsers::AWS::Compute::MonitorUnmonitorInstances.new
          }.merge!(params))
end