-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathecs-fluent-bit-daemonset.yml
107 lines (101 loc) · 3.8 KB
/
ecs-fluent-bit-daemonset.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Description: >
This template deploys a Fluent Bit Daemonset to an ECS Cluster
Parameters:
EnvironmentName:
Description: An environment name that will be prefixed to resource names
Type: String
DockerImage:
Description: The Fluent Bit Docker image.
Type: String
Cluster:
Description: Please provide the ECS Cluster name that this service should run on
Type: String
Resources:
Service:
Type: AWS::ECS::Service
Properties:
Cluster: !Ref Cluster
LaunchType: EC2
TaskDefinition: !Ref TaskDefinition
SchedulingStrategy: DAEMON
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: fluentd-aggregator
TaskRoleArn: !Ref TaskRole
NetworkMode: host
Volumes:
- Name: socket
Host:
SourcePath: /var/run
ContainerDefinitions:
- Name: fluentd-daemon
Essential: true
Environment:
- Name: FLB_LOG_LEVEL
Value: INFO
Image: !Ref DockerImage
MountPoints:
- ContainerPath: /var/run
SourceVolume: socket
MemoryReservation: 50
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref AWS::StackName
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: !Ref EnvironmentName
CloudWatchLogsGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Ref AWS::StackName
RetentionInDays: 14
# This IAM Role grants the task access to firehose and CloudWatch Logs
TaskRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Sub ecs-task-${AWS::StackName}
Path: /
AssumeRolePolicyDocument: |
{
"Statement": [{
"Sid": "",
"Effect": "Allow",
"Principal": { "Service": [ "ecs-tasks.amazonaws.com" ]},
"Action": "sts:AssumeRole"
}]
}
Policies:
- PolicyName: !Sub ecs-task-${AWS::StackName}
PolicyDocument:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"firehose:PutRecordBatch"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "logs:PutLogEvents",
"Resource": "arn:aws:logs:*:*:log-group:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"logs:CreateLogStream",
"logs:DescribeLogStreams",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:log-group:*"
},
{
"Effect": "Allow",
"Action": "logs:CreateLogGroup",
"Resource": "*"
}
]
}