Skip to content

9. Configure automatic file relocation to Amazon S3

1. Create an S3 bucket

  1. Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.
  2. Choose Create bucket.

    Create Bucket

  3. In the Bucket name field, type a unique DNS-compliant name for your new bucket. (The example screen shot uses the bucket name miarec-s3-storage. You cannot use this name because each S3 bucket names must be unique.) Create your own bucket name using the follow naming guidelines:

    • The name must be unique across all existing bucket names in Amazon S3.
    • After you create the bucket you cannot change the name, so choose wisely.
    • Choose a bucket name that reflects the objects in the bucket because the bucket name is visible in the URL that points to the objects that you're going to put in your bucket.

For information about naming buckets, see Rules for Bucket Naming in the Amazon Simple Storage Service Developer Guide.

  1. For Region, choose the region where you want the bucket to reside. It is recommended to chose the region that is closest to your end-users. This will provide them the best performance during playback.

    Choose Region

  2. In the section Bucket settings for Block Public Access, make sure that public access is blocked.

    Bucket Settings

  3. Click Create bucket in the last screen.

2. Create policy that grants access to the S3 bucket

  1. Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
  2. In the navigation pane on the left, click Policies and then click Create Policy.

    Create Policy

  3. Select JSON tab, copy the following access policy and paste it into the JSON field. Do not forget to replace miarec-s3-storage with your bucket name!!!.

{
"Version": "2012-10-17",
"Statement": [
    {
        "Effect": "Allow",
        "Action": [
            "s3:ListBucket"
        ],
        "Resource": [
            "arn:aws:s3:::miarec-s3-storage"
        ]
    },
    {
        "Effect": "Allow",
        "Action": [
            "s3:PutObject",
            "s3:GetObject",
            "s3:DeleteObject"
        ],
        "Resource": [
            "arn:aws:s3:::miarec-s3-storage/*"
        ]
    }
]
}
JSON Tab

In the step Review policy, choose a descriptive name for the policy and click Create policy button.

Review Policy

3. Create IAM user

  1. Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
  2. In the navigation pane on the left, click Users and then click Add user.

    Add User

  3. On Details screen, choose User name and enable Programmatic access.

    Details Screen

  4. On Permissions screen, select Attach existing policies directly and then select the previously created policy from the list. Use the search box to find the policy by name.

    Permissions Screen

  5. Review the settings and click Create user.

    Review Settings

  6. On Complete screen, copy Access Key ID and Secret access Key and store them in secure place. We will use it for configuring storage target in MiaRec.

    Complete Screen

4. Add Cross-Origin Resource Sharing (CORS) configuration to an S3 bucket

Cross-Origin Resource Sharing (CORS) allows client web applications that are loaded in one domain to interact with resources in another domain. This configuration is required for our setup because MiaRec web application is accessible using one domain (for example, https://recorder.example.com), but audio files are located at Amazon S3 domain (https://s3.amazonaws.com)

To add a CORS configuration to an S3 bucket:

  1. Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.
  2. In the Bucket name list, choose the name of the bucket that you want to create a bucket policy for.

    Choose Bucket Name

  3. Choose Permissions, and then choose CORS configuration.

    CORS Configuration

  4. Copy the following CORS configuration and paste it into the CORS configuration editor field:

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [],
        "MaxAgeSeconds": 3000
    }
]
CORS Configuration Editor

Choose Save.

5. Configure Storage Target in MiaRec

  1. Navigate in MiaRec web portal to Administration -> Storage -> Storage Targets and choose Add.
  2. Select Amazon S3 in Storage Target Type. Configure S3 Bucket, AWS Access Key ID and AWS Secret Access Key accordingly (as configured in the previous steps).

Configure Storage Target

6. Configure automatic file relocation to S3 storate target

  1. Navigate in MiaRec web portal to Administration -> Storage -> Relocate Recording files and choose Add job.
  2. Configure Storage Target. Change Mode to Incremental. Select scheduler setting Run this job to Custom (crontab) and schedule it to run every 15 minutes by using */15 in the Minute attribute.

Configure Automatic File Relocation

Make a few test calls and check status of this job. It is expected that files are automatically relocated to S3.

Check Status

Navigate to Amazon S3 console and verify that files are located there:

Amazon S3 console