Last active
March 12, 2019 12:17
-
-
Save innovia/6641a9505e9258d075d644d785d00499 to your computer and use it in GitHub Desktop.
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
# Set these names before you start. | |
CLUSTER_NAME={{cluster name}} | |
GROUP={{group name}} | |
# Get your account ID | |
ACCOUNT_ID=$(aws sts get-caller-identity --output text --query 'Account') | |
# Build a role name | |
ROLE_NAME="Kubernetes${CLUSTER_NAME}${GROUP_NAME}Group | |
# Define a role trust policy that opens the role to users in your account (limited by IAM policy) | |
POLICY=$(echo -n '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":"arn:aws:iam::'; echo -n "$ACCOUNT_ID"; echo -n ':root"},"Action":"sts:AssumeRole","Condition":{}}]}') | |
# Create a role named KubernetesAdmin (will print the new role's ARN) | |
aws iam create-role \ | |
--role-name $ROLE_NAME \ | |
--description "Kubernetes ${GROUP} role (for Heptio Authenticator for AWS)." \ | |
--assume-role-policy-document "$POLICY" \ | |
--output text \ | |
--query 'Role.Arn' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Handy. After running this, to apply for EKS, see https://docs.aws.amazon.com/eks/latest/userguide/add-user-role.html