Creating an origin group
To create an origin group:
- In the management console
, select the folder to host your origin group. - Select Cloud CDN.
-
If the CDN provider is not activated yet, click Connect to provider. CDN will be enabled automatically.
If you do not see the Connect to provider button but you can create resources and origin groups, it means the provider is already activated. Proceed to the next step.
- 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:
Active
orBackup
. For more information about priorities, see Origin groups. - Add other origins if needed.
- Specify the Origin type:
- Click Create.
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.
-
If you have not created origin groups before, connect to the provider first:
yc cdn provider activate --type gcore
-
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=true
Where
--origin
is 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: true
For more information about the
yc cdn origin-group create
command, see the CLI reference.
Make sure to activate the CDN provider before creating an origin group. You can activate it in the management console
yc cdn provider activate \
--folder-id <folder_ID> \
--type gcore
Where:
--folder-id
: ID of the folder where you want to activate the CDN provider.--type
: Provider type. The only possible value isgcore
.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the documentation on the Terraform
If you do not have Terraform yet, install it and configure its Yandex Cloud provider.
-
Define the parameters of the
yandex_cdn_origin_group
resource in the configuration file.Here is an example of the configuration file structure:
resource "yandex_cdn_origin_group" "my_group" { name = "<origin_group_name>" use_next = true 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.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 article
. -
Create the resources:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validate
If the configuration is correct, you will get this message:
Success! The configuration is valid.
-
Run this command:
terraform plan
You will see a detailed list of resources. No changes will be made at this step. Terraform will show any errors found in your configuration.
-
Apply the changes:
terraform apply
-
Type
yes
and press Enter to confirm the changes.
Terraform will create all required resources. You can check the new CDN resource using the management console
or this CLI command:yc cdn origin-group list
-
If you have not created any origin groups before, connect to the CDN provider. To do this, use the activate REST API method for the Provider resource or the ProviderService/Activate gRPC API call.
Use the create REST API method for the OriginGroup resource or the OriginGroupService/Create gRPC API call.