Alibaba Cloud Resource Orchestration Service (ROS) allows you to use templates to create groups of Alibaba Cloud resources. Such groups are called stacks. You can maintain Alibaba Cloud resources in groups by managing stacks.

Prerequisites

An Alibaba Cloud account is created. To create an Alibaba Cloud account, go to the Alibaba Cloud official website.

Background information

This topic describes how to create, manage, and maintain Alibaba Cloud resources in the ROS console. The simple_ecs_instance template is used in the example. ROS templates are text files in the JSON format. You can define Alibaba Cloud resources such as security groups, ECS instances, VPCs, and ApsaraDB for RDS instances in your template.

Procedure

  1. Log on to the ROS console.
  2. In the left-side navigation pane, choose Templates > Sample Templates.
  3. Enter simple_ecs_instance in the search box and find the sample template.
  4. Click View Details. The template appears as a JSON file.
    The simple_ecs_instance template contains the following content:
    {  
      "Description": "One simple ECS instance with a security group and a vSwitch in a VPC. The user only needs to specify the image ID.",  
      "Parameters": {    
        "ImageId": {      
          "Type": "String",      
          "Description": {        
            "en": "The image ID. For more information, see <a href='https://www.alibabacloud.com/help/doc-detail/112977.html' target='_blank'>Find an image</a>",        
          },      
          "Label": "ECS Image ID",      
          "Default": "centos_7"    
         },    
         "InstanceType": {      
           "Type": "String",      
           "Description": {        
             "en": "The ECS instance type. For more information, see <a href='https://www.alibabacloud.com/help/doc-detail/25378.html' target='_blank'>Instance families</a>."      
           "Label": "ECS Instance Type",      
           "Default": "ecs.c5.large"    
          },    
          "Password": {      
            "NoEcho": true,      
            "Type": "String",      
            "Description": {         
              "en": "It must be 8 to 30 characters in length. It must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. <br>Special characters include: ! @ # $ % ^ & * - + = | { } [ ] : ; ‘ < > , . ? /."
           },      
           "AllowedPattern": "[a-zA-Z0-9-\\(\\)\\`\\~\\! @\\#\\$%\\^&\\*-+=\\|\\{\\}\\[\\]\\:\\;\\'\\,\\. \\? \\/]*",      
           "Label": "Login Password",      
           "ConstraintDescription": "[8, 30] characters, consists of uppercase letter, lowercase letter, number or special characters.",      
           "MinLength": 8,      
           "MaxLength": 30    
           }  
         },  
         "ROSTemplateFormatVersion": "2015-09-01",  
         "Outputs": {    
           "InstanceId": {      
             "Description": "The instance id of created ecs instance",      
             "Value": {        
               "Fn::GetAtt": [          
                 "WebServer",          
                 "InstanceId"        
               ]      
            }    
          },    
          "PublicIp": {      
            "Description": "Public IP address of created ecs instance.",      
            "Value": {        
              "Fn::GetAtt": [          
                "WebServer",          
                "PublicIp"        
              ]     
             }    
           },    
           "SecurityGroupId": {      
             "Description": "Generated security group id for security group.",      
             "Value": {        
               "Fn::GetAtt": [          
                 "SecurityGroup",          
                 "SecurityGroupId"        
               ]
          }
        }
      },  
    "Resources": {
       "VSwitch": {
         "Type": "ALIYUN::ECS::VSwitch",
         "Properties": { 
           "VpcId": {
             "Ref": "VPC"
           }, 
           "ZoneId": { 
             "Fn::Select": [ 
               "0",  
               {  
                 "Fn::GetAZs": { 
                   "Ref": "ALIYUN::Region" 
                } 
               } 
             ]
           },  
           "CidrBlock": "192.168.XX.XX/16" 
         }
       }, 
       "WebServer": { 
         "Type": "ALIYUN::ECS::Instance",  
         "Properties": {
           "VpcId": { 
             "Ref": "VPC" 
           }, 
           "SecurityGroupId": { 
             "Ref": "SecurityGroup" 
           }, 
           "VSwitchId": { 
             "Ref": "VSwitch" 
           }, 
           "ImageId": { 
             "Ref": "ImageId" 
           }, 
           "InstanceType": { 
             "Ref": "InstanceType" 
           }, 
           "Password": { 
             "Ref": "Password" 
           } 
         } 
       }, 
       "VPC": { 
         "Type": "ALIYUN::ECS::VPC", 
         "Properties": { 
           "CidrBlock": "192.168.XX.XX/16", 
           "VpcName": "simple_ecs_vpc" 
         } 
       }, 
       "SecurityGroup": { 
         "Type": "ALIYUN::ECS::SecurityGroup", 
         "Properties": { 
           "VpcId": { 
             "Ref": "VPC" 
           } 
         } 
       } 
     }
    }
    This template contains five top-level objects:
    • "ROSTemplateFormatVersion" defines the version of the template.
    • "Description" defines the description of the template.
    • "Parameters": { } defines the parameters of the template. This example defines parameters such as ImageId and InstanceType, and specifies the default values of these parameters.
    • "Resources": { } defines the Alibaba Cloud resources that the template can create. This example defines an ECS instance and a security group with properties that are defined in Parameters.
    • "Outputs": { } defines property values that the stack can supply to external requests after the stack is created. This example defines the ECS instance ID, public IP address, and security group ID as outputs.
  5. Click Create Stack in the upper-right corner.
  6. In the Configure Template Parameters step, set the password and click Create.