There's probably something very obvious I'm missing or Sagemaker just doesn't support these kinds of extensions, but I've been trying to enable toc2 (Table of Contents) jupyter extension for my Sagemaker notebook via lifecycle configurations, but for whatever reason it still isn't showing up.
I built my script out combining a sample AWS script and a quick article on the usual ways of enabling extensions:
https://towardsdatascience.com/jupyter-notebook-extensions-517fa69d2231
#!/bin/bash
set -e
sudo -u ec2-user -i <<EOF
--Activate notebook environment
source activate JupyterSystemEnv
--Install extensions
pip install jupyter_contrib_nbextensions && jupyter contrib
nbextension install
jupyter nbextension enable toc2 --py --sys-prefix
source deactivate
EOF
Thanks!
Answering my question, looks like I was just missing the line jupyter contrib nbextension install --user
to copy the JS/CSS files into Jupyter's search directory and some config updates (https://github.com/ipython-contrib/jupyter_contrib_nbextensions).
Corrected statement
#!/bin/bash
set -e
sudo -u ec2-user -i <<'EOF'
source /home/ec2-user/anaconda3/bin/activate JupyterSystemEnv
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
jupyter nbextension enable toc2/main
source /home/ec2-user/anaconda3/bin/deactivate
EOF
##Below may be unnecessary, but other user needed to run to see success
initctl restart jupyter-server --no-wait