Tous les produits
Search
Centre de documentation

CDN:Exemple d'intégration ROS

Dernière mise à jour :Aug 18, 2026

Utilisez Resource Orchestration Service (ROS) pour appeler les opérations d'Alibaba Cloud CDN. Rédigez un modèle ROS pour ajouter automatiquement un nom de domaine accéléré Alibaba Cloud CDN.

Ressources prises en charge

Resource Orchestration Service (ROS) simplifie la gestion des ressources cloud. Vous pouvez rédiger des modèles pour définir les ressources Alibaba Cloud, telles que les instances ECS et les instances de base de données RDS, ainsi que leurs dépendances. Le moteur d'orchestration ROS crée et configure automatiquement toutes les ressources définies pour un déploiement et une exploitation/maintenance automatisés. Pour plus d'informations, consultez la rubrique Présentation de Resource Orchestration Service.

ROS prend en charge les types de ressources Alibaba Cloud CDN suivants : les ressources standard et les ressources de source de données.

Autorisations

Cet exemple ajoute un nom de domaine accéléré. Par défaut, Resource Orchestration Service utilise les identifiants de l'utilisateur actuel, qui doit disposer des autorisations suivantes :

  • AliyunCDNFullAccess : accorde un accès complet aux ressources Alibaba Cloud CDN.

Pour des raisons de sécurité, utilisez un utilisateur RAM plutôt que votre compte Alibaba Cloud pour l'accès API et les opérations d'exploitation et de maintenance courantes. L'utilisateur RAM doit disposer des autorisations nécessaires pour gérer les ressources Alibaba Cloud CDN. Pour plus d'informations, consultez la rubrique Politiques système pour Alibaba Cloud CDN.

Procédure

Procédure

  1. Connectez-vous à la console ROS. Dans la barre de navigation supérieure, sélectionnez la région souhaitée dans la liste déroulante region.

  2. Dans le volet de navigation de gauche, cliquez sur Stacks. Ensuite, choisissez Create Stack > Use ROS.

    • Specify Template : sélectionnez Select an Existing Template.

    • Template Import Method : sélectionnez Enter Template Content.

  3. Pour Template Content, sélectionnez ROS et saisissez le code.

    Pour connaître la syntaxe et les paramètres, consultez la rubrique 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 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

    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 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. Cliquez sur Next.

  5. Sur la page Configure Parameters, définissez les paramètres et cliquez sur Create.

  6. Vérifiez l'état de la pile.

    Le champ Status de la pile passe à CREATE_COMPLETE et la description de l'état est Stack CREATE completed successfully.

  7. Une fois la pile créée, vérifiez la création de la ressource à l'aide d'une API, d'un SDK ou de la console Alibaba Cloud CDN.

    Dans la console Alibaba Cloud CDN, accédez à la page Domain Management. Le nouveau nom de domaine accéléré apparaît avec un état Enabled et un état CNAME status configuré.