Files
fleet-terraform/addons/byo-cloudwatch-log-sharing/target-account-kinesis

Fleet CloudWatch Log Group Sharing via Kinesis (Target Account)

This module creates the cross-account CloudWatch Logs destination and a Kinesis Data Stream target.

Because CloudWatch Logs destinations must be created in the same region as the source log group, this module uses two provider aliases:

  • aws.destination: Region of the Fleet CloudWatch log group (source region).
  • aws.target: Region for the Kinesis stream (same region or different region).

Both provider aliases must use the same AWS account credentials. Cross-account is achieved between source and target subscriptions, not between aws.destination and aws.target within this module.

Usage

provider "aws" {
  alias  = "source_region"
  region = "us-east-2"
}

provider "aws" {
  alias  = "target_region"
  region = "us-west-2"
}

module "fleet_log_sharing_target" {
  source = "github.com/fleetdm/fleet-terraform//addons/byo-cloudwatch-log-sharing/target-account-kinesis?depth=1&ref=tf-mod-addon-byo-cloudwatch-log-sharing-v1.0.0"

  providers = {
    aws.destination = aws.source_region
    aws.target      = aws.target_region
  }

  source_account_ids = ["111111111111"]

  cloudwatch_destination = {
    name        = "fleet-app-logs"
    role_name   = "fleet-app-logs-role"
    policy_name = "fleet-app-logs-policy"
  }

  kinesis = {
    stream_name = "fleet-app-logs"
  }
}

output "fleet_log_sharing_target" {
  value = module.fleet_log_sharing_target
}

Then apply the source account module (../cloudwatch) using module.fleet_log_sharing_target.log_destination.arn and set destination_type = "kinesis".

Requirements

Name Version
terraform >= 1.3.7
aws >= 5.29.0

Providers

Name Version
aws >= 5.29.0
aws.destination >= 5.29.0
aws.target >= 5.29.0

Modules

No modules.

Resources

Name Type
aws_cloudwatch_log_destination.destination resource
aws_cloudwatch_log_destination_policy.destination resource
aws_iam_policy.destination resource
aws_iam_role.destination resource
aws_iam_role_policy_attachment.destination resource
aws_kinesis_stream.destination resource
aws_caller_identity.destination data source
aws_caller_identity.target data source
aws_iam_policy_document.assume_role data source
aws_iam_policy_document.destination data source
aws_iam_policy_document.destination_policy data source
aws_partition.destination data source
aws_region.destination data source
aws_region.target data source

Inputs

Name Description Type Default Required
cloudwatch_destination CloudWatch Logs destination settings in the source log-group region.
object({
name = optional(string, "fleet-log-sharing-destination")
role_name = optional(string, "fleet-log-sharing-destination-role")
policy_name = optional(string)
})
{} no
destination_policy_source_organization_id Optional AWS Organization ID allowed to subscribe to this destination. string "" no
kinesis Kinesis stream settings used as the CloudWatch Logs destination target.
object({
stream_name = string
stream_mode = optional(string, "ON_DEMAND")
shard_count = optional(number, 1)
retention_period = optional(number, 24)
})
n/a yes
source_account_ids AWS account IDs allowed to create subscription filters to this destination. list(string) n/a yes
tags Tags to apply to created resources that support tags. map(string) {} no

Outputs

Name Description
kinesis Kinesis destination details.
log_destination CloudWatch Logs destination details to share with the source-account team.