Sha256: 748da97e51ebd9a9f45eb67a44d36569061c13c9eb236c1ac10c0aaa9db3a649

Contents?: true

Size: 882 Bytes

Versions: 23

Compression:

Stored size: 882 Bytes

Contents

module Awspec::Type
  class IamUser < Base
    aws_resource Aws::IAM::User

    def initialize(id)
      super
      @resource_via_client = find_iam_user(id)
      @id = @resource_via_client.user_id if @resource_via_client
    end

    def has_iam_policy?(policy_id)
      policies = select_iam_policy_by_user_name(@resource_via_client.user_name)
      policies.find do |policy|
        policy.policy_arn == policy_id || policy.policy_name == policy_id
      end
    end

    def has_inline_policy?(policy_name, document = nil)
      res = iam_client.get_user_policy({
                                         user_name: @resource_via_client.user_name,
                                         policy_name: policy_name
                                       })
      return JSON.parse(URI.decode(res.policy_document)) == JSON.parse(document) if document
      res
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
awspec-0.37.6 lib/awspec/type/iam_user.rb
awspec-0.37.5 lib/awspec/type/iam_user.rb
awspec-0.37.4 lib/awspec/type/iam_user.rb