Automatically activate Alibaba Cloud services

更新时间:
复制 MD 格式

Resource Orchestration Service (ROS) lets you activate one or more Alibaba Cloud services through a stack template. Add an ALIYUN::ROS::AutoEnableService resource to your template to activate services automatically, without enabling each one in its own console.

Prerequisites

Before you begin, ensure that you have:

  • An Alibaba Cloud account with access to the ROS console

  • Reviewed the billing details of each cloud service you want to activate

Supported services

Each supported service has a corresponding ServiceName value in ALIYUN::ROS::AutoEnableService. For the full list, see ALIYUN::ROS::AutoEnableService.

Activate a single service

This example activates Simple Log Service (SLS). To activate a different service, change the Default value under ServiceName to the target service code, such as OSS for Object Storage Service.

  1. Log in to the ROS console.

  2. In the left-side navigation pane, click Stacks.

  3. In the top navigation bar, select the region where you want to create the stack, such as China (Hangzhou).

  4. On the Stacks page, click Create Stack. In the Specify Template section, click Select an Existing Template.

    Note
    • If you select Create Template or ROS Infrastructure Composer, you are redirected to the corresponding page.

    • If you select Synchronize Template from Code Repository, see Manage stacks by using a code repository.

  5. In the Select Template step, select Select an Existing Template in the Specify Template section. Set Template Import Method to Enter Template Content, paste the following YAML template into the Template Content code editor, and then click Next.

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      ServiceName:
        Type: String
        Default: SLS
    Resources:
      AutoEnableService:
        Type: ALIYUN::ROS::AutoEnableService
        Properties:
          ServiceName:
            Ref: ServiceName
    
  6. In the Configure Parameters step, specify Stack Name.

  7. Click Create.

After the stack is created, log on to the Simple Log Service console and confirm that the service is available.

Activate multiple services

This example activates Simple Log Service and Object Storage Service (OSS) together. The ServiceName parameter takes a JSON array of service codes, and the template iterates over the array with built-in functions.

  1. Log in to the ROS console.

  2. In the left-side navigation pane, click Stacks.

  3. In the top navigation bar, select the region where you want to create the stack, such as China (Hangzhou).

  4. On the Stacks page, click Create Stack. In the Specify Template section, click Select an Existing Template.

    Note
    • If you select Create Template or ROS Infrastructure Composer, you are redirected to the corresponding page.

    • If you select Synchronize Template from Code Repository, see Manage stacks by using a code repository.

  5. In the Select Template step, select Select an Existing Template in the Specify Template section, set Template Import Method to Enter Template Content, paste the following YAML template into the Template Content code editor, and then click Next.

    The following table describes the template functions that this example uses.

    Function Purpose
    Fn::Length Returns the number of items in the ServiceName array. Count uses this value to create one AutoEnableService resource per service.
    ALIYUN::Index A pseudo parameter that resolves to the current iteration index (0, 1, 2, ...).
    Fn::Select Picks the service code at the current index from the ServiceName array.

    For details on all template functions, see Functions.

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      ServiceName:
        Type: Json
        Default:
          - SLS
          - OSS
    Resources:
      AutoEnableService:
        Type: ALIYUN::ROS::AutoEnableService
        Properties:
          ServiceName:
            Fn::Select:
              - Ref: ALIYUN::Index
              - Ref: ServiceName
        Count:
          Fn::Length:
            Ref: ServiceName
    
  6. In the Configure Parameters step, specify Stack Name.

  7. Click Create.

After the stack is created, log on to each service console and confirm that the services are available: