Install
@cloudbase/cli is the official CloudBase command line tool. After installation it provides the tcb command for deploying and managing CloudBase resources.
Prerequisites
- Node.js 18 or later.
- A Tencent Cloud account. Sub-accounts need authorization from the root account first, see Sub-account authorization.
Install the CLI
Install it globally with any package manager:
- npm
- yarn
- pnpm
npm i -g @cloudbase/cli
yarn global add @cloudbase/cli
pnpm add -g @cloudbase/cli
If the installation fails with a network timeout such as ETIMEOUT or network request failed, point it at the Tencent Cloud npm mirror for this install:
npm i -g @cloudbase/cli --registry=http://mirrors.cloud.tencent.com/npm/
Verify the Installation
tcb -v
A version number means the installation succeeded. If the CLI reports that the Node.js version is too old, upgrade Node.js and reinstall.
Sign In
tcb login
tcb login uses the device code flow by default: the terminal prints an authorization link and a user code, and the CLI also tries to open the browser. Click Approve to finish signing in.
- International site account:
tcb login --intl true. - Local browser callback:
tcb login --flow web. - CI/CD, environment-level API keys, custom endpoints: see Login and authentication.
After signing in, run tcb env list to confirm that your environments are listed.
List Commands
tcb -h
For the parameters of a single command, run tcb <command> -h, for example tcb pull -h.
Sub-account Authorization
A sub-account needs the matching policies before it can access CloudBase resources.
Grant Policies
- Sign in to the Tencent Cloud access management console.
- In the left navigation, choose Users > User List.
- Click Create User, fill in the user information, and finish creating the user.
- Select the CloudBase preset policies listed below in the policy list.
- Click Done.
You can also attach policies to an existing sub-account, see Authorization management.
Preset Policies
| Policy | Description |
|---|---|
QcloudAccessForTCBRole | Access to cloud resources for CloudBase |
QcloudAccessForTCBRoleInAccessCloudBaseRun | Access to VPC, CVM and other cloud services for CloudBase, used by CloudBase Run |
⚠️ Both policies grant read and write access to Object Storage, Cloud Functions, logs, monitoring, VPC and other resources, and automatically cover resources created later. Grant them only to sub-accounts that need them.
Web Authorization for the CLI
A sub-account that signs in to the CLI with web authorization also needs CAM read-only access:
| Policy | Description |
|---|---|
QcloudCamReadOnlyAccess | Read-only access to Cloud Access Management (CAM) |
Without this policy, the sub-account can only sign in to the CLI with an API key.
Network Proxy
When the terminal cannot reach the public network, route the CLI through an HTTP proxy. The CLI reads the http_proxy or HTTP_PROXY environment variable.
# Applies to the current terminal session
export HTTP_PROXY=http://127.0.0.1:8000
Add the command to ~/.bashrc or ~/.zshrc to apply the proxy every time a terminal starts. Use the proxy address and port of your own network.