// Module included in the following assemblies:
//
// * rosa_planning/rosa-sts-ocm-role.adoc
// * rosa_planning/rosa-sts-aws-prereqs.adoc
// * support/troubleshooting/rosa-troubleshooting-iam-resources.adoc
:_mod-docs-content-type: PROCEDURE
[id="rosa-associating-account_{context}"]
= Associating your AWS account with IAM roles

[role="_abstract"]
You can associate or link your AWS account with existing IAM roles by using the {rosa-cli-first}.

.Prerequisites

* You have an AWS account.
* You have the permissions required to install AWS account-wide roles. See the "Additional resources" of this section for more information.
* You have installed and configured the latest AWS CLI (`aws`) and {rosa-cli} on your installation host.
* You have created the `ocm-role` and `user-role` IAM roles, but have not yet linked them to your AWS account. You can check whether your IAM roles are already linked by running the following commands:
+
[source,terminal]
----
$ rosa list ocm-role
----
+
[source,terminal]
----
$ rosa list user-role
----
+
If `Yes` is displayed in the `Linked` column for both roles, you have already linked the roles to an AWS account.

.Procedure

. In the ROSA CLI, link your `ocm-role` resource to your Red{nbsp}Hat organization by using your Amazon Resource Name (ARN):
+
[NOTE]
====
You must have Red{nbsp}Hat Organization Administrator privileges to run the `rosa link` command. After you link the `ocm-role` resource with your AWS account, it takes effect and is visible to all users in the organization.
====
+
[source,terminal]
----
$ rosa link ocm-role --role-arn <arn>
----
+
For example:
+
[source,terminal]
----
I: Linking OCM role
? Link the '<AWS ACCOUNT ID>` role with organization '<ORG ID>'? Yes
I: Successfully linked role-arn '<AWS ACCOUNT ID>' with organization account '<ORG ID>'
----
. In the ROSA CLI, link your `user-role` resource to your Red{nbsp}Hat user account by using your Amazon Resource Name (ARN):
+
[source,terminal]
----
$ rosa link user-role --role-arn <arn>
----
+
For example:
+
[source,terminal]
----
I: Linking User role
? Link the 'arn:aws:iam::<ARN>:role/ManagedOpenShift-User-Role-125' role with organization '<AWS ID>'? Yes
I: Successfully linked role-arn 'arn:aws:iam::<ARN>:role/ManagedOpenShift-User-Role-125' with organization account '<AWS ID>'
----
