Serverless Wordpress and S3 Integration

0

Hi,

While preparing serverless architecture for wordpress, we are facing issue in storage as we know lambda is Read-only filesystem which is not persistent but for wordpress we require a persistent storage for that we are going to integrate wordpress with S3. For this we are going to add s3-plugins in wordpress for storing media files with s3. Here we tried two methods or plugins to solve the requirement.

Method 1 - The blog (https://github.com/keichan34/wordpress-on-lambda.git) we referred to build the serverless architecture also contains the s3-uploads plugin https://github.com/keichan34/wordpress-on-lambda/tree/master/src/php/wp-content/plugins/S3-Uploads-2.1.0 and here after activating the plugin and tried to upload media files but it shows** Endpoint request timed out** error as shown in screenshot

Error

From the scenerio it looks like 504 time out error, so wordpress can't able to reach the s3. We checked if there any policy/permission issue for both plugin and infrastructure side. To resolve permission issue, from infrastructure side we modify s3 policy to do all actions in the provided s3 bucket and in plugin we provide new access key but it doesn't worked.

Method 2 - we tried to add another s3 plugin (https://github.com/deliciousbrains/wp-amazon-s3-and-cloudfront.git) which has most number of installation in wordpress. so we added this plugin code with our wordpress in the wp-content/plugins path.Here it shows the Wp-offload-media-lite plugin in the activation page as shown in screenshot Wp-offload-media-lite

but it doesn't show any configure page for that plugin after the activation. So, Please suggest me any s3-upload plugin and their code to add with wordpress.

1 Answer
0
Accepted Answer
DucLuu
answered 7 months ago
  • You have to create a AWS role and assign it to your lambda. Here are the steps Sign in to the AWS Management Console: Log in to your AWS account using your credentials.

    Open the IAM Console: Navigate to the Identity and Access Management (IAM) service in the AWS Management Console.

    Create an IAM Role: To create an IAM role, follow these steps:

    a. In the IAM dashboard, click on "Roles" from the left-hand menu.

    b. Click the "Create role" button.

    c. For the "Select type of trusted entity," choose "AWS service."

    d. For the "Use case," choose "Lambda."

    e. Click "Next: Permissions."

    Attach Permissions Policies: In this step, you'll attach policies to the role to grant S3 full permissions. You can either attach the "AmazonS3FullAccess" policy, or you can create a custom policy with S3 full permissions and attach it. Here's how to attach an existing policy:

    a. In the "Permissions" step, search for and select the "AmazonS3FullAccess" policy.

    b. Click "Next: Tags" (you can add tags if needed) and then click "Next: Review."

    c. Give your role a meaningful name and add an optional description.

    d. Click "Create role."

    Role Created: You've now created the IAM role with S3 full permissions. The next step is to assign this role to your Lambda function.

    Open the Lambda Console: Go to the AWS Lambda service in the AWS Management Console.

    Create or Select Your Lambda Function: Either create a new Lambda function or select an existing one to which you want to attach the IAM role.

  • Hi DucLuu, Thanks for the response. Yes, I actually used the s3-upload plugin as you mentioned but not able upload any media files as it shows "Endpoint Requested Timed out". Can you please give some suggestion for this.

  • Hi DucLuu, I have build a serverless architecture for wordpress using serverless components such as lambda,cloudfront,apigateway and s3. As lambda is Read-only file system we can't store media files so I tried to use s3. For Integrating s3 with wordpress, used S3-uploads plugin (https://github.com/keichan34/wordpress-on-lambda/tree/master/src/php/wp-content/plugins/S3-Uploads-2.1.0) but It shows Endpoint Requested Timed out (or) The server cannot process the image. This can happen if the server is busy or does not enough resources to complete the task.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions