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

Commit fc61802

Browse files
committed
fixes #78
1 parent b1d3bd2 commit fc61802

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

import_users.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ fi
4545
: ${USERADD_ARGS:="--create-home --shell /bin/bash"}
4646

4747
# Initizalize INSTANCE variable
48-
INSTANCE_ID=$(curl -s http://instance-data//latest/meta-data/instance-id)
48+
INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
49+
REGION=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{print $4}')
4950

5051
function log() {
5152
/usr/bin/logger -i -p auth.info -t aws-ec2-ssh "$@"
@@ -74,10 +75,9 @@ function get_iam_groups_from_tag() {
7475
if [ "${IAM_AUTHORIZED_GROUPS_TAG}" ]
7576
then
7677
IAM_AUTHORIZED_GROUPS=$(\
77-
aws ec2 describe-tags \
78+
aws --region $REGION ec2 describe-tags \
7879
--filters "Name=resource-id,Values=$INSTANCE_ID" "Name=key,Values=$IAM_AUTHORIZED_GROUPS_TAG" \
79-
--query "Tags[0].Value" \
80-
--output text \
80+
--query "Tags[0].Value" --output text \
8181
)
8282
fi
8383
}
@@ -123,10 +123,9 @@ function get_sudoers_groups_from_tag() {
123123
if [ "${SUDOERS_GROUPS_TAG}" ]
124124
then
125125
SUDOERS_GROUPS=$(\
126-
aws ec2 describe-tags \
126+
aws --region $REGION ec2 describe-tags \
127127
--filters "Name=resource-id,Values=$INSTANCE_ID" "Name=key,Values=$SUDOERS_GROUPS_TAG" \
128-
--query "Tags[0].Value" \
129-
--output text \
128+
--query "Tags[0].Value" --output text \
130129
)
131130
fi
132131
}

0 commit comments

Comments
 (0)