This document describes how to use Tencent Cloud SCF to create two functions in order to regularly store CDN logs into COS.
This document describes how to create the "storage" and "task distribution" functions, use them together, and configure a timer trigger in order to regularly store CDN logs into COS.
There are four key steps:
A. Prepare the Tencent Cloud API access key and COS information
B. Create the storage function (cdn-save-log-into-cos)
C. Create the task function (cdn-dispatch-log-jobs)
D. Configure the timer
Go to the access key management page, query or create a key, and record the following information:
Access credential name (SecretId
), such as AKIDRVI54XXn10r58oZpmzbBOnwt47xO1LRv
Access credential key (SecretKey
), such as 3t0SYPHRIpjmAAUPfKM8b4yXnff4Aq56
Log in to the COS Console, access the Bucket List to query or create a bucket, access the bucket to view its Basic Information, and record the following information:
Bucket name (Bucket Name
), such as examples-1251002854
Bucket region (Region
), such as ap-chengdu
Log in to the SCF Console and click Function Service.
Select Create and enter cdn-save-log-into-cos as the function name.
Select Function Template, search with the keyword "CDN", select the "cdn-save-log-into-cos" template, and click "Next" to access the function configuration page:
Click Complete to create the function.
Log in to the SCF Console and click Create.
Select Function Template, search with the keyword "CDN", and select the "cdn-dispatch-log-jobs" template.
Enter cdn-dispatch-log-jobs as the function name and click "Next".
Click Complete to create the function.
In the config
variable on row 143, enter the corresponding configuration information:
secret_id
, secret_key
, cos_region
, cos_bucket
, and scf_region
.scf_function
.cdn_host
is an empty array (i.e., the logs of all domain names under the account will be stored). If needed, you can enter the list of specified domain names.Click Save.
Click Test to check whether the code runs properly. After the testing program stops running, you can access the COS Console and check whether the corresponding logs are stored in COS.
After you create the two functions above, the list on the SCF Console will be as shown below:
Once you complete all the steps above, CDN logs will be regularly stored into COS.
Was this page helpful?