wordpress-operator icon indicating copy to clipboard operation
wordpress-operator copied to clipboard

Unable to get S3 media bucket to work

Open RichardMills opened this issue 5 years ago • 5 comments

What happened:

I'm setting up a Wordpress site using the wordpress-operator. For media backing store, I was hoping to use S3.

I read through the CRD spec and found that it supports s3: media library as well as gcs: media library. So I created a definition block that should have made use of a bucket and stored media there. I tested it by visiting my Media library and upload/view some images. Instead of pushing/pulling the images from S3, it created a wp-content/uploads directory and stored the sample images in there.

spec:
  media: # where to find the media files
    # For S3, see: https://github.com/presslabs/wordpress-operator/blob/ce3af26178f206075ba7bde57985beb4181f59cb/config/crds/wordpress.presslabs.org_wordpresses.yaml#L1868
    s3:
      bucket: my-bucket
      prefix: mysite
      env:
        - name: AWS_ACCESS_KEY_ID
          valueFrom:
            secretKeyRef:
              name: wordpress-aws-secret
              key: aws_access_key_id
        - name: AWS_SECRET_ACCESS_KEY
          valueFrom:
            secretKeyRef:
              name: wordpress-aws-secret
              key: aws_secret_access_key

I also created the wordpress-aws-secret with proper credentials.

What you expected to happen:

I expected that after starting up mysite with the wordpress-operator, the Media library would either read/write images to S3 or at least start spewing errors due to misconfiguration. That is what happened when I put some dummy gcs: configuration settings in. (I don't actually have a GCS account.)

How to reproduce it (as minimally and precisely as possible):

  • define a mysite wordpress CR spec
  • use the spec configuration for the media setup above
  • create a aws secret with two values to match the configuration above

Anything else?:

Is there anything else that needs to be done to configure Wordpress to use S3?

RichardMills avatar Jul 28 '20 21:07 RichardMills

Hi, @RichardMills did you installed stack-mu-plugin? In order to work, you have to install this plugin which creates a stream wrapper, more details can be found here

AMecea avatar Aug 04 '20 10:08 AMecea

I will attempt to get this plugin installed. Let me know if there's any docs associated with making this work within the operator or if there's any slick way to tell the operator about mu plugins. I think my plan is:

  • install the stack-my-plugin into my wp-content/my-plugins git repository per the instructions you pointed to
  • launch the WP instance with the S3 spec listed above
  • watch the WP instance logs for evidence that the S3 parameters are being handled by the plugin to connect with the S3 bucket as specified

RichardMills avatar Aug 07 '20 14:08 RichardMills

Here are two examples:

  • classic WordPress approach: https://github.com/presslabs/stack-example-wordpress (which is a little bit outdated)
  • bedrock WordPress structure: https://github.com/presslabs/stack-example-bedrock

AMecea avatar Aug 11 '20 07:08 AMecea

As i understand this plugin support only gcp