Custom domain name-related commands

Updated at:
Copy as MD

The FC component is an operation tool for Alibaba Cloud Function Compute (FC) built on Serverless Devs. Use it to manage custom domain names by running CLI commands that call the underlying FC API operations directly.

Prerequisites

Before you begin, ensure that you have:

Create a custom domain name

Synopsis:

sudo s cli fc api CreateCustomDomain \
  --region <region-id> \
  [--access <access-name>] \
  [--apiVersion <20210416 | 20160815>] \
  --body '{"domainName": "<domain-name>", "protocol": "<protocol-type>", "certConfig": "<cert-config>", "routeConfig": "<route-config>"}'

Parameters:

ParameterRequiredDescription
--regionYesThe region where resources are deployed. Example: cn-hangzhou
--access / -aNoThe alias of the key to use
--apiVersionNoThe API version. Valid values: 20210416, 20160815
--body.domainNameYesThe custom domain name
--body.protocolYesThe protocol type. Valid values: HTTP, HTTP,HTTPS
--body.certConfigYesThe HTTPS certificate configuration
--body.routeConfigYesThe route table that maps request paths to functions

Example:

To create a custom domain name with an HTTP route to a function:

sudo s cli fc api CreateCustomDomain \
  --region cn-hangzhou \
  --apiVersion 20210416 \
  --body '{
    "domainName": "41055826-1034354682****.example.com",
    "routeConfig": {
      "routes": [{
        "path": "/login/*",
        "serviceName": "mytest",
        "functionName": "mytest",
        "qualifier": "LATEST"
      }]
    }
  }'

For the full API reference, see CreateCustomDomain.

Delete a custom domain name

Synopsis:

sudo s cli fc api DeleteCustomDomain \
  --region <region-id> \
  [--access <access-name>] \
  [--apiVersion <20210416 | 20160815>] \
  --path '{"domainName": "<domain-name>"}'

Parameters:

ParameterRequiredDescription
--regionYesThe region where resources are deployed. Example: cn-hangzhou
--access / -aNoThe alias of the key to use
--apiVersionNoThe API version. Valid values: 20210416, 20160815
--path.domainNameYesThe custom domain name to delete

Example:

To delete a custom domain name:

sudo s cli fc api DeleteCustomDomain \
  --region cn-hangzhou \
  --path '{"domainName": "41055826-1034354682****.example.com"}'

For the full API reference, see DeleteCustomDomain.

Update a custom domain name

Synopsis:

sudo s cli fc api UpdateCustomDomain \
  --region <region-id> \
  [--access <access-name>] \
  [--apiVersion <20210416 | 20160815>] \
  --path '{"domainName": "<domain-name>"}' \
  --body '{"protocol": "<protocol-type>", "certConfig": "<cert-config>", "routeConfig": "<route-config>"}'

Parameters:

ParameterRequiredDescription
--regionYesThe region where resources are deployed. Example: cn-hangzhou
--access / -aNoThe alias of the key to use
--apiVersionNoThe API version. Valid values: 20210416, 20160815
--path.domainNameYesThe custom domain name to update
--body.protocolYesThe protocol type. Valid values: HTTP, HTTP,HTTPS
--body.certConfigYesThe HTTPS certificate configuration
--body.routeConfigYesThe route table that maps request paths to functions

Example:

To update the route configuration of a custom domain name:

sudo s cli fc api UpdateCustomDomain \
  --region cn-hangzhou \
  --access default \
  --apiVersion 20210416 \
  --path '{"domainName": "41055826-1034354682****.example.com"}' \
  --body '{
    "routeConfig": {
      "routes": [{
        "path": "/login/*",
        "serviceName": "mytest",
        "functionName": "mytest",
        "qualifier": "LATEST"
      }]
    }
  }'

For the full API reference, see UpdateCustomDomain.

Query a custom domain name

Synopsis:

sudo s cli fc api GetCustomDomain \
  --region <region-id> \
  [--access <access-name>] \
  [--apiVersion <20210416 | 20160815>] \
  --path '{"domainName": "<domain-name>"}'

Parameters:

ParameterRequiredDescription
--regionYesThe region where resources are deployed. Example: cn-hangzhou
--access / -aNoThe alias of the key to use
--apiVersionNoThe API version. Valid values: 20210416, 20160815
--path.domainNameYesThe custom domain name to query

Example:

To query the details of a custom domain name:

sudo s cli fc api GetCustomDomain \
  --region cn-hangzhou \
  --path '{"domainName": "41055826-1034354682****.example.com"}'

For the full API reference, see GetCustomDomain.

List custom domain names

Synopsis:

sudo s cli fc api ListCustomDomains \
  --region <region-id> \
  [--access <access-name>] \
  [--apiVersion <20210416 | 20160815>] \
  [--query '{"limit": "<limit>", "nextToken": "<token>", "prefix": "<prefix>", "startKey": "<start-key>"}']

Parameters:

ParameterRequiredDescription
--regionYesThe region where resources are deployed. Example: cn-hangzhou
--access / -aNoThe alias of the key to use
--apiVersionNoThe API version. Valid values: 20210416, 20160815
--query.limitNoThe maximum number of results to return
--query.nextTokenNoThe pagination token from a previous response. Omit in the first request
--query.prefixNoFilters results to domain names that start with this prefix
--query.startKeyNoReturns results alphabetically starting from this key (inclusive)

Example:

To list the first 10 custom domain names in a region:

sudo s cli fc api ListCustomDomains \
  --region cn-hangzhou \
  --query '{"limit": "10"}'

For the full API reference, see ListCustomDomains.