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
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1200 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
416 417 418 419 420 421 422 423 424 425 426 427 |
# File 'lib/aws-sdk-ec2/resource.rb', line 416 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
441 442 443 444 445 446 447 448 |
# File 'lib/aws-sdk-ec2/resource.rb', line 441 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
467 468 469 470 471 472 473 474 |
# File 'lib/aws-sdk-ec2/resource.rb', line 467 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
491 492 493 494 495 496 497 498 |
# File 'lib/aws-sdk-ec2/resource.rb', line 491 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
568 569 570 571 572 573 574 575 |
# File 'lib/aws-sdk-ec2/resource.rb', line 568 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
602 603 604 605 606 607 608 |
# File 'lib/aws-sdk-ec2/resource.rb', line 602 def create_placement_group( = {}) resp = @client.create_placement_group() PlacementGroup.new( name: [:group_name], client: @client ) end |
#create_route_table(options = {}) ⇒ RouteTable
625 626 627 628 629 630 631 632 |
# File 'lib/aws-sdk-ec2/resource.rb', line 625 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
669 670 671 672 673 674 675 |
# File 'lib/aws-sdk-ec2/resource.rb', line 669 def create_security_group( = {}) resp = @client.create_security_group() SecurityGroup.new( id: resp.data.group_id, client: @client ) end |
#create_snapshot(options = {}) ⇒ Snapshot
708 709 710 711 712 713 714 715 |
# File 'lib/aws-sdk-ec2/resource.rb', line 708 def create_snapshot( = {}) resp = @client.create_snapshot() Snapshot.new( id: resp.data.snapshot_id, data: resp.data, client: @client ) end |
#create_subnet(options = {}) ⇒ Subnet
750 751 752 753 754 755 756 757 |
# File 'lib/aws-sdk-ec2/resource.rb', line 750 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
787 788 789 790 791 792 793 794 795 796 |
# File 'lib/aws-sdk-ec2/resource.rb', line 787 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
905 906 907 908 909 910 911 912 |
# File 'lib/aws-sdk-ec2/resource.rb', line 905 def create_volume( = {}) resp = @client.create_volume() Volume.new( id: resp.data.volume_id, data: resp.data, client: @client ) end |
#create_vpc(options = {}) ⇒ Vpc
948 949 950 951 952 953 954 955 |
# File 'lib/aws-sdk-ec2/resource.rb', line 948 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
988 989 990 991 992 993 994 995 |
# File 'lib/aws-sdk-ec2/resource.rb', line 988 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
1222 1223 1224 1225 1226 1227 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1222 def (id) DhcpOptions.new( id: id, client: @client ) end |
#dhcp_options_sets(options = {}) ⇒ DhcpOptions::Collection
1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1273 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
1013 1014 1015 1016 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1013 def disassociate_route_table( = {}) resp = @client.disassociate_route_table() resp.data end |
#image(id) ⇒ Image
1291 1292 1293 1294 1295 1296 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1291 def image(id) Image.new( id: id, client: @client ) end |
#images(options = {}) ⇒ Image::Collection
1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1419 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
1037 1038 1039 1040 1041 1042 1043 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1037 def import_key_pair( = {}) resp = @client.import_key_pair() KeyPairInfo.new( name: resp.data.key_name, client: @client ) end |
#instance(id) ⇒ Instance
1437 1438 1439 1440 1441 1442 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1437 def instance(id) Instance.new( id: id, client: @client ) end |
#instances(options = {}) ⇒ Instance::Collection
1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1729 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
1751 1752 1753 1754 1755 1756 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1751 def internet_gateway(id) InternetGateway.new( id: id, client: @client ) end |
#internet_gateways(options = {}) ⇒ InternetGateway::Collection
1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1804 def internet_gateways( = {}) batches = Enumerator.new do |y| batch = [] resp = @client.describe_internet_gateways() resp.data.internet_gateways.each do |i| batch << InternetGateway.new( id: i.internet_gateway_id, data: i, client: @client ) end y.yield(batch) end InternetGateway::Collection.new(batches) end |
#key_pair(name) ⇒ KeyPairInfo
1822 1823 1824 1825 1826 1827 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1822 def key_pair(name) KeyPairInfo.new( name: name, client: @client ) end |
#key_pairs(options = {}) ⇒ KeyPairInfo::Collection
1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1858 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
1876 1877 1878 1879 1880 1881 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1876 def network_acl(id) NetworkAcl.new( id: id, client: @client ) end |
#network_acls(options = {}) ⇒ NetworkAcl::Collection
1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1959 def network_acls( = {}) batches = Enumerator.new do |y| batch = [] resp = @client.describe_network_acls() resp.data.network_acls.each do |n| batch << NetworkAcl.new( id: n.network_acl_id, data: n, client: @client ) end y.yield(batch) end NetworkAcl::Collection.new(batches) end |
#network_interface(id) ⇒ NetworkInterface
1977 1978 1979 1980 1981 1982 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1977 def network_interface(id) NetworkInterface.new( id: id, client: @client ) end |
#network_interfaces(options = {}) ⇒ NetworkInterface::Collection
2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2119 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
2139 2140 2141 2142 2143 2144 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2139 def placement_group(name) PlacementGroup.new( name: name, client: @client ) end |
#placement_groups(options = {}) ⇒ PlacementGroup::Collection
2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2180 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
1130 1131 1132 1133 1134 1135 1136 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1130 def register_image( = {}) resp = @client.register_image() Image.new( id: resp.data.image_id, client: @client ) end |
#route_table(id) ⇒ RouteTable
2198 2199 2200 2201 2202 2203 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2198 def route_table(id) RouteTable.new( id: id, client: @client ) end |
#route_table_association(id) ⇒ RouteTableAssociation
2207 2208 2209 2210 2211 2212 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2207 def route_table_association(id) RouteTableAssociation.new( id: id, client: @client ) end |
#route_tables(options = {}) ⇒ RouteTable::Collection
2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2308 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
2328 2329 2330 2331 2332 2333 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2328 def security_group(id) SecurityGroup.new( id: id, client: @client ) end |
#security_groups(options = {}) ⇒ SecurityGroup::Collection
2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2446 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
2466 2467 2468 2469 2470 2471 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2466 def snapshot(id) Snapshot.new( id: id, client: @client ) end |
#snapshots(options = {}) ⇒ Snapshot::Collection
2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2539 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
2559 2560 2561 2562 2563 2564 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2559 def subnet(id) Subnet.new( id: id, client: @client ) end |
#subnets(options = {}) ⇒ Subnet::Collection
2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2638 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
2656 2657 2658 2659 2660 2661 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2656 def volume(id) Volume.new( id: id, client: @client ) end |
#volumes(options = {}) ⇒ Volume::Collection
2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2732 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
2752 2753 2754 2755 2756 2757 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2752 def vpc(id) Vpc.new( id: id, client: @client ) end |
#vpc_addresses(options = {}) ⇒ VpcAddress::Collection
2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2819 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
2841 2842 2843 2844 2845 2846 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2841 def vpc_peering_connection(id) VpcPeeringConnection.new( id: id, client: @client ) end |
#vpc_peering_connections(options = {}) ⇒ VpcPeeringConnection::Collection
2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2911 def vpc_peering_connections( = {}) batches = Enumerator.new do |y| batch = [] resp = @client.describe_vpc_peering_connections() resp.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 VpcPeeringConnection::Collection.new(batches) end |
#vpcs(options = {}) ⇒ Vpc::Collection
2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2995 def vpcs( = {}) batches = Enumerator.new do |y| batch = [] resp = @client.describe_vpcs() resp.data.vpcs.each do |v| batch << Vpc.new( id: v.vpc_id, data: v, client: @client ) end y.yield(batch) end Vpc::Collection.new(batches) end |