zoomoid / strapi-provider-upload-aws-s3-advanced

A partial fork of https://github.com/strapi/strapi to extend the S3 Upload Provider to support path prefixes inside a bucket
MIT License
27 stars 23 forks source link

support for other types of credentials for S3 client #29

Closed dejwsz closed 1 year ago

dejwsz commented 1 year ago

Is your feature request related to a problem? Please describe. In this version we can see fixed credentials config using key id and secret. AWS SDK for JS supports much more options for credentials.

Describe the solution you'd like An option to override credentials using different providers from @aws-sdk/credential-providers like fromTokenFile, fromIni, fromEnv etc.

Describe alternatives you've considered Provide dummy values for key id and secret and set default AWS env variables what I guess should also work in exchange as AWS SDK for JS detects them automatically? I will try to check it

dejwsz commented 1 year ago

I checked and it gets and uses standard AWS environment variables well so I was able to use web identity token file provider instead.

dejwsz commented 1 year ago

it worked well for me in EKS using such entry in config/plugins.js in strapi:

      const { fromTokenFile } = require("@aws-sdk/credential-providers");
      upload: {
        config: {
          provider: 'strapi-provider-upload-aws-s3-advanced',
          providerOptions: {
            credentials: fromTokenFile(),
            region: process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION,
            baseUrl: process.env.AWS_CDN_URL,
            params: {
              Bucket: process.env.AWS_S3_BUCKET,
            },
          },
        },
      },

and strapi dependencies should be updated with:

    "@aws-sdk/credential-providers": "^3.43.0",
    "@aws-sdk/client-s3": "^3.43.0",