COS Component

Last updated: 2019-12-04 17:20:51

Tencent Cloud Object Storage Component

Instantly deploy & manage Tencent Cloud Object Storage buckets with Serverless Components.
 
 

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

 

1. Install

$ npm install -g serverless

2. Create

Just create serverless.yml and .env files

$ 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=123
TENCENT_SECRET_KEY=123
  • If you don't have a Tencent Cloud account, you could sign up first.

3. Configure

# serverless.yml

myBucket:
  component: '@serverless/tencent-cos'
  inputs:
    bucket: my-bucket
    region: ap-guangzhou

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 ─ Deploying "my-bucket-1300415943" bucket in the "ap-guangzhou" region.
  DEBUG ─ "my-bucket-1300415943" bucket was successfully deployed to the "ap-guangzhou" region.
  DEBUG ─ Setting ACL for "my-bucket-1300415943" bucket in the "ap-guangzhou" region.
  DEBUG ─ Ensuring no CORS are set for "my-bucket-1300415943" bucket in the "ap-guangzhou" region.
  DEBUG ─ Ensuring no Tags are set for "my-bucket-1300415943" bucket in the "ap-guangzhou" region.

  myBucket: 
    bucket: my-bucket-1300415943
    region: ap-guangzhou

  10s › myBucket › done

5. Remove

$ sls remove --debug

  DEBUG ─ Flushing template state and removing all components.
  DEBUG ─ Removing files from the "my-bucket-1300415943" bucket.
  DEBUG ─ Removing "my-bucket-1300415943" bucket from the "ap-guangzhou" region.
  DEBUG ─ "my-bucket-1300415943" bucket was successfully removed from the "ap-guangzhou" region.

  2s › myBucket › done

New to Components?

Checkout the Serverless Components repo for more information.