All Products
Search
Document Center

ActionTrail:Resource Orchestration Service (ROS) integration example

Last Updated:Jun 04, 2026

Use ROS to manage ActionTrail resources. The following example writes a Resource Orchestration Service template to create a trail.

Supported resources

ROS simplifies cloud resource management. Define your Alibaba Cloud resources (such as ECS and ApsaraDB RDS instances) and their dependencies in a template, and ROS creates and configures them automatically. What is Resource Orchestration Service?

ROS supports the following ActionTrail resources:

Permissions

This example creates a trail. By default, Resource Orchestration Service uses the current user's credentials. The user needs these permissions:

  • AliyunActionTrailFullAccess: Provides full access to ActionTrail.

  • AliyunLogFullAccess: Provides full access to Simple Log Service (SLS).

An Alibaba Cloud account has full API permissions, which poses security risks. We recommend that you create a RAM user for API access and daily operations, and grant only the required permissions. Authorize a RAM User.

Procedure

  1. Log on to the ROS console and select a region from the Region drop-down list.

  2. In the left-side navigation pane, click Stacks, and then select Create Stack > Use ROS:

    • Specify Template: Select Select an Existing Template.

    • Template Import Method: Select Enter Template Content.

  3. Under Template Content, select ROS and enter the following code in YAML or JSON format.

    This example creates a trail named test-trail using the ALIYUN::ACTIONTRAIL::Trail resource type.

    YAML format

    ROSTemplateFormatVersion: '2015-09-01'
    Resources:
      SlsProject:
        Type: ALIYUN::SLS::Project
        Properties:
          Name: test-sls-project-for-actiontrail
      TrailLogging:
        Type: ALIYUN::ACTIONTRAIL::TrailLogging
        Properties:
          Enable: true
          Name:
            Fn::GetAtt:
              - Trail
              - Name
      SlsLogStore:
        Type: ALIYUN::SLS::Logstore
        Properties:
          ProjectName:
            Fn::GetAtt:
              - SlsProject
              - Name
          AutoSplit: true
          MaxSplitShard: 64
          LogstoreName: actiontrail_test-trail
          AppendMeta: true
          ShardCount: 2
          EnableTracking: false
          PreserveStorage: true
        DependsOn: SlsProject
      Trail:
        Type: ALIYUN::ACTIONTRAIL::Trail
        Properties:
          SlsProjectArn:
            Fn::Sub: acs:log:${ALIYUN::Region}::project/test-sls-project-for-actiontrail
          EventRW: All
          Name: test-trail
        DependsOn:
          - SlsLogStore
    Parameters: {}
    Outputs:
      Name:
        Value:
          Fn::GetAtt:
            - Trail
            - Name

    JSON format

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Resources": {
        "SlsProject": {
          "Type": "ALIYUN::SLS::Project",
          "Properties": {
            "Name": "test-sls-project-for-actiontrail"
          }
        },
        "TrailLogging": {
          "Type": "ALIYUN::ACTIONTRAIL::TrailLogging",
          "Properties": {
            "Enable": true,
            "Name": {
              "Fn::GetAtt": [
                "Trail",
                "Name"
              ]
            }
          }
        },
        "SlsLogStore": {
          "Type": "ALIYUN::SLS::Logstore",
          "Properties": {
            "ProjectName": {
              "Fn::GetAtt": [
                "SlsProject",
                "Name"
              ]
            },
            "AutoSplit": true,
            "MaxSplitShard": 64,
            "LogstoreName": "actiontrail_test-trail",
            "AppendMeta": true,
            "ShardCount": 2,
            "EnableTracking": false,
            "PreserveStorage": true
          },
          "DependsOn": "SlsProject"
        },
        "Trail": {
          "Type": "ALIYUN::ACTIONTRAIL::Trail",
          "Properties": {
            "SlsProjectArn": {
              "Fn::Sub": "acs:log:${ALIYUN::Region}::project/test-sls-project-for-actiontrail"
            },
            "EventRW": "All",
            "Name": "test-trail"
          },
          "DependsOn": [
            "SlsLogStore"
          ]
        }
      },
      "Parameters": {},
      "Outputs": {
        "Name": {
          "Value": {
            "Fn::GetAtt": [
              "Trail",
              "Name"
            ]
          }
        }
      }
    }
  4. Click Next. For Rollback on Failure, select Yes.

  5. Click Create.

  6. View the output.

    image

  7. After the stack is created, use OpenAPI, SDKs, or the ActionTrail console to verify the test-trail trail.

    image