PostgreSQL for Serverless (ServerlessDB) is a PostgreSQL-based database product that enables on-demand allocation of resources. It can automatically allocate resources according to the actual number of requests. You can simply create a database instance to use PostgreSQL for Serverless without caring about instance specification, and you only need to pay for resource usage during active period of the instance.
Through the PostgreSQL ServerlessDB component, you can create, configure, and manage Tencent Cloud PostgreSQL instances with speed and ease.
Use npm to install Serverless CLI globally:
npm install -g serverless
.env file locally:
$ touch .env # Tencent Cloud configuration information
Configure Tencent Cloud's
SecretKey information in the
.env file and save it:
# .env TENCENT_SECRET_ID=123 TENCENT_SECRET_KEY=123
Create a directory and enter it:
$ mkdir tencent-postgreSQL && cd tencent-postgreSQL
serverless.yml file in the new directory:
serverless.yml as follows:
# serverless.yml component: postgresql # (Required) Name of the imported component. The `postgresql` component is used in this example name: serverlessDB # (Required) Name of the instance created by the `postgresql` component org: test # (Optional) Organization information. The default value is the `appid` of your Tencent Cloud account. app: serverlessDB # (Optional) SQL application name stage: dev # (Optional) Information for identifying environment. The default value is `dev`. inputs: region: ap-guangzhou # You can select `ap-guangzhou`, `ap-shanghai`, or `ap-beijing` zone: ap-guangzhou-2 # You can select `ap-guangzhou-2`, `ap-shanghai-2`, or `ap-beijing-3` dBInstanceName: serverlessDB vpcConfig: vpcId: vpc-xxxxxxx subnetId: subnet-xxxxxx extranetAccess: false
The PostgreSQL ServerlessDB component supports "zero" configuration deployment, that is, it can be deployed directly through the default values in the configuration file. Nonetheless, you can also modify more optional configuration items to further customize your project.
Currently, PostgreSQL for Serverless instances can be created and deployed only in Beijing Zone 3, Guangzhou Zone 2, and Shanghai Zone 2. Therefore, when entering the region and AZ in the YAML file, please be sure to enter a correct region and corresponding VPC and subnet information.
Deploy by running the
sls command, and you can add the
--debug parameter to view the information during the deployment process:
slsis short for the
$ sls deploy
You can run the following commands to remove the deployed database instance:
$ sls remove
You can view more component information in the repository of Serverless Components.