Module: Awspec::Helper::Finder::Subnet

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

Instance Method Summary collapse

Instance Method Details

#find_subnet(subnet_id) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/awspec/helper/finder/subnet.rb', line 4

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

#select_subnet_by_vpc_id(vpc_id) ⇒ Object



21
22
23
24
25
26
# File 'lib/awspec/helper/finder/subnet.rb', line 21

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