Skip to content

How do I log my VPC Flow Log cloudwatch logs to cross account using Kinesis Firehose?

0

I'm trying to stream CloudWatch logs in all my member accounts to a central logging account. I was able to create a subscription in one account and assign it the destination of firehose; however, I get an error message in CloudWatch Logging in Firehose basically saying the IAM does not have permission to the S3 bucket (I reviewed the IAM permissions for Kinesis and i see the resource listed for this s3 bucket). Not sure what I was doing wrong so I checked the documentation below. This is suppose to store the logs in S3 bucket.

I'm getting what I believe contradicting ways on how to do this from AWS Documentation, which is causing much confusion.

I'm currently following the steps here to achieve this: https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CreateFirehoseStream.html

However, AWS Documentation also mentions a separate way on how to do this with policies and instructions that don't fully match the first link here: https://docs.aws.amazon.com/vpc/latest/userguide/firehose-cross-account-delivery.html

3 Answers
0

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:

  1. 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 AWSLogDeliveryFirehoseCrossAccountRole with 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
  1. 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
  1. Create the VPC Flow Log with cross-account delivery:
  • Use the create-flow-logs command 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-arn parameter
  • The destination account role ARN in the deliver-cross-account-role parameter

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

0

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/

EXPERT

answered a year ago

AWS
EXPERT

reviewed a year ago

0

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.

EXPERT

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.