AccessDeniedException for calling DynamoDB for backend

Hi Netlify Team,

This is for the app: dainty-cucurucho-50b7c0

I am trying to access a DynamoDB table that I created with my AWS account from my Next JS backend hosted on Netlify. However, I’m getting:

May 14, 10:55:15 PM: 069f5bf7 ERROR  AccessDeniedException: User: arn:aws:sts::xxxxxxx:assumed-role/aws-lambda-execute/xxxxx is not authorized to perform: dynamodb:GetItem on resource: arn:aws:dynamodb:us-west-1:xxxx:table/xxxx because no identity-based policy allows the dynamodb:GetItem action

I have added my AWS credentials via environment variables. Note that I modified these from there original names due to conflict with Netlify’s reserved environment variable names. So I’m using:

BRAYNIAC_AWS_ACCESS_KEY_ID=xxxxx
BRAYNIAC_AWS_SECRET_ACCESS_KEY=xxxx
BRAYNIAC_AWS_REGION=xxxxx

And set up my DynamoDB client with these

const client = new DynamoDBClient({
  accessKeyId: process.env.BRAYNIAC_AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.BRAYNIAC_AWS_SECRET_ACCESS_KEY,
  region: process.env.BRAYNIAC_AWS_REGION,
});

I’ve also console logged the client and can verify it is using the provided access keys. From my understanding providing the credentials as I did should be enough to access a DynamoDB. Also since I don’t have access to the netlify-handler’s IAM policies I don’t see how I would attach any policies to allow access to this DB as a resource.

Could you help me resolve this please.

Thank you,
Lars

Hi @BrayniacLars,

I believe this is due to your DynamoDB being in us-west region and Netlify Functions being in us-east. On pro and above plans we can change regions, but if that’s not an option, you might have to change your Dynamo DB region.