This repository was archived by the owner on Nov 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change 45
45
: ${USERADD_ARGS:= " --create-home --shell /bin/bash" }
46
46
47
47
# 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}' )
49
50
50
51
function log() {
51
52
/usr/bin/logger -i -p auth.info -t aws-ec2-ssh " $@ "
@@ -74,10 +75,9 @@ function get_iam_groups_from_tag() {
74
75
if [ " ${IAM_AUTHORIZED_GROUPS_TAG} " ]
75
76
then
76
77
IAM_AUTHORIZED_GROUPS=$( \
77
- aws ec2 describe-tags \
78
+ aws --region $REGION ec2 describe-tags \
78
79
--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 \
81
81
)
82
82
fi
83
83
}
@@ -123,10 +123,9 @@ function get_sudoers_groups_from_tag() {
123
123
if [ " ${SUDOERS_GROUPS_TAG} " ]
124
124
then
125
125
SUDOERS_GROUPS=$( \
126
- aws ec2 describe-tags \
126
+ aws --region $REGION ec2 describe-tags \
127
127
--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 \
130
129
)
131
130
fi
132
131
}
You can’t perform that action at this time.
0 commit comments