Tüm Ürünler
Search
Belge Merkezi

Resource Orchestration Service:ALIYUN::ACTIONTRAIL::Trail

Son Güncelleme:Oct 05, 2026

Olayları Simple Log Service (SLS) veya Object Storage Service hizmetine ileten bir iz oluşturur.

Sözdizimi

{
  "Type": "ALIYUN::ACTIONTRAIL::Trail",
  "Properties": {
    "Name": String,
    "OssBucketName": String,
    "RoleName": String,
    "OssKeyPrefix": String,
    "EventRW": String,
    "SlsProjectArn": String,
    "SlsWriteRoleArn": String
  }
}            

Properties

Property Name

Type

Required

Update Allowed

Description

Constraints

Name

String

Yes

No

İz adı.

Ad 6 ila 36 karakter uzunluğunda olmalıdır. Bir harfle başlamalı ve harfler, rakamlar, kısa çizgiler (-) ve alt çizgiler (_) içerebilir.

Not

İz adı, bir Alibaba Cloud hesabı içinde benzersiz olmalıdır.

EventRW

String

No

Yes

İletilecek olayların okuma/yazma türü.

Geçerli değerler:

  • Read: Yalnızca okuma olayları.

  • Write (varsayılan): Yalnızca yazma olayları.

  • All: Hem okuma hem de yazma olayları.

OssBucketName

String

No

Yes

İzin olaylarının iletildiği OSS paketinin adı.

Ad 3 ila 63 karakter uzunluğunda olmalıdır. Küçük bir harf veya rakamla başlamalı ve küçük harfler, rakamlar ve kısa çizgiler (-) içerebilir.

Not
  • Bir OSS paketi oluşturduğunuzdan emin olun. Daha fazla bilgi için bkz. Create a bucket.

  • OssBucketName veya SlsProjectArn parametrelerinden en az birini belirtin.

OssKeyPrefix

String

No

Yes

OSS paketinde depolanan günlük dosyalarının ön eki.

Değer bir harfle başlamalı ve 6 ila 32 karakter uzunluğunda olmalıdır. Harfler, sayılar, kısa çizgiler (-), eğik çizgiler (/) ve alt çizgiler (_) içerebilir.

RoleName

String

No

Yes

ActionTrail için hizmete bağlı rolün adı.

Varsayılan değer: AliyunServiceRoleForActionTrail.

SlsProjectArn

String

No

Yes

İzin olaylarının iletildiği SLS projesinin Alibaba Cloud Resource Name (ARN) değeri.

Bir SLS projesi ve bir Logstore oluşturduğunuzdan emin olun. Logstore adı actiontrail_<trail_name> biçiminde adlandırılmalıdır.

Daha fazla bilgi için bkz. Create a project ve Create a standard Logstore.

Not

OssBucketName veya SlsProjectArn parametrelerinden en az birini belirtin.

SlsWriteRoleArn

String

No

Yes

ActionTrail'ın yönetim olaylarını SLS projesine iletmek için üstlendiği rolün ARN değeri.

None

Dönüş değeri

Fn::GetAtt

Name: İz adı.

Örnekler

YAML biçimi

ROSTemplateFormatVersion: '2015-09-01'
Parameters: {}
Resources:
  Role:
    Type: ALIYUN::RAM::Role
    Properties:
      RoleName: TestRole
      Policies:
        - PolicyName:
            Fn::Sub: ActionTrailPolicy-${ALIYUN::StackId}
          PolicyDocument:
            Version: '1'
            Statement:
              - Action:
                  - oss:GetBucketLocation
                  - oss:ListObjects
                  - oss:PutObject
                Resource:
                  - '*'
                Effect: Allow
              - Action:
                  - log:PostLogStoreLogs
                  - log:CreateLogstore
                  - Log:GetLogstore
                Resource:
                  - '*'
                Effect: Allow
              - Action:
                  - mns:PublishMessage
                Resource:
                  - '*'
                Effect: Allow
      AssumeRolePolicyDocument:
        Version: '1'
        Statement:
          - Action: sts:AssumeRole
            Effect: Allow
            Principal:
              Service:
                - actiontrail.aliyuncs.com
  Bucket:
    Type: ALIYUN::OSS::Bucket
    Properties:
      AccessControl: private
      BucketName: MyTestBucket
      DeletionForce: true
  SlsProject:
    Type: ALIYUN::SLS::Project
    Properties:
      Name: DemoSls
  SlsLogStore:
    Type: ALIYUN::SLS::Logstore
    DependsOn: SlsProject
    Properties:
      LogstoreName: ActiontrailTestTrail
      PreserveStorage: true
      ProjectName:
        Fn::GetAtt:
          - SlsProject
          - Name
      AppendMeta: true
      MaxSplitShard: 64
      AutoSplit: true
      EnableTracking: false
      ShardCount: 2
  Trail:
    DependsOn:
      - Role
      - Bucket
      - SlsLogStore
    Type: ALIYUN::ACTIONTRAIL::Trail
    Properties:
      SlsProjectArn:
        Fn::Sub: acs:log:${ALIYUN::Region}::project/DemoSls
      RoleName:
        Fn::GetAtt:
          - Role
          - RoleName
      EventRW: All
      OssKeyPrefix: TestFile
      OssBucketName:
        Fn::GetAtt:
          - Bucket
          - Name
      SlsWriteRoleArn:
        Fn::Sub: acs:ram::${ALIYUN::TenantId}:role/${Role.RoleName}
      Name: TestTrail
  TrailLogging:
    Type: ALIYUN::ACTIONTRAIL::TrailLogging
    Properties:
      Name:
        Fn::GetAtt:
          - Trail
          - Name
      Enable: true
Outputs:
  Name:
    Value:
      Fn::GetAtt:
        - Trail
        - Name

JSON biçimi

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {},
  "Resources": {
    "Role": {
      "Type": "ALIYUN::RAM::Role",
      "Properties": {
        "RoleName": "TestRole",
        "Policies": [
          {
            "PolicyName": {
              "Fn::Sub": "ActionTrailPolicy-${ALIYUN::StackId}"
            },
            "PolicyDocument": {
              "Version": "1",
              "Statement": [
                {
                  "Action": [
                    "oss:GetBucketLocation",
                    "oss:ListObjects",
                    "oss:PutObject"
                  ],
                  "Resource": [
                    "*"
                  ],
                  "Effect": "Allow"
                },
                {
                  "Action": [
                    "log:PostLogStoreLogs",
                    "log:CreateLogstore",
                    "Log:GetLogstore"
                  ],
                  "Resource": [
                    "*"
                  ],
                  "Effect": "Allow"
                },
                {
                  "Action": [
                    "mns:PublishMessage"
                  ],
                  "Resource": [
                    "*"
                  ],
                  "Effect": "Allow"
                }
              ]
            }
          }
        ],
        "AssumeRolePolicyDocument": {
          "Version": "1",
          "Statement": [
            {
              "Action": "sts:AssumeRole",
              "Effect": "Allow",
              "Principal": {
                "Service": [
                  "actiontrail.aliyuncs.com"
                ]
              }
            }
          ]
        }
      }
    },
    "Bucket": {
      "Type": "ALIYUN::OSS::Bucket",
      "Properties": {
        "AccessControl": "private",
        "BucketName": "MyTestBucket",
        "DeletionForce": true
      }
    },
    "SlsProject": {
      "Type": "ALIYUN::SLS::Project",
      "Properties": {
        "Name": "DemoSls"
      }
    },
    "SlsLogStore": {
      "Type": "ALIYUN::SLS::Logstore",
      "DependsOn": "SlsProject",
      "Properties": {
        "LogstoreName": "ActiontrailTestTrail",
        "PreserveStorage": true,
        "ProjectName": {
          "Fn::GetAtt": [
            "SlsProject",
            "Name"
          ]
        },
        "AppendMeta": true,
        "MaxSplitShard": 64,
        "AutoSplit": true,
        "EnableTracking": false,
        "ShardCount": 2
      }
    },
    "Trail": {
      "DependsOn": [
        "Role",
        "Bucket",
        "SlsLogStore"
      ],
      "Type": "ALIYUN::ACTIONTRAIL::Trail",
      "Properties": {
        "SlsProjectArn": {
          "Fn::Sub": "acs:log:${ALIYUN::Region}::project/DemoSls"
        },
        "RoleName": {
          "Fn::GetAtt": [
            "Role",
            "RoleName"
          ]
        },
        "EventRW": "All",
        "OssKeyPrefix": "TestFile",
        "OssBucketName": {
          "Fn::GetAtt": [
            "Bucket",
            "Name"
          ]
        },
        "SlsWriteRoleArn": {
          "Fn::Sub": "acs:ram::${ALIYUN::TenantId}:role/${Role.RoleName}"
        },
        "Name": "TestTrail"
      }
    },
    "TrailLogging": {
      "Type": "ALIYUN::ACTIONTRAIL::TrailLogging",
      "Properties": {
        "Name": {
          "Fn::GetAtt": [
            "Trail",
            "Name"
          ]
        },
        "Enable": true
      }
    }
  },
  "Outputs": {
    "Name": {
      "Value": {
        "Fn::GetAtt": [
          "Trail",
          "Name"
        ]
      }
    }
  }
}