You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: AWS::EC2

Inherits:
Object
  • Object
show all
Includes:
Core::ServiceInterface
Defined in:
lib/aws/ec2.rb,
lib/aws/ec2/vpc.rb,
lib/aws/ec2/tag.rb,
lib/aws/ec2/image.rb,
lib/aws/ec2/errors.rb,
lib/aws/ec2/subnet.rb,
lib/aws/ec2/volume.rb,
lib/aws/ec2/region.rb,
lib/aws/ec2/client.rb,
lib/aws/ec2/instance.rb,
lib/aws/ec2/resource.rb,
lib/aws/ec2/snapshot.rb,
lib/aws/ec2/key_pair.rb,
lib/aws/ec2/elastic_ip.rb,
lib/aws/ec2/collection.rb,
lib/aws/ec2/attachment.rb,
lib/aws/ec2/tagged_item.rb,
lib/aws/ec2/vpn_gateway.rb,
lib/aws/ec2/export_task.rb,
lib/aws/ec2/network_acl.rb,
lib/aws/ec2/route_table.rb,
lib/aws/ec2/dhcp_options.rb,
lib/aws/ec2/security_group.rb,
lib/aws/ec2/vpc_collection.rb,
lib/aws/ec2/vpn_connection.rb,
lib/aws/ec2/tag_collection.rb,
lib/aws/ec2/has_permissions.rb,
lib/aws/ec2/customer_gateway.rb,
lib/aws/ec2/internet_gateway.rb,
lib/aws/ec2/image_collection.rb,
lib/aws/ec2/network_interface.rb,
lib/aws/ec2/tagged_collection.rb,
lib/aws/ec2/network_acl/entry.rb,
lib/aws/ec2/route_table/route.rb,
lib/aws/ec2/subnet_collection.rb,
lib/aws/ec2/volume_collection.rb,
lib/aws/ec2/availability_zone.rb,
lib/aws/ec2/region_collection.rb,
lib/aws/ec2/reserved_instances.rb,
lib/aws/ec2/key_pair_collection.rb,
lib/aws/ec2/snapshot_collection.rb,
lib/aws/ec2/filtered_collection.rb,
lib/aws/ec2/instance_collection.rb,
lib/aws/ec2/elastic_ip_collection.rb,
lib/aws/ec2/attachment_collection.rb,
lib/aws/ec2/block_device_mappings.rb,
lib/aws/ec2/permission_collection.rb,
lib/aws/ec2/route_table_collection.rb,
lib/aws/ec2/vpc_peering_connection.rb,
lib/aws/ec2/vpn_gateway_collection.rb,
lib/aws/ec2/vpn_gateway/attachment.rb,
lib/aws/ec2/export_task_collection.rb,
lib/aws/ec2/network_acl_collection.rb,
lib/aws/ec2/dhcp_options_collection.rb,
lib/aws/ec2/route_table/association.rb,
lib/aws/ec2/network_acl/association.rb,
lib/aws/ec2/resource_tag_collection.rb,
lib/aws/ec2/vpn_connection/telemetry.rb,
lib/aws/ec2/vpn_connection_collection.rb,
lib/aws/ec2/security_group_collection.rb,
lib/aws/ec2/internet_gateway_collection.rb,
lib/aws/ec2/customer_gateway_collection.rb,
lib/aws/ec2/reserved_instances_offering.rb,
lib/aws/ec2/internet_gateway/attachment.rb,
lib/aws/ec2/security_group/ip_permission.rb,
lib/aws/ec2/availability_zone_collection.rb,
lib/aws/ec2/network_interface_collection.rb,
lib/aws/ec2/network_interface/attachment.rb,
lib/aws/ec2/reserved_instances_collection.rb,
lib/aws/ec2/vpc_peering_connection_collection.rb,
lib/aws/ec2/reserved_instances_offering_collection.rb,
lib/aws/ec2/security_group/ip_permission_collection.rb

Overview

Provides an expressive, object-oriented interface to Amazon EC2.

Credentials

You can setup default credentials for all AWS services via AWS.config:

AWS.config(
  :access_key_id => 'YOUR_ACCESS_KEY_ID',
  :secret_access_key => 'YOUR_SECRET_ACCESS_KEY')

Or you can set them directly on the EC2 interface:

ec2 = AWS::EC2.new(
  :access_key_id => 'YOUR_ACCESS_KEY_ID',
  :secret_access_key => 'YOUR_SECRET_ACCESS_KEY')

Instances

EC2 uses instances to run your software.

To run an instance:

ec2.instances.create(:image_id => "ami-8c1fece5")

To get an instance by ID:

i = ec2.instances["i-12345678"]
i.exists?

To get a list of instances:

ec2.instances.inject({}) { |m, i| m[i.id] = i.status; m }
# => { "i-12345678" => :running, "i-87654321" => :shutting_down }

Security Groups

A security group is a named collection of access rules. These access rules specify which ingress (i.e., incoming) network traffic should be delivered to your instance. All other ingress traffic will be discarded.

To create a security group:

websvr = ec2.security_groups.create('webservers')

Then you can add ingress authorizations. In the following example we add a rule that allows web traffic from the entire internet.

# web traffic
websvr.authorize_ingress(:tcp, 80)

You can also specify a port range. Here we are opening FTP traffic:

# ftp traffic
websvr.authorize_ingress(:tcp, 20..21)

If you want to limit an authorization to a particular CIDR IP address or list of address, just add them to the #authorize_ingress call.

# ssh access
websrvr.authorize_ingress(:tcp, 22, '1.1.1.1/0', '2.2.2.2/0')

You can also provide another security group instead of CIDR IP addresses. This allows incoming traffic from EC2 instances in the given security group(s).

# get two existing security groups
dbsvrs = ec2.security_groups.filter('group-name', 'db-servers').first
websvrs = ec2.security_groups.filter('group-name', 'web-servers').first

# allow instances in the 'web-servers' security group to connect
# to instances in the 'db-servers' security group over tcp port 3306
dbsvrs.authorize_ingress(:tcp, 3306, websvrs)

There are a few handy shortcuts for allowing pings:

wbsvrs.allow_ping

Just like with authorize_ingress you can pass a security group or a list of CIDR IP addresses to allow ping to limit where you can ping from.

You can also use the same parameters from the examples above to SecurityGroup#revoke_ingress and SecurityGroup#disallow_ping.

You can specify other protocols than :tcp, like :udp and :icmp.

Elastic IPs

You can allocate up to 5 elastic IP addresses for each account. You can associate those elastic IP addresses with EC2 instances:

instance = ec2.instances['i-12345678']
ip = ec2.elastic_ips.allocate

instance.ip_address                # 1.1.1.1
ip.ip_address                      # 2.2.2.2

instance.associate_elastic_ip(ip)
instance.ip_address                # 2.2.2.2

instance.disassociate_elastic_ip
instance.ip_address                # 1.1.1.1

When you are done with an elastic IP address you should release it. In the following example we release all elastic IP addresses that are not currently associated with an instance:

ec2.elastic_ips.select{|ip| !ip.associated? }.each(&:release)

Key Pairs

Public Amazon Machine Image (AMI) instances have no password, and you need a public/private key pair to log in to them. The public key half of this pair is embedded in your instance, allowing you to use the private key to log in securely without a password.

You can generate a key pair yourself and then send the public part to EC2 using KeyPairCollection#import. For example:

key_pair = ec2.key_pairs.import("mykey", File.read("~/.ssh/identity.pub"))

You can also ask EC2 to generate a key pair for you. For example:

key_pair = ec2.key_pairs.create("mykey")
File.open("~/.ssh/ec2", "wb") do |f|
  f.write(key_pair.private_key)
end

Filtering and Tagging

Any of the collections in the interface may be filtered by a number of different parameters. For example, to get all the windows images owned by amazon where the description includes the string "linux", you can do this:

ec2.images.with_owner("amazon").
  filter("platform", "windows").
  filter("description", "*linux*")

Similarly, you can tag images, instances, security groups, snapshots, and volumes with free-form key-value metadata and filter on that metadata. For example:

ec2.images["ami-123"].tags << "myapp"
ec2.images.tagged("myapp")             # will include ami-123

Regions

Amazon has data centers in different areas of the world (e.g., North America, Europe, Asia, etc.). Correspondingly, EC2 is available to use in different Regions. By launching instances in separate Regions, you can design your application to be closer to specific customers or to meet legal or other requirements. Prices for Amazon EC2 usage vary by Region (for more information about pricing by Region, go to the Amazon EC2 Pricing page). You can use the Ruby SDK to see which regions are available for your account:

ec2.regions.map(&:name)            # => ["us-east-1", ...]

The default region is us-east-1; you can access other regions like this:

ec2 = AWS::EC2.new(:region => "us-west-1")
ec2.instances.create(:image_id => 'ami-3bc9997e')

Availability Zones

Each Region contains multiple distinct locations called Availability Zones. Each Availability Zone is engineered to be isolated from failures in other Availability zones and to provide inexpensive, low-latency network connectivity to other zones in the same Region. By launching instances in separate Availability Zones, you can protect your applications from the failure of a single location.

You can use the #availability_zones collection to get information about the available zones available to your account. For example:

ec2.availability_zones.map(&:name)   # => ["us-east-1a", ...]

Images

An Amazon Machine Image (AMI) contains all information necessary to boot instances of your software. For example, an AMI might contain all the software to act as a web server (e.g., Linux, Apache, and your web site) or it might contain all the software to act as a Hadoop node (e.g., Linux, Hadoop, and a custom application).

You can use the #images collection to get information about the images available to your account. For example:

ec2.images.with_owner("amazon").map(&:name)

You can also use the images collection to create new images:

ec2.images.create(
 :image_location => "mybucket/manifest.xml",
 :name => "my-image")

Defined Under Namespace

Modules: Errors, FilteredCollection, HasPermissions, TaggedCollection, TaggedItem Classes: Attachment, AttachmentCollection, AvailabilityZone, AvailabilityZoneCollection, Client, Collection, CustomerGateway, CustomerGatewayCollection, DHCPOptions, DHCPOptionsCollection, ElasticIp, ElasticIpCollection, ExportTask, ExportTaskCollection, Image, ImageCollection, Instance, InstanceCollection, InternetGateway, InternetGatewayCollection, KeyPair, KeyPairCollection, NetworkACL, NetworkACLCollection, NetworkInterface, NetworkInterfaceCollection, PermissionCollection, Region, RegionCollection, ReservedInstances, ReservedInstancesCollection, ReservedInstancesOffering, ReservedInstancesOfferingCollection, ResourceObject, ResourceTagCollection, RouteTable, RouteTableCollection, SecurityGroup, SecurityGroupCollection, Snapshot, SnapshotCollection, Subnet, SubnetCollection, Tag, TagCollection, VPC, VPCCollection, VPCPeeringConnection, VPCPeeringConnectionCollection, VPNConnection, VPNConnectionCollection, VPNGateway, VPNGatewayCollection, Volume, VolumeCollection

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Core::ServiceInterface

included, #initialize, #inspect

Instance Attribute Details

#clientClient (readonly)

Returns the low-level EC2 client object

Returns:

  • (Client)

    the low-level EC2 client object



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# File 'lib/aws/ec2.rb', line 225

class EC2

  autoload :Attachment, 'aws/ec2/attachment'
  autoload :AttachmentCollection, 'aws/ec2/attachment_collection'
  autoload :AvailabilityZone, 'aws/ec2/availability_zone'
  autoload :AvailabilityZoneCollection, 'aws/ec2/availability_zone_collection'
  autoload :BlockDeviceMappings, 'aws/ec2/block_device_mappings'
  autoload :Client, 'aws/ec2/client'
  autoload :Collection, 'aws/ec2/collection'
  autoload :CustomerGateway, 'aws/ec2/customer_gateway'
  autoload :CustomerGatewayCollection, 'aws/ec2/customer_gateway_collection'
  autoload :DHCPOptions, 'aws/ec2/dhcp_options'
  autoload :DHCPOptionsCollection, 'aws/ec2/dhcp_options_collection'
  autoload :ElasticIp, 'aws/ec2/elastic_ip'
  autoload :ElasticIpCollection, 'aws/ec2/elastic_ip_collection'
  autoload :Errors, 'aws/ec2/errors'
  autoload :ExportTask, 'aws/ec2/export_task'
  autoload :ExportTaskCollection, 'aws/ec2/export_task_collection'
  autoload :FilteredCollection, 'aws/ec2/filtered_collection'
  autoload :HasPermissions, 'aws/ec2/has_permissions'
  autoload :Image, 'aws/ec2/image'
  autoload :ImageCollection, 'aws/ec2/image_collection'
  autoload :Instance, 'aws/ec2/instance'
  autoload :InstanceCollection, 'aws/ec2/instance_collection'
  autoload :InternetGateway, 'aws/ec2/internet_gateway'
  autoload :InternetGatewayCollection, 'aws/ec2/internet_gateway_collection'
  autoload :KeyPair, 'aws/ec2/key_pair'
  autoload :KeyPairCollection, 'aws/ec2/key_pair_collection'
  autoload :NetworkACL, 'aws/ec2/network_acl'
  autoload :NetworkACLCollection, 'aws/ec2/network_acl_collection'
  autoload :NetworkInterface, 'aws/ec2/network_interface'
  autoload :NetworkInterfaceCollection, 'aws/ec2/network_interface_collection'
  autoload :PermissionCollection, 'aws/ec2/permission_collection'
  autoload :Region, 'aws/ec2/region'
  autoload :RegionCollection, 'aws/ec2/region_collection'
  autoload :ReservedInstances, 'aws/ec2/reserved_instances'
  autoload :ReservedInstancesCollection, 'aws/ec2/reserved_instances_collection'
  autoload :ReservedInstancesOffering, 'aws/ec2/reserved_instances_offering'
  autoload :ReservedInstancesOfferingCollection, 'aws/ec2/reserved_instances_offering_collection'
  autoload :Resource, 'aws/ec2/resource'
  autoload :ResourceObject, 'aws/ec2/tag_collection'
  autoload :ResourceTagCollection, 'aws/ec2/resource_tag_collection'
  autoload :RouteTable, 'aws/ec2/route_table'
  autoload :RouteTableCollection, 'aws/ec2/route_table_collection'
  autoload :SecurityGroup, 'aws/ec2/security_group'
  autoload :SecurityGroupCollection, 'aws/ec2/security_group_collection'
  autoload :Snapshot, 'aws/ec2/snapshot'
  autoload :SnapshotCollection, 'aws/ec2/snapshot_collection'
  autoload :Subnet, 'aws/ec2/subnet'
  autoload :SubnetCollection, 'aws/ec2/subnet_collection'
  autoload :Tag, 'aws/ec2/tag'
  autoload :TagCollection, 'aws/ec2/tag_collection'
  autoload :TaggedCollection, 'aws/ec2/tagged_collection'
  autoload :TaggedItem, 'aws/ec2/tagged_item'
  autoload :Volume, 'aws/ec2/volume'
  autoload :VolumeCollection, 'aws/ec2/volume_collection'
  autoload :VPC, 'aws/ec2/vpc'
  autoload :VPCCollection, 'aws/ec2/vpc_collection'
  autoload :VPNConnection, 'aws/ec2/vpn_connection'
  autoload :VPNConnectionCollection, 'aws/ec2/vpn_connection_collection'
  autoload :VPNGateway, 'aws/ec2/vpn_gateway'
  autoload :VPNGatewayCollection, 'aws/ec2/vpn_gateway_collection'

  include Core::ServiceInterface

  endpoint_prefix 'ec2'

  # @return [InstanceCollection] A collection representing all instances
  def instances
    InstanceCollection.new(:config => config)
  end

  # @return [SecurityGroupCollection] A collection representing all security
  #   groups.
  def security_groups
    SecurityGroupCollection.new(:config => config)
  end

  # @return [ElasticIpCollection] A collection representing all
  #   elastic IP addresses for this account.
  def elastic_ips
    ElasticIpCollection.new(:config => config)
  end

  # @return [KeyPairCollection] A collection representing all key pairs.
  def key_pairs
    KeyPairCollection.new(:config => config)
  end

  # @return [TagCollection] A collection representing all EC2 tags for
  #   all resource types.
  def tags
    TagCollection.new(:config => config)
  end

  # @return [RegionCollection] A collection representing all EC2
  #   regions.
  def regions
    RegionCollection.new(:config => config)
  end

  # @return [AvailabilityZoneCollection] A collection representing
  #   all EC2 availability zones.
  def availability_zones
    AvailabilityZoneCollection.new(:config => config)
  end

  # @return [ImageCollection] A collection representing
  #   all Amazon Machine Images available to your account.
  def images
    ImageCollection.new(:config => config)
  end

  # @return [VolumeCollection] A collection representing
  #   all EBS volumes available to your account.
  def volumes
    VolumeCollection.new(:config => config)
  end

  # @return [ReservedInstancesCollection] A collection representing all
  #   purchased reserved instance offerings.
  def reserved_instances
    ReservedInstancesCollection.new(:config => config)
  end

  # @return [ReservedInstancesOfferingCollection] A collection representing all
  #   reserved instance offerings that may be purchased.
  def reserved_instances_offerings
    ReservedInstancesOfferingCollection.new(:config => config)
  end

  # @return [SnapshotCollection] A collection representing
  #   all EBS snapshots available to your account.
  def snapshots
    SnapshotCollection.new(:config => config)
  end

  # @return [VPCCollection] A collection representing
  #   all VPCs in your account.
  def vpcs
    VPCCollection.new(:config => config)
  end

  # @return [SubnetCollection] Returns a collection that represents all
  #   of the subnets associated with this account (across all VPCs).
  def subnets
    SubnetCollection.new(:config => config)
  end

  # @return [NetworkACLCollection] Returns a collection that represents
  #   all of the network ACLs for this account.
  def network_acls
    NetworkACLCollection.new(:config => config)
  end

  # @return [RouteTableCollection] Returns a collection that represents
  #   all of the route tables for this account.
  def route_tables
    RouteTableCollection.new(:config => config)
  end

  # @return [NetworkInterfaceCollection] Returns a collection that
  #   represents all of the network interfaces for this account.
  def network_interfaces
    NetworkInterfaceCollection.new(:config => config)
  end

  # @return [InternetGatewayCollection] Returns a collection that
  #   represents all of the internet gateways for this account.
  def internet_gateways
    InternetGatewayCollection.new(:config => config)
  end

  # @return [CustomerGatewayCollection] Returns a collection that
  #   represents all of the customer gateways for this account.
  def customer_gateways
    CustomerGatewayCollection.new(:config => config)
  end

  # @return [VPNGatewayCollection] Returns a collection that
  #   represents all of the vpn gateways for this account.
  def vpn_gateways
    VPNGatewayCollection.new(:config => config)
  end

  # @return [DHCPOptionsCollection] Returns a collection that
  #   represents all of the dhcp options for this account.
  def dhcp_options
    DHCPOptionsCollection.new(:config => config)
  end

  # @return [VPNConnections] Returns a collection that
  #   represents all of vpn connections for this account.
  def vpn_connections
    VPNConnectionCollection.new(:config => config)
  end

  # @return [ExportTaskCollection]
  def export_tasks
    ExportTaskCollection.new(:config => config)
  end

end

Instance Method Details

#availability_zonesAvailabilityZoneCollection

Returns A collection representing all EC2 availability zones.

Returns:



328
329
330
# File 'lib/aws/ec2.rb', line 328

def availability_zones
  AvailabilityZoneCollection.new(:config => config)
end

#customer_gatewaysCustomerGatewayCollection

Returns a collection that represents all of the customer gateways for this account.

Returns:



400
401
402
# File 'lib/aws/ec2.rb', line 400

def customer_gateways
  CustomerGatewayCollection.new(:config => config)
end

#dhcp_optionsDHCPOptionsCollection

Returns a collection that represents all of the dhcp options for this account.

Returns:

  • (DHCPOptionsCollection)

    Returns a collection that represents all of the dhcp options for this account.



412
413
414
# File 'lib/aws/ec2.rb', line 412

def dhcp_options
  DHCPOptionsCollection.new(:config => config)
end

#elastic_ipsElasticIpCollection

Returns A collection representing all elastic IP addresses for this account.

Returns:

  • (ElasticIpCollection)

    A collection representing all elastic IP addresses for this account.



305
306
307
# File 'lib/aws/ec2.rb', line 305

def elastic_ips
  ElasticIpCollection.new(:config => config)
end

#export_tasksExportTaskCollection



423
424
425
# File 'lib/aws/ec2.rb', line 423

def export_tasks
  ExportTaskCollection.new(:config => config)
end

#imagesImageCollection

Returns A collection representing all Amazon Machine Images available to your account.

Returns:

  • (ImageCollection)

    A collection representing all Amazon Machine Images available to your account.



334
335
336
# File 'lib/aws/ec2.rb', line 334

def images
  ImageCollection.new(:config => config)
end

#instancesInstanceCollection

Returns A collection representing all instances

Returns:



293
294
295
# File 'lib/aws/ec2.rb', line 293

def instances
  InstanceCollection.new(:config => config)
end

#internet_gatewaysInternetGatewayCollection

Returns a collection that represents all of the internet gateways for this account.

Returns:



394
395
396
# File 'lib/aws/ec2.rb', line 394

def internet_gateways
  InternetGatewayCollection.new(:config => config)
end

#key_pairsKeyPairCollection

Returns A collection representing all key pairs.

Returns:



310
311
312
# File 'lib/aws/ec2.rb', line 310

def key_pairs
  KeyPairCollection.new(:config => config)
end

#network_aclsNetworkACLCollection

Returns a collection that represents all of the network ACLs for this account.

Returns:

  • (NetworkACLCollection)

    Returns a collection that represents all of the network ACLs for this account.



376
377
378
# File 'lib/aws/ec2.rb', line 376

def network_acls
  NetworkACLCollection.new(:config => config)
end

#network_interfacesNetworkInterfaceCollection

Returns a collection that represents all of the network interfaces for this account.

Returns:



388
389
390
# File 'lib/aws/ec2.rb', line 388

def network_interfaces
  NetworkInterfaceCollection.new(:config => config)
end

#regionsRegionCollection

Returns A collection representing all EC2 regions.

Returns:



322
323
324
# File 'lib/aws/ec2.rb', line 322

def regions
  RegionCollection.new(:config => config)
end

#reserved_instancesReservedInstancesCollection

Returns A collection representing all purchased reserved instance offerings.

Returns:



346
347
348
# File 'lib/aws/ec2.rb', line 346

def reserved_instances
  ReservedInstancesCollection.new(:config => config)
end

#reserved_instances_offeringsReservedInstancesOfferingCollection

Returns A collection representing all reserved instance offerings that may be purchased.

Returns:



352
353
354
# File 'lib/aws/ec2.rb', line 352

def reserved_instances_offerings
  ReservedInstancesOfferingCollection.new(:config => config)
end

#route_tablesRouteTableCollection

Returns a collection that represents all of the route tables for this account.

Returns:

  • (RouteTableCollection)

    Returns a collection that represents all of the route tables for this account.



382
383
384
# File 'lib/aws/ec2.rb', line 382

def route_tables
  RouteTableCollection.new(:config => config)
end

#security_groupsSecurityGroupCollection

Returns A collection representing all security groups.

Returns:



299
300
301
# File 'lib/aws/ec2.rb', line 299

def security_groups
  SecurityGroupCollection.new(:config => config)
end

#snapshotsSnapshotCollection

Returns A collection representing all EBS snapshots available to your account.

Returns:

  • (SnapshotCollection)

    A collection representing all EBS snapshots available to your account.



358
359
360
# File 'lib/aws/ec2.rb', line 358

def snapshots
  SnapshotCollection.new(:config => config)
end

#subnetsSubnetCollection

Returns a collection that represents all of the subnets associated with this account (across all VPCs).

Returns:

  • (SubnetCollection)

    Returns a collection that represents all of the subnets associated with this account (across all VPCs).



370
371
372
# File 'lib/aws/ec2.rb', line 370

def subnets
  SubnetCollection.new(:config => config)
end

#tagsTagCollection

Returns A collection representing all EC2 tags for all resource types.

Returns:

  • (TagCollection)

    A collection representing all EC2 tags for all resource types.



316
317
318
# File 'lib/aws/ec2.rb', line 316

def tags
  TagCollection.new(:config => config)
end

#volumesVolumeCollection

Returns A collection representing all EBS volumes available to your account.

Returns:

  • (VolumeCollection)

    A collection representing all EBS volumes available to your account.



340
341
342
# File 'lib/aws/ec2.rb', line 340

def volumes
  VolumeCollection.new(:config => config)
end

#vpcsVPCCollection

Returns A collection representing all VPCs in your account.

Returns:

  • (VPCCollection)

    A collection representing all VPCs in your account.



364
365
366
# File 'lib/aws/ec2.rb', line 364

def vpcs
  VPCCollection.new(:config => config)
end

#vpn_connectionsVPNConnections

Returns a collection that represents all of vpn connections for this account.

Returns:

  • (VPNConnections)

    Returns a collection that represents all of vpn connections for this account.



418
419
420
# File 'lib/aws/ec2.rb', line 418

def vpn_connections
  VPNConnectionCollection.new(:config => config)
end

#vpn_gatewaysVPNGatewayCollection

Returns a collection that represents all of the vpn gateways for this account.

Returns:

  • (VPNGatewayCollection)

    Returns a collection that represents all of the vpn gateways for this account.



406
407
408
# File 'lib/aws/ec2.rb', line 406

def vpn_gateways
  VPNGatewayCollection.new(:config => config)
end