Skip to content

Twingate-Labs/tg-github-codespaces

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Twingate + GitHub Codespaces

Example of Github Codespaces with Twingate

What this is

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.

Getting started

Prerequisites

  1. 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.
  2. Ensure that there exists a .devcontainer directory in your repository
  3. Copy the Dockerfile from .devcontainer in this repository to the same location in your repository.

Connect using a Twingate Service Account Key

  1. 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).
  2. Copy the file devcontainer.serviceaccount.json to the .devcontainer directory in your respository and rename it to devcontainer.json.
  3. Create a Codespaces User Secret named TWINGATE_SERVICE_KEY set to your Twingate Service Account Key.
  4. Start your codespace and confirm that Twingate is connected by running twingate status - it should return online
    1. Run twingate resources to obtain a list of resources
    2. In case of problems please run sudo twingate report and send the report file to support@twingate.com.

Connect using a regular Twingate account (interactive login)

  1. Copy the file devcontainer.interactive.json to the .devcontainer directory in your respository and rename it to devcontainer.json.
  2. Create a Codespaces Secret named TWINGATE_ACCOUNT set to your Twingate Account Name. For example, if your Twingate domain is acme.twingate.com then set the value to acme.
  3. Start your Codespace and run twingate status (note: be sure to execute these commands without sudo)
    1. If status is authenticating you should follow the URL displayed to authenticate
    2. If status is not running then you should execute twingate start followed by /usr/bin/twingate-notifier console and follow the URL displayed to authenticate
    3. Once online, run twingate resources to obtain a list of resources
    4. In case of problems please run sudo twingate report and send the report file to support@twingate.com.

Feedback, improvements, comments

Please open an issue or submit a Pull Request in this repository with any feedback you may have.

About

Example of Github Codespaces with Twingate

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published