|
| 1 | +--- |
| 2 | +title: Workspaces |
| 3 | +description: Workspaces organize teams and manage billing for Defang deployments. |
| 4 | +--- |
| 5 | + |
| 6 | +# Workspaces |
| 7 | + |
| 8 | +Workspaces are the primary way to organize teams and manage billing in Defang. A workspace represents a billing context that can be shared among team members, allowing multiple developers to deploy services under a team subscription. |
| 9 | + |
| 10 | +## Types of Workspaces |
| 11 | + |
| 12 | +Defang supports three types of workspaces: |
| 13 | + |
| 14 | +### Personal Workspace |
| 15 | + |
| 16 | +When you create a Defang account, a personal workspace is automatically created using your username. This workspace: |
| 17 | + |
| 18 | +- Cannot be deleted |
| 19 | +- Cannot have additional members |
| 20 | +- Is always available as your default workspace |
| 21 | +- Can have a subscription attached for individual use |
| 22 | + |
| 23 | +### Defang-Managed Workspaces |
| 24 | + |
| 25 | +You can create additional workspaces directly in the [Defang Portal](./portal.md). These workspaces: |
| 26 | + |
| 27 | +- Can be renamed or deleted by the owner |
| 28 | +- Support inviting team members via invite links |
| 29 | +- Allow full membership management within Defang |
| 30 | + |
| 31 | +### Provider-Managed Workspaces |
| 32 | + |
| 33 | +When you log in with GitHub or GitLab and authorize Defang to access your organizations, workspaces are automatically created for each authorized organization. These workspaces: |
| 34 | + |
| 35 | +- Cannot be deleted (the organization must be disconnected from Defang) |
| 36 | +- Cannot have members directly invited: membership is managed through your Git provider |
| 37 | +- The user who initially connects the organization becomes the workspace owner with billing access |
| 38 | + |
| 39 | +:::info |
| 40 | +Ownership transfer for provider-managed workspaces is not yet implemented. The user who connects an organization remains the billing contact. |
| 41 | +::: |
| 42 | + |
| 43 | +## Creating a Workspace |
| 44 | + |
| 45 | +To create a Defang-managed workspace: |
| 46 | + |
| 47 | +1. Log in to the [Defang Portal](https://portal.defang.dev) |
| 48 | +2. Click the workspace switcher dropdown in the navigation bar |
| 49 | +3. Click **Create Workspace** at the bottom of the dropdown |
| 50 | +4. Enter a name (lowercase kebab-case is recommended, e.g., `my-team`) |
| 51 | +5. Optionally add teammates and select a billing plan |
| 52 | + |
| 53 | +Workspace names are unique and can be changed later. While the portal encourages kebab-case naming for compatibility with CLI usage, the name is stored as entered. |
| 54 | + |
| 55 | +## Using Workspaces with the CLI |
| 56 | + |
| 57 | +### Specifying a Workspace |
| 58 | + |
| 59 | +You can specify which workspace to use for any CLI command using the `--workspace` flag: |
| 60 | + |
| 61 | +```bash |
| 62 | +defang compose up --workspace=my-team |
| 63 | +``` |
| 64 | + |
| 65 | +Alternatively, set the `DEFANG_WORKSPACE` environment variable: |
| 66 | + |
| 67 | +```bash |
| 68 | +export DEFANG_WORKSPACE=my-team |
| 69 | +defang compose up |
| 70 | +``` |
| 71 | + |
| 72 | +:::tip |
| 73 | +Workspaces can be specified by name or ID. Both work interchangeably. |
| 74 | +::: |
| 75 | + |
| 76 | +### Listing Workspaces |
| 77 | + |
| 78 | +To see all workspaces you have access to: |
| 79 | + |
| 80 | +```bash |
| 81 | +defang workspace ls |
| 82 | +``` |
| 83 | + |
| 84 | +Add `--verbose` to include workspace IDs, or `--json` for JSON output. |
| 85 | + |
| 86 | +### Viewing Current Workspace |
| 87 | + |
| 88 | +The `defang whoami` command shows your current workspace: |
| 89 | + |
| 90 | +```bash |
| 91 | +defang whoami |
| 92 | +``` |
| 93 | + |
| 94 | +## Workspace Membership |
| 95 | + |
| 96 | +### Defang-Managed Workspaces |
| 97 | + |
| 98 | +For workspaces created in the Defang Portal: |
| 99 | + |
| 100 | +1. The workspace owner can generate an invite link from the **Invites** tab |
| 101 | +2. Share the link with team members |
| 102 | +3. When a user clicks the link, they request access |
| 103 | +4. The owner approves or denies the request from the portal |
| 104 | + |
| 105 | +Members can have different roles: |
| 106 | +- **Owner**: Full control including billing, settings, and member management |
| 107 | +- **Admin**: Can manage members and settings |
| 108 | +- **Member**: Can use the workspace subscription for deployments |
| 109 | +- **Billing**: Can manage payment and subscription details |
| 110 | + |
| 111 | +### Provider-Managed Workspaces |
| 112 | + |
| 113 | +For workspaces created from GitHub or GitLab organizations, membership is managed entirely through your Git provider: |
| 114 | + |
| 115 | +- Add users to the organization in GitHub/GitLab to grant them workspace access |
| 116 | +- Remove users from the organization to revoke workspace access |
| 117 | +- Changes sync automatically when users log in to Defang |
| 118 | + |
| 119 | +## How Workspaces Relate to Projects |
| 120 | + |
| 121 | +Workspaces provide access to _features_ (deployment capabilities, subscriptions) rather than to specific _projects_. This means: |
| 122 | + |
| 123 | +- Any developer with access to both a workspace (with an active subscription) and a codebase can deploy that code |
| 124 | +- If a developer changes workspaces, they can continue deploying the same project using a different workspace's subscription |
| 125 | +- The deployment itself lives in the configured cloud account, independent of which workspace was used |
| 126 | + |
| 127 | +:::warning |
| 128 | +Deployment logs and history are associated with the workspace used at deployment time. If you deploy a project with Workspace A, then later deploy the same project with Workspace B, the deployment record will be stored under Workspace B. |
| 129 | +::: |
| 130 | + |
| 131 | +## CI/CD Integration |
| 132 | + |
| 133 | +When deploying from GitHub Actions using OIDC authentication, the repository owner automatically becomes the tenant context. This allows CI/CD pipelines to deploy without explicitly specifying a workspace, as long as the repository owner has an active subscription. |
| 134 | + |
| 135 | +For more details, see [Deploying from GitHub Actions](/docs/tutorials/deploying-from-github-actions). |
0 commit comments