View more context

 

lexandclo

cool, cheers again guys. latest on server is 7.2 and that works fine

👍 (1)
CptPillow

Hi Everyone I am trying to add Silverstripe/S3 but have never done it before. I dont see a lot of info to go on in the readme.md can someone point me in the right direction?

wmk

Did you read https://www.silverstripe.org/blog/utilising-amazon-s3-to-supercharge-your-silverstripe-hosting/ ?

Show 1 attachment(s)
silverstripe.org  
Utilising Amazon S3 to supercharge your SilverStripe Hosting

Scaling your hosting on the fly has never been easier. Chief Architect at Moosylvania, Joe Madden, explains Flysystem and the SilverStripe S3 module, offering agencies more flexibility to host on new platforms and maintain high performance.

Hide attachment content
wmk

also https://github.com/silverstripe/silverstripe-s3/issues/26#issuecomment-505525388 should help you

Show 1 attachment(s)
GitHub  
Module does not work when running locally via Docker · Issue #26 · silverstripe/silverstripe-s3

I've installed this module on a 4.3 site and I'm stuck at the following error. I cannot run dev/build... this is the error I get when I try to do that: [Emergency] Uncaught Aws\Exception\Cr...

Hide attachment content
CptPillow

Yes I did read the first article. But not sure how to set it up in my config.

CptPillow

Havent even gotten to where its not working on localhost or virtual servers yet

wmk

you need to set the right env vars

CptPillow

Ive got an AWS server that I will be testing on so need to make sure I have the settings right then I can test it on there

wmk

I just examined that module for another flysystem adapter, didn't setup S3 myself. Maybe @kinglozzer or @dorsetdigital can shed some light on this?

CptPillow

Think I got somewhere. instead of having the stuff set in yml I need to do it in .env but now I got an error which I think is because im on local at the moment

Mo

Have you added your secret key correctly and added it?

Mo

Haven't used this module, but we backup to S3 and the permissions can be a little fiddly

wmk

You backup manually or with flysystem's replication?

CptPillow

I believe I added my secret key correctly. waiting for my site to get on the aws server to see if it is working correctly

dorsetdigital

Did you get it working? I've just set up a test here, and it seems to be doing what it should

CptPillow

Busy getting server ready to see if it is working

CptPillow

Im getting the following error now: [Unknown Error] Uncaught GuzzleHttp\Exception\ClientException: Client error: GET http://169.254.169.254/latest/meta-data/iam/security-credentials/ resulted in a 404 Not Found response:

CptPillow

@dorsetdigital can you possibly walk me through what you did to get it to work?

CptPillow

I think I might have done something wrong

dorsetdigital

I haven't deployed on EC2, so it may be different. I just set up a local site here

CptPillow

I have a local version of the site on my PC so If it works on my PC I know what to look for

dorsetdigital

In my case, it was literally: Install SS4, configure the .env and .yml files, install the S3 module with composer. Dev/build?flush

dorsetdigital

(Obviously I set up the S3 bucket and added an IAM user first to get the credentials)

CptPillow

I got the following credentials set in my env[AWS_REGION, AWS_BUCKET_NAME, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY] Did I miss anything there?

dorsetdigital
  1. AWS_REGION="eu-west-2"
  2. AWS_BUCKET_NAME="mybucket"
  3. AWS_ACCESS_KEY_ID='****************************'
  4. AWS_SECRET_ACCESS_KEY=""
CptPillow

ahh you couldnt use the starts for secret key too?

dorsetdigital

And this is the yml file:

  1. ---
  2. Only:
  3. envvarset: AWS_BUCKET_NAME
  4. After:
  5. - '#assetsflysystem'
  6. ---
  7. SilverStripe\Core\Injector\Injector:
  8. Aws\S3\S3Client:
  9. constructor:
  10. configuration:
  11. region: '`AWS_REGION`'
  12. version: latest
  13. credentials:
  14. key: '`AWS_ACCESS_KEY_ID`'
  15. secret: '`AWS_SECRET_ACCESS_KEY`'
CptPillow

wait so the yml file you dont add the details in there?

dorsetdigital

If you put them in there, I don't think that would have broken anything

CptPillow

wait could be the server going nope... give me a few

dorsetdigital

Don't forget, if you change the yml, you'll probably need to dev/build?flush

CptPillow

Yip. Just waiting for the DB to be added with populated pages then Im going to go further.

CptPillow

to be able to see that error again I need to figure out why its saying that I am using wrong create options for my DB

CptPillow

@dorsetdigital this is the error I am getting: [Emergency] Uncaught Aws\S3\Exception\S3Exception: Error executing "PutObject" on "https://s3.eu-west-1.amazonaws.com/AWS_Bucket/public/error-404.html"; AWS HTTP error: Client error: PUT https://s3.eu-west-1.amazonaws.com/AWS_Bucket/public/error-404.html resulted in a 403 Forbidden response: AccessDeniedAccess Denied49E57C (truncated...) AccessDenied (client): Access Denied - AccessDeniedAccess

dorsetdigital

OK, so that looks like the policy on your bucket isn't right, or the IAM user doesn't have the right permissions

CptPillow

now I need to specify the root folder where the assets is sitting on the bucket. any clue on how I would do that?

dorsetdigital

Do you need to do that? If it's a new bucket, the asset directories just sit in the root

CptPillow

okay got it in the root of the bucket. My assets are not pulling through from the bucket tho

dorsetdigital

Pulling through to where? The admin system or the front end?

dorsetdigital

Are the URLs right in the page? ie. do they point to an S3 resource

CptPillow

the url is showing my aws url with the assets attached to the end instead of my s3 bucket

dorsetdigital

OK. Check that the file is actually in the bucket where it's supposed to be. Then check that the bucket has public viewing permissions for the public assets

CptPillow

The guy who is handeling the servers says that public access is allowed

dorsetdigital

If that's true, then the file either isn't there, or isn't where it's supposed to be

CptPillow

But would that cause the image to refer to the aws server instead of the bucket?

dorsetdigital

Oh. When you said AWS url, I thought you meant the bucket

dorsetdigital

If the URLs in the front-end are still pointing to the web server, that would suggest the module isn't working

CptPillow

ah okay because the image link starts with assets/ but when i hover over it it shows the aws IP address

CptPillow

Hi @dorsetdigital So you said you set it up to work but does it pull the images from the s3 bucket?

CptPillow

its so strange because I have my settings the same as you showed but its not pulling through but also not throwing an error

dorsetdigital

I'm not really sure what to suggest to be honest. It should work pretty much out of the box

dorsetdigital

The only thing I can't be sure of is whether the server makes a difference. I've only set it up with the webserver outside the AWS system, but I don't know what different that would make

CptPillow

I would have thought that it would be easier to get to work with a server on aws than one thats outside

CptPillow

Im thinking it might be a conflict of vendor files... I did try using more than one for the s3 integration so im hoping cleaning up the vendor folder will work


Show less replies
mukmuk

what is the preferred way for importing dataobjects by modeladmin's CSV importer?

upload all assets beforehand through /admin/assets/, then write down the File.ID as MyDataFileId in the csv?

dorsetdigital

I'd have thought it was better to make a custom importer

wmk

you can add that custom importer to the modeladmin, yes. It could try to find the file by path in DB and import it from a "files-to-import" folder if not found.

dorsetdigital

A lot depends where the files are really. If they're already online somewhere, you can automate the entire process

dorsetdigital

Otherwise you could upload them and find them as @wmk suggests

mukmuk

They're physically on the same server, so i could get them by the local path. Basically i could write a custom importer while using File::setFromLocalFile ? That would be the most stress-free way indeed