I have a python script that loops through all of the AWS accounts we have and lists the EC2 instances in each one. 
I want to turn it into an AWS Lambda function. But I can't figure out how to pull the AWS credentials that would allow me to list the servers in all the accounts.
How can I achieve this in AWS Lambda?
When you create lambda you have so specify a role
In IAM you can attach required permission to a lambda role. 
If you want to use some specific set of credentials in a file, you can utilize AWS Systems Manager to retrieve credentials. 
Though, I would recommend role on lambda
Loop through AWS Accounts in Lambda Python Function