Creating an origin group
To create an origin group:
- In the management console
, select the folder to host your origin group. - Go to Cloud CDN.
- In the left-hand panel, select
Origin groups. - Click Create origin group.
- Enter a name for the origin group.
- Configure Origin:
- Specify the Origin type:
Server,Bucket, orL7 load balancer. For more information about types, see Origins and origin groups. - Specify an origin.
- Select the Priority:
ActiveorBackup. For more information about priorities, see Origin groups. - Add other origins if needed.
- Specify the Origin type:
- Select the CDN provider. Always set it to
Yandex Cloud CDN. - Click Create.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
-
View the description of the CLI command to create an origin group:
yc cdn origin-group create --help -
Create an origin group in the default folder:
yc cdn origin-group create --name <origin_group_name> \ --origin source=<origin_IP_address_or_domain_name>,enabled=true \ --origin source=<origin_IP_address_or_domain_name>,enabled=true,backup=trueWhere
--originis the origin specification:source: Origin IP address or domain name.enabled: Flag showing whether the origin is enabled.backup: Flag showing whether the origin as a backup one. For more information about priorities, see Origin groups.
Result:
id: "89018" folder_id: b1g86q4m5vej******** name: test-group use_next: true origins: - id: "559295" origin_group_id: "89018" source: www.example2.com enabled: true backup: true - id: "559294" origin_group_id: "89018" source: www.example1.com enabled: trueFor more information about the
yc cdn origin-group createcommand, see the CLI reference.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
Define the parameters of the
yandex_cdn_origin_groupresource in the configuration file.resource "yandex_cdn_origin_group" "my_group" { name = "<origin_group_name>" use_next = true provider_type = "<CDN_provider>" origin { source = "<origin_1_IP_address_or_domain_name>" } origin { source = "<origin_2_IP_address_or_domain_name>" } origin { source = "<origin_3_IP_address_or_domain_name>" backup = false } }Where:
name: Origin group name.use_next: Indicates whether to use the next origin on the list.provider_type: CDN provider. This is an optional setting. The only possible value isourcdn, the Yandex Cloud CDN provider.origin: Origin specification:source: Origin IP address or domain name.enabled: Flag showing whether the origin is enabled.backup: Flag showing whether the origin as a backup one. For more information about priorities, see Origin groups.
For more information about the resources you can create with Terraform, see this provider guide.
-
Create the resources:
-
In the terminal, navigate to the configuration file directory.
-
Make sure the configuration is correct using this command:
terraform validateIf the configuration is valid, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
-
Apply the configuration changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
Terraform will create all the required resources. You can check the new CDN resource using the management console
or this CLI command:yc cdn origin-group list -
Use the create REST API method for the OriginGroup resource or the OriginGroupService/Create gRPC API call.