Cloud Native 8 min read

Mastering Cloud Studio YAML Templates: From Creation to Deployment

This guide explains how Cloud Studio users can simplify workspace setup by using YAML templates that define environment images, variables, extensions, lifecycle commands, and sidecar services, providing step‑by‑step instructions, code examples, and visual illustrations for creating, importing, and deploying fully configured cloud development environments.

Tencent Cloud Developer
Tencent Cloud Developer
Tencent Cloud Developer
Mastering Cloud Studio YAML Templates: From Creation to Deployment

Feature Overview

The Cloud Studio YAML template feature lets you define a workspace configuration in a workspace.yml file. The file describes the source repository, environment variables, VS Code extensions, lifecycle commands, and optional sidecar services (MySQL, Redis). Using a template eliminates manual setup for each collaborator and enables one‑click workspace creation.

Accessing the Feature

On any template page, a button in the top‑right corner opens the YAML template UI. Two actions are available:

Manually create a new workspace from a template.

Import an existing workspace.yml file.

Manual Creation Workflow

When you choose to create a workspace manually, you can upload a workspace.yml. The system reads the file and automatically provisions the defined environment, extensions, and sidecars, so collaborators do not need to repeat the same configuration steps.

Structure of workspace.yml

A typical file looks like the example below:

---
name: "react-demo"
description: "A simple YAML example"
tags:
  - "Node.js"
  - "React"
repository: "https://e.coding.net/coding-public/cloud-studio-samples/react-quickstart.git"
ref: "master"
envs:
  - name: "PROJECT_NAME"
    value: "this is a react-demo project"
extensions:
  - "[email protected]"
  - "[email protected]"
lifecycle:
  init:
    - name: "update apt cache"
      command: "apt update"
    - name: "install nginx"
      command: "apt install -y nginx"
  start:
    - name: "run nginx"
      command: "service nginx start"
sidecar:
  mysql:
    enabled: true
    password: "123456"
    database: "test"
  redis:
    enabled: true
    password: "123456"
image_id: 5

Key sections:

envs : initial environment variables injected into the container.

extensions : VS Code extensions automatically installed when the workspace starts.

lifecycle : commands executed at three stages— init (first start), start (every launch), and destroy (shutdown). Commands must be simple shell strings; they cannot rely on scripts stored in the cloned repository.

sidecar : auxiliary containers (currently MySQL and Redis) that run alongside the IDE and are reachable via network ports.

Sidecar Mechanics

Sidecar services are launched as separate containers in parallel with the editor. Users interact only with the IDE, while the sidecar containers provide database or cache services that the application can connect to.

Example: React Template

The React template uses the configuration shown above. It clones the repository

https://e.coding.net/coding-public/cloud-studio-samples/react-quickstart.git

, installs the listed extensions, runs apt update and apt install -y nginx during init, and starts Nginx on each launch.

Example: Java E‑commerce Template

A Spring Boot (2.1.5) + JDK 11 template demonstrates a different configuration:

---
name: "java-demo"
description: "A simple YAML example"
tags:
  - "Java"
repository: "https://e.coding.net/coding-public/cloud-studio-samples/java-ecommerce.git"
ref: "master"
extensions:
  - "Pivotal.vscode-spring-boot"
  - "[email protected]"
lifecycle:
  init:
    - name: "update apt cache"
      command: "apt update"
    - name: "install mysqlclient"
      command: "apt-get install -y mysql-client"
sidecar:
  mysql:
    enabled: true
    password: "123456"
    database: "uzymall"
  redis:
    enabled: true
    password: "uzymall"
image_id: 4

This file installs the MySQL client, enables a MySQL sidecar for data storage, and adds Spring Boot and Maven extensions for development.

Preview and Automatic Run

If the template includes a .vscode/preview.yml file, Cloud Studio executes the defined run command when the workspace opens, allowing immediate preview of the service (e.g., the e‑commerce application).

Export / Import of workspace.yml

You can export the generated workspace.yml from an existing workspace and later import it to recreate the same environment. This is useful for sharing a fully configured workspace with teammates.

Important Caveats

Lifecycle commands run in the container’s shell; they cannot invoke scripts that reside in the cloned repository because the repository is mounted after the init phase.

Sidecar services are limited to MySQL and Redis at present. Set enabled: false to disable a service.

Generated Workspace Links (plain URLs)

Use the following URLs to view workspaces created from the templates and to copy their workspace.yml files:

https://cloudstudio.net/templates/hBswiZB0M4Z

https://cloudstudio.net/templates/hQGhL1EYuEF

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DevOpsLifecycleYAMLSidecarCloud StudioWorkspace Templates
Tencent Cloud Developer
Written by

Tencent Cloud Developer

Official Tencent Cloud community account that brings together developers, shares practical tech insights, and fosters an influential tech exchange community.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.