Chapter 7. Configure Red Hat OpenShift Service on AWS account roles with an AWS STS external ID
You can configure Red Hat OpenShift Service on AWS on Amazon Web Services (AWS) account roles with an AWS Security Token Service (STS) external ID. The external ID is an optional, unique identifier that you add to the trust policies of your Installer and Support account roles. When configured, AWS Identity and Access Management (IAM) requires the external ID to match before allowing Red Hat OpenShift Cluster Manager to assume those roles.
Without an external ID, the trust policies on your Installer and Support roles rely on the principal Amazon Resource Name (ARN) to authorize access. By adding an external ID, you create a shared secret between you and OpenShift Cluster Manager that proves each role assumption request is legitimately for your account, providing a second layer of verification beyond the principal ARN alone.
The external ID is complementary to the ocm-role, which links your AWS account to your Red Hat organization. While the OpenShift Cluster Manager role establishes who can manage your cluster, the external ID on the Installer and Support roles verifies that each individual role assumption request is scoped specifically to your account.
Because the external ID is optional, clusters without one are fully functional. However, their trust policies only provide principal-based authorization without the additional verification that an external ID offers. If you choose to use an external ID, you can only set it at cluster creation. You cannot add an external ID to existing clusters, and external IDs are not automatically generated. You must provide your own unique identifier string that meets the AWS requirements.
You must create the ocm-role IAM role before you can create your Red Hat OpenShift Service on AWS cluster.
7.1. Create account roles with an external ID Copy linkLink copied to clipboard!
Configure Red Hat OpenShift Service on AWS account roles with an external ID to ensure that Red Hat OpenShift Cluster Manager assumes your account-wide IAM roles only when the unique identifier matches your Amazon Web Services (AWS) trust policy configuration.
Prerequisites
-
You installed version 1.2.65 or higher of the Red Hat OpenShift Service on AWS CLI (
rosa). -
You are logged in to your Red Hat account by running the
rosa logincommand. - Your AWS CLI credentials are configured with permissions to create IAM roles and policies.
Procedure
Ensure that your external ID string meets the AWS requirements.
NoteExternal IDs are not automatically generated by the CLI.
Generate your account-wide roles and policies with your unique external ID by running the following command:
$ rosa create account-roles --mode auto --external-id "my-secure-unique-id-123" --yesOptional: If you prefer to review the JSON policy documents before applying them to AWS, run the command in manual mode instead:
$ rosa create account-roles --mode manual --external-id "my-secure-unique-id-123"Review the STS JSON trust policy files that you generated. Create a role and attach a policy for each of the following role and policy pairs:
-
sts_installer_trust_policy.jsonfor theInstallerrole -
sts_support_trust_policy.jsonfor theSupportrole -
sts_worker_trust_policy.jsonfor the worker node instance role. This role does not include an external ID because it is only assumed within the account of the cluster.
-
For each role, create the account role by running the
aws iam create-rolecommand provided to you. For example, to create theSupportrole:$ aws iam create-role \ --assume-role-policy-document file://sts_support_trust_policy.json \ --role-name ManagedOpenShift-HCP-ROSA-Support-Role \ --tags Key=red-hat-managed,Value=true Key=rosa_hcp_policies,Value=true Key=rosa_role_type,Value=support Key=rosa_managed_policies,Value=true Key=rosa_openshift_version,Value=4.22 Key=rosa_role_prefix,Value=ManagedOpenShiftFor each role, attach the role policy by running the
aws iam attach-role-policycommand provided to you. For example, to attach theSupportrole policy:$ aws iam attach-role-policy \ --policy-arn arn:aws:iam::aws:policy/service-role/ROSASRESupportPolicy \ --role-name ManagedOpenShift-HCP-ROSA-Support-Role- Continue to attach policies to the remaining roles by running these same commands.
Create the Red Hat OpenShift Service on AWS cluster by using the interactive mode or the flags for automation. Choose one of the following methods:
For the interactive mode, run the following command:
$ rosa create cluster --interactive- Answer the questions that the CLI gives you.
Select the Amazon Resource Name (ARN) of the account roles that have the external ID defined in their trust policies, for example:
arn:aws:iam::<aws_account_id>:role/externalid-HCP-ROSA-Installer-Role
For the automation flags, if you have more than one external ID in a single trust policy, then you must manually set the external ID flag. Run the following command:
$ rosa create cluster --cluster-name my-rosa-cluster \ --sts \ --mode auto \ --external-id "my-secure-unique-id-123" \ --yes --hosted-cpNote-
Setting the
--external-idfield is optional unless you have more than one external ID in a single trust policy. -
If you pass the
--external-idflag during cluster creation, the CLI validates that the specified value exists across yourInstallerandSupportrole policies.
-
Setting the
Verification
Verify that the external ID is applied to your cluster specification by querying the cluster description:
$ rosa describe cluster --cluster my-rosa-clusterIn the output metadata, confirm that the External ID field reflects your custom identifier:
Name: my-rosa-cluster ID: 1abc2def3ghi4jklmnopqstuv External ID: my-secure-unique-id-123 Control Plane: Customer Hosted (HCP) ...
7.2. Troubleshoot Red Hat OpenShift Service on AWS account roles with an AWS STS external ID Copy linkLink copied to clipboard!
If the Installer and Support roles contain mismatched external IDs, you can delete and re-create the account roles with a consistent external ID to resolve cluster creation failures.
Procedure
Delete the existing account roles by running the following command. Replace
ManagedOpenShiftwith your custom prefix if you used a custom prefix:ImportantDeleting account roles affects all clusters that use those roles. Before proceeding, ensure that no other clusters depend on these account roles.
$ rosa delete account-roles -p ManagedOpenShift --mode auto --yesWhen you get confirmation that you successfully deleted the account roles, re-create account roles with your external ID by running the following command:
$ rosa create account-roles --mode auto --external-id "my-secure-unique-id-123" --yes- Continue with your cluster creation process.
Verification
Verify that the re-created account roles contain the correct external ID by running the following command for each role:
$ aws iam get-role --role-name ManagedOpenShift-HCP-ROSA-Installer-Role --query 'Role.AssumeRolePolicyDocument'-
In the output, confirm that the
sts:ExternalIdvalue matches your external ID string.