Where do AWS lamba's load credentials from?

Viewed 119

I am writing an AWS Lamda in C# using this example:

https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/lambda-creating-project-in-visual-studio.html

I have set my credentials in the environmental variables according to this document:

https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html

But when I try to upload my lamda I get errors about not having the correct IAM roles. However, the account name in the error message is not the same as the account I put into the credentials in the environmental variables. It relates to an account on a different S3 bucket which I was testing with little while ago.

Where is it reading this from?

1 Answers

I have set my credentials in the environmental variables according to this document

This is not a good practice. The lambda permissions should be provided using lambda execution role. Once you set the role, AWS SDK will automatically get the temporary credentials from your function's runtime environment variables.

Since it seems that you need a cross-account access in your function, then you have to use cross-account roles as explained in AWS docs:

Related