8.6 KiB
Fleet CloudWatch Log Group Sharing via Firehose (Target Account)
This module creates the cross-account CloudWatch Logs destination and a Firehose delivery stream target.
CloudWatch Logs subscription payloads are already gzip-compressed. This module defaults Firehose compression_format to UNCOMPRESSED to avoid double-compression.
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 Firehose stream and S3 bucket (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-firehose?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-firehose"
role_name = "fleet-app-logs-destination-role"
policy_name = "fleet-app-logs-destination-policy"
}
firehose = {
delivery_stream_name = "fleet-app-logs-firehose"
role_name = "fleet-app-logs-firehose-role"
policy_name = "fleet-app-logs-firehose-policy"
# Optional override; default is UNCOMPRESSED.
compression_format = "UNCOMPRESSED"
}
s3 = {
bucket_name = "fleet-app-logs-firehose-example"
}
}
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 (default destination_type is firehose).
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
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cloudwatch_destination | CloudWatch Logs destination settings in the source log-group region. | object({ |
{} |
no |
| destination_policy_source_organization_id | Optional AWS Organization ID allowed to subscribe to this destination. | string |
"" |
no |
| firehose | Firehose delivery stream settings used as the CloudWatch Logs destination target. CloudWatch Logs subscription payloads are already gzip-compressed, so UNCOMPRESSED is the default to avoid double compression. | object({ |
n/a | yes |
| s3 | S3 configuration for Firehose delivered logs. | object({ |
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 |
|---|---|
| firehose | Firehose destination details. |
| log_destination | CloudWatch Logs destination details to share with the source-account team. |
| s3_bucket | S3 bucket details used as the Firehose destination. |