Sha256: 07f7bf94286ed84c6b41a9c45370ff40122b6d80509cd7463dcaf0d4fcda278d

Contents?: true

Size: 1.25 KB

Versions: 40

Compression:

Stored size: 1.25 KB

Contents

module Awspec::Helper
  module Finder
    module SecurityGroup
      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

      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
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
awspec-0.26.2 lib/awspec/helper/finder/security_group.rb
awspec-0.26.1 lib/awspec/helper/finder/security_group.rb
awspec-0.26.0 lib/awspec/helper/finder/security_group.rb
awspec-0.25.3 lib/awspec/helper/finder/security_group.rb
awspec-0.25.2 lib/awspec/helper/finder/security_group.rb
awspec-0.25.1 lib/awspec/helper/finder/security_group.rb
awspec-0.25.0 lib/awspec/helper/finder/security_group.rb
awspec-0.24.2 lib/awspec/helper/finder/security_group.rb
awspec-0.24.1 lib/awspec/helper/finder/security_group.rb
awspec-0.24.0 lib/awspec/helper/finder/security_group.rb
awspec-0.23.0 lib/awspec/helper/finder/security_group.rb
awspec-0.22.1 lib/awspec/helper/finder/security_group.rb
awspec-0.22.0 lib/awspec/helper/finder/security_group.rb
awspec-0.21.6 lib/awspec/helper/finder/security_group.rb
awspec-0.21.5 lib/awspec/helper/finder/security_group.rb
awspec-0.21.4 lib/awspec/helper/finder/security_group.rb
awspec-0.21.3 lib/awspec/helper/finder/security_group.rb
awspec-0.21.2 lib/awspec/helper/finder/security_group.rb
awspec-0.21.1 lib/awspec/helper/finder/security_group.rb
awspec-0.21.0 lib/awspec/helper/finder/security_group.rb