Page 1 of 1

AWS cli - check if user is logged in in shell script

Posted: Fri Oct 28, 2022 7:01 am
by veera
Trying to build a simple shell script - but in order to run AWS cli commands like aws ssm start-session I first need to check if the user is logged in. How can I do this in a shell script with the aws cli?

Code: Select all

#!/usr/bin/env bash

# if no sso access token, do login
if [!aws sts get-caller-identity]
    aws sso login


# my script
aws ssm start-session ......

Re: AWS cli - check if user is logged in in shell script

Posted: Fri Oct 28, 2022 11:27 am
by Klaus
This is a forum for users of LIVECODE: https://livecode.com
If you do not use Livecode for programming, then you are at the wrong place.