AWS cli - check if user is logged in in shell script
Posted: Fri Oct 28, 2022 7:01 am
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 ......