tencent cloud

All product documents
Serverless Application Center
VPC Component
Last updated: 2024-12-02 10:48:10
VPC Component
Last updated: 2024-12-02 10:48:10

Operation Scenarios

Tencent Cloud VPC component supports configuring serverless.yml to quickly create VPCs and subnets with specified names and output VPCID and SubnetID in order to facilitate the configuration of network information required by other components.

Directions

Installation

Install the latest version of Serverless Framework through npm:
$ npm install -g serverless

Configuration

Create a vpcDemo directory and create a serverless.yml file in it.
$ mkdir vpcDemo && cd vpcDemo
$ touch serverless.yml
Configure serverless.yml as follows:
# serverless.yml
org: orgDemo # Organization information, which is optional. The default value is the `appid` of your Tencent Cloud account.
app: appDemo # VPC application name, which is optional.
stage: dev # Information for identifying environment, which is optional. The default value is `dev`.

component: vpc # Name of the imported component, which is required. The `tencent-vpc` component is used in this example
name: vpcDemo # Name of the instance created by this component, which is required.

inputs:
region: ap-guangzhou
zone: ap-guangzhou-2
vpcName: serverless
subnetName: serverless

Deployment

Run sls deploy to deploy:
$ sls deploy
serverless ⚡ framework
Action: "deploy" - Stage: "dev" - App: "appDemo" - Instance: "vpcDemo"

region: ap-guangzhou
zone: ap-guangzhou-2
vpcId: vpc-xxxxxxxx
vpcName: serverless
subnetId: subnet-xxxxxxxx
subnetName: serverless


3s › vpcDemo › Success
Note:
sls is short for the serverless command.

Information viewing

Run sls info to view the information of successful deployment:
$ sls info

serverless ⚡ framework

Status: active
Last Action: deploy (5 minutes ago)
Deployments: 2

region: ap-guangzhou
zone: ap-guangzhou-2
vpcId: vpc-xxxxxxx
vpcName: serverless
subnetId: subnet-xxxxxxx
subnetName: serverless

vpcDemo › Info successfully loaded

Removal

You can run the following commands to remove the deployed VPC:
$ sls remove

serverless ⚡ framework
Action: "remove" - Stage: "dev" - App: "appDemo" - Instance: "vpcDemo"

6s › vpcDemo › Success

Account configuration (optional)

Currently, you can scan a QR code to log in to the CLI by default. If you want to configure persistent environment variables/key information, you can also create a local .env file:
$ touch .env # Tencent Cloud configuration information
Configure Tencent Cloud's SecretId and SecretKey information in the .env file and save it:
# .env
TENCENT_SECRET_ID=123
TENCENT_SECRET_KEY=123
Note:
If you don't have a Tencent Cloud account yet, please sign up first.
If you already have a Tencent Cloud account, you can get SecretId and SecretKey in API Key Management.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon