Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Support for deleted/non-existant IAM group #128

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions import_users.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ function get_iam_users() {
| sed "s/\r//g"
else
for group in $(echo ${IAM_AUTHORIZED_GROUPS} | tr "," " "); do
aws iam get-group \
if ! aws iam get-group \
--group-name "${group}" \
--query "Users[].[UserName]" \
--output text \
| sed "s/\r//g"
--output text;
then
continue;
fi
done
fi
}
Expand Down Expand Up @@ -142,10 +144,13 @@ function get_sudoers_users() {

[[ -z "${SUDOERS_GROUPS}" ]] || [[ "${SUDOERS_GROUPS}" == "##ALL##" ]] ||
for group in $(echo "${SUDOERS_GROUPS}" | tr "," " "); do
aws iam get-group \
if ! aws iam get-group \
--group-name "${group}" \
--query "Users[].[UserName]" \
--output text
--output text;
then
continue;
fi
done
}

Expand Down
6 changes: 4 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ tmpdir=$(mktemp -d)

cd "$tmpdir"

git clone -b master https://github.com/widdix/aws-ec2-ssh.git
git clone -b master https://github.com/nicholascowan/aws-ec2-ssh.git

cd "$tmpdir/aws-ec2-ssh"

Expand Down Expand Up @@ -143,8 +143,10 @@ SHELL=/bin/bash
PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin
MAILTO=root
HOME=/
*/10 * * * * root $IMPORT_USERS_SCRIPT_FILE
RANDOM_DELAY=19
*/20 * * * * root $IMPORT_USERS_SCRIPT_FILE
EOF

chmod 0644 /etc/cron.d/import_users

$IMPORT_USERS_SCRIPT_FILE
Expand Down