Can not upload file to s3 when I use strapi/provider-upload-aws-s3 plugin on production mode

I have installed the ‘strapi/provider-upload-aws-s3’ provider plugin in Strapi to upload files to my S3 bucket. Locally, I am able to upload files successfully, and they are stored in the bucket on S3. However, when I deploy Strapi to the cloud, it seems that the plugin is not working. The files are not being saved to S3. What could be causing this issue and how can I resolve it?
middleware.ts file:

export default [
  'strapi::errors',
   {
    name: 'strapi::security',
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          'script-src': ["'self'", "'unsafe-inline'", 'cdn.jsdelivr.net', "dl.airtable.com", "https://market-assets.strapi.io", '*.s3.ap-southeast-1.amazonaws.com'],
          'img-src': ["'self'", 'data:', 'cdn.jsdelivr.net', 'strapi.io', "dl.airtable.com", "https://market-assets.strapi.io", 'https://*.s3.ap-southeast-1.amazonaws.com'],
        },
        upgradeInsecureRequests: null,
      }
    },
  },
  'strapi::cors',
  'strapi::poweredBy',
  'strapi::logger',
  'strapi::query',
  'strapi::body',
  'strapi::session',
  'strapi::favicon',
  'strapi::public',
];

plugins.ts file::

    'import-export-entries': {
      enabled: true,
    },
    upload: {
        config: {
          provider: 'aws-s3',
          providerOptions: {
            accessKeyId: env('AWS_ACCESS_KEY_ID'),
            secretAccessKey: env('AWS_ACCESS_SECRET'),
            region: env('AWS_REGION'),
            params: {
              Bucket: env('AWS_BUCKET'),
            },
          },
          actionOptions: {
            upload: {},
            uploadStream: {},
            delete: {},
          },
        },
      },
      graphql: {
        config: {
          endpoint: '/graphql',
          shadowCRUD: true,
          playgroundAlways: true,
          depthLimit: 7,
          amountLimit: 100,
          apolloServer: {
            tracing: false,
          },
        },
      },
  });
System Information
  • Strapi Version: v4.10.7
  • Operating System: MacOS
  • Database: PostgreSQL (built in)
  • Node Version: 16.20.0
  • NPM Version: 8.19.4
  • Yarn Version: 1.22.19
  • strapi/provider-upload-aws-s3 Version: 4.11.0

Exact same problem here. Did you ever resolve it?

The issue was resolved by moving the plugins.ts file to the config/env/production directory