Todos os produtos
Search
Central de documentação

CDN:Exemplo de integração com o ROS

Última atualização: Jul 03, 2026

Use o Resource Orchestration Service (ROS) para chamar operações do Alibaba Cloud CDN. Escreva um modelo do ROS para adicionar automaticamente um nome de domínio acelerado do Alibaba Cloud CDN.

Recursos compatíveis

O Resource Orchestration Service (ROS) simplifica o gerenciamento de recursos em nuvem. Escreva modelos para definir recursos da Alibaba Cloud, como instâncias ECS e instâncias de banco de dados RDS, além de suas dependências. O mecanismo de orquestração do ROS cria e configura automaticamente todos os recursos definidos, permitindo a implantação e a operação e manutenção automatizadas. Para mais informações, consulte O que é o Resource Orchestration Service.

O ROS oferece suporte aos seguintes tipos de recursos do Alibaba Cloud CDN: recursos regulares e recursos de source de dados.

Permissões

Este exemplo adiciona um nome de domínio acelerado. Por padrão, o Resource Orchestration Service usa as credenciais do usuário atual, que deve ter as seguintes permissões:

  • AliyunCDNFullAccess: Concede acesso total aos recursos do Alibaba Cloud CDN.

Por questões de segurança, use um usuário RAM em vez da sua conta Alibaba Cloud para acesso à API e operações rotineiras de operação e manutenção. O usuário RAM precisa ter permissões para gerenciar recursos do Alibaba Cloud CDN. Para mais informações, consulte Políticas de sistema para o Alibaba Cloud CDN.

Procedimento

Procedimento

  1. Faça login no console do ROS. Na barra de navegação superior, selecione a região desejada na lista suspensa de region.

  2. No painel de navegação à esquerda, clique em Stacks. Em seguida, escolha Create Stack > Use ROS.

    • Specify Template: Selecione Select an Existing Template.

    • Template Import Method: Selecione Enter Template Content.

  3. Em Template Content, selecione ROS e insira o código.

    Para consultar a sintaxe e os 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. Clique em Next.

  5. Na página Configure Parameters, defina os parâmetros e clique em Create.

  6. Verifique o status da pilha.

    O Status da pilha muda para CREATE_COMPLETE e a descrição do status exibe Stack CREATE completed successfully.

  7. Após a criação da pilha, valide a criação do recurso por meio de uma API, um SDK ou o console do Alibaba Cloud CDN.

    No console do Alibaba Cloud CDN, acesse a página Domain Management. O novo nome de domínio acelerado aparece com o status Enabled e o CNAME status definido como Configured.