Skip to content

Instantly share code, notes, and snippets.

@tyrostone
Created July 11, 2019 20:34
Show Gist options
  • Save tyrostone/4ffd4a263e620522a133de0e6ec11ba0 to your computer and use it in GitHub Desktop.
Save tyrostone/4ffd4a263e620522a133de0e6ec11ba0 to your computer and use it in GitHub Desktop.
A small bash script to import AWS IAM users into Terraform
#!/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