Created
May 6, 2023 18:38
-
-
Save darkn3rd/b9ec9c63382feb7f5b3c3b0151e3ad89 to your computer and use it in GitHub Desktop.
Get Inline Policy Attached to Node IAM Role
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EKS_CLUSTER_NAME=${EKS_CLUSTER_NAME:-"my-cluster"} | |
NODE_GROUP=$(aws eks list-nodegroups \ | |
--cluster-name $EKS_CLUSTER_NAME \ | |
| jq -r '.nodegroups[0]' | |
) | |
ROLE_ARN=$(aws eks describe-nodegroup \ | |
--cluster-name $EKS_CLUSTER_NAME \ | |
--nodegroup-name $NODE_GROUP \ | |
| jq -r '.nodegroup.nodeRole' | |
) | |
ROLE_NAME=$(cut -d/ -f2 <<< $ROLE_ARN) | |
POLICY_NAME=$(aws iam list-role-policies \ | |
--role-name $ROLE_NAME \ | |
| jq -r '.PolicyNames[]' \ | |
| grep EBS | |
) | |
# print the policy | |
aws iam get-role-policy \ | |
--role-name $ROLE_NAME \ | |
--policy-name $POLICY_NAME | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment