-
-
Save rrobby86/9c1935b4d2d6f7ca496ebfda95b65a73 to your computer and use it in GitHub Desktop.
Simple CLI for AWS SageMaker notebook instances
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # TODO: | |
| # - start, stop, status commands | |
| # - jupyterlab option | |
| # - pass settings (e.g. profile) to aws cli | |
| PROGNAME=$(basename $0) | |
| AWS="aws" | |
| OPEN="xdg-open" | |
| cmd_help() { | |
| echo "Usage: $PROGNAME <command> [args]\n" | |
| cat <<EOF | |
| Subcommands: | |
| list | |
| open <instance> | |
| EOF | |
| } | |
| cmd_list() { | |
| $AWS sagemaker list-notebook-instances --query 'NotebookInstances[*].[NotebookInstanceName]' --output text | |
| } | |
| cmd_open() { | |
| $OPEN $($AWS sagemaker create-presigned-notebook-instance-url --notebook-instance-name $1 --query AuthorizedUrl --output text) | |
| } | |
| subcmd=$1 | |
| case $subcmd in | |
| "" | "-h" | "--help") | |
| cmd_help | |
| ;; | |
| *) | |
| shift | |
| cmd_${subcmd} $@ | |
| if [ $? = 127 ]; then | |
| echo "Unrecognized subcommand, run '$PROGNAME --help' to list subcommands" | |
| exit 1 | |
| fi | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment