Sha256: edf74f00d6b17b66ca266955f9633705c0592ed0abab53a80fd60600392fb305

Contents?: true

Size: 1.13 KB

Versions: 117

Compression:

Stored size: 1.13 KB

Contents

module Awspec::Helper
  module Finder
    module SecurityGroup
      def find_security_group(sg_id)
        resource = select_security_group_by_group_id([sg_id]).single_resource(sg_id)
        return resource if resource

        resource = select_security_group_by_group_name([sg_id]).single_resource(sg_id)
        return resource if resource

        select_security_group_by_tag_name([sg_id]).single_resource(sg_id)
      end

      def select_security_group_by_vpc_id(vpc_id)
        describe_security_groups({ filters: [{ name: 'vpc-id', values: [vpc_id] }] })
      end

      def select_security_group_by_group_id(ids)
        describe_security_groups({ filters: [{ name: 'group-id', values: ids }] })
      end

      def select_security_group_by_group_name(names)
        describe_security_groups({ filters: [{ name: 'group-name', values: names }] })
      end

      def select_security_group_by_tag_name(names)
        describe_security_groups({ filters: [{ name: 'tag:Name', values: names }] })
      end

      def describe_security_groups(param)
        ec2_client.describe_security_groups(param).security_groups
      end
    end
  end
end

Version data entries

117 entries across 117 versions & 4 rubygems

Version Path
awspec-1.25.1 lib/awspec/helper/finder/security_group.rb
awspec-1.25.0 lib/awspec/helper/finder/security_group.rb
awspec-1.24.4 lib/awspec/helper/finder/security_group.rb
awspec-1.24.3 lib/awspec/helper/finder/security_group.rb
awspec-1.24.2 lib/awspec/helper/finder/security_group.rb
awspec-1.24.1 lib/awspec/helper/finder/security_group.rb
awspec-1.24.0 lib/awspec/helper/finder/security_group.rb
awspec-1.23.0 lib/awspec/helper/finder/security_group.rb
awspec-1.22.1 lib/awspec/helper/finder/security_group.rb
awspec-1.22.0 lib/awspec/helper/finder/security_group.rb
awspec-1.21.1 lib/awspec/helper/finder/security_group.rb
awspec-1.21.0 lib/awspec/helper/finder/security_group.rb
awspec-1.20.0 lib/awspec/helper/finder/security_group.rb
awspec-1.19.2 lib/awspec/helper/finder/security_group.rb
awspec-1.19.1 lib/awspec/helper/finder/security_group.rb
awspec-1.19.0 lib/awspec/helper/finder/security_group.rb
cthiesfork-awspec-1.2.4 lib/awspec/helper/finder/security_group.rb
awspec-api_gateway_extended-1.2.4 lib/awspec/helper/finder/security_group.rb
awspec-api_gateway_extended-1.2.3 lib/awspec/helper/finder/security_group.rb
awspec-1.18.6 lib/awspec/helper/finder/security_group.rb