Creating an IAM Role for Service Account
You will create an IAM policy that specifies the permissions that you would like the containers in your pods to have.
In this workshop we will use the AWS managed policy named “AmazonS3ReadOnlyAccess” which allow get
and list
for all your S3 buckets.
Let’s start by finding the ARN for the “AmazonS3ReadOnlyAccess” policy
aws iam list-policies --query 'Policies[?PolicyName==`AmazonS3ReadOnlyAccess`].Arn'
Now you will create a IAM role bound to a service account with read-only access to S3
eksctl create iamserviceaccount \
--name iam-test \
--namespace default \
--cluster eksworkshop-eksctl \
--attach-policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess \
--approve \
--override-existing-serviceaccounts
If you go to the CloudFormation in IAM Console, you will find that the stack “eksctl-eksworkshop-eksctl-addon-iamserviceaccount-default-iam-test” has created a role for your service account.