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:
org: orgDemo
app: appDemo
stage: dev
component: vpc
name: vpcDemo
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.
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:
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?