Override the output of class S3AssetSourceType->getBucketList from a plugin My issue is that for security I don’t have the s3:ListAllMyBuckets permission (as I can only see one bucket), but not list them. Craft needs this to function, so I need to manually force the list of one bucket.

I am trying to override the output of class S3AssetSourceType->getBucketList from a plugin (in Craft 2) to return my own list.

In Craft 3 I’d create my own AssetSource. I guess I’m going to need to amend the core (I know very bad), but I think its the only option I have at this stage (unless anyone has a bright idea). We won’t allow updates via the CMS, so I could write a unit test to check the output is as I have amended it after any core updates. Also, I’d assume that S3AssetSourceType won’t be edited much in Craft 2.

Not an ideal solution, but its the only way I can think of doing it. I have tried every other workaround I can think about (before editing the core code). I looked at mounting the filesystem using s3fs-fuse on Ubuntu, but Docker won’t allow it in our setup.

Anyway, any help would be much appreciated before I start hacking away… thanks.
OK, this doesn't completely answer my question, but I think this is the more elegant solution to the problem I was trying to solve. If you don't have the all s3:ListAllMyBuckets permission available in AWS then the following plugin code will allow you to pass in a static bucket list. This meant I didn't have to start hacking the core code.

&lt;?php
namespace Craft;

class MyPlugin extends BasePlugin
{
    public function init()
    {
        parent::init();

        if(isset($_GET['p']) &amp;&amp; $_GET['p'] == "admin/actions/assetSources/getS3Buckets")
        {
            // Requires an admin
            craft()-&gt;userSession-&gt;requireAdmin();

            // Making the money
            craft()-&gt;requireEdition(Craft::Pro); 

            $bucketList = array();

            $bucketList[] = array(
                'bucket' =&gt; 'my-bucket-name',
                'location' =&gt; 'EU',
                'urlPrefix' =&gt; 'http://s3-eu-west-1.amazonaws.com/my-bucket-name/'
            );

            $this-&gt;returnJson($bucketList);
        }
    }


    private function returnJson($var = array(), $options = array())
    {
        // Set the 'application/json' Content-Type header
        JsonHelper::setJsonContentTypeHeader();

        $options = array_merge(array(
            'expires' =&gt; false,
        ), $options);

        // Set the Expires header
        if ($options['expires'] === false)
        {
            HeaderHelper::setNoCache();
        }
        else if ($options['expires'])
        {
            HeaderHelper::setExpires($options['expires']);
        }

        // Output it into a buffer, in case TasksService wants to close the connection prematurely
        ob_start();
        echo JsonHelper::encode($var);

        craft()-&gt;end();
    }
}