简体   繁体   中英

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM