Problem
I have a Lambda function in Account 1, which retrieves EC2 instance status.
Similarly, I want to retrieve EC2 instance status in other 4 accounts.
What I did
I Created trust relationship with the other 4 account by updating the IAM role.
Question:
Will my python code (residing in my lambda function in account 1) is enough to retrieve ec2 instance status from the other 4 accounts? or should I do something more ?
Please suggest!
Thanks in advance.
Each AWS Account is separate. You cannot access details of one AWS Account from another AWS Account. However, you can temporarily assume an IAM Role from another account to gain access.
Instead, you will need to:

Create an IAM Role for the central Lambda function (Lambda-Role) and grant it permission to call AssumeRole
Create an IAM Role in each account that you wish to access, grant it permission to call DescribeInstances and configure it to trust Lambda-Role
The Lambda function can then loop through each account and:


Call AssumeRole for that account, which will return temporary credentials
Use those credentials to call DescribeInstances
Is my python code enough to retrieve ec2 instance status from other accounts?