Skip to main content

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:

ModuleDescription
fnPull SCF configuration
integrationPull integration configuration

Command Behavior

Pull SCF Configuration (tcb config pull fn):

  1. 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.).
  2. Merge to Local:
    • If the local cloudbaserc.json does 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 functions array.
  3. 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):

  1. Query cloud configuration: Based on the specified integration name, obtain the complete configuration of the created integration from the cloud (authTypeCode, envVariables, etc.).
  2. 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.
  3. Merge to Local:
    • If the local cloudbaserc.json does 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 integrations array.
  4. When the integration does not exist: Returns an error message, suggesting the user to use tcb config init integration to create a configuration template.

Command Parameters

ParameterDescriptionRequired
[name...]SCF/integration name(s). Specify one or more names.No
--allPull configurations of all functions/integrations in the configuration fileNo
-e, --env-id <envId>Environment IDNo
-o, --output <output>Output file path, defaults to cloudbaserc.json in the current directoryNo
--stdoutOutput the result to the console instead of writing to a fileNo
--code-secret <codeSecret>CodeSecret for code encryption functionsNo
--dir <dir>Specifies the directory for inferring the configuration (when the SCF does not exist)No
--yesSkip interactive confirmation and automatically overwrite existing configurationsNo

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
Use Cases

SCF Configuration:

  • Initialize local configuration: In a new environment or on a new machine, quickly synchronize configuration from the cloud via the pull command, without manual input.
  • Configuration Review: After pulling, use the tcb config diff fn command 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:

ModuleDescription
fnPush SCF configuration
integrationPush integration configuration

Command Parameters

ParameterDescriptionRequired
[name]Resource name (SCF name or integration name)No (choose one with --all)
--allPush configurations of all resources in the configuration fileNo
-e, --env-id <envId>Environment IDNo
--timeout <timeout>[fn] Timeout (seconds)No
--memory <memory>[fn] Memory size (MB)No
--runtime <runtime>[fn] RuntimeNo
--handler <handler>[fn] Entry functionNo
--vpc <vpcId/subnetId>[fn] VPC configuration (format: vpcId/subnetId)No
--yesSkip interactive confirmationNo

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):

  1. Read Local Configuration: Read function configurations from the functions field in cloudbaserc.json.
  2. Parameter Priority: CLI parameters (e.g., --timeout) > values in configuration file.
  3. 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
  4. Batch Push: When using the --all parameter, it will push configurations of all functions in the configuration file.

Push Integration Configuration (tcb config update integration):

  1. Read Local Configuration: Read integration configurations from the integrations field in cloudbaserc.json.
  2. Match Cloud Instance: Match the existing integration instance in the cloud based on the name field in the configuration.
  3. 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.
  4. Batch Push: When using the --all parameter, it will push configurations of all integrations in the configuration file.
Use Cases

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 --all parameter.
  • 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.