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
1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1150 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
376 377 378 379 380 381 382 383 384 385 386 387 |
# File 'lib/aws-sdk-ec2/resource.rb', line 376 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
401 402 403 404 405 406 407 408 |
# File 'lib/aws-sdk-ec2/resource.rb', line 401 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
427 428 429 430 431 432 433 434 |
# File 'lib/aws-sdk-ec2/resource.rb', line 427 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
451 452 453 454 455 456 457 458 |
# File 'lib/aws-sdk-ec2/resource.rb', line 451 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
528 529 530 531 532 533 534 535 |
# File 'lib/aws-sdk-ec2/resource.rb', line 528 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
558 559 560 561 562 563 564 |
# File 'lib/aws-sdk-ec2/resource.rb', line 558 def create_placement_group( = {}) resp = @client.create_placement_group() PlacementGroup.new( name: [:group_name], client: @client ) end |
#create_route_table(options = {}) ⇒ RouteTable
581 582 583 584 585 586 587 588 |
# File 'lib/aws-sdk-ec2/resource.rb', line 581 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
625 626 627 628 629 630 631 |
# File 'lib/aws-sdk-ec2/resource.rb', line 625 def create_security_group( = {}) resp = @client.create_security_group() SecurityGroup.new( id: resp.data.group_id, client: @client ) end |
#create_snapshot(options = {}) ⇒ Snapshot
664 665 666 667 668 669 670 671 |
# File 'lib/aws-sdk-ec2/resource.rb', line 664 def create_snapshot( = {}) resp = @client.create_snapshot() Snapshot.new( id: resp.data.snapshot_id, data: resp.data, client: @client ) end |
#create_subnet(options = {}) ⇒ Subnet
703 704 705 706 707 708 709 710 |
# File 'lib/aws-sdk-ec2/resource.rb', line 703 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
737 738 739 740 741 742 743 744 745 746 |
# File 'lib/aws-sdk-ec2/resource.rb', line 737 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
851 852 853 854 855 856 857 858 |
# File 'lib/aws-sdk-ec2/resource.rb', line 851 def create_volume( = {}) resp = @client.create_volume() Volume.new( id: resp.data.volume_id, data: resp.data, client: @client ) end |
#create_vpc(options = {}) ⇒ Vpc
894 895 896 897 898 899 900 901 |
# File 'lib/aws-sdk-ec2/resource.rb', line 894 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
934 935 936 937 938 939 940 941 |
# File 'lib/aws-sdk-ec2/resource.rb', line 934 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
1172 1173 1174 1175 1176 1177 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1172 def (id) DhcpOptions.new( id: id, client: @client ) end |
#dhcp_options_sets(options = {}) ⇒ DhcpOptions::Collection
1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1227 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
959 960 961 962 |
# File 'lib/aws-sdk-ec2/resource.rb', line 959 def disassociate_route_table( = {}) resp = @client.disassociate_route_table() resp.data end |
#image(id) ⇒ Image
1245 1246 1247 1248 1249 1250 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1245 def image(id) Image.new( id: id, client: @client ) end |
#images(options = {}) ⇒ Image::Collection
1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1380 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
983 984 985 986 987 988 989 |
# File 'lib/aws-sdk-ec2/resource.rb', line 983 def import_key_pair( = {}) resp = @client.import_key_pair() KeyPairInfo.new( name: resp.data.key_name, client: @client ) end |
#instance(id) ⇒ Instance
1398 1399 1400 1401 1402 1403 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1398 def instance(id) Instance.new( id: id, client: @client ) end |
#instances(options = {}) ⇒ Instance::Collection
1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1690 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
1712 1713 1714 1715 1716 1717 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1712 def internet_gateway(id) InternetGateway.new( id: id, client: @client ) end |
#internet_gateways(options = {}) ⇒ InternetGateway::Collection
1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1769 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
1787 1788 1789 1790 1791 1792 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1787 def key_pair(name) KeyPairInfo.new( name: name, client: @client ) end |
#key_pairs(options = {}) ⇒ KeyPairInfo::Collection
1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1823 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
1841 1842 1843 1844 1845 1846 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1841 def network_acl(id) NetworkAcl.new( id: id, client: @client ) end |
#network_acls(options = {}) ⇒ NetworkAcl::Collection
1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1932 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
1950 1951 1952 1953 1954 1955 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1950 def network_interface(id) NetworkInterface.new( id: id, client: @client ) end |
#network_interfaces(options = {}) ⇒ NetworkInterface::Collection
2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2099 def network_interfaces( = {}) batches = Enumerator.new do |y| batch = [] resp = @client.describe_network_interfaces() resp.data.network_interfaces.each do |n| batch << NetworkInterface.new( id: n.network_interface_id, data: n, client: @client ) end y.yield(batch) end NetworkInterface::Collection.new(batches) end |
#placement_group(name) ⇒ PlacementGroup
2117 2118 2119 2120 2121 2122 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2117 def placement_group(name) PlacementGroup.new( name: name, client: @client ) end |
#placement_groups(options = {}) ⇒ PlacementGroup::Collection
2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2158 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
1076 1077 1078 1079 1080 1081 1082 |
# File 'lib/aws-sdk-ec2/resource.rb', line 1076 def register_image( = {}) resp = @client.register_image() Image.new( id: resp.data.image_id, client: @client ) end |
#route_table(id) ⇒ RouteTable
2176 2177 2178 2179 2180 2181 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2176 def route_table(id) RouteTable.new( id: id, client: @client ) end |
#route_table_association(id) ⇒ RouteTableAssociation
2185 2186 2187 2188 2189 2190 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2185 def route_table_association(id) RouteTableAssociation.new( id: id, client: @client ) end |
#route_tables(options = {}) ⇒ RouteTable::Collection
2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2287 def route_tables( = {}) batches = Enumerator.new do |y| batch = [] resp = @client.describe_route_tables() resp.data.route_tables.each do |r| batch << RouteTable.new( id: r.route_table_id, data: r, client: @client ) end y.yield(batch) end RouteTable::Collection.new(batches) end |
#security_group(id) ⇒ SecurityGroup
2305 2306 2307 2308 2309 2310 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2305 def security_group(id) SecurityGroup.new( id: id, client: @client ) end |
#security_groups(options = {}) ⇒ SecurityGroup::Collection
2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2426 def security_groups( = {}) batches = Enumerator.new do |y| batch = [] resp = @client.describe_security_groups() resp.data.security_groups.each do |s| batch << SecurityGroup.new( id: s.group_id, data: s, client: @client ) end y.yield(batch) end SecurityGroup::Collection.new(batches) end |
#snapshot(id) ⇒ Snapshot
2444 2445 2446 2447 2448 2449 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2444 def snapshot(id) Snapshot.new( id: id, client: @client ) end |
#snapshots(options = {}) ⇒ Snapshot::Collection
2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2524 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
2544 2545 2546 2547 2548 2549 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2544 def subnet(id) Subnet.new( id: id, client: @client ) end |
#subnets(options = {}) ⇒ Subnet::Collection
2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2623 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
2641 2642 2643 2644 2645 2646 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2641 def volume(id) Volume.new( id: id, client: @client ) end |
#volumes(options = {}) ⇒ Volume::Collection
2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2724 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
2744 2745 2746 2747 2748 2749 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2744 def vpc(id) Vpc.new( id: id, client: @client ) end |
#vpc_addresses(options = {}) ⇒ VpcAddress::Collection
2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2815 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
2837 2838 2839 2840 2841 2842 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2837 def vpc_peering_connection(id) VpcPeeringConnection.new( id: id, client: @client ) end |
#vpc_peering_connections(options = {}) ⇒ VpcPeeringConnection::Collection
2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 |
# File 'lib/aws-sdk-ec2/resource.rb', line 2914 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
3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 |
# File 'lib/aws-sdk-ec2/resource.rb', line 3003 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 |