Enabling file segmentation
To enable segmentation of resource files:
-
In the management console
, select the folder where your resource is located. -
Go to Cloud CDN.
-
Click the resource name.
-
Navigate to the Content tab.
-
At the top right, click
Edit. -
In the Segmentation of large files field, enable Optimize delivery.
-
Click Save.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
-
View the description of the CLI command to update a resource:
yc cdn resource update --help -
Get a list of all resources in the default folder:
yc cdn resource list --format yamlResult:
id: s0me1dkfjq******** folder_id: s0mef01der7p******** cname: testexample.com created_at: "2022-01-19T09:23:57.921365Z" updated_at: "2022-01-19T10:55:30.305141Z" active: true options: edge_cache_settings: enabled: true default value: "345600" cache_http_headers: enabled: true value: - content-type - content-length - connection - server - date - test stale: enabled: true value: - error - updating allowed_http_methods: value: - GET - POST - HEAD - OPTIONS origin_group_id: "89783" origin_group_name: My origins group origin_protocol: HTTP ssl_certificate: type: DONT_USE status: READY -
Enable file segmentation using the
--sliceflag set totrue:yc cdn resource update <resource_ID> --slice trueFor more information about the
yc cdn resource updatecommand, see the CLI reference.
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
In the configuration file, describe the properties of the CDN resource to create:
terraform { required_providers { yandex = { source = "yandex-cloud/yandex" version = "0.69.0" } } } provider "yandex" { token = "<OAuth_token>" cloud_id = "<cloud_ID>" folder_id = "<folder_ID>" zone = "<availability_zone>" } resource "yandex_cdn_resource" "my_resource" { cname = "cdn1.yandex-example.ru" active = false origin_protocol = "https" secondary_hostnames = ["cdn-example-1.yandex.ru", "cdn-example-2.yandex.ru"] origin_group_id = yandex_cdn_origin_group.my_group.id options { slice = true } }Where:
cname: Primary domain name used for content distribution. This is a required setting.active: Flag indicating content availability to end users.True: CDN content will be available to clients. This is an optional setting. The default value istrue.origin_protocol: Protocol for origins. This is an optional setting. The default value ishttp.secondary_hostnames: Additional domain names. This is an optional setting.origin_group_id: Origin group ID. This is a required setting. Use the ID from the description of the origin group in theyandex_cdn_origin_groupresource.- The
optionssection contains additional parameters of CDN resources:slice: Flag indicating whether segmentation will be used. This is an optional setting. The default value isfalse.
For more information about the
yandex_cdn_resourceproperties in Terraform, see the provider documentation. -
In the command line, go to the directory with the Terraform configuration file.
-
Check the configuration using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.You can check the CDN resource update in the management console
or using this CLI command:yc cdn resource list
Use the update REST API method for the Resource resource or the ResourceService/Update gRPC API call.
It may take up to 15 minutes for the new settings of the existing resource to apply to the CDN servers. After that, we recommend purging the resource cache.