Sha256: 50bc4f41abe045bb3059cc8d99bc5488a9206e289a00a658a07b39f0b04172c5

Contents?: true

Size: 1.26 KB

Versions: 61

Compression:

Stored size: 1.26 KB

Contents

module Awspec::Helper
  module Finder
    module SecurityGroup
      def find_security_group(sg_id)
        res = ec2_client.describe_security_groups({
                                                    filters: [{ name: 'group-id', values: [sg_id] }]
                                                  })
        resource = res.security_groups.single_resource(sg_id)
        return resource if resource
        res = ec2_client.describe_security_groups({
                                                    filters: [{ name: 'group-name', values: [sg_id] }]
                                                  })
        resource = res.security_groups.single_resource(sg_id)
        return resource if resource
        res = ec2_client.describe_security_groups({
                                                    filters: [{ name: 'tag:Name', values: [sg_id] }]
                                                  })
        res.security_groups.single_resource(sg_id)
      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

61 entries across 61 versions & 1 rubygems

Version Path
awspec-0.34.0 lib/awspec/helper/finder/security_group.rb