Skip to content

Amplify : CredentialProvider Error , with correct policies attached

0

In my next.js amplify app, there is a valid policy attached to the Service role.

The role has policy , which has acccess to S3 Read and write.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "DocuFlowSID",
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:DeleteObject"
            ],
            "Resource": "arn:aws:s3:::<bucketname>/*"
        }
    ]
}

Even with that, when , I try to put an object on S3, I get ,Could not load credentials from any providers Error [CredentialsProviderError]: Could not load credentials from any providers

2 Answers
4

Please try on AWS.config.credentials under Amplify configuration, also check for session expiry

EXPERT

answered a year ago

0

Hey,

Hope you're keeping well.

That error means the app isn’t actually receiving any AWS credentials, regardless of the IAM policy. In Amplify, S3 calls from a Next.js frontend require an authenticated user via Amplify Auth (Cognito) or an explicitly configured IAM role when running server-side. Check that Amplify.configure includes your Auth settings and that AWS.config.credentials is being populated before the S3 call. Also verify your policy’s resource is correct — it should be arn:aws:s3:::your-bucket-name/* instead of arn:aws:s3:::/* — and that the role is assumed by the identity making the request. Without valid, non-expired temporary credentials, the SDK will always throw a CredentialsProviderError.

Thanks and regards,
Taz

answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.