π‘οΈ AWS ECS Task Definition logging is not configuredπ’
- Contextual name: π‘οΈ Task Definition logging is not configuredπ’
- ID:
/ce/ca/aws/ecs/task-definition-logging - Tags:
- π’ Policy with categories
- π’ Policy with type
- π’ Production policy
- Policy Type:
COMPLIANCE_POLICY - Policy Categories:
SECURITY
Logicβ
- π§ prod.logic.yamlπ’
Similar Policiesβ
- AWS Security Hub: [ECS.9] ECS task definitions should have a logging configuration
Descriptionβ
Descriptionβ
This policy identifies AWS ECS Task Definitions in which container definitions do not include a
logConfiguration, specifically where alogDriveris not specified.Without a proper log configuration, container logs (stdout/stderr) may be lost or only accessible through ephemeral methods, such as
docker logson the host, if accessible.Rationaleβ
Application logs are essential for diagnosing errors, monitoring performance, and supporting post-incident analysis. They provide a historical record of application activity and are critical for compliance and auditing purposes.
Proper log configuration allows log streams to be analyzed in real time (e.g., using CloudWatch Logs Metric Filters) to detect error patterns and trigger alerts.
The
awslogsdriver is commonly used to send logs to Amazon CloudWatch Logs. Other supported drivers, such as Splunk or Fluentd, are also valid.Auditβ
This policy marks an AWS ECS Task Definition as
INCOMPLIANTif any associated AWS ECS Container Definition does not include a Log Configuration Driver.... see more
Remediationβ
Remediationβ
Enable Logging for ECS Task Definitionsβ
Using the AWS CLIβ
Retrieve the existing task definition
aws ecs describe-task-definition \
--task-definition {{family-or-full-arn}} \
--query 'taskDefinition' > task-def.jsonEdit
task-def.jsonAdd a
logConfigurationobject to each container definition."containerDefinitions": [
{
"name": "{{my-app}}",
"image": "{{my-image}}",
"logConfiguration": {
"logDriver": "{{awslogs}}",
"options": {
"awslogs-group": "{{/ecs/my-app-logs}}",
"awslogs-region": "{{us-east-1}}",
"awslogs-stream-prefix": "{{ecs}}"
}
},
...
}
]Note: Ensure that the Task Execution Role (
executionRoleArn) has the following permissions:
logs:CreateLogStreamlogs:PutLogEventsRegister the updated task definition
... see more