This guide explains how to properly set up AWS permissions for the S3 Media Sync plugin. By following these steps, you'll create a secure IAM user with only the permissions needed for the plugin to function.
It's a best practice to create a group with the required permissions, then add users to that group.
- Log in to the AWS Management Console
- Navigate to the IAM service (search for "IAM" in the top search bar)
- In the left navigation menu, click on "User groups"
- Click the "Create group" button
- Enter a name for your group (e.g., "s3-media-sync-users")
- Skip the "Add users to the group" and "Attach permissions" sections for now
- Click "Create group"
Next, create a policy that defines exactly what permissions the plugin needs.
-
In the IAM dashboard, click on "Policies" in the left navigation menu
-
Click "Create policy"
-
Click on the "JSON" tab
-
Delete any existing code in the editor and paste the following:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:ListBucket", "s3:GetBucketLocation" ], "Resource": "arn:aws:s3:::YOUR-BUCKET-NAME" }, { "Effect": "Allow", "Action": [ "s3:PutObject", "s3:GetObject", "s3:DeleteObject", "s3:PutObjectAcl" ], "Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/wp-content/uploads/*" } ] } -
Replace
YOUR-BUCKET-NAMEwith the actual name of your S3 bucket (in both places) -
Click "Next: Tags" (you can skip adding tags)
-
Click "Next: Review"
-
Enter a name for the policy (e.g., "S3-Media-Sync-Policy")
-
Enter a description like "Permissions required for S3 Media Sync WordPress plugin"
-
Click "Create policy"
The policy above includes the minimum permissions needed for S3 Media Sync to work properly:
- s3:ListBucket and s3:GetBucketLocation: Allows the plugin to check if the bucket exists and locate it
- s3:PutObject: Allows the plugin to upload new media files to S3
- s3:GetObject: Allows the plugin to read and serve files from S3
- s3:DeleteObject: Allows the plugin to automatically remove files from S3 when they're deleted from the WordPress media library
- s3:PutObjectAcl: Allows the plugin to set access controls (public/private) on uploaded files
The permissions are scoped to only apply to the wp-content/uploads/* path within your bucket for enhanced security.
- Go back to "User groups" in the left navigation menu
- Click on the name of the group you created earlier
- Go to the "Permissions" tab
- Click "Add permissions" and select "Attach policies"
- Search for the policy you just created and select it
- Click "Add permissions"
- In the IAM dashboard, click on "Users" in the left navigation menu
- Click "Add users"
- Enter a username (e.g., "s3-media-sync")
- Under "Select AWS access type", check "Access key - Programmatic access"
- Click "Next: Permissions"
- Choose "Add user to group"
- Select the group you created earlier
- Click "Next: Tags" (you can skip adding tags)
- Click "Next: Review"
- Click "Create user"
IMPORTANT: On the success page, you'll see the Access key ID and Secret access key. Copy both of these immediately and store them securely. You will not be able to retrieve the Secret access key again.
- In your WordPress admin, go to Settings → S3 Media Sync
- Enter the following information:
- S3 Access Key ID: The Access key ID from the IAM user you created
- S3 Secret Access Key: The Secret access key from the IAM user you created
- S3 Bucket Name: Your bucket name
- S3 Bucket Region: The AWS region where your bucket is located (e.g., us-east-1, us-west-2)
- S3 Object ACL: Choose "public-read" if you want your media to be publicly accessible, or "private" for restricted access
- Click "Save Changes"
After saving your settings, the plugin will display a "Test S3 Access" button.
- Click the "Test S3 Access" button
- If the test succeeds, you'll see a success message
- If the test fails, you'll see an error message with details about what went wrong
If you get "Access Denied" errors, check:
- The IAM policy is correctly attached to the group
- The IAM user is in the group
- The bucket name is spelled correctly
- The bucket exists in the region you specified
- The bucket policy (if any) doesn't restrict the actions needed by the plugin
If you get "Bucket does not exist" errors, check:
- The bucket name is spelled correctly (bucket names are case-sensitive)
- The bucket is in the region specified in your settings
- The IAM user has the
s3:ListBucketands3:GetBucketLocationpermissions
If you get "Invalid credentials" errors, check:
- The Access Key ID and Secret Access Key are entered correctly
- The IAM user is active and not deleted
- Create a dedicated IAM user specifically for this plugin
- Use the principle of least privilege (only grant the permissions needed)
- Regularly rotate your access keys
- Consider using AWS CloudTrail to monitor S3 activity
- If you no longer need the plugin, delete the IAM user to revoke access