Todos los productos
Search
Centro de documentos

CDN:Ejemplo de integración con ROS

Última actualización: Sep 02, 2026

Utilice Resource Orchestration Service (ROS) para invocar operaciones de Alibaba Cloud CDN. Escriba una plantilla de ROS para agregar automáticamente un nombre de dominio acelerado de Alibaba Cloud CDN.

Recursos compatibles

Resource Orchestration Service (ROS) simplifica la gestión de recursos en la nube. Puede escribir plantillas para definir recursos de Alibaba Cloud, como instancias de ECS e instancias de base de datos de RDS, junto con sus dependencias. El motor de orquestación de ROS crea y configura automáticamente todos los recursos definidos para automatizar el despliegue y las tareas de operación y mantenimiento. Para obtener más información, consulte What is Resource Orchestration Service.

ROS admite los siguientes tipos de recursos de Alibaba Cloud CDN: recursos regulares y recursos de origen de datos.

Permisos

Este ejemplo agrega un nombre de dominio acelerado. De forma predeterminada, Resource Orchestration Service utiliza las credenciales del usuario actual, quien debe contar con los siguientes permisos:

  • AliyunCDNFullAccess: Otorga acceso total a los recursos de Alibaba Cloud CDN.

Por motivos de seguridad, utilice un usuario de RAM en lugar de su cuenta de Alibaba Cloud para acceder a la API y realizar tareas rutinarias de operación y mantenimiento. El usuario de RAM debe tener permisos para gestionar recursos de Alibaba Cloud CDN. Para obtener más información, consulte System policies for Alibaba Cloud CDN.

Procedimiento

Procedimiento

  1. Inicie sesión en la consola de ROS. En la barra de navegación superior, seleccione la región deseada en la lista desplegable de region.

  2. En el panel de navegación izquierdo, haga clic en Stacks. A continuación, elija Create Stack > Use ROS.

    • Specify Template: Seleccione Select an Existing Template.

    • Template Import Method: Seleccione Enter Template Content.

  3. En Template Content, seleccione ROS e introduzca el código.

    Para consultar la sintaxis y los parámetros, consulte ALIYUN::CDN::Domain.

    Formato YAML

    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 for image and small file downloads. download:
       acceleration for 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 the instance. Up to 20 tags can be added when the instance is created. A tag consists of a Key and a Value, and the 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

    Formato JSON

    {
     "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 for image and small file downloads. download: acceleration for 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 the instance. Up to 20 tags can be added when the instance is created. A tag consists of a Key and a Value, and the 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. Haga clic en Next.

  5. En la página Configure Parameters, establezca los parámetros y haga clic en Create.

  6. Compruebe el estado de la pila.

    El Status de la pila cambia a CREATE_COMPLETE y la descripción del estado es Stack CREATE completed successfully.

  7. Una vez creada la pila, compruebe la creación del recurso mediante una API, un SDK o la consola de Alibaba Cloud CDN.

    En la consola de Alibaba Cloud CDN, vaya a la página Domain Management. El nuevo nombre de dominio acelerado aparece con un estado Enabled y un CNAME status de Configured.