ALIYUN::ACTIONTRAIL::Trail digunakan untuk membuat jejak guna mengirimkan peristiwa ke Simple Log Service atau Object Storage Service (OSS).
Sintaksis
{
"Type": "ALIYUN::ACTIONTRAIL::Trail",
"Properties": {
"Name": String,
"OssBucketName": String,
"RoleName": String,
"OssKeyPrefix": String,
"EventRW": String,
"SlsProjectArn": String,
"SlsWriteRoleArn": String
}
} Properti
Properti | Tipe | Diperlukan | Dapat Diedit | Deskripsi | Kendala |
Name | String | Ya | Tidak | Nama jejak. | Nama harus terdiri dari 6 hingga 36 karakter dan dapat berisi huruf, angka, tanda hubung (-), serta garis bawah (_). Nama harus dimulai dengan huruf. Catatan Nama harus unik dalam akun Alibaba Cloud. |
EventRW | String | Tidak | Ya | Jenis baca/tulis peristiwa yang ingin Anda kirimkan. | Nilai valid:
|
OssBucketName | String | Tidak | Ya | Nama Bucket OSS tempat Anda ingin mengirimkan peristiwa. | Nama harus terdiri dari 3 hingga 63 karakter dan dapat berisi huruf kecil, angka, serta tanda hubung (-). Nama harus dimulai dengan huruf kecil atau angka. Catatan
|
OssKeyPrefix | String | Tidak | Ya | Awalan nama objek tempat Anda ingin menyimpan peristiwa yang dikirimkan di bucket OSS. | Awalan harus terdiri dari 6 hingga 32 karakter dan dapat berisi huruf, angka, tanda hubung (-), garis miring (/), serta garis bawah (_). Awalan harus dimulai dengan huruf. |
RoleName | String | Tidak | Ya | Peran layanan yang diasumsikan oleh ActionTrail. | Nilai default: AliyunServiceRoleForActionTrail. |
SlsProjectArn | String | Tidak | Ya | ARN Alibaba Cloud Resource Name (ARN) dari proyek Simple Log Service tempat Anda ingin mengirimkan peristiwa. | Pastikan bahwa sebuah proyek dan penyimpanan log telah dibuat di Simple Log Service. Anda harus menentukan nama penyimpanan log dalam format berikut: Untuk informasi lebih lanjut, lihat Buat proyek dan Buat penyimpanan log. Catatan Anda harus menentukan setidaknya satu dari OssBucketName dan SlsProjectArn. |
SlsWriteRoleArn | String | Tidak | Ya | ARN dari peran yang diasumsikan oleh ActionTrail untuk mengirimkan peristiwa ke proyek Simple Log Service. | Tidak ada. |
Nilai pengembalian
Fn::GetAtt
Name: Nama jejak.
Contoh
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:
Ref: Enable
Outputs:
Name:
Value:
Fn::GetAtt:
- Trail
- NameJSON 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": {
"Ref": "Enable"
}
}
}
},
"Outputs": {
"Name": {
"Value": {
"Fn::GetAtt": [
"Trail",
"Name"
]
}
}
}
}