2

I am in the process of setting up notebook instances for several users in a team. These users will be able to use version control. The issue is that when a user commits the Author of the commit is ec2-default-user. I want the author to be "username" eg john doe.

I know that one solution to this is to tell the users to write in the command line "git config --global user.name "John Doe"".

This does not work for me as I want this to be automated for the users. Therefore I am looking for a way to extract the user's username in the lifecycle config and then pass this username to some code which will set the author of any commits to the user's username.

This is what I have currently

set -e
cat << EOF >> /home/ec2-user/.gitconfig
[user]
        name = John Doe

EOF

but where there is John Doe I would like it to be the username of the current user who has opened up their sagemaker notebook instance.

I would like a way to extract the username in the lifecycle config and pas this value to the code that sets the username. I'm relatively new to all this hence the limited knowledge. I've looked on documentation but can't seem to find much.

Nicholas
  • 125
  • 2
  • 12
  • What do you mean by username? Is it the IAM user name? The real user name? Can you use Tags to capture that user name? – Guy Jun 13 '19 at 06:41
  • So it would be the real user name. I have thought about the use of Tags to capture the username but I'm not entirely sure how to do this.the notebook instance would look something like johndoe-notebook-instance. So I'd like to extract the johndoe part to use it as the username. – Nicholas Jun 13 '19 at 07:15

1 Answers1

2

You can include the username as part of Notebook Instance name or tag the Notebook Instance with username and extract that info in Lifecycle Config using Notebook Instance metadata present under /opt/ml/metadata/resource-metadata.json.

Please check out our documentation on how to use Notebook Instance metadata: https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-metadata.html .

Thanks for using Amazon SageMaker!

Han
  • 222
  • 1
  • 2