Skip to content

Instantly share code, notes, and snippets.

@eoinsha
Last active November 4, 2024 08:46
Show Gist options
  • Save eoinsha/07b4ee786be31233fed6110d3dc7510d to your computer and use it in GitHub Desktop.
Save eoinsha/07b4ee786be31233fed6110d3dc7510d to your computer and use it in GitHub Desktop.
Running VSCode in AWS CloudShell

VSCode in AWS CloudShell

From time to time, you might want a quick envrionment for doing some dev or troubleshooting within an AWS environment. Since CloudShell now support VPC connections, this is especially useful. Pasting the following commands into CloudShell give you a way to connect from VS Code, edit code, and more.

Install Tools

cd
mkdir -p ~/.local/bin
export PATH=~/.local/bin:${PATH}
# Download and install VS Code CLI for AMD64 Linux
curl -L "https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64"  | tar -C ~/.local/bin -xzf -

# Install UV for working with Python versions and dependencies
curl -LsSf https://astral.sh/uv/0.4.6/install.sh | sh
source $HOME/.cargo/env

# Install the GitHub CLI to make repo cloning and setup quick
curl -L "https://github.com/cli/cli/releases/download/v2.60.1/gh_2.60.1_linux_amd64.tar.gz" | tar --strip-components=2 -xzv -f - "*/gh"
mv gh ~/.local/bin/

# Log in with the GitHub CLI:
gh auth login -p https -h github.com 

# Go to https://github.com/login/device and copy the one-time code

Run VSCode Remote Tunnel

Run the following and log in to your GitHub account.

code tunnel

You'll see something like the following. Enter the details to set up the tunnel.

✔ How would you like to log in to Visual Studio Code? · GitHub Account
To grant access to the server, please log into https://github.com/login/device and use code AABB-DD99
? What would you like to call this machine? (ip-10-0-3-201eu-west) › my-cloudshell-session

Done

Now, you can connect to your tunnel:

  • In vscode.dev using the link provided
  • From your local VS Code installation

Now, you can gh repo clone https://github.com/fourtheorem/slic-watch.git, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment