Config Operations
Synchronize configurations between the local cloudbaserc.json and cloud resources using the tcb config pull and tcb config update commands.
Pull Configuration
The tcb config pull command is used to pull the configuration of deployed resources from the cloud and write it to the local cloudbaserc.json file, helping you quickly synchronize cloud state or initialize local configuration files.
Command Format
tcb config pull <module> [name...] [options]
Where <module> indicates the resource module to be pulled. Currently supported:
| Module | Description |
|---|---|
fn | Pull SCF configuration |
integration | Pull integration configuration |
Command Behavior
Pull SCF Configuration (tcb config pull fn):
- Query cloud configuration: Based on the specified function name, obtain the complete configuration of the deployed SCF from the cloud (timeout, memory, runtime, environment variables, triggers, etc.).
- Merge to Local:
- If the local
cloudbaserc.jsondoes not exist, it will be automatically created and the pulled configuration will be written to it. - If the file already exists, for functions with the same name, the CLI will ask whether to overwrite; for functions with different names, they will be appended to the
functionsarray.
- If the local
- When the SCF does not exist: The CLI will ask whether to infer the configuration based on the local project directory and write it.
Pull Integration Configuration (tcb config pull integration):
- Query cloud configuration: Based on the specified integration name, obtain the complete configuration of the created integration from the cloud (authTypeCode, envVariables, etc.).
- Sensitive Field Desensitization: For password-type fields (e.g., API keys, certificates), the cloud returns
******as placeholders, requiring the user to manually fill in real values. - Merge to Local:
- If the local
cloudbaserc.jsondoes not exist, it will be automatically created and the pulled configuration will be written to it. - If the file already exists, for integrations with the same name, the CLI will ask whether to overwrite; for integrations with different names, they will be appended to the
integrationsarray.
- If the local
- When the integration does not exist: Returns an error message, suggesting the user to use
tcb config init integrationto create a configuration template.
Command Parameters
| Parameter | Description | Required |
|---|---|---|
[name...] | SCF/integration name(s). Specify one or more names. | No |
--all | Pull configurations of all functions/integrations in the configuration file | No |
-e, --env-id <envId> | Environment ID | No |
-o, --output <output> | Output file path, defaults to cloudbaserc.json in the current directory | No |
--stdout | Output the result to the console instead of writing to a file | No |
--code-secret <codeSecret> | CodeSecret for code encryption functions | No |
--dir <dir> | Specifies the directory for inferring the configuration (when the SCF does not exist) | No |
--yes | Skip interactive confirmation and automatically overwrite existing configurations | No |
Usage Example
Pull SCF configuration:
# Pulling Configuration for a Single Function
tcb config pull fn myFunc
# Pulling Configuration for Multiple Functions
tcb config pull fn func1 func2 func3
# Pulling Configurations for All Functions in the Configuration File
tcb config pull fn --all
# Output the result to the console (without writing to a file)
tcb config pull fn func1 --stdout
# Specify output file path
tcb config pull fn myFunc -o ./config/cloudbaserc.json
# Automatic confirmation, skip interactive prompts
tcb config pull fn --all --yes
Pull integration configuration:
# Pull configuration for a single integration
tcb config pull integration myPayment
# Pull configuration for multiple integrations
tcb config pull integration payment1 payment2
# Pull configurations for all integrations in the configuration file
tcb config pull integration --all
# Output the result to the console (without writing to a file)
tcb config pull integration myPayment --stdout
# Specify output file path
tcb config pull integration myPayment -o ./config/cloudbaserc.json
# Automatic confirmation, skip interactive prompts
tcb config pull integration --all --yes
SCF Configuration:
- Initialize local configuration: In a new environment or on a new machine, quickly synchronize configuration from the cloud via the
pullcommand, without manual input. - Configuration Review: After pulling, use the
tcb config diff fncommand to compare the differences between local and cloud configurations. - Team Collaboration: Commit the pulled results to the version control repository to ensure team members use consistent function configurations.
Integration Configuration:
- Quick Synchronization: Pull created integration configurations from the cloud to avoid manually filling in complex fields like authTypeCode.
- Configuration Backup: Export cloud integration configurations to local for version management and backup.
- Team Collaboration: Team members can quickly synchronize integration configurations, only need to fill in real values for sensitive fields.
Push Configuration
The tcb config update command is used to push configurations from cloudbaserc.json to the cloud, synchronizing local configurations with cloud resources.
Command Format
tcb config update <module> [name] [options]
Where <module> indicates the module to push. Currently supported:
| Module | Description |
|---|---|
fn | Push SCF configuration |
integration | Push integration configuration |
Command Parameters
| Parameter | Description | Required |
|---|---|---|
[name] | Resource name (SCF name or integration name) | No (choose one with --all) |
--all | Push configurations of all resources in the configuration file | No |
-e, --env-id <envId> | Environment ID | No |
--timeout <timeout> | [fn] Timeout (seconds) | No |
--memory <memory> | [fn] Memory size (MB) | No |
--runtime <runtime> | [fn] Runtime | No |
--handler <handler> | [fn] Entry function | No |
--vpc <vpcId/subnetId> | [fn] VPC configuration (format: vpcId/subnetId) | No |
--yes | Skip interactive confirmation | No |
Usage Example
Push SCF configuration:
# Push configuration for a single function
tcb config update fn hello
# Push single function configuration and override timeout parameter
tcb config update fn hello --timeout 30
# Batch push configurations of all functions in the configuration file
tcb config update fn --all
# Push function configuration and specify VPC
tcb config update fn myFunc --vpc vpc-xxx/subnet-xxx
Push integration configuration:
# Push configuration for a single integration
tcb config update integration myPayment
# Batch push configurations of all integrations in the configuration file
tcb config update integration --all
# Automatic confirmation, skip interactive prompts
tcb config update integration --all --yes
Push Behavior
Push SCF Configuration (tcb config update fn):
- Read Local Configuration: Read function configurations from the
functionsfield incloudbaserc.json. - Parameter Priority: CLI parameters (e.g.,
--timeout) > values in configuration file. - Environment Variable Handling:
- If the configuration contains environment variables, the CLI will ask for the update method:
- Overwrite Update: Completely replace cloud environment variables with local environment variables
- Merge Update: Merge local and cloud environment variables, local overrides variables with the same name
- If the configuration contains environment variables, the CLI will ask for the update method:
- Batch Push: When using the
--allparameter, it will push configurations of all functions in the configuration file.
Push Integration Configuration (tcb config update integration):
- Read Local Configuration: Read integration configurations from the
integrationsfield incloudbaserc.json. - Match Cloud Instance: Match the existing integration instance in the cloud based on the
namefield in the configuration. - Smart Merge:
- For optional fields (e.g.,
demoCodeFunctionName), if the local configuration is explicitly set to an empty string'', the corresponding field in the cloud will be cleared. - For required fields (e.g.,
authTypeCode), if not specified locally, the original value in the cloud will be retained.
- For optional fields (e.g.,
- Batch Push: When using the
--allparameter, it will push configurations of all integrations in the configuration file.
SCF Configuration:
- Configuration Synchronization: Push locally modified function configurations to the cloud to keep them consistent.
- Batch Update: Update configurations of multiple functions at once via the
--allparameter. - Parameter Override: Temporarily modify a parameter (e.g.,
--timeout) without modifying the configuration file.
Integration Configuration:
- Credential Rotation: Update integration credential information (e.g., API keys, certificates, etc.).
- Configuration Management: Manage configurations of multiple integrations through configuration files.
- Team Collaboration: Team members synchronize integration configurations through configuration files, only need to fill in sensitive fields.