All Products
Search
Document Center

Resource Orchestration Service:Overview of ROS CDK commands

Last Updated:Jun 04, 2026

ROS CDK provides CLI commands to initialize projects, configure credentials, synthesize templates, deploy stacks, and manage resources.

Command reference

Command

Description

ros-cdk init

Initializes a ROS CDK project.

ros-cdk config

Configures an Alibaba Cloud account in interactive mode.

ros-cdk load-config

Loads Alibaba Cloud credentials from Alibaba Cloud CLI.

ros-cdk list (ls)

Lists all stacks in a project.

ros-cdk synthesize (synth)

Generates a stack template from code.

ros-cdk deploy

Deploys a stack.

ros-cdk list-stacks

Lists stacks with details.

ros-cdk event

Queries stack events.

ros-cdk output

Queries stack outputs.

ros-cdk resource

Queries resources in a stack.

ros-cdk diff

Compares local and deployed templates.

ros-cdk destroy

Deletes a stack.

ros-cdk generate-stack-file

Generates the stack.info.json file in a project in synchronous mode.

ros-cdk config-set

Configures an Alibaba Cloud account in non-interactive mode.

Usage examples

ros-cdk init

Set --language to specify the project language (csharp, java, javascript, python, or typescript). Set --generate-only=true to skip Git configuration, dependency installation, and project compilation.

ros-cdk init --language=typescript --generate-only=true

ros-cdk config

Configures an Alibaba Cloud account interactively. Supported authentication methods: AK, StsToken, RamRoleArn, and EcsRamRole. Use --global for global settings.

 ros-cdk config
 endpoint(optional, default:https://ros.aliyuncs.com):
 defaultRegionId(optional, default:cn-hangzhou):cn-beijing
 
 [1] AK
 [2] StsToken
 [3] RamRoleArn
 [4] EcsRamRole
 [0] CANCEL
 
 Authenticate mode [1...4 / 0]: 1
 accessKeyId:************************
 accessKeySecret:******************************
 
  ✅ Your cdk configuration has been saved successfully!

ros-cdk load-config

Imports Alibaba Cloud CLI credentials into CDK. Select an authentication mode and profile. Use --file-path to specify a custom profile path, or --global for global settings.

 ros-cdk load-config
 [1] AK
 [2] StsToken
 [3] RamRoleArn
 [4] EcsRamRole
 [0] CANCEL
 
 Select authenticate mode [1...4 / 0]: 1
 
 [1] default
 [2] akProfile
 [0] CANCEL
 
 Select Authenticate profile name [1, 2, 0]: 2
 
  ✅ Your cdk configuration has been load from Aliyun Cli configuration saved successfully AK akProfile!

ros-cdk list (ls)

Lists all stacks in the project and their status.

 ros-cdk list 
 CdkDemoStack synth
 CdkTestStack deploy

ros-cdk synthesize(synth)

Previews ROS templates in the project. Use --json for JSON output. For multi-stack projects, specify the stack name.

 ros-cdk synth CdkTestStack --json
 {
   "ROSTemplateFormatVersion": "2015-09-01",
   "Resources": {
     "VPC": {
       "Type": "ALIYUN::ECS::VPC",
       "Properties": {
         "CidrBlock": "10.0.0.0/8",
         "Description": "This is ros cdk test",
         "EnableIpv6": false,
         "VpcName": "test-ros-cdk-javascript"
       }
     }
   }
 }

Use --app to run a specific application project or pass custom parameters.

 ros-cdk synth NewStack --json --app "npx ts-node bin/new.app.ts"
 {
   "ROSTemplateFormatVersion": "2015-09-01",
   "Resources": {
    "vpc-from-ros-cdk": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "CidrBlock": "10.0.0.0/8",
        "Description": "This is ros cdk new app test",
        "EnableIpv6": false,
        "VpcName": "new-app-test"
       }
     }
   }
 }

ros-cdk deploy

For multi-stack projects, specify a stack name. Available options:

  • --timeoutMinutes: stack creation timeout in minutes.

  • --parameters: template parameters.

  • --region: deployment region.

  • --app: application to run.

  • --sync: deploy synchronously.

  • --outputs-file: save template outputs to stack.outputs.json.

  • --skip-if-no-changes: skip redeployment if the template is unchanged.

  • --resource-group-id: target resource group. Defaults to the default resource group.

  • -- json, -j: output the template in JSON instead of YAML.

  • -- ignore-errors: ignore composition errors.

  • -- detail-log: show detailed error messages on deployment failure.

  • -- disable-rollback: disable rollback on failure.

ros-cdk deploy        # The following example shows how to use the commands in a project that contains only one stack. 
 ros-cdk deploy NewStack --app "npx ts-node bin/new.app.ts" # Specifies the application that is run by the project. 
 ros-cdk deploy --sync=true NewStack # Deploys the stack in synchronous mode and generates resource details. 
 ros-cdk deploy --sync=true --outputs-file=true NewStack # Deploys the stack in synchronous mode and synchronizes the information in the Outputs section of the template to the stack.outputs.json file. 
 ros-cdk deploy CdkTestStack --timeoutMinutes 60 --region cn-beijing  
 ros-cdk deploy CdkTestStack CdkDemoStack 
 ros-cdk deploy CdkTestStack CdkDemoStack --disable-rollback=true # Disables rollback when stack creation fails. 
 ros-cdk deploy CdkDemoStack --parameters uploadBucketName=UploadBucket
 ros-cdk deploy CdkDemoStack CdkTestStack --parameters CdkDemoStack:uploadBucketName=UploadBucket --parameters CdkTestStack:uploadBucketName=UpBuckett

ros-cdk list-stacks

Queries the details and status of all stacks in the project.

  • --all: list all stacks in the current region.

  • --resource-group-id: filter by resource group.

  • --page-number: page number. Default: 1.

  • --page-size: entries per page. Maximum: 50. Default: 10.

  • -- app: specify the application.

  • -- ignore-errors: ignore composition errors.

  • -- json, -j: output in JSON instead of YAML.

 ros-cdk list-stacks --all
  ✅ The Stacks list is:
  [
         {
                 "Status": "CREATE_COMPLETE",
                 "StackType": "ROS",
                 "StatusReason": "Stack CREATE completed successfully",
                 "CreateTime": "2021-01-14T09:28:09",
                 "RegionId": "cn-beijing",
                 "DisableRollback": false,
                 "StackName": "CdkTestStack",
                 "StackId": "ceb59a66-b2e8-4b30-9da6-59a66****",
                 "TimeoutInMinutes": 20
         },
         {
                 "Status": "CREATE_COMPLETE",
                 "StackType": "ROS",
                 "StatusReason": "Stack CREATE completed successfully",
                 "CreateTime": "2021-01-13T03:10:42",
                 "RegionId": "cn-beijing",
                 "DisableRollback": false,
                 "StackName": "stack_2021-01-13",
                 "StackId": "37e697cc-3ea6-4a79-9dcd-59a66****",
                 "TimeoutInMinutes": 60
         }
 ]

ros-cdk event

Queries stack events. Specify the stack name. Use --logical-resource-id to filter by resource, and --page-number / --page-size for pagination.

 ros-cdk event CdkTestStack -l ros-cdk-test-sg 
  ✅ The Stack CdkTestStack 
  Events is: 
  [
         {
                 "Status": "CREATE_COMPLETE",
                 "LogicalResourceId": "ros-cdk-test-sg",
                 "PhysicalResourceId": "sg-2ze7i61on1gb48zi****",
                 "StatusReason": "state changed",
                 "CreateTime": "2021-01-14T09:28:10",
                 "EventId": "fc10f59e-7dcc-492d-af5e-0f59e****",
                 "ResourceType": "ALIYUN::ECS::SecurityGroup",
                 "StackName": "CdkTestStack",
                 "StackId": "ceb59a66-b2e8-4b30-9da6-0f59e****"
         },
         {
                 "Status": "CREATE_IN_PROGRESS",
                 "LogicalResourceId": "ros-cdk-test-sg",
                 "StatusReason": "state changed",
                 "CreateTime": "2021-01-14T09:28:09",
                 "EventId": "4d7a4b33-9d5e-49e8-a2b4-0f59e****",
                 "ResourceType": "ALIYUN::ECS::SecurityGroup",
                 "StackName": "CdkTestStack",
                 "StackId": "ceb59a66-b2e8-4b30-9da6-0f59e****"
         }
 ]

ros-cdk output

Queries the output values of a stack.

 ros-cdk output cdk-demo
   ✅ The Stack cdk-demo 
  Output is: 
  [
         {
                 "Description": "No description given",
                 "OutputKey": "BucketDomainName",
                 "OutputValue": "bestros.oss-cn-beijing.aliyuncs.com"
         }
 ]

ros-cdk resource

Queries the resources in a stack. Supports multiple stack names in a single command.

 ros-cdk resource CdkTestStack
 
 ✅ The Stack CdkTestStack 
  Resource is: 
  [
         {
                 "Status": "CREATE_COMPLETE",
                 "LogicalResourceId": "ros-cdk-test-sg-ingres****",
                 "PhysicalResourceId": "sg-2ze7i61on1gb48zi****",
                 "StatusReason": "state changed",
                 "CreateTime": "2021-01-14T09:28:09",
                 "UpdateTime": "2021-01-14T09:28:14",
                 "ResourceType": "ALIYUN::ECS::SecurityGroupIngress",
                 "StackName": "CdkTestStack",
                 "StackId": "ceb59a66-b2e8-4b30-9da6-59a66****"
         },
         {
                 "Status": "CREATE_COMPLETE",
                 "LogicalResourceId": "ros-cdk-tes****",
                 "PhysicalResourceId": "sg-2ze7i61on1gb48zi****",
                 "StatusReason": "state changed",
                 "CreateTime": "2021-01-14T09:28:09",
                 "UpdateTime": "2021-01-14T09:28:10",
                 "ResourceType": "ALIYUN::ECS::SecurityGroup",
                 "StackName": "CdkTestStack",
                 "StackId": "ceb59a66-b2e8-4b30-9da6-59a66****"
         },
         {
                 "Status": "CREATE_COMPLETE",
                 "LogicalResourceId": "ros-cdk-test-sg-ingres****",
                 "PhysicalResourceId": "sg-2ze7i61on1gb48zi****",
                 "StatusReason": "state changed",
                 "CreateTime": "2021-01-14T09:28:09",
                 "UpdateTime": "2021-01-14T09:28:14",
                 "ResourceType": "ALIYUN::ECS::SecurityGroupIngress",
                 "StackName": "CdkTestStack",
                 "StackId": "ceb59a66-b2e8-4b30-9da6-59a66****"
         }
 ]

ros-cdk diff

Compares the current stack template with the deployed version to preview changes before deployment.

 ros-cdk diff CdkDemoStack
 Stack CdkDemoStack
 Resources
 [~] ALIYUN::ECS::VPC vpc-from-ros-cdk/vpc-from-ros-cdk vpc-from-ros-cdk 
  └─ [~] VpcName
      ├─ [-] test-ros-cdk-vpc
      └─ [+] test-ros-cdk-vpc-modify
 [~] ALIYUN::ECS::VSwitch vsw-from-ros-cdk/vsw-from-ros-cdk vsw-from-ros-cdk 
  └─ [~] VSwitchName
      ├─ [-] test-ros-cdk-vsw
      └─ [+] test-ros-cdk-vsw-modify

ros-cdk destroy

Deletes stacks. Available options:

  • --all: delete all stacks.

  • --quiet: skip confirmation prompts.

  • --sync: delete synchronously.

ros-cdk destroy CdkDemoStack
ros-cdk destroy --all
ros-cdk destroy --quiet=true
ros-cdk destroy --sync=true

ros-cdk generate-stack-file

Regenerates the stack.info.json file if it is lost or deleted.

--resource-group-id: regenerate for stacks in a specific resource group.

 ros-cdk generate-stack-file   ✅ The generate stack info has completed!

ros-cdk config-set

Configures an Alibaba Cloud account in non-interactive mode. Configuration items:

 [1] region: the ID of the region in which the specified stack is created. You must configure this parameter. 
 [2] mode: the credential type of the configuration. You must configure this parameter. The following authentication methods are supported: AK, StsToken, RamRoleArn, and EcsRamRole. 
 [3] ak: your AccessKey ID. 
 [4] sk: your AccessKey secret. 
 [5] sts-token: the information that is required for StsToken authentication. 
 [6] ram-role-arn: the information that is required for RamRoleArn authentication. 
 [7] role-session-name: the value of RoleSessionName. 
 [8] ram-role-name: the name of the role that is assigned to your Elastic Compute Service (ECS) instance. 
 
 ros-cdk config-set --region cn-beijing --mode AK --ak LTAI**************** --sk yourAccessKeySecret
 
  ✅ Your cdk configuration has been saved successfully!
Note

Run ros-cdk COMMAND --help to view all available parameters.