-
-
Save RafPe/6c03ed500a1267d8b296b79f3d0fa1f4 to your computer and use it in GitHub Desktop.
Create AWS console user from the awscli
This file contains hidden or 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
#!/bin/bash | |
# USAGE: ./create-aws-console-user.sh $GROUPNAME $USERNAME $PASSWORD | |
# http://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html#id_users_create_cliwpsapi | |
# Create administrator group | |
aws iam create-group --group-name $1 | |
aws iam attach-group-policy --group-name $1 --policy-arn 'arn:aws:iam::aws:policy/AdministratorAccess' | |
# Create user and attach to AdministratorAccess policy | |
aws iam create-user --user-name $2 | |
aws iam create-login-profile --user-name $2 --password $3 | |
aws iam add-user-to-group --group-name $1 --user-name $2 | |
aws iam attach-user-policy --user-name $2 --policy-arn 'arn:aws:iam::aws:policy/AdministratorAccess' | |
# Grab account ID | |
ID=$(aws iam list-users --out text | head -1 | cut -f2 | awk -F'::' '{print $2}' | cut -f1 -d:) | |
echo | |
echo SIGNIN URL: | |
echo "https://$ID.signin.aws.amazon.com/console/" |
This file contains hidden or 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
#!/bin/bash | |
# USAGE: ./delete-console-user.sh $GROUPNAME $USERNAME | |
aws iam delete-login-profile --user-name $2 | |
aws iam detach-user-policy --user-name $2 --policy-arn 'arn:aws:iam::aws:policy/AdministratorAccess' | |
aws iam remove-user-from-group --user-name $2 --group-name $1 | |
aws iam delete-user --user-name $2 | |
aws iam detach-group-policy --group-name $1 --policy-arn 'arn:aws:iam::aws:policy/AdministratorAccess' | |
aws iam delete-group --group-name $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment