bluethundr
bluethundr

Reputation: 1345

Loop through AWS Accounts in Lambda Python Function

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?

Upvotes: 0

Views: 475

Answers (2)

fmcmac
fmcmac

Reputation: 138

  1. Create a role with cross account permissions for ec2:ListInstances
  2. Attach the role to the lambda function

Upvotes: 0

Vladyslav Didenko
Vladyslav Didenko

Reputation: 1641

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

Upvotes: 0

Related Questions