Created
July 11, 2019 20:34
-
-
Save tyrostone/4ffd4a263e620522a133de0e6ec11ba0 to your computer and use it in GitHub Desktop.
A small bash script to import AWS IAM users into Terraform
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
#!/bin/bash | |
aws iam list-users --profile=${DEV_PROFILE} | grep UserName | awk '{ print substr($2, 2, length($2)-3) }' > iam_users.txt | |
terraform init | |
INPUT="./iam_users.txt" | |
while IFS= read -r USER | |
do | |
terraform import aws_iam_user.${USER//\./_} "$USER" | |
done < "${INPUT}" | |
rm iam_users.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment