How to Create Amazon S3 Bucket and Get User Access Key

The AWS access keys are required for configuring our extensions in order to connect your WordPress website to Amazon S3 service.

In this article, we will walk you through the following steps to create a new Amazon S3 bucket and get user access keys as quickly as possible.

  1. Log in to the AWS Console
  2. Create an Amazon S3 public bucket
  3. Create an IAM user and define permission policy
  4. Create an access key under that IAM user
  5. Configure our extensions with the given access key

1. Log in to the AWS Console

  • Already have an Amazon Web Services (AWS) account? Sign in here.
  • If you don’t have an AWS account yet, you will need to sign up here.

2. Create an Amazon S3 public bucket

Step 1: In AWS console, go to S3 Management Console at https://console.aws.amazon.com/s3/

Step 2: Click on “Create Bucket” button

Step 3: You will be prompted to enter a bucket name as well as selecting a region where you want the bucket to reside.

pda-aws-s3-bucket-step2

The bucket must be unique and won’t be able to be changed after created. Please refer to Rules for Bucket Naming for more information.

Step 4: Uncheck “Block all public access” under Set permission option to create a public bucket.

Review all your settings last time before clicking on “Create bucket” icon.

3. Create an IAM user and define permission policy

3.1. Create a new IAM user

Step 1: In AWS console, go to IAM Management Console at https://console.aws.amazon.com/iam/

Step 2: Click on “Add user” button

  • Enter a name for the user in the Username field
    • Names are case-insensitive and must be unique within your AWS account. Usernames can be a combination of up to 64 letters, digits, and these characters: plus (+), equal (=), comma (,), period (.), at sign (@), and hyphen (-).
  • Under AWS access type check Programmatic access only

 

3.2. Define the user’s permission policy

Step 1: Set permissions by clicking on “Attach existing policies directly” and then “Create policy” button.

Step 2: Insert the following code snippet to your policy file using JSON. Remember to change your S3 bucket name accordingly.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "POLICYPDAS3",
            "Effect": "Allow",
            "Action": [
                "s3:List*",
                "s3:Get*",
                "s3:Put*",
                "s3:Delete*"
            ],
            "Resource": [
                "arn:aws:s3:::your-bucket_name/*",
                "arn:aws:s3:::your-bucket_name"
            ]
        }
    ]
}

If you’re using CloudFront CDN, please use the code snippet below instead.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "POLICYPDAS3",
            "Effect": "Allow",
            "Action": [
                "s3:List*",
                "s3:Get*",
                "s3:Put*",
                "s3:Delete*"
            ],
            "Resource": [
                "arn:aws:s3:::your-bucket_name/*",
                "arn:aws:s3:::your-bucket_name"
            ]
        },
        {
            "Action": [
                "cloudfront:*" 
            ],
            "Effect": "Allow",  
            "Resource": "*"
        }
    ]
}

Once done, double-check if everything is alright by searching your newly created policy.

Finally, click on “Create user” button.

Create an access key under that IAM user

After you create a new IAM user, a security credentials file including an Access Key ID and a Secret Access Key will be shown to you for download. Amazon will not display this information again so please download the .csv file and keep them somewhere safe.

In case you’ve already created an IAM user,

  1. Go to Users page
  2. Click on the Security Credentials tab and then Create Access Key button.
    Once the success message pops up, click on Download Credentials button.

Configure our extensions

PDA S3 Integration extension

Once activating our plugins, go to Prevent Direct Access Gold >> Amazon S3 menu from your admin dashboard. Then input the information you get above to under “Storage” section.

PDA Protect Videos & Audios extension

You can stream the HSL videos stored in Amazon S3 bucket without any extra configuration. Our plugin will connect to your bucket automatically as long as you make the bucket public to access.

WordPress Amazon S3 Direct Upload Free version

Refer to this guide on how to configure and upload files directly to S3 bucket with WordPress Amazon S3 Direct Upload plugin.

Lasted updated on July 3, 2021