All Products
Search
Document Center

CDN:Resource integration by using ROS

Last Updated:Sep 04, 2024

You can use Resource Orchestration Service (ROS) to call API operations of Alibaba Cloud CDN. This topic describes how to create an ROS template and use the template to automatically add a domain name to Alibaba Cloud CDN.

Supported resources

ROS is an Alibaba Cloud service that simplifies the management of cloud computing resources. You can create a template to describe the cloud computing resources that you want to use, such as Elastic Compute Service (ECS) and ApsaraDB RDS instances, and the relationship between the resources. ROS automatically creates and configures all resources based on the template to implement automated deployment and O&M. For more information, see What is ROS?

You can use ROS to call API operations of Alibaba Cloud CDN. Resources that can be orchestrated by using ROS include regular resources and data resources.

Permissions

In this example, you need to add a domain name. By default, Resource Orchestration Service uses the credentials of the user who logs on to the ROS console. The user must be granted the following permissions:

  • AliyunCDNFullAccess: full access to Alibaba Cloud CDN resources.

An Alibaba Cloud account has permissions on all API operations. Security risks may arise if you use an Alibaba Cloud account to call API operations. We strongly recommend that you call API operations or perform routine O&M as a RAM user. Before you call API operations as a RAM user, grant the required permissions to the RAM user based on your business requirements. The RAM user must have the permissions to manage Alibaba Cloud CDN resources. For more information, see Alibaba Cloud CDN system policies.

Procedure

  1. Log on to the ROS console. In the top navigation bar, select a region from the region drop-down list.

  2. In the left-side navigation pane, click Stacks. On the Stacks page, choose Create Stack > Use ROS.

    • Specify Template: Select Select an Existing Template.

    • Template Import Method: Select Enter Template Content.

  3. Template Content: Select ROS and then enter code.

    For more information about the syntax, description, and examples of how to add a domain name, see ALIYUN::CDN::Domain.

    YAML format

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
     CdnType:
      AllowedValues:
      - video
      - download
      - web
      - liveStream
      Description: 'The business type. Valid values: web, download, video, livestream,
       and httpsdelivery. web: acceleration of images and small files download. download:
       acceleration of large file downloads. video: live streaming acceleration. httpsdelivery:
       SSL acceleration for HTTPS.'
      Type: String
     CheckUrl:
      Description: The validation of the origin.
      Type: String
     DomainName:
      Description: The CDN domain name. Wildcard domain names that start with periods
       (.) are supported. For example, .example.com.
      Type: String
     ResourceGroupId:
      Description: The ID of the resource group. If this is left blank, the system automatically
       fills in the ID of the default resource group.
      Type: String
     Scope:
      Description: 'Valid values: domestic, overseas, and global. Default value: domestic.
       The setting is supported for users outside mainland China, users in mainland
       China of level 3 or above.'
      Type: String
     Sources:
      Description: The list of origin URLs.
      Type: String
     Tags:
      Description: Tags to attach to instance. Max support 20 tags to add during create
       instance. Each tag with two properties Key and Value, and Key is required.
      MaxLength: 20
      Type: Json
     TopLevelDomain:
      Description: The top-level domain, which can only be configured by users on the
       whitelist.
      Type: String
    Resources:
     Domain:
      Properties:
       CdnType:
        Ref: CdnType
       CheckUrl:
        Ref: CheckUrl
       DomainName:
        Ref: DomainName
       ResourceGroupId:
        Ref: ResourceGroupId
       Scope:
        Ref: Scope
       Sources:
        Ref: Sources
       Tags:
        Ref: Tags
       TopLevelDomain:
        Ref: TopLevelDomain
      Type: ALIYUN::CDN::Domain
    Outputs:
     Cname:
      Description: The CNAME generated for the CDN domain.You must add a CNAME record
       with your DNS provider to map the CDN domain name to the CNAME.
      Value:
       Fn::GetAtt:
       - Domain
       - Cname
     DomainName:
      Description: The CDN domain name. Wildcard domain names that start with periods
       (.) are supported. For example, .example.com.
      Value:
       Fn::GetAtt:
       - Domain
       - DomainName

    JSON format

    {
     "ROSTemplateFormatVersion": "2015-09-01",
     "Parameters": {
      "CheckUrl": {
       "Type": "String",
       "Description": "The validation of the origin."
      },
      "ResourceGroupId": {
       "Type": "String",
       "Description": "The ID of the resource group. If this is left blank, the system automatically fills in the ID of the default resource group."
      },
      "Scope": {
       "Type": "String",
       "Description": "Valid values: domestic, overseas, and global. Default value: domestic. The setting is supported for users outside mainland China, users in mainland China of level 3 or above."
      },
      "DomainName": {
       "Type": "String",
       "Description": "The CDN domain name. Wildcard domain names that start with periods (.) are supported. For example, .example.com."
      },
      "CdnType": {
       "Type": "String",
       "Description": "The business type. Valid values: web, download, video, livestream, and httpsdelivery. web: acceleration of images and small files download. download: acceleration of large file downloads. video: live streaming acceleration. httpsdelivery: SSL acceleration for HTTPS.",
       "AllowedValues": [
        "video",
        "download",
        "web",
        "liveStream"
       ]
      },
      "TopLevelDomain": {
       "Type": "String",
       "Description": "The top-level domain, which can only be configured by users on the whitelist."
      },
      "Sources": {
       "Type": "String",
       "Description": "The list of origin URLs."
      },
      "Tags": {
       "Type": "Json",
       "Description": "Tags to attach to instance. Max support 20 tags to add during create instance. Each tag with two properties Key and Value, and Key is required.",
       "MaxLength": 20
      }
     },
     "Resources": {
      "Domain": {
       "Type": "ALIYUN::CDN::Domain",
       "Properties": {
        "CheckUrl": {
         "Ref": "CheckUrl"
        },
        "ResourceGroupId": {
         "Ref": "ResourceGroupId"
        },
        "Scope": {
         "Ref": "Scope"
        },
        "DomainName": {
         "Ref": "DomainName"
        },
        "CdnType": {
         "Ref": "CdnType"
        },
        "TopLevelDomain": {
         "Ref": "TopLevelDomain"
        },
        "Sources": {
         "Ref": "Sources"
        },
        "Tags": {
         "Ref": "Tags"
        }
       }
      }
     },
     "Outputs": {
      "DomainName": {
       "Description": "The CDN domain name. Wildcard domain names that start with periods (.) are supported. For example, .example.com.",
       "Value": {
        "Fn::GetAtt": [
         "Domain",
         "DomainName"
        ]
       }
      },
      "Cname": {
       "Description": "The CNAME generated for the CDN domain.You must add a CNAME record with your DNS provider to map the CDN domain name to the CNAME.",
       "Value": {
        "Fn::GetAtt": [
         "Domain",
         "Cname"
        ]
       }
      }
     }
    }
  4. Click Next.

  5. In the Configure Parameters step, configure the parameters and click Create.

  6. View the created stack.

    image

  7. After the stack is created, call API operations, use SDKs, or log on to the Alibaba Cloud CDN console to view the domain name.

    image