Migrating media assets from Cloudinary to AWS S3 using Strapi can significantly improve storage flexibility, cost efficiency, and integration with other AWS services. This guide provides a comprehensive, step-by-step approach to seamlessly transition media files while ensuring minimal downtime and preserving metadata.

Why Migrate from Cloudinary to AWS S3?

Cloudinary is a robust media management platform, but AWS S3 offers more cost-effective, scalable, and customizable storage options, especially for projects requiring deeper integration with AWS tools like Lambda, CloudFront, and IAM policies.

Prerequisites

Before starting the migration process, ensure the following:

  • AWS S3 Bucket: Created and configured with appropriate permissions.
  • AWS IAM User: Access keys with PutObject and GetObject permissions for the S3 bucket.
  • Strapi Installation: A working Strapi project with a properly configured database.
  • Cloudinary API Keys: Access to retrieve existing media files.

Step 1: Export Media from Cloudinary

  1. Log in to Cloudinary and navigate to the Media Library.
  2. Use the Cloudinary API or bulk export feature to download all assets.
  3. curl -X GET ‘https://res.cloudinary.com/<cloud_name>/image/list.json’ -u ‘<API_KEY>:<API_SECRET>’
  4. Save the downloaded media locally before uploading to AWS S3.

Step 2: Configure AWS S3 for Strapi

  1. Create an S3 bucket in AWS.
  2. Configure CORS policies to allow Strapi to interact with the bucket.
  3. Set up an IAM user with the following permissions:


{

  “Version”: “2012-10-17”,

  “Statement”: [

    {

      “Effect”: “Allow”,

      “Action”: [

        “s3:PutObject”,

        “s3:GetObject”,

        “s3:ListBucket”

      ],

      “Resource”: “arn:aws:s3:::your-bucket-name/*”

    }

  ]

}

  1. Obtain the Access Key ID and Secret Access Key for authentication.

Step 3: Install and Configure Strapi S3 Plugin

  1. Install the AWS S3 upload provider for Strapi:
  2. npm install strapi-provider-upload-aws-s3
  3. Modify the config/plugins.js file in the Strapi project:


module.exports = ({ env }) => ({

  upload: {

    provider: ‘aws-s3’,

    providerOptions: {

      accessKeyId: env(‘AWS_ACCESS_KEY_ID’),

      secretAccessKey: env(‘AWS_SECRET_ACCESS_KEY’),

      region: env(‘AWS_REGION’),

      params: {

        Bucket: env(‘AWS_BUCKET_NAME’),

      },

    },

  },

});

  1. Add the corresponding environment variables to .env:


AWS_ACCESS_KEY_ID=your-access-key

AWS_SECRET_ACCESS_KEY=your-secret-key

AWS_REGION=your-region

  1. AWS_BUCKET_NAME=your-bucket-name
  2. Restart Strapi to apply the changes.

Step 4: Upload Media to AWS S3

  1. Write a script or use the AWS CLI to upload exported Cloudinary files:
  2. aws s3 cp /local/path s3://your-bucket-name –recursive
  3. Verify that the files appear in the S3 bucket.
  4. Update existing database records in Strapi to reflect new S3 URLs.

Step 5: Test and Validate Migration

  1. Open the Strapi Admin Panel and confirm media files load correctly.
  2. Check AWS S3 to ensure the uploaded files are accessible.
  3. Test integrations with front-end applications or CMS to confirm the successful migration.

Conclusion

Migrating media from Cloudinary to AWS S3 using Strapi is a straightforward process that enhances cost efficiency and storage control. By following these steps, developers can ensure a smooth transition while maintaining high performance and scalability for media assets.