Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To switch from one AWS Organizations account to another using aws-cli, follow the steps below:

  1. Open a terminal window and ensure the AWS CLI is installed and configured correctly.

  2. Use the following command to switch to the new account:

aws organizations create-standby | jq '.AcountId'
  1. Take note of the AccountId that is returned from the previous command.

  2. Use the following command to assume the new account role:

aws sts assume-role --role-arn arn:aws:iam::<new-account-id>:role/<role-name> --role-session-name awstest
  1. Replace the <new-account-id> and <role-name> placeholders in the previous command with the actual new account and role names.

  2. After running the previous command, a set of temporary credentials will be outputted. Copy and paste these credentials somewhere safe, as they will be required to perform any operations in the new account.

  3. Use the temporary credentials to execute commands in the new account using the AWS CLI.