Module: Awspec::Helper::Finder::Vpc

Included in:
Awspec::Helper::Finder
Defined in:
lib/awspec/helper/finder/vpc.rb

Instance Method Summary collapse

Instance Method Details

#find_network_acl(id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/awspec/helper/finder/vpc.rb', line 26

def find_network_acl(id)
  res = ec2_client.describe_network_acls({
                                           filters: [{ name: 'network-acl-id', values: [id] }]
                                         })
  return res[:network_acls].first if res[:network_acls].count == 1
  res = ec2_client.describe_network_acls({
                                           filters: [{ name: 'tag:Name', values: [id] }]
                                         })
  return res[:network_acls].first if res[:network_acls].count == 1
end

#find_route_table(route_table_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/awspec/helper/finder/vpc.rb', line 15

def find_route_table(route_table_id)
  res = ec2_client.describe_route_tables({
                                           filters: [{ name: 'route-table-id', values: [route_table_id] }]
                                         })
  return res[:route_tables].first if res[:route_tables].count == 1
  res = ec2_client.describe_route_tables({
                                           filters: [{ name: 'tag:Name', values: [route_table_id] }]
                                         })
  return res[:route_tables].first if res[:route_tables].count == 1
end

#find_subnet(subnet_id) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/awspec/helper/finder/vpc.rb', line 51

def find_subnet(subnet_id)
  res = ec2_client.describe_subnets({
                                      filters: [{ name: 'subnet-id', values: [subnet_id] }]
                                    })
  return res[:subnets].first if res[:subnets].count == 1
  res = ec2_client.describe_subnets({
                                      filters: [{ name: 'tag:Name', values: [subnet_id] }]
                                    })
  return res[:subnets].first if res[:subnets].count == 1
end

#find_vpc(id) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/awspec/helper/finder/vpc.rb', line 4

def find_vpc(id)
  res = ec2_client.describe_vpcs({
                                   filters: [{ name: 'vpc-id', values: [id] }]
                                 })
  return res[:vpcs].first if res[:vpcs].count == 1
  res = ec2_client.describe_vpcs({
                                   filters: [{ name: 'tag:Name', values: [id] }]
                                 })
  return res[:vpcs].first if res[:vpcs].count == 1
end

#find_vpc_peering_connection(vpc_peering_connection_id) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/awspec/helper/finder/vpc.rb', line 69

def find_vpc_peering_connection(vpc_peering_connection_id)
  res = ec2_client.describe_vpc_peering_connections({
                                                      filters: [
                                                        {
                                                          name: 'vpc-peering-connection-id',
                                                          values: [vpc_peering_connection_id]
                                                        }
                                                      ]
                                                    })
  return res[:vpc_peering_connections].first if res[:vpc_peering_connections].count == 1
  res = ec2_client.describe_vpc_peering_connections({
                                                      filters: [
                                                        {
                                                          name: 'tag:Name',
                                                          values: [vpc_peering_connection_id]
                                                        }
                                                      ]
                                                    })
  return res[:vpc_peering_connections].first if res[:vpc_peering_connections].count == 1
end

#select_network_acl_by_vpc_id(vpc_id) ⇒ Object



44
45
46
47
48
49
# File 'lib/awspec/helper/finder/vpc.rb', line 44

def select_network_acl_by_vpc_id(vpc_id)
  res = ec2_client.describe_network_acls({
                                           filters: [{ name: 'vpc-id', values: [vpc_id] }]
                                         })
  res[:network_acls]
end

#select_route_table_by_vpc_id(vpc_id) ⇒ Object



37
38
39
40
41
42
# File 'lib/awspec/helper/finder/vpc.rb', line 37

def select_route_table_by_vpc_id(vpc_id)
  res = ec2_client.describe_route_tables({
                                           filters: [{ name: 'vpc-id', values: [vpc_id] }]
                                         })
  res[:route_tables]
end

#select_subnet_by_vpc_id(vpc_id) ⇒ Object



62
63
64
65
66
67
# File 'lib/awspec/helper/finder/vpc.rb', line 62

def select_subnet_by_vpc_id(vpc_id)
  res = ec2_client.describe_subnets({
                                      filters: [{ name: 'vpc-id', values: [vpc_id] }]
                                    })
  res[:subnets]
end