Module: Awspec::Helper::Finder::SecurityGroup

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

Instance Method Summary collapse

Instance Method Details

#find_security_group(id) ⇒ Object



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

def find_security_group(id)
  res = @ec2_client.describe_security_groups({
                                               filters: [{ name: 'group-id', values: [id] }]
                                             })

  return res[:security_groups].first if res[:security_groups].count == 1
  res = @ec2_client.describe_security_groups({
                                               filters: [{ name: 'group-name', values: [id] }]
                                             })

  return res[:security_groups].first if res[:security_groups].count == 1
  res = @ec2_client.describe_security_groups({
                                               filters: [{ name: 'tag:Name', values: [id] }]
                                             })

  return res[:security_groups].first if res[:security_groups].count == 1
end

#select_security_group_by_vpc_id(vpc_id) ⇒ Object



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

def select_security_group_by_vpc_id(vpc_id)
  res = @ec2_client.describe_security_groups({
                                               filters: [{ name: 'vpc-id', values: [vpc_id] }]
                                             })
  res[:security_groups]
end