Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
© 2022 Yandex.Cloud LLC
Yandex Cloud CDN
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Resources
      • Creating a resource
      • Editing basic settings of a resource
      • Configuring resource caching
      • Configuring log export
      • Pre-loading files to CDN servers
      • Purging resource cache
      • Configuring request and response headers
      • Configuring CORS for responses to clients
      • Configuring HTTP methods
      • Enabling file compression
      • Enabling file segmentation
      • Enabling origin shielding
      • Disabling a resource
      • Deleting a resource
    • Origin groups
      • Creating an origin group
      • Editing an origin group
      • Connecting an origin group to a resource
      • Deleting an origin group
  • Practical guidelines
    • Publishing game updates
    • Integrating an L7 load balancer with the CDN and Object Storage
    • Blue-green and canary deployment
  • Concepts
    • Service overview
    • Resource
    • Origins and origin groups
    • Exchanging data between clients and the CDN
      • Overview
      • TLS certificates
      • CORS
      • Compressing content
    • Exchanging data between the CDN and origins
      • Overview
      • Host header
      • Segmenting content
      • Origin shielding
    • Caching content
    • Exporting logs
    • Quotas and limits
  • Access management
  • Troubleshooting
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • CacheService
      • OriginGroupService
      • OriginService
      • ProviderService
      • RawLogsService
      • ResourceService
      • OperationService
    • REST
      • Overview
      • Cache
        • Overview
        • prefetch
        • purge
      • OriginGroup
        • Overview
        • create
        • delete
        • get
        • list
        • update
      • Origin
        • Overview
        • create
        • delete
        • get
        • list
        • update
      • Provider
        • Overview
        • activate
        • listActivated
      • RawLogs
        • Overview
        • activate
        • deactivate
        • get
        • update
      • Resource
        • Overview
        • create
        • delete
        • get
        • getProviderCName
        • list
        • update
  • Pricing policy
  1. Step-by-step instructions
  2. Origin groups
  3. Connecting an origin group to a resource

Connecting an origin group to a resource

Written by
Yandex Cloud
  • Connecting an origin group when creating a resource
  • Connecting an origin group when editing resource settings

To connect an origin group to the resource, under Content, select Origin group when creating or updating resource settings.

Connecting an origin group when creating a resource

Management console
CLI
Terraform
  1. In the management console, select the folder where you want to create a resource.

  2. Select Cloud CDN.

  3. Click Create resource.

  4. Under Content, select From origin group in the Content query field.

  5. Select an origin group.

  6. Specify the other resource settings. For more information, see Creating a resource.

  7. Click Create.

If you don't have the Yandex Cloud command line interface yet, install and initialize it.

The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name or --folder-id parameter.

  1. View a description of the CLI create resource command:

    yc cdn resource create --help
    
  2. Get a list of all origin groups in the default folder:

    yc cdn origin-group list --format yaml
    

    Result:

    - id: "90209"
      folder_id: b1g86q4m5vej8lkljme5
      name: test-group-1
      use_next: true
      origins:
      - id: "561547"
        origin_group_id: "90209"
        source: www.example2.com
        enabled: true
        backup: true
      - id: "561546"
        origin_group_id: "90209"
        source: www.example1.com
        enabled: true
    - id: "90208"
      folder_id: b1g86q4m5vej8lkljme5
      name: test-group
      use_next: true
      origins:
      - id: "561545"
        origin_group_id: "90208"
        source: www.a2.com
        enabled: true
        backup: true
      - id: "561544"
        origin_group_id: "90208"
        source: www.a1.com
        enabled: true
    
  3. Create a resource with the connected origin group:

    yc cdn resource create --cname <resource domain name> \
      --origin-group-id <origin group ID> \
      --origin-protocol https
    

    Where:

    • origin-group-id: Origin group ID.
    • origin-protocol: Origin protocol.

    Result:

    id: bc855oumelrqw3ceywih
    folder_id: b1g86q4m5vej8lkljme5
    cname: res1.example.com
    created_at: "2022-01-15T15:13:42.827643Z"
    updated_at: "2022-01-15T15:13:42.827671Z"
    active: true
    options:
      edge_cache_settings:
        enabled: true
        default_value: "345600"
      cache_http_headers:
        value:
        - accept-ranges
        - cache-control
        - connection
        - content-encoding
        - content-length
        - content-type
        - date
        - etag
        - expires
        - keep-alive
        - last-modified
        - server
        - vary
      stale:
        enabled: true
        value:
        - error
        - updating
      allowed_http_methods:
        value:
        - GET
        - POST
        - HEAD
        - OPTIONS
    origin_group_id: "90208"
    origin_group_name: test-group-22
    origin_protocol: HTTPS
    ssl_certificate:
      type: DONT_USE
      status: READY
    

    For more information about the yc cdn resource create command, see the CLI reference.

If you don't have Terraform, install it and configure the Yandex Cloud provider.

  1. Describe the resource parameters in the yandex_cdn_resource configuration file.

    Example configuration file structure:

    provider "yandex" {
      token     = "<OAuth>"
      cloud_id  = "<cloud ID>"
      folder_id = "<folder ID>"
      zone      = "<default availability zone>"
    }
    
    resource "yandex_cdn_resource" "my_resource" {
      cname = "<resource domain name>"
      active = true
      origin_protocol = "https"
      origin_group_id = <origin group ID>
    }
    

    For more information about the resources you can create using Terraform, see the provider documentation.

  2. Make sure the settings are correct.

    1. Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.

    2. Run the command:

      terraform validate
      

      If there are errors in the configuration files, Terraform will point to them.

  3. Create an origin group.

    1. Run the command to view planned changes:

      terraform plan
      

      If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.

    2. If you are happy with the planned changes, apply them:

      1. Run the command:

        terraform apply
        
      2. Confirm the update of resources.

      3. Wait for the operation to complete.

Connecting an origin group when editing resource settings

Management console
CLI
  1. In the management console, select the folder where you a resource is located.

  2. Select Cloud CDN.

  3. Click the name of the desired resource.

  4. In the top right-hand corner, click Edit.

  5. Select an origin group.

  6. Enter the other resource settings if needed. For more information, see Editing the basic settings of a resource.

  7. Click Save.

If you don't have the Yandex Cloud command line interface yet, install and initialize it.

The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name or --folder-id parameter.

  1. View a description of the CLI update resource command:

    yc cdn resource update --help
    
  2. Get a list of all resources in the default folder:

    yc cdn resource list --format yaml
    

    Result:

    - id: bc82xll34xuc4kymnpqq
      folder_id: b1g86q4m5vej8lkljme5
      cname: res1.example.com
      created_at: "2022-01-21T08:17:48.850086Z"
      updated_at: "2022-01-21T08:17:48.850125Z"
      active: true
      options:
        edge_cache_settings:
          enabled: true
          default_value: "345600"
        cache_http_headers:
          value:
          - accept-ranges
          - cache-control
          - connection
          - content-encoding
          - content-length
          - content-type
          - date
          - etag
          - expires
          - keep-alive
          - last-modified
          - server
          - vary
        stale:
          enabled: true
          value:
          - error
          - updating
        allowed_http_methods:
          value:
          - GET
          - POST
          - HEAD
          - OPTIONS
      origin_group_id: "90208"
      origin_group_name: test-group
      origin_protocol: HTTPS
      ssl_certificate:
        type: DONT_USE
        status: READY
    
  3. Get a list of all origin groups in the default folder and select the ID of the appropriate group:

    yc cdn origin-group list --format yaml
    

    Result:

    - id: "90209"
      folder_id: b1g86q4m5vej8lkljme5
      name: test-group-1
      use_next: true
      origins:
      - id: "561547"
        origin_group_id: "90209"
        source: www.example2.com
        enabled: true
        backup: true
      - id: "561546"
        origin_group_id: "90209"
        source: www.example1.com
        enabled: true
    - id: "90208"
      folder_id: b1g86q4m5vej8lkljme5
      name: test-group
      use_next: true
      origins:
      - id: "561545"
        origin_group_id: "90208"
        source: www.a2.com
        enabled: true
        backup: true
      - id: "561544"
        origin_group_id: "90208"
        source: www.a1.com
        enabled: true
    
  4. Update resource settings by specifying the ID of the appropriate origin group:

    yc cdn resource update --id <resource ID> \
      --origin-group-id <origin group ID>
    

    Result:

    id: bc8krsk72icwnvyvs6c3
    folder_id: b1g86q4m5vej8lkljme5
    cname: res2.example.com
    created_at: "2022-01-15T15:29:19.103653Z"
    updated_at: "2022-01-15T15:33:22.819916Z"
    active: true
    options:
      edge_cache_settings:
        enabled: true
        default_value: "345600"
      cache_http_headers:
        value:
        - accept-ranges
        - cache-control
        - connection
        - content-encoding
        - content-length
        - content-type
        - date
        - etag
        - expires
        - keep-alive
        - last-modified
        - server
        - vary
      stale:
        enabled: true
        value:
        - error
        - updating
      allowed_http_methods:
        value:
        - GET
        - POST
        - HEAD
        - OPTIONS
    origin_group_id: "90209"
    origin_group_name: test-group-1
    origin_protocol: HTTPS
    ssl_certificate:
      type: DONT_USE
      status: READY
    

    For more information about the yc cdn resource update command, see the CLI reference.

It may take up to 15 minutes for the new resource settings to apply to CDN servers. After that, we recommend purging the resource cache.

Was the article helpful?

Language / Region
© 2022 Yandex.Cloud LLC
In this article:
  • Connecting an origin group when creating a resource
  • Connecting an origin group when editing resource settings