- Newest
- Most votes
- Most comments
The issue you're experiencing with exporting CloudWatch logs to an S3 bucket in another account is likely due to insufficient permissions. Here are a few things to check and modify:
-
IAM Role Permissions: Ensure that the IAM role used by the Lambda function in Account B has the necessary permissions. The role should have the AmazonS3ReadOnlyAccess policy attached, along with the custom policy you've provided. Make sure the "Resource" fields in your custom policy are not empty and specify the correct ARNs for the S3 bucket and CloudWatch log groups.
-
S3 Bucket Policy: Your bucket policy looks mostly correct, but there are a few adjustments to make:
- Add a condition to the s3:PutObject permission for the CloudWatch Logs service principal to include "s3:x-amz-acl": "bucket-owner-full-control".
- Ensure that the account IDs in the policy match the correct accounts (Account A for the bucket, Account B for the role).
- Add the aws:SourceAccount condition to the CloudWatch Logs service principal statements.
-
KMS Key Policy (if using SSE-KMS): If the S3 bucket is encrypted with SSE-KMS, make sure the KMS key policy allows the CloudWatch Logs service and the IAM role from Account B to use the key.
-
CloudWatch Logs Service-Linked Role: Ensure that the CloudWatch Logs service-linked role exists in Account B. This role is automatically created when you use CloudWatch Logs, but if it's missing, you may need to create it manually.
-
S3 Bucket ACL: Check that the bucket ACL allows the bucket owner (Account A) full control over new objects.
-
Cross-Account Setup: Double-check that you've properly set up the cross-account access between Account A and Account B, including any necessary trust relationships.
After making these adjustments, retry the export task. If you're still encountering issues, review the CloudWatch Logs for the Lambda function and the S3 access logs for more detailed error messages to further troubleshoot the problem.
Sources
Exporting Cloudwatch log group To S3 is failing | AWS re:Post
Troubleshoot a failed export task in CloudWatch Logs | AWS re:Post
Export log data to Amazon S3 using the AWS CLI - Amazon CloudWatch Logs
Relevant content
- asked 3 years ago
- AWS OFFICIALUpdated 25 days ago

Thanks for your quick reply. @Gary Mclean
I want to ask you about your suggestion 4. Service linked role named" AWSServiceRoleForLogDelivery " doesn't exist in accountB.
But according to documents all listed permissions are seemed to be related to fierhose, do I have to create other permissions for service linked role?
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/using-service-linked-roles-cwl.html#slr-permissions