Skip to content

Instantly share code, notes, and snippets.

@namuan
Created July 15, 2018 10:31
Show Gist options
  • Save namuan/6e744de6fb4a48577c5874da0228f8ce to your computer and use it in GitHub Desktop.
Save namuan/6e744de6fb4a48577c5874da0228f8ce to your computer and use it in GitHub Desktop.
Rotate AWS access keys
AWSUSERNAME=<aws-user>
AWSPROFILE=<aws-profile>
# Get all the access keys currently used. We'll keep note of the one we are trying to rotate
aws iam list-access-keys --user-name $AWSUSERNAME
# Create a new access key
aws iam create-access-key --user-name $AWSUSERNAME
# Configure using aws-cli with the values generated from the above command
aws configure --profile $AWSPROFILE
# Delete the old access key
aws iam delete-access-key --access-key-id <old-access-key-id-from-first-command> --user-name AWSUSERNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment