Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Cloud Storage Plugin - Could not load credentials from any providers

default discord avatar
snackdexlast year

Hello,


I was able to get this working locally on a docker container by passing my own credentials like so:


const configCredentials =
  process.env.NODE_ENV === "development"
    ? {
        credentials: {
          accessKeyId: process.env.S3_ACCESS_KEY_ID,
          secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
        },
      }
    : {};
const adapter = s3Adapter({
  config: {
    ...configCredentials,
    region: process.env.S3_REGION,
  },
  bucket: process.env.S3_BUCKET,
});

In the docs it says, "Note that the credentials option does not have to be used when you are using PayloadCMS on an EC2 instance that has been configured with an IAM Role with necessary permissions." -

https://github.com/payloadcms/plugin-cloud-storage#s3-adapter

The difference is that I am running this on ECS and was wondering if there was something else that I have to do. I did create a policy with

["s3:GetObject", "s3:PutObject"]

and attached it to the ecs task definition

execution_role_arn

.



Any help would be appreciated



I made a very noob oversight when looking over my code. The issue was caused because i was setting the permissions on the execution role instead of the task role.



In summary:



The Task Role is for giving permissions to the containers within the task itself to interact with other AWS services.


The Task Execution Role is for the ECS service to manage tasks, including pulling Docker images and performing ECS-specific operations.



everything works as expected 🙂

    Star on GitHub

    Star

    Chat on Discord

    Discord

    online

    Can't find what you're looking for?

    Get dedicated engineering support directly from the Payload team.