Appendix: Shared COS Bucket (ExternalStorage)
The number of COS buckets under a single Tencent Cloud account has an account-level quota limit. When the platform needs to create more than 150 environments under a single account, if each environment is automatically allocated an independent COS bucket, the quota will be reached and environment creation will fail.
In this case, you can pass ExternalStorage in CreateEnv so that multiple environments share the same external COS bucket: the environment no longer automatically allocates an independent bucket, but mounts the specified bucket as the cloud storage medium of the environment, and uses the BasePath prefix to isolate file directories between environments.
ExternalStorage Field Description
| Field | Required | Type | Description |
|---|---|---|---|
BucketName | Yes | String | Name of the shared COS bucket, for example tcb-ext-stor-1257619089 |
Region | Yes | String | Region of the bucket, for example ap-shanghai |
BasePath | Yes | String | Base path. After binding, when users access files in cloud storage, the backend automatically prepends BasePath as a prefix, which is used for directory isolation within the bucket |
Enabled | No | Boolean | Whether to enable external storage; pass true to enable it |
This parameter only takes effect when
Resourcescontainsstorage.
Call Example
const tencentcloud = require("tencentcloud-sdk-nodejs");
const TcbClient = tencentcloud.tcb.v20180608.Client;
const client = new TcbClient({
credential: {
secretId: process.env.TENCENTCLOUD_SECRETID,
secretKey: process.env.TENCENTCLOUD_SECRETKEY,
},
profile: {
httpProfile: {
endpoint: "tcb.tencentcloudapi.com",
},
},
});
client
.CreateEnv({
PackageId: "baas_personal",
Alias: "tenant-a-env",
Resources: ["storage"],
ExternalStorage: {
Enabled: true,
BucketName: "tcb-ext-stor-1257619089",
Region: "ap-shanghai",
BasePath: "ext-storage-v1",
},
Period: 1,
})
.then(
(resp) => {
console.log(resp.EnvId);
},
(err) => {
console.error("error", err);
},
);
Confirm It Takes Effect
After the environment is created, you can confirm the shared bucket has taken effect through Storages[0].Bucket returned by DescribeEnvs.