README
Tencent CDN Component
Easily provision Tencent CDN using Serverless Components.
1. Install
Install the Serverless Framework:
$ npm install -g serverless
2. Create
Just create the following simple boilerplate:
$ touch serverless.yml
$ touch .env # your Tencent api keys
Add the access keys of a Tencent CAM Role with AdministratorAccess
in the .env
file, using this format:
# .env
TENCENT_SECRET_ID=XXX
TENCENT_SECRET_KEY=XXX
- If you don't have a Tencent Cloud account, you could sign up first.
Also should goto CDN Service Page, and open CDN service。
3. Configure
# serverless.yml
MyCDN:
component: '@serverless/tencent-cdn'
inputs:
host: abc.com
hostType: cos
origin: ww.test.com
backupOrigin: ww.test.com
serviceType: web
fullUrl: on
fwdHost: ww.test.com
https:
cert: 123
privateKey: 123
http2: off
httpsType: 2
forceSwitch: -2
4. Deploy
$ sls --debug
DEBUG ─ Resolving the template's static variables.
DEBUG ─ Collecting components from the template.
DEBUG ─ Downloading any NPM components found in the template.
DEBUG ─ Analyzing the template's components dependencies.
DEBUG ─ Creating the template's components graph.
DEBUG ─ Syncing template state.
DEBUG ─ Executing the template's components graph.
DEBUG ─ The CDN domain fullstack.yugasun.com has existed. Updating...
DEBUG ─ Waiting for CDN deploy success...
DEBUG ─ CDN deploy success to host: fullstack.yugasun.com
DEBUG ─ Setup https for fullstack.yugasun.com...
MyCDN:
host: fullstack.yugasun.com
origin: rahbqkq-a81kuv2-1251556596.cos-website.ap-guangzhou.myqcloud.com
hostId: 1714502
https: true
100s › MyCDN › done
5. Remove
$ sls remove --debug
DEBUG ─ Flushing template state and removing all components.
DEBUG ─ Start removing CDN for fullstack.yugasun.com
DEBUG ─ Waiting for offline fullstack.yugasun.com...
DEBUG ─ Removing CDN for fullstack.yugasun.com
DEBUG ─ Removed CDN for fullstack.yugasun.com.
73s › MyCDN › done
New to Components?
Checkout the Serverless Components repo for more information.