This will be needed to make the initial tags. Once merged to main, I will tag with the same module revisions as what exists in the Fleet repo. We can then test the example module using the new settings. Once validated, we'll then update the main fleet repo to redirect here for /terraform and remove everything there. Anything referring to old tags will still work in-place. Additionally any website references will be updated as well to reflect these changes.
Firehose Logging Destination Setup
In this Terraform code, we are defining an IAM Role named fleet_role in our AWS Account, that will be assumed by the Fleet application we are hosting. We are only allowing this specific IAM Role (identified by its ARN) to perform certain actions on the Firehose service, such as DescribeDeliveryStream, PutRecord, and PutRecordBatch.
The reason we need a local IAM role in your account is so that we can assume role into it, and you have full control over the permissions it has. The associated IAM policy in the same file specifies the minimum allowed permissions.
The Firehose service is KMS encrypted, so the IAM Role we assume into needs permission to the KMS key that is being used to encrypt the data going into Firehose. Additionally, if the data is being delivered to S3, it will also be encrypted with KMS using the AWS S3 KMS key that is managed by AWS. This is because only customer managed keys can be shared across accounts, and the Firehose delivery stream is actually the one writing to S3.
This code sets up a secure and controlled environment for the Fleet application to perform its necessary actions on the Firehose service within your AWS Account.
If you wanted to make changes to the individual files to fit your environment, feel free. However, it's recommended to use a module like the example below for simplicity.
module "firehose_logging" {
source = "github.com/fleetdm/fleet-terraform//addons/byo-firehose-logging-destination/target-account"
# Variables
osquery_logging_destination_bucket_name = {your-desired-bucket-prefix}
fleet_iam_role_arn = {supplied by Fleet}
sts_external_id = {if using}
}
Requirements
| Name | Version |
|---|---|
| terraform | >= 1.3.7 |
| aws | >= 5.29.0 |
Providers
| Name | Version |
|---|---|
| aws | >= 5.29.0 |
Modules
No modules.
Resources
| Name | Type |
|---|---|
| aws_iam_policy.firehose | resource |
| aws_iam_policy.fleet_firehose | resource |
| aws_iam_role.firehose | resource |
| aws_iam_role.fleet_role | resource |
| aws_iam_role_policy_attachment.firehose | resource |
| aws_iam_role_policy_attachment.fleet_firehose | resource |
| aws_kinesis_firehose_delivery_stream.fleet_log_destinations | resource |
| aws_kms_key.firehose_key | resource |
| aws_s3_bucket.destination | resource |
| aws_s3_bucket_public_access_block.destination | resource |
| aws_s3_bucket_server_side_encryption_configuration.destination | resource |
| aws_caller_identity.current | data source |
| aws_iam_policy_document.assume_role | data source |
| aws_iam_policy_document.firehose | data source |
| aws_iam_policy_document.firehose_policy | data source |
| aws_iam_policy_document.osquery_firehose_assume_role | data source |
| aws_kms_alias.s3 | data source |
| aws_region.current | data source |
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| fleet_iam_role_arn | the arn of the fleet role that firehose will assume to write data to your bucket | string |
n/a | yes |
| kms_key_arn | An optional KMS key ARN for server-side encryption. If not provided and encryption is enabled, a new key will be created. | string |
"" |
no |
| log_destinations | A map of configurations for Firehose delivery streams. | map(object({ |
{ |
no |
| osquery_logging_destination_bucket_name | name of the bucket to store osquery results & status logs | string |
n/a | yes |
| server_side_encryption_enabled | A boolean flag to enable/disable server-side encryption. Defaults to true (enabled). | bool |
true |
no |
| sts_external_id | Optional unique identifier that can be used by the principal assuming the role to assert its identity. | string |
"" |
no |
Outputs
| Name | Description |
|---|---|
| firehose_iam_role | n/a |
| log_destinations | Map of Firehose delivery streams' names. |
| s3_destination | n/a |