Fix assume-role: check if -T and -A options are set together @jfagoagas

Fix assume-role: check if `-T` and `-A` options are set together @jfagoagas
This commit is contained in:
Toni de la Fuente authored and GitHub committed 2021-11-29 10:56:27 +01:00
commit 315b4cc7c9
2 files changed
+5 -5

No files matched your search

+3 -3
View File
@@ -11,9 +11,9 @@
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
# both variables are mandatory to be set together
assume_role(){
if [[ -z $ROLE_TO_ASSUME ]]; then
# Both variables are mandatory to be set togethe
if [[ -z $ROLE_TO_ASSUME || -z $ACCOUNT_TO_ASSUME ]]; then
echo "$OPTRED ERROR!$OPTNORMAL - Both Account ID (-A) and IAM Role to assume (-R) must be set"
exit 1
fi
@@ -89,4 +89,4 @@ assume_role(){
cleanSTSAssumeFile() {
rm -fr "${TEMP_STS_ASSUMED_FILE}"
}
}
+2 -2
View File
@@ -392,7 +392,7 @@ show_group_title() {
# Function to execute the check
execute_check() {
if [[ $ACCOUNT_TO_ASSUME ]]; then
if [[ -n "${ACCOUNT_TO_ASSUME}" || -n "${ROLE_TO_ASSUME}" ]]; then
# Following logic looks for time remaining in the session and review it
# if it is less than 600 seconds, 10 minutes.
CURRENT_TIMESTAMP=$(date -u "+%s")
@@ -639,7 +639,7 @@ fi
# Gather account data / test aws cli connectivity
getWhoami
if [[ $ACCOUNT_TO_ASSUME ]]; then
if [[ -n "${ACCOUNT_TO_ASSUME}" || -n "${ROLE_TO_ASSUME}" ]]; then
assume_role
fi