[Recipes] How to switch between 2 accounts in AWS

Problem: 

How to switch between 2 accounts in AWS

Solution Summary: 

  1. Create a role with necessary permissions in Account B.
  2. Grant access to the user groups in Account A to assume that role from Account B providing the complete role ARN.
  3. Sign in as a user from the testusergroup into Account A and switch role to Account B.

Prerequisites: 

You should have two different AWS Accounts

 

Solution Steps: 

We will be giving access to the S3 bucket of Account B to Account A.

  1. Create a role with necessary permissions in Account B.
    1. Create a Policy 'Account_B_Policy' with access to the S3 buckets of the account
    2. Create a Role 'Account_B_Role' by selecting the trusted entity as another AWS account. Provide the account id of Account A while selecting the trusted entity
    3. Assign the policy 'Account_B_Policy' to 'Account_B_Role'.
  2. Grant access to the user groups in Account A to assume that role from Account B providing the complete role ARN.
    1. Create a policy 'Account_A_Policy' with permission as STS:AssumeRole and provide the ARN of 'Account_B_Role'.
    2. Create a group 'Account_A_Group' and assign the 'Account_A_policy' to this group
    3. Assign 'Account_A_Group' to 'testuser'.
  3. Sign in as a user from the testusergroup(Account_A_Group) into Account A and switch role to Account B.
    1. Login as 'testuser' to Account A.
    2. On the top upper right side , there will be a dropdown along with the logged in username where you can find the 'Switch Role' option
    3.  Click 'Switch Role', provide the account id and Role name and click 'Switch Role'
    4. You will be redirected to the other AWS account where you can perform allowed actions
    5. You will have the option to switch back to the curren test user account

Recipe Tags: 

Learn Serverless from Serverless Programming Cookbook

Contact

Please first use the contact form or facebook page messaging to connect.

Offline Contact
We currently connect locally for discussions and sessions at Bangalore, India. Please follow us on our facebook page for details.
WhatsApp (Primary): (+91) 7411174113
Phone (Escalations): (+91) 7411174114

Business newsletter

Complete the form below, and we'll send you an e-mail every now and again with all the latest news.

About

CloudMaterials is my blog to share notes and learning materials on Cloud and Data Analytics. My current focus is on Microsoft Azure and Amazon Web Services (AWS).

I like to write and I try to document what I learn to share with others. I believe that knowledge is useless unless you share it; the more you share, the more you learn.

Recent comments

Photo Stream