@serverless/tencent-layer

Tencent Cloud Layer Component

Usage no npm install needed!

<script type="module">
  import serverlessTencentLayer from 'https://cdn.skypack.dev/@serverless/tencent-layer';
</script>

README

Tencent Cloud Layer Component

npm NPM downloads

简体中文 | English

Introduction

Tencent Cloud Layer serverless component.

Content

  1. Install
  2. Create
  3. Configure
  4. Deploy
  5. Remove

1. Install

Install the Serverless Framework globally:

$ npm install -g serverless

2. Create

In project root, 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.

3. Configure

# serverless.yml
MyLayer:
  component: '@serverless/tencent-layer'
  inputs:
    region: ap-guangzhou
    name: test
    src: ./node_modules
    runtimes:
      - Nodejs8.9
    description: test project layer

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 ─ Compressing layer test file to /Users/yugasun/Desktop/Develop/serverless/tencent-layer/example/.serverless/test-layer.zip.
  DEBUG ─ Compressed layer test file successful
  DEBUG ─ Uploading layer package to cos[sls-cloudlayer-ap-guangzhou-layer]. sls-cloudlayer-test-1583823859.zip
  DEBUG ─ Creating layer test
  DEBUG ─ Created layer: test, version: 7 successful

  MyLayer:
    region:      ap-guangzhou
    name:        test
    description: test project layer
    runtimes:
      - Nodejs8.9
    licenseInfo:
    hash:        d41cdf04bd33315be0d87e8562de9dd8
    version:     7

  12s › MyLayer › done

Notice: sls is short for serverless command.

 

5. Remove

$ sls remove --debug

  DEBUG ─ Flushing template state and removing all components.
  DEBUG ─ Start removing layer: test, version: 7...
  DEBUG ─ Remove layer: test, version: 7 successfully

  6s › MyLayer › done

More Components

Checkout the Serverless Components repo for more information.