Skip to content

Instantly share code, notes, and snippets.

@darkn3rd
Created May 6, 2023 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darkn3rd/b9ec9c63382feb7f5b3c3b0151e3ad89 to your computer and use it in GitHub Desktop.
Save darkn3rd/b9ec9c63382feb7f5b3c3b0151e3ad89 to your computer and use it in GitHub Desktop.
Get Inline Policy Attached to Node IAM Role
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