module StackMaster
  class Identity
    def running_in_allowed_account?(allowed_accounts)
      allowed_accounts.nil? || allowed_accounts.empty? || allowed_accounts.include?(account)
    end

    def account
      @account ||= sts.get_caller_identity.account
    end

    private

    attr_reader :sts

    def region
      @region ||= ENV['AWS_REGION'] || Aws.config[:region] || Aws.shared_config.region || 'us-east-1'
    end

    def sts
      @sts ||= Aws::STS::Client.new(region: region)
    end
  end
end

module StackMaster
  class Identity
    def running_in_allowed_account?(allowed_accounts)
      allowed_accounts.nil? || allowed_accounts.empty? || allowed_accounts.include?(account)
    end

    def account
      @account ||= sts.get_caller_identity.account
    end


    private

    def region
      @region ||= ENV['AWS_REGION'] || Aws.config[:region] || Aws.shared_config.region || 'us-east-1'
    end

    def sts
      @sts ||= Aws::STS::Client.new(region: region)
    end
  end
end

Remove unneeded attr_reader in Identity class
Remove unneeded attr_reader in Identity class

There's a method with that name.
