Open caseyg opened 4 years ago
Some initial notes:
S3Client
constructor, which mentions this configuration option:
bucket_endpoint: (bool) Set to true to send requests to a hardcoded bucket endpoint rather than create an endpoint as a result of injecting the bucket into the URL. This option is useful for interacting with CNAME endpoints.
AwsClient
constructor -- AwsClient
is the base class for S3Client
-- which mentions this configuration option that likely corresponds to the above "hardcoded bucket endpoint" option:
endpoint: (string) The full URI of the webservice. This is only required when connecting to a custom endpoint (e.g., a local version of S3).
I tested this by making the modification below in my local development environment, and it appears to work.
diff --git a/modules/AmazonS3/src/File/Store/AwsS3.php b/modules/AmazonS3/src/File/Store/AwsS3.php
index b3b3eead..4f5d9836 100644
--- a/modules/AmazonS3/src/File/Store/AwsS3.php
+++ b/modules/AmazonS3/src/File/Store/AwsS3.php
@@ -56,6 +56,8 @@ class AwsS3 implements StoreInterface
'version' => 'latest',
'region' => $awsRegion,
'credentials' => new Credentials($awsKey, $awsSecretKey),
+ 'bucket_endpoint' => true,
+ 'endpoint' => 'https://files.disorientations.org',
]);
$this->client->registerStreamWrapper();
However, this change is specific to our installation and as such can't be contributed upstream. This is a concern because we want our local instance of the module to diverge as little as possible from upstream to avoid making any future module upgrades more difficult.
It would be preferable to work around this without modifying module code, but I'm not sure that's possible because the module isn't configured to autoload external code. So, this will likely require a change to the module itself.
I set up a CNAME for our s3 bucket: files.disorientations.org
instead of loading:
https://s3.amazonaws.com/files.disorientations.org/original/Barnard_Columbia_University/2017/Barnard_20Columbia_20Disorientation_20Guide_202017.pdf
we should load:
https://files.disorientations.org/original/Barnard_Columbia_University/2017/Barnard_20Columbia_20Disorientation_20Guide_202017.pdf
The CNAME already works, but the module still points to the s3 url. We might need to modify the S3 module to make this happen?
I might also have to setup HTTPS for the S3 bucket.
https://thenewstack.io/how-to-set-up-your-s3-bucket-with-https-in-an-hour/