- Newest
- Most votes
- Most comments
To stream VPC Flow Logs from CloudWatch Logs in member accounts to a central logging account using Kinesis Firehose, you need to set up cross-account log data sharing. Here's how to do it properly:
- In the central logging account (destination):
- Create an S3 bucket to store the logs
- Create a Kinesis Data Firehose delivery stream configured to deliver to the S3 bucket
- Create a bucket policy that allows the Firehose service to write to the S3 bucket
- Create an IAM role named
AWSLogDeliveryFirehoseCrossAccountRolewith permissions to create service-linked roles and tag delivery streams - Set up a trust policy that allows the source account's role to assume this role
- In the member account (source):
- Create an IAM role (e.g.,
mySourceRole) with: - Permissions for Kinesis Data Firehose to manage log deliveries
- Permission to assume the role in the destination account
- A trust policy allowing the log delivery service to assume this role
- Create a CloudWatch Logs subscription filter that points to the Firehose delivery stream in the central account
- Create the VPC Flow Log with cross-account delivery:
- Use the
create-flow-logscommand specifying: - The VPC as the resource
- Kinesis Data Firehose as the destination type
- The ARN of the Firehose delivery stream in the central account
- The source account role ARN in the
deliver-logs-permission-arnparameter - The destination account role ARN in the
deliver-cross-account-roleparameter
The error you're encountering is likely due to missing or incorrect IAM permissions. Make sure the Firehose delivery role in the central account has proper permissions to write to the S3 bucket, including appropriate conditions for cross-account access. The bucket policy should explicitly allow the Firehose service principal with proper source account conditions.
For security best practices, include conditions in your bucket policy such as aws:SourceAccount and aws:SourceArn to prevent confused deputy issues.
Sources
Cloudwatch Cross account logs in central logging account to be pushed in S3 | AWS re:Post
IAM roles for cross account delivery - Amazon Virtual Private Cloud
Cross-account cross-Region log data sharing using Kinesis Data Streams - Amazon CloudWatch Logs
Create a flow log that publishes to Amazon Data Firehose - Amazon Virtual Private Cloud
answered a year ago
Hello.
If you follow the steps in the first URL you are referring to, you will be using the Assume role, which should allow cross-account access.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CreateFirehoseStream.html
If the Firehose destination bucket is incorrect or the IAM role used is incorrect, access will fail.
If you want to change the S3 bucket, you can use the following command:
aws firehose update-destination --delivery-stream-name <your-firehose-name> --current-delivery-stream-version-id <VersionId> --destination-id <DestinationId> --s3-destination-update BucketARN=S3 ARN
Although it is a Japanese blog, it also introduces a method to access S3 without using an Assume role.
In this method, the S3 bucket policy is configured to allow the Firehose IAM role.
https://dev.classmethod.jp/articles/firehosetos3croosaccount/
Since you are writing the logs cross account, you also need to have a S3 bucket policy that allows from that Kinesis IAM role. Also, confirm if you are writing cross region - there might be SCP policies into action in that case.
Relevant content
asked 3 years ago
