awsiamcreate-user--user-namecwagent-onprem
# attach user policyawsiamattach-user-policy--user-namecwagent-onprem--policy-arnarn:aws:iam::aws:policy/CloudWatchAgentServerPolicy
# create access key, save the outputawsiamcreate-access-key--user-namecwagent-onprem
account_id=$(awsstsget-caller-identity\--query'Account'--outputtext)role_arn=arn:aws:iam::${account_id}:role/eksworkshop-admin
tmp_file=/tmp/$$.1
awsstsassume-role--role-arn${role_arn}\--duration-seconds43200\--role-session-nameSession-$RANDOM|tee${tmp_file}exportAWS_ACCESS_KEY_ID=$(cat${tmp_file}|jq-r'.Credentials.AccessKeyId')exportAWS_SECRET_ACCESS_KEY=$(cat${tmp_file}|jq-r'.Credentials.SecretAccessKey')exportAWS_SESSION_TOKEN=$(cat${tmp_file}|jq-r'.Credentials.SessionToken')# compatibility for old version exportAWS_SECURITY_TOKEN=$(cat${tmp_file}|jq-r'.Credentials.SessionToken')exportAWS_DEFAULT_REGION=$(curl-s169.254.169.254/latest/dynamic/instance-identity/document|jq-r'.region')