Codespace regional settings in [#github-codespaces]

Overview

At the time of this writing, Codespaces may be hosted in one of the following regions:

  1. United States West
  2. United States East
  3. Europe West
  4. Southeast Asia

Unless otherwise specified, all Codespaces will be generated in the closest available region based on your location (IP address) at creation time. Setting your default region for GitHub Codespaces provides instructions for viewing or modifying this setting.

As stated in Using Github Codespaces prebuilds, modifying Region availability for Codespace prebuilds is recommended as it reduces prebuild creation time and storage requirements.

The purpose of this guide is to provide the reader confidence in aligning these two configuration settings.

Check the region of an existing Codespace

To check the region of an existing Codespace, do the following:

Add the GitHub CLI to the devcontainer

    "features": {
        "ghcr.io/devcontainers/features/github-cli:1": {}
    }
  • Rebuild the Codespace by choosing View > Command Pallette from the Codespace menu.
  • Then type rebuild and select Codespaces: Rebuild Container.

Request the Codespace location

After the Codespace has been rebuilt, open a bash terminal and execute the following command:

gh api /user/codespaces/$CODESPACE_NAME --jq .location

This will return the region of the current Codespace.

Best practices

  • By Setting a default region for GitHub Codespaces, readers can have confidence when setting prebuild configurations.
  • If setting a single default region for all Codespaces is not possible or appropriate, readers can identify the region of an existing Codespace and set or modify the prebuild regional configuration accordingly.
About GitHub Codespaces