Chapter 2. Tutorial: Verify permissions for a Red Hat OpenShift Service on AWS classic architecture STS deployment
Before deploying a Red Hat OpenShift Service on AWS classic architecture cluster, verify that your AWS account has the required roles and permissions. AWS Service Control Policies (SCPs) cannot block the API calls made by the installer or Operator roles.
For more information about the IAM resources required for an STS-enabled installation of Red Hat OpenShift Service on AWS classic architecture, see "About IAM resources for STS clusters" in Additional resources.
This guide is validated for Red Hat OpenShift Service on AWS classic architecture v4.11.X.
2.1. Permission verification for STS deployments Copy linkLink copied to clipboard!
You can verify the permissions required for Red Hat OpenShift Service on AWS classic architecture by running a script without creating any AWS resources.
The script uses the rosa, aws, and jq CLI commands to create files in the working directory that are used to verify permissions in the account connected to the current AWS configuration.
The AWS Policy Simulator is used to verify the permissions of each role policy against the API calls extracted by jq; results are then stored in a text file appended with .results.
This script is designed to verify the permissions for the current account and region.
2.2. Verify your AWS account permissions Copy linkLink copied to clipboard!
Run the permissions verification script to check whether your AWS account has the required permissions for a Red Hat OpenShift Service on AWS classic architecture STS deployment. The script verifies the permissions for the current account and region.
Prerequisites
- The AWS CLI is installed.
-
The ROSA command-line interface (CLI) (
rosa) v1.2.6 or later is installed. - The jq CLI tool is installed.
- You have an AWS role with the required permissions.
Procedure
To use the script, run the following commands in a
bashterminal (the-p`option defines a prefix for the roles):$ mkdir scratch $ cd scratch $ cat << 'EOF' > verify-permissions.sh #!/bin/bash while getopts 'p:' OPTION; do case "$OPTION" in p) PREFIX="$OPTARG" ;; ?) echo "script usage: $(basename \$0) [-p PREFIX]" >&2 exit 1 ;; esac done shift "$(($OPTIND -1))" rosa create account-roles --mode manual --prefix $PREFIX INSTALLER_POLICY=$(cat sts_installer_permission_policy.json | jq ) CONTROL_PLANE_POLICY=$(cat sts_instance_controlplane_permission_policy.json | jq) WORKER_POLICY=$(cat sts_instance_worker_permission_policy.json | jq) SUPPORT_POLICY=$(cat sts_support_permission_policy.json | jq) simulatePolicy () { outputFile="${2}.results" echo $2 aws iam simulate-custom-policy --policy-input-list "$1" --action-names $(jq '.Statement | map(select(.Effect == "Allow"))[].Action | if type == "string" then . else .[] end' "$2" -r) --output text > $outputFile } simulatePolicy "$INSTALLER_POLICY" "sts_installer_permission_policy.json" simulatePolicy "$CONTROL_PLANE_POLICY" "sts_instance_controlplane_permission_policy.json" simulatePolicy "$WORKER_POLICY" "sts_instance_worker_permission_policy.json" simulatePolicy "$SUPPORT_POLICY" "sts_support_permission_policy.json" EOF $ chmod +x verify-permissions.sh $ ./verify-permissions.sh -p SimPolTestAfter the script completes, review each results file to ensure that none of the required API calls are blocked:
$ for file in $(ls *.results); do echo $file; cat $file; doneExample output
sts_installer_permission_policy.json.results EVALUATIONRESULTS autoscaling:DescribeAutoScalingGroups allowed * MATCHEDSTATEMENTS PolicyInputList.1 IAM Policy ENDPOSITION 6 195 STARTPOSITION 17 3 EVALUATIONRESULTS ec2:AllocateAddress allowed * MATCHEDSTATEMENTS PolicyInputList.1 IAM Policy ENDPOSITION 6 195 STARTPOSITION 17 3 EVALUATIONRESULTS ec2:AssociateAddress allowed * MATCHEDSTATEMENTS PolicyInputList.1 IAM Policy ...NoteIf any actions are blocked, review the error provided by AWS and consult with your administrator to determine if SCPs are blocking the required API calls.