Creates a trail that delivers events to Simple Log Service (SLS) or Object Storage Service (OSS).
Syntax
{
"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 |
The trail name. |
The name must be 6 to 36 characters in length. It must start with a letter and can contain letters, digits, hyphens (-), and underscores (_). Note
The trail name must be unique within an Alibaba Cloud account. |
|
EventRW |
String |
No |
Yes |
The read/write type of events to deliver. |
Valid values:
|
|
OssBucketName |
String |
No |
Yes |
The name of the OSS bucket to which the trail delivers events. |
The name must be 3 to 63 characters in length. It must start with a lowercase letter or a digit and can contain lowercase letters, digits, and hyphens (-). Note
|
|
OssKeyPrefix |
String |
No |
Yes |
The prefix of the log files stored in the OSS bucket. |
The value must start with a letter and be 6 to 32 characters long. It can contain letters, numbers, hyphens (-), forward slashes (/), and underscores (_). |
|
RoleName |
String |
No |
Yes |
The name of the service-linked role for ActionTrail. |
Default value: AliyunServiceRoleForActionTrail. |
|
SlsProjectArn |
String |
No |
Yes |
The Alibaba Cloud Resource Name (ARN) of the SLS project to which the trail delivers events. |
Make sure that you have created an SLS project and a Logstore. The Logstore must be named in the For more information, see Create a project and Create a standard Logstore. Note
Specify at least one of OssBucketName or SlsProjectArn. |
|
SlsWriteRoleArn |
String |
No |
Yes |
The ARN of the role that ActionTrail assumes to deliver management events to the SLS project. |
None |
Return value
Fn::GetAtt
Name: The name of the trail.
Examples
YAML format
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 format
{
"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"
]
}
}
}
}