AWS Cross-Account Role for EC2 Instances - Configuration Guide

Using the EC2Update Cross-Account Role for AWS Instance Management

Prev Question Next Question

Question

You are an AWS administrator.

Your company has two key EC2 instances owned by AWS account A.

The users in AWS account B may start/stop these EC2 instances from time to time.

These users are under the same IAM user group called “Group_QA”

You already created a cross-account role “EC2Update” in account A.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer- B and C.

You can grant your IAM users permission to switch to roles within your AWS account or to roles defined in other AWS accounts that you own.

The user chooses the account name on the navigation bar and chooses Switch Role.

The user specifies the account ID (or alias) and role name.

Alternatively, the user can click on a link sent in an email by the administrator.

The link takes the user to the Switch Role page with the details already filled in.

Option A is incorrect because, for AWS API/AWS CLI, the user in the group “Group_QA” should call the AssumeRole function to obtain credentials for the “EC2Update” role.

Option D is incorrect because it should be “Switch Role” rather than “Switch Accounts,” and no key credentials are needed for switching rules to another account.

References:

https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_aws-accounts.html

As an AWS administrator, your company has two EC2 instances owned by AWS account A that need to be accessed by users in AWS account B who belong to the "Group_QA" IAM user group. You have already created a cross-account role "EC2Update" in account A to grant the required permissions to these users.

To allow users in account B to start/stop the EC2 instances in account A, they need to assume the "EC2Update" role. There are several ways to do this, and the correct answer depends on the specific requirements of your organization.

Let's go through each answer option in detail:

A. With AWS CLI, the user calls the AssumeRoleWithSAML function to obtain credentials for the “EC2Update” role.

This option requires users to have the AWS Command Line Interface (CLI) installed and configured on their local machine. Users must also be familiar with the CLI and the AssumeRoleWithSAML function, which is used to obtain temporary credentials to assume the "EC2Update" role.

Assuming the "EC2Update" role with the CLI involves executing a command similar to the following:

ruby
aws sts assume-role-with-saml --role-arn arn:aws:iam::ACCOUNT-A-ID:role/EC2Update --principal-arn arn:aws:iam::ACCOUNT-B-ID:saml-provider/EXAMPLE-IDP --saml-assertion base64-encoded-SAML-assertion

This command requires the user to provide the ARN of the "EC2Update" role, the ARN of the SAML provider in account B, and a base64-encoded SAML assertion obtained from the SAML provider. Once the command is executed, the CLI returns a set of temporary credentials that can be used to access the resources in account A.

B. The user chooses the account name on the navigation bar and clicks “Switch Role”. The user specifies the account ID (or alias) and role name.

This option requires users to have access to the AWS Management Console and to be familiar with the Switch Role feature. To assume the "EC2Update" role, users must click on the account name on the navigation bar and choose "Switch Role". They must then specify the account ID (or alias) of account A, the name of the "EC2Update" role, and optionally a display name for the role. Once the user clicks "Switch Role", they are granted access to the resources in account A.

C. The user can click on a link sent in an email by the administrator which takes the user to the Switch Role page with the details already filled in. The link can be found when the role “EC2Update” was created.

This option involves sending a link to the users in account B that takes them directly to the Switch Role page with the necessary details already filled in. This can be done by copying the link provided by AWS when the "EC2Update" role was created and sending it to the users via email or another communication channel. This option requires users to have access to the AWS Management Console and to be familiar with the Switch Role feature.

D. In the AWS console, the user clicks its account name and chooses “Switch Accounts”. The user then specifies the account ID, key credentials, and the role name for account A.

This option requires users to have multiple AWS accounts and to switch between them using the Switch Accounts feature. To assume the "EC2Update" role in account A, users must click on their account name in the AWS Management Console and choose "Switch Accounts". They must then specify the account ID of account A, their access key ID and secret access key, and the name of the "EC2Update" role. Once the user clicks "Sign In