How to Create Orchestration Service Resource Stack using Templates

ROS can automatically create and configure all resources for automatic deployment, operation, and maintenance according to your template.

Alibaba Cloud Resource Orchestration Service (ROS) is a service that helps you simplify the cloud computing resource management and automate O&M. After compiling a resource stack template, define what cloud resources you need, the dependency between the resources, and the resource configurations.

With the orchestration engine, ROS can automatically create and configure all resources for automatic deployment, operation, and maintenance according to your template. An orchestration template is a text file in JSON format that you can read and edit at any time. You can compile your template in JSON directly, or you can use Visual Editor in the ROS console to compile the template more visually. You can control the template version with tools such as SVN or Git.

You can also enable IAC (Infrastructure as Code) using API, SDK, and other methods to integrate the orchestration capabilities of ROS into your own applications.

Resource Orchestration Service (ROS) uses a template to create a group of Alibaba Cloud resources. This group of resources is defined as a resource stack, or a stack. ROS manages and maintains this group of resources through the resource stack.

You can customize Alibaba Cloud resources such as security groups, Elastic Cloud Service (ECS) instances, Virtual Private Clouds (VPCs), and ApsaraDB for RDS (RDS) instances in your template.

Procedure

  1. Log on to the ROS console.
  2. Click Sample Template in the left-side navigation pane. Find the template named simple_ecs_instance.
  3. Click Preview and the template appears as a JSON file.

    The contents of simple_ecs_instance are as follows:

    { "ROSTemplateFormatVersion": "2015-09-01", "Description": "A simple ECS instance with a security group and a VSwitch in a VPC. You need to specify an image ID.", "Parameters": { "ImageId": { "Type": "String", "Description": "ImageId is the unique identifier of the image that is required by the ECS instance.", "Label": "ECS Image ID", "Default": "centos_7", }, "InstanceType": { "Type": "String", "Description": "Type of the ECS instance" "Label": "ECS Instance Type", "Default": "ecs.c5.large", "AllowedValues": [ "ecs.c5.large", "ecs.g5.large", "ecs.c5.xlarge", "ecs.g5.xlarge" ] }, "Password": { "Type": "String", "Description": "Login password of the ECS instance", "ConstraintDescription": "The password must be 8 to 30 characters in length and consist of letters, numbers, and special characters.", "Label": "ECS Instance Password", "MaxLength": "30", "MinLength": "8", "AllowedPattern": "[a-zA-Z0-9-\\(\\)\\`\\~\\! @\\#\\$%\\^&\\*-+=\\|\\{\\}\\[\\]\\:\\;\\‘\\,\\. \\? \\/]*", "NoEcho": true, "Confirm": true } }, "Resources": { "WebServer": { "Type": "ALIYUN::ECS::Instance", "Properties": { "ImageId": { "Ref": "ImageId" }, "InstanceType": { "Ref": "InstanceType" }, "SecurityGroupId": { "Ref": "SecurityGroup" }, "PrivateIpAddress": "192.168.0.1", "VSwitchId": { "Ref": "vswitch" }, "VpcId": { "Ref": "vpc" }, "Password": { "Ref": "Password" } } }, "vswitch": { "Type": "ALIYUN::ECS::VSwitch", "Properties": { "VpcId": { "Ref": "vpc" }, "ZoneId": { "Fn::Select": [ "0", { "Fn::GetAZs": { "Ref": "ALIYUN::Region" } } ] }, "CidrBlock": "192.168.0.0/16", } }, "SecurityGroup": { "Type": "ALIYUN::ECS::SecurityGroup", "Properties": { "VpcId": { "Ref": "vpc" } } }, "vpc": { "Type": "ALIYUN::ECS::VPC", "Properties": { "CidrBlock": "192.168.0.0/16", "VpcName": "simple_ecs_vpc" } } }, "Outputs": { "InstanceId": { "Description": "Instance ID of the created ECS instance", "Value": { "Fn::GetAtt": [ "WebServer", "InstanceId": ] } }, "PublicIp": { "Description": "Public IP address of the created ECS instance", "Value": { "Fn::GetAtt": [ "WebServer", "PublicIp": { ] } }, "SecurityGroupId": { "Description": "ID of the security group.", "Value": { "Fn::GetAtt": [ "SecurityGroup", "SecurityGroupId" ] } } } }

    This template contains five top-level objects:

    • "ROSTemplateFormatVersion" indicates the version of the template.
    • "Description" is a description of the template.
    • "Parameters":{ } defines the parameters of the template. This example defines parameters such as the image ID, instance type, among other parameters. It also specifies the default values of these parameters.
    • "Resources":{ } defines the Alibaba Cloud resources that the template intends to 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 resource stack is created. This example defines ECS instance ID, public IP address, and security group ID as outputs.
  4. Click Create stack to start creating your resource stack.
  5. Select a region from the Region drop-down list. Click Next to continue.
  6. Enter a name for the stack in the Stack Name field. Click Create.
  7. Click Stack Management in the left-side navigation pane. The Stack Management page appears.
  8. Find your template and click Manage in the Operation column. The Stack Overview page appears.
    • Click Overview in the left-side navigation pane to view the stack overview.
    • Click Resources in the left-side navigation pane to view all resources in the stack.
    • Click Event in the left-side navigation pane to view all events in the lifecycle of the stack. If any operation fails, the specific cause of failure is displayed here.
    • Click Template in the left-side navigation pane to view the content of the template.

If your template fails the validation process, see one of the following:

Format:

Make sure that the template is a valid JSON file with UTF-8 encoding. Valid means that content can be correctly interpreted as JSON.

Version (ROSTemplateFormatVersion)

Make sure ROSTemplateFormatVersion is correctly spelled and the value is 2015-09-01.

Mappings

Make sure that mapping definitions meets the Resource Orchestration Service (ROS) requirements.

Parameters

Make sure that parameter definitions meet the ROS requirements.

Functions cannot be used in parameters. If the parameter definition contains a constraint and a default value, the default value must also conform to the parameter constraint.

Resources

Resource ID cannot contain the slash (/) characters.

A resource definition must contain a Type with a String value.

A resource definition must not contain anything other than Type, Properties, Metadata, DependsOn, DeletionPolicy and Description.

Outputs

An output must have a value defined.

Unsupported resource type

If the template contains unsupported resources, validation fails.

Others

Make sure the size of the template file is no larger than 512 KB.

Make sure the template does not contain any top-level object other than ROSTemplateFormatVersion, Description, Mappings, Parameters, Resources, and Outputs.

 

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More