Search code examples
amazon-web-servicesterraformcommand-line-interfaceaws-cloud9

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


Is it possible using the CLI in AWS cloud9 to acquire the current user name?

In terraform its possible to get a user's display name with a module like data.aws_canonical_user_id.current.display_name

...But it would be good to also be able to achieve this without terraform.


Solution

  • If want to use AWS CLI, that AWS docs explain how to get the canonical user id:

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

    Display Name:

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

    Account id:

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