This topic describes how to convert an AWS CloudFormation template to a Resource Orchestration Service (ROS) template. In this example, the template that you use to create a virtual private cloud (VPC) and a security group is used.
Background information
Step 1: Modify the AWS CloudFormation template file
The following sample code shows the content of the AWS CloudFormation template file:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "This template create vpc security group.",
"Metadata": {
"AWS::CloudFormation::Interface": {
"ParameterGroups": {
"Parameters": [
"CidrBlock"
],
"Label": {
"default": "VPC"
}
},
"ParameterLabels": {
"CidrBlock": {
"default": "Vpc Cidr Block"
}
}
}
},
"Parameters": {
"CidrBlock": {
"Type": "String",
"Default": "10.0.0.0/16"
}
},
"Resources": {
"MyVpc": {
"DeletionPolicy": "Retain",
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": {
"Ref": "CidrBlock"
},
"EnableDnsSupport": "false",
"EnableDnsHostnames": "false",
"InstanceTenancy": "dedicated",
"Tags": [
{
"Key": "foo",
"Value": "bar"
}
]
}
},
"MySg": {
"DependsOn": "MyVpc",
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Create vpc security group",
"VpcId": {
"Ref": "MyVpc"
}
}
}
},
"Outputs": {
"VpcId": {
"Description": "Vpc ID",
"Value": {
"Ref": "MyVpc"
}
},
"SgId": {
"Description": "SecurityGroup ID",
"Value": {
"Fn::GetAtt": [
"MySg",
"GroupId"
]
}
}
}
}
Step 2: Convert the template
Run the following command to convert the AWS CloudFormation template to an ROS template
and generate a JSON ROS template file named template.json
in the directory in which the AWS CloudFormation template file is stored.
rostran transform templates/cloudformation/vpc_sg.json --target-format json
Step 3: View the ROS template
Open the template.json
file and view the ROS template that is generated. The following sample code shows
the content of the ROS template:
{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": "This template create vpc security group.",
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": {
"Parameters": [
"CidrBlock"
],
"Label": {
"default": "VPC"
}
},
"ParameterLabels": {
"CidrBlock": {
"default": "Vpc Cidr Block"
}
}
}
},
"Parameters": {
"CidrBlock": {
"Type": "String",
"Default": "10.0.0.0/16",
"Label": "Vpc Cidr Block"
}
},
"Resources": {
"MyVpc": {
"Type": "ALIYUN::ECS::VPC",
"Properties": {
"CidrBlock": {
"Ref": "CidrBlock"
},
"Tags": [
{
"Key": "foo",
"Value": "bar"
}
]
},
"DeletionPolicy": "Retain"
},
"MySg": {
"Type": "ALIYUN::ECS::SecurityGroup",
"Properties": {
"Description": "Create vpc security group",
"VpcId": {
"Ref": "MyVpc"
}
},
"DependsOn": "MyVpc"
}
},
"Outputs": {
"VpcId": {
"Value": {
"Ref": "MyVpc"
}
},
"SgId": {
"Value": {
"Fn::GetAtt": [
"MySg",
"SecurityGroupId"
]
}
}
}
}