DataSync tasks should have logging enabled
DataSync tasks move data between storage systems, often across network boundaries or into S3. Without logging, you have no visibility into transfer failures, skipped files, or verification errors. A silent transfer failure can lead to data loss that goes unnoticed for days.
Logging also gives you the evidence trail needed to confirm that data landed where it was supposed to, when it was supposed to. If a DataSync task copies sensitive records between on-premises NFS and S3, the CloudWatch logs are your only record of what actually happened during the transfer.
Retrofit consideration
Existing tasks need an update to add the CloudWatch Log Group ARN. The task itself does not need to be recreated, but you must also confirm the log group exists and that DataSync has permission to write to it via a resource policy.
Implementation
Choose the approach that matches how you manage Terraform.
Use AWS provider resources directly. See docs for the resources involved: aws_datasync_task.
resource "aws_datasync_task" "this" {
destination_location_arn = "arn:aws:datasync:us-east-1:123456789012:location/loc-12345678901234567"
options {
gid = "NONE"
log_level = "BASIC"
posix_permissions = "NONE"
uid = "NONE"
}
source_location_arn = "arn:aws:datasync:us-east-1:123456789012:location/loc-12345678901234567"
cloudwatch_log_group_arn = "arn:aws:logs:us-east-1:123456789012:log-group:example-log-group"
}
What this control checks
In Terraform, this control validates the aws_datasync_task resource. The cloudwatch_log_group_arn argument must be set to a valid aws_cloudwatch_log_group ARN. If cloudwatch_log_group_arn is omitted or empty, the control fails.
A passing configuration requires three things:
- An
aws_cloudwatch_log_groupresource (e.g.,/aws/datasync). - The
aws_datasync_taskresource withcloudwatch_log_group_arnset to that log group's ARN. - An
aws_cloudwatch_log_resource_policygranting the DataSync service principallogs:PutLogEventsandlogs:CreateLogStreamon that log group.
The log_level option within the task_report_config block is separate from this control. The control checks specifically for the presence of cloudwatch_log_group_arn on the task itself.
Common pitfalls
Missing CloudWatch Logs resource policy
DataSync will accept the
cloudwatch_log_group_arnvalue and create the task without error, but if theaws_cloudwatch_log_resource_policygrantinglogs:PutLogEventsandlogs:CreateLogStreamtodatasync.amazonaws.comis missing, nothing gets written. The task looks configured; the log group stays empty.Log group ARN format mismatch
Use the ARN directly from
aws_cloudwatch_log_group.arn, not a constructed string with a trailing:*. DataSync expects the log group ARN without that suffix. If the format is wrong, task creation may succeed but logging silently fails. Verify the value passed tocloudwatch_log_group_arnends with the log group name, not:*.Cross-region log group references
The CloudWatch Log Group must be in the same region as the DataSync task. A cross-region ARN won't be rejected at plan time, but the task will fail to deliver logs, with no clear error surfaced during apply.
Log level defaults to BASIC
With
cloudwatch_log_group_arnset, this control passes. But iflog_levelin theoptionsblock is explicitly set toOFF, no logs are written. The control checks for the association, not the effective log level, so you can pass the check and still get no data. UseBASICorTRANSFERdepending on how much detail you need.
Audit evidence
AWS Config rule evaluation results showing all DataSync tasks as COMPLIANT, or equivalent output from a cloud security posture management tool. Supporting evidence includes the CloudWatch Log Group with actual log entries from recent DataSync executions, confirming that logging is operational and not merely configured. The DescribeTask API response for each task should show a non-empty CloudWatchLogGroupArn field.
CloudTrail events for CreateTask and UpdateTask calls establish when logging was enabled and by whom, which matters if the control was previously failing and remediation needs a timeline.
Framework-specific interpretation
Related controls
EKS clusters should have control plane audit logging enabled
CloudWatch log groups should have retention period of at least 365 days
Tool mappings
Use these identifiers to cross-reference this control across tools, reports, and evidence.
Compliance.tf Control:
datasync_task_logging_enabledAWS Config Managed Rule:
DATASYNC_TASK_LOGGING_ENABLEDPowerpipe Control:
aws_compliance.control.datasync_task_logging_enabledProwler Check:
datasync_task_logging_enabledAWS Security Hub Control:
DataSync.1
Last reviewed: 2026-03-09