API Gateway Component

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

    tencent-apigateway

    Easily provision Tencent API Gateway using Serverless Components.

     
     

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

    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.

    3. Configure

    # serverless.yml
    
    restApi:
      component: "@serverless/tencent-apigateway"
      inputs:
        region: ap-shanghai
        protocol: http
        serviceName: serverless
        environment: release
        endpoints:
          - path: /users
            method: POST
            function:
              functionName: myFunction

    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 ─ Starting API-Gateway deployment with name restApi in the ap-shanghai region
      DEBUG ─ Service with ID service-g1ihx7c7 created.
      DEBUG ─ API with id api-4dv8r7wg created.
      DEBUG ─ Deploying service with id service-g1ihx7c7.
      DEBUG ─ Deployment successful for the api named restApi in the ap-shanghai region.
    
      restApi: 
        protocol:    http
        subDomain:   service-g1ihx7c7-1300415943.ap-shanghai.apigateway.myqcloud.com
        environment: release
        region:      ap-shanghai
        serviceId:   service-g1ihx7c7
        apis: 
          - 
            path:   /users
            method: POST
            apiId:  api-4dv8r7wg
    
      24s › restApi › done
    

     

    5. Remove

    $ sls remove --debug
    
      DEBUG ─ Flushing template state and removing all components.
      DEBUG ─ Removing any previously deployed API. api-4dv8r7wg
      DEBUG ─ Removing any previously deployed service. service-g1ihx7c7
    
      13s › restApi › done
    

    New to Components?

    Checkout the Serverless Components repo for more information.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help