Create resources with a template

Last Updated: Jul 26, 2017

Resource Orchestration Service (ROS) allows you to create a set of Alibaba Cloud resources based on templates. ROS defines, manages, and maintains the created set of Alibaba Cloud resources as a stack. This document uses a simple ROS template to create a set of Alibaba Cloud resources, and then manages and maintains them through the ROS console.

The ROS template is a JSON text file. You can declare and define your Alibaba Cloud Resources in the text, such as security groups, ECS, VPC, and RDS. The ROS Console offers some common Sample Templates. This example uses an existing sample template to create Alibaba Cloud resources.`

  1. An Alibaba Cloud account is required first. If you do not have one, go to the Alibaba Cloud Homepage and sign up.

  2. Go to the ROS Console. If you are using ROS for the first time, you must first read, and then indicate that you accept the ROS user agreement in order to activate ROS. ROS is a free service.

  3. In the upper left corner of the console, click Sample Template to go to the page that shows the common templates available in ROS. Find the sample template titled simple_ecs_instance and use it to create an ECS instance and add the ECS instance to a security group.


  4. Each sample template has two buttons: Preview and Create. Click Preview to show the JSON template. The details of the simple_ecs_instance template are as follows:

    1. {
    2. "ROSTemplateFormatVersion" : "2015-09-01",
    3. "Description": " A simple ECS instance includes a security group. You only need to designate an imageID.",
    4. "Parameters" : {
    5. "ImageId": {
    6. "Type" : "String",
    7. "Default": "centos7u2_64_40G_cloudinit_20160728.raw",
    8. "Description": " The image file ID indicates the image resources selected when the instance was started. <a href='#/product/cn-shenzhen/list/imageList' target='_blank'>View Image Resources</a>"
    9. },
    10. "InstanceType": {
    11. "Type": "String",
    12. "Description": " Resource type of the instance ",
    13. "Default": "ecs.s1.small",
    14. "AllowedValues": [
    15. "ecs.t1.small",
    16. "ecs.s1.small",
    17. "ecs.s1.medium",
    18. "ecs.s1.large",
    19. "ecs.s2.small",
    20. "ecs.s2.large",
    21. "ecs.s2.xlarge",
    22. "ecs.s2.2xlarge",
    23. "ecs.s3.medium",
    24. "ecs.s3.large",
    25. "ecs.m1.medium",
    26. "ecs.m2.medium",
    27. "ecs.m1.xlarge",
    28. "ecs.c1.small",
    29. "ecs.c1.large",
    30. "ecs.c2.medium",
    31. "ecs.c2.large",
    32. "ecs.c2.xlarge"
    33. ]
    34. }
    35. },
    36. "Resources" : {
    37. "WebServer": {
    38. "Type": "ALIYUN::ECS::Instance",
    39. "Properties": {
    40. "ImageId" : {"Ref": "ImageId"},
    41. "InstanceType": {"Ref": "InstanceType"},
    42. "SecurityGroupId": {"Ref": "SecurityGroup"}
    43. }
    44. },
    45. "SecurityGroup": {
    46. "Type": "ALIYUN::ECS::SecurityGroup",
    47. }
    48. },
    49. "Outputs": {
    50. "InstanceId": {
    51. "Value" : {"Fn::GetAtt": ["WebServer","InstanceId"]}
    52. },
    53. "PublicIp": {
    54. "Value" : {"Fn::GetAtt": ["WebServer","PublicIp"]}
    55. },
    56. "SecurityGroupId": {
    57. "Value" : {"Fn::GetAtt": ["SecurityGroup","SecurityGroupId"]}
    58. }
    59. }
    60. }

    The JSON text contains five top-level fields:

    "ROSTemplateFormatVersion" : "2015-09-01"

    Defines the template version.

    "Description": " A simple ECS instance includes a security group. You only need to designate an imageID"

    Defines the template description.

    "Parameters" : { }

    Defines certain template parameters. In this example, the parameters of imageID and instance type are defined, with their default values specified.

    "Resources" : { }

    Defines the Alibaba Cloud resources this template will create. This example declares the creation of an ECS instance and a security group. The resource attributes declared here can reference the values defined in Parameters.

    "Outputs": { }

    Defines the stack output resource information from ROS when the resources are created. This example will output the ECS instance ID, public IP address, and security group ID.

  5. Click Create Stack to open a new page. Select a region from the Region dropdown list, which is China North 2 in this example. Click Next in the bottom right corner.

    Preview Specified Region

  6. Specify a unique stack name for the set of resources to be created, while keeping other default options unchanged. Click Create and a message will appear indicating Creation Request Submitted.

    Input Parameters

  7. Click Resource Stack Management on the left to check the stack status. When a stack is successfully created, the values defined in Outputs will be outputted. The following is the stack output from this example:

    Stack Information Output

On the page from Step 7, in the Resources section, review all resources in the stack. In the Events section, review what actions were performed when using ROS to create this resource stack, when any operation related to the resource stack fails, and which specific resource caused the failure, if any. In the Template section, review the original template of the resource stack.

This example only shows how to quickly create resources using the ROS text template. ROS also allows you to create resources using a template URL you have specified, and ROS can manage resources. You can delete your own resource sets, delete stacks but retain their resources, update a resource stack as needed, or recheck resource stack status.

Stack Operations

Thank you! We've received your feedback.