Created
October 1, 2016 04:08
-
-
Save SkaTeMasTer/c2ebfa8cd0f0a1ee38107a9a1ff0b450 to your computer and use it in GitHub Desktop.
Create a user user IAM
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
# 1. Creates an IAM user account in AWS | |
# 2. Randomly generates a password for the account using apg | |
# 3. Adds the user to the Administrators group | |
# 4. Creates a login profile for the user (set password and set flag to force user to reset password upon initial logon) | |
#!/bin/bash | |
if [ $# -eq 0 ]; then | |
echo "Usage: $0 <username>" | |
exit 1 | |
fi | |
USERNAME=$1 | |
#Generate random password | |
PASSWD=$(apg -n 1 -m 12 -x 12 -M SNCL -c cl_seed -a 1) | |
aws iam create-user --user-name $USERNAME | |
aws iam add-user-to-group --group-name Administrators --user-name $USERNAME | |
aws iam create-login-profile --user-name $USERNAME --password $PASSWD --password-reset-required | |
echo Password: $PASSWD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment