AWS CLI profiles

One of the easiest ways to use a cross-account role, is to configure it as a profile for the AWS CLI tool to use. This means that you can quickly and easily switch accounts, just by changing the profile you use when executing your commands.

To do this, you must define the target role in the CLI configuration file. With this configuration, it is assumed that your default profile is in the source account (that is, account A).

Add the following snippet to the ~/.aws/config file on Linux and macOS computers, and to the C:Users[USERNAME].awsconfig file on Windows:

[profile accountb] 
role_arn = <your-target-account-role-arn>
source_profile = default

To use switch roles, all you need to do is pass the --profile argument along with your command:

      aws --profile accountb ...
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset