Example of Github Codespaces with Twingate
GitHub Codespaces is a service from GitHub that provides a way for developers to run a full development environment entirely within the cloud and accessible via a web-browser or via VisualStudio Code.
This repository provides an example of how to configure a Twingate client running with either a Service Account (default) or as a regular user. Codespaces users will then be able to access private resources such as internal databases or APIs that are protected behind Twingate directly from their web-browser or from within VS Code.
Note: For connecting your GitHub workflows to private resources please also see the Connect to Twingate GitHub Action.
- Ensure you have a GitHub repository that you'd like to open with Codespaces and ensure you have permissions to launch Codespaces. You may need assistance from your organization's GitHub Administrator.
- Ensure that there exists a
.devcontainer
directory in your repository - Copy the
Dockerfile
from.devcontainer
in this repository to the same location in your repository.
- Ensure you have a Service Account Key - this can be generated within the Twingate Admin Console (you may need to ask your Twingate Administrator to do this for you).
- Copy the file
devcontainer.serviceaccount.json
to the.devcontainer
directory in your respository and rename it todevcontainer.json
. - Create a Codespaces User Secret named
TWINGATE_SERVICE_KEY
set to your Twingate Service Account Key. - Start your codespace and confirm that Twingate is connected by running
twingate status
- it should returnonline
- Run
twingate resources
to obtain a list of resources - In case of problems please run
sudo twingate report
and send the report file to support@twingate.com.
- Run
- Copy the file
devcontainer.interactive.json
to the.devcontainer
directory in your respository and rename it todevcontainer.json
. - Create a Codespaces Secret named
TWINGATE_ACCOUNT
set to your Twingate Account Name. For example, if your Twingate domain isacme.twingate.com
then set the value toacme
. - Start your Codespace and run
twingate status
(note: be sure to execute these commands withoutsudo
)- If status is
authenticating
you should follow the URL displayed to authenticate - If status is
not running
then you should executetwingate start
followed by/usr/bin/twingate-notifier console
and follow the URL displayed to authenticate - Once
online
, runtwingate resources
to obtain a list of resources - In case of problems please run
sudo twingate report
and send the report file to support@twingate.com.
- If status is
Please open an issue or submit a Pull Request in this repository with any feedback you may have.