Class: Aws::EC2::Resource
- Inherits:
-
Object
- Object
- Aws::EC2::Resource
- Defined in:
- lib/aws-sdk-ec2/customizations/resource.rb,
lib/aws-sdk-ec2/resource.rb
Actions collapse
- #create_dhcp_options(options = {}) ⇒ DhcpOptions
- #create_instances(options = {}) ⇒ Instance::Collection
- #create_internet_gateway(options = {}) ⇒ InternetGateway
- #create_key_pair(options = {}) ⇒ KeyPair
- #create_network_acl(options = {}) ⇒ NetworkAcl
- #create_network_interface(options = {}) ⇒ NetworkInterface
- #create_placement_group(options = {}) ⇒ PlacementGroup
- #create_route_table(options = {}) ⇒ RouteTable
- #create_security_group(options = {}) ⇒ SecurityGroup
- #create_snapshot(options = {}) ⇒ Snapshot
- #create_subnet(options = {}) ⇒ Subnet
- #create_tags(options = {}) ⇒ EmptyStructure
- #create_volume(options = {}) ⇒ Volume
- #create_vpc(options = {}) ⇒ Vpc
- #create_vpc_peering_connection(options = {}) ⇒ VpcPeeringConnection
- #disassociate_route_table(options = {}) ⇒ EmptyStructure
- #import_key_pair(options = {}) ⇒ KeyPairInfo
- #register_image(options = {}) ⇒ Image
Associations collapse
- #classic_addresses(options = {}) ⇒ ClassicAddress::Collection
- #dhcp_options(id) ⇒ DhcpOptions
- #dhcp_options_sets(options = {}) ⇒ DhcpOptions::Collection
- #image(id) ⇒ Image
- #images(options = {}) ⇒ Image::Collection
- #instance(id) ⇒ Instance
- #instances(options = {}) ⇒ Instance::Collection
- #internet_gateway(id) ⇒ InternetGateway
- #internet_gateways(options = {}) ⇒ InternetGateway::Collection
- #key_pair(name) ⇒ KeyPairInfo
- #key_pairs(options = {}) ⇒ KeyPairInfo::Collection
- #network_acl(id) ⇒ NetworkAcl
- #network_acls(options = {}) ⇒ NetworkAcl::Collection
- #network_interface(id) ⇒ NetworkInterface
- #network_interfaces(options = {}) ⇒ NetworkInterface::Collection
- #placement_group(name) ⇒ PlacementGroup
- #placement_groups(options = {}) ⇒ PlacementGroup::Collection
- #route_table(id) ⇒ RouteTable
- #route_table_association(id) ⇒ RouteTableAssociation
- #route_tables(options = {}) ⇒ RouteTable::Collection
- #security_group(id) ⇒ SecurityGroup
- #security_groups(options = {}) ⇒ SecurityGroup::Collection
- #snapshot(id) ⇒ Snapshot
- #snapshots(options = {}) ⇒ Snapshot::Collection
- #subnet(id) ⇒ Subnet
- #subnets(options = {}) ⇒ Subnet::Collection
- #volume(id) ⇒ Volume
- #volumes(options = {}) ⇒ Volume::Collection
- #vpc(id) ⇒ Vpc
- #vpc_addresses(options = {}) ⇒ VpcAddress::Collection
- #vpc_peering_connection(id) ⇒ VpcPeeringConnection
- #vpc_peering_connections(options = {}) ⇒ VpcPeeringConnection::Collection
- #vpcs(options = {}) ⇒ Vpc::Collection
Instance Method Summary collapse
- #client ⇒ Client
-
#initialize(options = {}) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
Instance Method Details
#classic_addresses(options = {}) ⇒ ClassicAddress::Collection
1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1232 def classic_addresses( = {}) batches = Enumerator.new do |y| batch = [] = Aws::Util.deep_merge(, filters: [{ name: "domain", values: ["standard"] }]) resp = @client.describe_addresses() resp.data.addresses.each do |a| batch << ClassicAddress.new( public_ip: a.public_ip, data: a, client: @client ) end y.yield(batch) end ClassicAddress::Collection.new(batches) end |
#create_dhcp_options(options = {}) ⇒ DhcpOptions
44 45 46 47 48 49 50 51 |
# File 'lib/aws-sdk-ec2/resource.rb', line 44 def ( = {}) resp = @client.() DhcpOptions.new( id: resp.data.., data: resp.data., client: @client ) end |
#create_instances(options = {}) ⇒ Instance::Collection
441 442 443 444 445 446 447 448 449 450 451 452 |
# File 'lib/aws-sdk-ec2/resource.rb', line 441 def create_instances( = {}) batch = [] resp = @client.run_instances() resp.data.instances.each do |i| batch << Instance.new( id: i.instance_id, data: i, client: @client ) end Instance::Collection.new([batch], size: batch.size) end |
#create_internet_gateway(options = {}) ⇒ InternetGateway
466 467 468 469 470 471 472 473 |
# File 'lib/aws-sdk-ec2/resource.rb', line 466 def create_internet_gateway( = {}) resp = @client.create_internet_gateway() InternetGateway.new( id: resp.data.internet_gateway.internet_gateway_id, data: resp.data.internet_gateway, client: @client ) end |
#create_key_pair(options = {}) ⇒ KeyPair
492 493 494 495 496 497 498 499 |
# File 'lib/aws-sdk-ec2/resource.rb', line 492 def create_key_pair( = {}) resp = @client.create_key_pair() KeyPair.new( name: resp.data.key_name, data: resp.data, client: @client ) end |
#create_network_acl(options = {}) ⇒ NetworkAcl
516 517 518 519 520 521 522 523 |
# File 'lib/aws-sdk-ec2/resource.rb', line 516 def create_network_acl( = {}) resp = @client.create_network_acl() NetworkAcl.new( id: resp.data.network_acl.network_acl_id, data: resp.data.network_acl, client: @client ) end |
#create_network_interface(options = {}) ⇒ NetworkInterface
593 594 595 596 597 598 599 600 |
# File 'lib/aws-sdk-ec2/resource.rb', line 593 def create_network_interface( = {}) resp = @client.create_network_interface() NetworkInterface.new( id: resp.data.network_interface.network_interface_id, data: resp.data.network_interface, client: @client ) end |
#create_placement_group(options = {}) ⇒ PlacementGroup
627 628 629 630 631 632 633 |
# File 'lib/aws-sdk-ec2/resource.rb', line 627 def create_placement_group( = {}) resp = @client.create_placement_group() PlacementGroup.new( name: [:group_name], client: @client ) end |
#create_route_table(options = {}) ⇒ RouteTable
650 651 652 653 654 655 656 657 |
# File 'lib/aws-sdk-ec2/resource.rb', line 650 def create_route_table( = {}) resp = @client.create_route_table() RouteTable.new( id: resp.data.route_table.route_table_id, data: resp.data.route_table, client: @client ) end |
#create_security_group(options = {}) ⇒ SecurityGroup
694 695 696 697 698 699 700 |
# File 'lib/aws-sdk-ec2/resource.rb', line 694 def create_security_group( = {}) resp = @client.create_security_group() SecurityGroup.new( id: resp.data.group_id, client: @client ) end |
#create_snapshot(options = {}) ⇒ Snapshot
733 734 735 736 737 738 739 740 |
# File 'lib/aws-sdk-ec2/resource.rb', line 733 def create_snapshot( = {}) resp = @client.create_snapshot() Snapshot.new( id: resp.data.snapshot_id, data: resp.data, client: @client ) end |
#create_subnet(options = {}) ⇒ Subnet
775 776 777 778 779 780 781 782 |
# File 'lib/aws-sdk-ec2/resource.rb', line 775 def create_subnet( = {}) resp = @client.create_subnet() Subnet.new( id: resp.data.subnet.subnet_id, data: resp.data.subnet, client: @client ) end |
#create_tags(options = {}) ⇒ EmptyStructure
812 813 814 815 816 817 818 819 820 821 |
# File 'lib/aws-sdk-ec2/resource.rb', line 812 def () resp = @client.() = [] [:resources].each do |resource_id| [:tags].each do |tag| << Tag.new(resource_id, tag[:key], tag[:value], client: @client) end end Tag::Collection.new([], size: .size) end |
#create_volume(options = {}) ⇒ Volume
937 938 939 940 941 942 943 944 |
# File 'lib/aws-sdk-ec2/resource.rb', line 937 def create_volume( = {}) resp = @client.create_volume() Volume.new( id: resp.data.volume_id, data: resp.data, client: @client ) end |
#create_vpc(options = {}) ⇒ Vpc
980 981 982 983 984 985 986 987 |
# File 'lib/aws-sdk-ec2/resource.rb', line 980 def create_vpc( = {}) resp = @client.create_vpc() Vpc.new( id: resp.data.vpc.vpc_id, data: resp.data.vpc, client: @client ) end |
#create_vpc_peering_connection(options = {}) ⇒ VpcPeeringConnection
1020 1021 1022 1023 1024 1025 1026 1027 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1020 def create_vpc_peering_connection( = {}) resp = @client.create_vpc_peering_connection() VpcPeeringConnection.new( id: resp.data.vpc_peering_connection.vpc_peering_connection_id, data: resp.data.vpc_peering_connection, client: @client ) end |
#dhcp_options(id) ⇒ DhcpOptions
1254 1255 1256 1257 1258 1259 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1254 def (id) DhcpOptions.new( id: id, client: @client ) end |
#dhcp_options_sets(options = {}) ⇒ DhcpOptions::Collection
1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1305 def ( = {}) batches = Enumerator.new do |y| batch = [] resp = @client.() resp.data..each do |d| batch << DhcpOptions.new( id: d., data: d, client: @client ) end y.yield(batch) end DhcpOptions::Collection.new(batches) end |
#disassociate_route_table(options = {}) ⇒ EmptyStructure
1045 1046 1047 1048 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1045 def disassociate_route_table( = {}) resp = @client.disassociate_route_table() resp.data end |
#image(id) ⇒ Image
1323 1324 1325 1326 1327 1328 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1323 def image(id) Image.new( id: id, client: @client ) end |
#images(options = {}) ⇒ Image::Collection
1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1454 def images( = {}) batches = Enumerator.new do |y| batch = [] resp = @client.describe_images() resp.data.images.each do |i| batch << Image.new( id: i.image_id, data: i, client: @client ) end y.yield(batch) end Image::Collection.new(batches) end |
#import_key_pair(options = {}) ⇒ KeyPairInfo
1069 1070 1071 1072 1073 1074 1075 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1069 def import_key_pair( = {}) resp = @client.import_key_pair() KeyPairInfo.new( name: resp.data.key_name, client: @client ) end |
#instance(id) ⇒ Instance
1472 1473 1474 1475 1476 1477 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1472 def instance(id) Instance.new( id: id, client: @client ) end |
#instances(options = {}) ⇒ Instance::Collection
1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1764 def instances( = {}) batches = Enumerator.new do |y| resp = @client.describe_instances() resp.each_page do |page| batch = [] page.data.reservations.each do |r| r.instances.each do |i| batch << Instance.new( id: i.instance_id, data: i, client: @client ) end end y.yield(batch) end end Instance::Collection.new(batches) end |
#internet_gateway(id) ⇒ InternetGateway
1786 1787 1788 1789 1790 1791 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1786 def internet_gateway(id) InternetGateway.new( id: id, client: @client ) end |
#internet_gateways(options = {}) ⇒ InternetGateway::Collection
1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1839 def internet_gateways( = {}) batches = Enumerator.new do |y| resp = @client.describe_internet_gateways() resp.each_page do |page| batch = [] page.data.internet_gateways.each do |i| batch << InternetGateway.new( id: i.internet_gateway_id, data: i, client: @client ) end y.yield(batch) end end InternetGateway::Collection.new(batches) end |
#key_pair(name) ⇒ KeyPairInfo
1859 1860 1861 1862 1863 1864 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1859 def key_pair(name) KeyPairInfo.new( name: name, client: @client ) end |
#key_pairs(options = {}) ⇒ KeyPairInfo::Collection
1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1895 def key_pairs( = {}) batches = Enumerator.new do |y| batch = [] resp = @client.describe_key_pairs() resp.data.key_pairs.each do |k| batch << KeyPairInfo.new( name: k.key_name, data: k, client: @client ) end y.yield(batch) end KeyPairInfo::Collection.new(batches) end |
#network_acl(id) ⇒ NetworkAcl
1913 1914 1915 1916 1917 1918 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1913 def network_acl(id) NetworkAcl.new( id: id, client: @client ) end |
#network_acls(options = {}) ⇒ NetworkAcl::Collection
1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1996 def network_acls( = {}) batches = Enumerator.new do |y| resp = @client.describe_network_acls() resp.each_page do |page| batch = [] page.data.network_acls.each do |n| batch << NetworkAcl.new( id: n.network_acl_id, data: n, client: @client ) end y.yield(batch) end end NetworkAcl::Collection.new(batches) end |
#network_interface(id) ⇒ NetworkInterface
2016 2017 2018 2019 2020 2021 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2016 def network_interface(id) NetworkInterface.new( id: id, client: @client ) end |
#network_interfaces(options = {}) ⇒ NetworkInterface::Collection
2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2158 def network_interfaces( = {}) batches = Enumerator.new do |y| resp = @client.describe_network_interfaces() resp.each_page do |page| batch = [] page.data.network_interfaces.each do |n| batch << NetworkInterface.new( id: n.network_interface_id, data: n, client: @client ) end y.yield(batch) end end NetworkInterface::Collection.new(batches) end |
#placement_group(name) ⇒ PlacementGroup
2178 2179 2180 2181 2182 2183 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2178 def placement_group(name) PlacementGroup.new( name: name, client: @client ) end |
#placement_groups(options = {}) ⇒ PlacementGroup::Collection
2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2219 def placement_groups( = {}) batches = Enumerator.new do |y| batch = [] resp = @client.describe_placement_groups() resp.data.placement_groups.each do |p| batch << PlacementGroup.new( name: p.group_name, data: p, client: @client ) end y.yield(batch) end PlacementGroup::Collection.new(batches) end |
#register_image(options = {}) ⇒ Image
1162 1163 1164 1165 1166 1167 1168 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1162 def register_image( = {}) resp = @client.register_image() Image.new( id: resp.data.image_id, client: @client ) end |
#route_table(id) ⇒ RouteTable
2237 2238 2239 2240 2241 2242 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2237 def route_table(id) RouteTable.new( id: id, client: @client ) end |
#route_table_association(id) ⇒ RouteTableAssociation
2246 2247 2248 2249 2250 2251 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2246 def route_table_association(id) RouteTableAssociation.new( id: id, client: @client ) end |
#route_tables(options = {}) ⇒ RouteTable::Collection
2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2347 def route_tables( = {}) batches = Enumerator.new do |y| resp = @client.describe_route_tables() resp.each_page do |page| batch = [] page.data.route_tables.each do |r| batch << RouteTable.new( id: r.route_table_id, data: r, client: @client ) end y.yield(batch) end end RouteTable::Collection.new(batches) end |
#security_group(id) ⇒ SecurityGroup
2367 2368 2369 2370 2371 2372 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2367 def security_group(id) SecurityGroup.new( id: id, client: @client ) end |
#security_groups(options = {}) ⇒ SecurityGroup::Collection
2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2485 def security_groups( = {}) batches = Enumerator.new do |y| resp = @client.describe_security_groups() resp.each_page do |page| batch = [] page.data.security_groups.each do |s| batch << SecurityGroup.new( id: s.group_id, data: s, client: @client ) end y.yield(batch) end end SecurityGroup::Collection.new(batches) end |
#snapshot(id) ⇒ Snapshot
2505 2506 2507 2508 2509 2510 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2505 def snapshot(id) Snapshot.new( id: id, client: @client ) end |
#snapshots(options = {}) ⇒ Snapshot::Collection
2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2578 def snapshots( = {}) batches = Enumerator.new do |y| resp = @client.describe_snapshots() resp.each_page do |page| batch = [] page.data.snapshots.each do |s| batch << Snapshot.new( id: s.snapshot_id, data: s, client: @client ) end y.yield(batch) end end Snapshot::Collection.new(batches) end |
#subnet(id) ⇒ Subnet
2598 2599 2600 2601 2602 2603 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2598 def subnet(id) Subnet.new( id: id, client: @client ) end |
#subnets(options = {}) ⇒ Subnet::Collection
2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2677 def subnets( = {}) batches = Enumerator.new do |y| batch = [] resp = @client.describe_subnets() resp.data.subnets.each do |s| batch << Subnet.new( id: s.subnet_id, data: s, client: @client ) end y.yield(batch) end Subnet::Collection.new(batches) end |
#volume(id) ⇒ Volume
2695 2696 2697 2698 2699 2700 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2695 def volume(id) Volume.new( id: id, client: @client ) end |
#volumes(options = {}) ⇒ Volume::Collection
2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2771 def volumes( = {}) batches = Enumerator.new do |y| resp = @client.describe_volumes() resp.each_page do |page| batch = [] page.data.volumes.each do |v| batch << Volume.new( id: v.volume_id, data: v, client: @client ) end y.yield(batch) end end Volume::Collection.new(batches) end |
#vpc(id) ⇒ Vpc
2791 2792 2793 2794 2795 2796 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2791 def vpc(id) Vpc.new( id: id, client: @client ) end |
#vpc_addresses(options = {}) ⇒ VpcAddress::Collection
2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2858 def vpc_addresses( = {}) batches = Enumerator.new do |y| batch = [] = Aws::Util.deep_merge(, filters: [{ name: "domain", values: ["vpc"] }]) resp = @client.describe_addresses() resp.data.addresses.each do |a| batch << VpcAddress.new( allocation_id: a.allocation_id, data: a, client: @client ) end y.yield(batch) end VpcAddress::Collection.new(batches) end |
#vpc_peering_connection(id) ⇒ VpcPeeringConnection
2880 2881 2882 2883 2884 2885 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2880 def vpc_peering_connection(id) VpcPeeringConnection.new( id: id, client: @client ) end |
#vpc_peering_connections(options = {}) ⇒ VpcPeeringConnection::Collection
2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2950 def vpc_peering_connections( = {}) batches = Enumerator.new do |y| resp = @client.describe_vpc_peering_connections() resp.each_page do |page| batch = [] page.data.vpc_peering_connections.each do |v| batch << VpcPeeringConnection.new( id: v.vpc_peering_connection_id, data: v, client: @client ) end y.yield(batch) end end VpcPeeringConnection::Collection.new(batches) end |
#vpcs(options = {}) ⇒ Vpc::Collection
3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 |
# File 'lib/aws-sdk-ec2/resource.rb', line 3036 def vpcs( = {}) batches = Enumerator.new do |y| resp = @client.describe_vpcs() resp.each_page do |page| batch = [] page.data.vpcs.each do |v| batch << Vpc.new( id: v.vpc_id, data: v, client: @client ) end y.yield(batch) end end Vpc::Collection.new(batches) end |