在 AWS Cloud9 中,实例元数据或 cli 是否有可能知道使用会话的人的用户名?

In AWS Cloud9, is it possible with instance metadata or the cli to know the user name of the person utilising the session?

是否可以使用AWS cloud9中的CLI获取当前用户名?

在 terraform 中,可以使用类似的模块获取用户的显示名称 data.aws_canonical_user_id.current.display_name

...但是如果没有 terraform 也能实现这一点就好了。

如果想使用 AWS CLI,AWS docs 说明如何获取规范用户 ID:

aws s3api list-buckets --query Owner.ID --output text

显示名称:

aws s3api list-buckets --query Owner.DisplayName --output text

账户编号:

aws sts get-caller-identity --query Account --output text