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.
Kinesis Data Stream Logging Destination Setup
How to use
Below is an example of defining the module to use a single Kinesis Data Stream for all log types (results, status, and audit):
module "kinesis" {
source = "github.com/fleetdm/fleet-terraform//addons/byo-kinesis-logging-destination/target-account"
fleet_iam_role_arn = "arn:aws:iam::123456789:role/fleet-server-role" # this is the ARN of the IAM (ECS-task) role the fleet servers are running as
log_destinations = {
test = {
name = "unified-log-stream"
shard_count = 0 # shard count only matters if `stream_mode` is `PROVISIONED`
stream_mode = "ON_DEMAND" # valid values are `ON_DEMAND` or `PROVISIONED`
retention_period = 24 # number of hours you want the data to be retained on the stream
shard_level_metrics = [] # IncomingBytes IncomingRecords OutgoingBytes OutgoingRecords WriteProvisionedThroughputExceeded ReadProvisionedThroughputExceeded IteratorAgeMilliseconds
}
}
}
output "kinesis_logging_destination" {
value = module.kinesis
}
If you desired a Kinesis Data Stream per "topic":
module "kinesis" {
source = "github.com/fleetdm/fleet-terraform//addons/byo-kinesis-logging-destination/target-account"
fleet_iam_role_arn = "arn:aws:iam::123456789:role/fleet-server-role" # this is the ARN of the IAM (ECS-task) role the fleet servers are running as
log_destinations = {
results = {
name = "osquery-results"
shard_count = 0 # shard count only matters if `stream_mode` is `PROVISIONED`
stream_mode = "ON_DEMAND" # valid values are `ON_DEMAND` or `PROVISIONED`
retention_period = 24 # number of hours you want the data to be retained on the stream
shard_level_metrics = [] # IncomingBytes IncomingRecords OutgoingBytes OutgoingRecords WriteProvisionedThroughputExceeded ReadProvisionedThroughputExceeded IteratorAgeMilliseconds
}
status = {
name = "osquery-status"
shard_count = 0 # shard count only matters if `stream_mode` is `PROVISIONED`
stream_mode = "ON_DEMAND" # valid values are `ON_DEMAND` or `PROVISIONED`
retention_period = 24 # number of hours you want the data to be retained on the stream
shard_level_metrics = [] # IncomingBytes IncomingRecords OutgoingBytes OutgoingRecords WriteProvisionedThroughputExceeded ReadProvisionedThroughputExceeded IteratorAgeMilliseconds
}
audit = {
name = "fleet-audit"
shard_count = 0 # shard count only matters if `stream_mode` is `PROVISIONED`
stream_mode = "ON_DEMAND" # valid values are `ON_DEMAND` or `PROVISIONED`
retention_period = 24 # number of hours you want the data to be retained on the stream
shard_level_metrics = [] # IncomingBytes IncomingRecords OutgoingBytes OutgoingRecords WriteProvisionedThroughputExceeded ReadProvisionedThroughputExceeded IteratorAgeMilliseconds
}
}
}
output "kinesis_logging_destination" {
value = module.kinesis
}
-
Variables:
fleet_iam_role_arn: A string variable that holds the ARN of the IAM role which will assume the role defined in this module to gain permissions for writing to the Kinesis Data Streams.sts_external_id: An optional string variable that can be used as a unique identifier for the principal assuming the role to assert its identity. Default is an empty string.log_destinations: A map variable that contains configurations for multiple Kinesis Data Streams. Each stream configuration includes its name, shard count, stream mode, retention period, and shard-level metrics. Default values are provided for three streams:osquery_results,osquery_status, andfleet_audit.
-
IAM Role:
aws_iam_role.fleet_role: Creates an IAM role with a trust policy that allows the specified IAM role ARN (fleet_iam_role_arn) to assume this role. Ifsts_external_idis provided, it adds a condition to the trust policy to require this external ID for the assume role operation.
-
IAM Policy Documents:
data.aws_iam_policy_document.assume_role: Defines the assume role policy for the IAM role. It allows the specified actions (sts:AssumeRole) for the specified principals.data.aws_iam_policy_document.kinesis: Defines the policy document allowing the IAM role to perform Kinesis and KMS actions. It allows the IAM role to describe, put records into the Kinesis streams (defined inlog_destinations), and use KMS keys for encryption.
-
IAM Policy and Attachment:
aws_iam_policy.fleet_kinesis: Creates an IAM policy using the defined policy document (data.aws_iam_policy_document.kinesis).aws_iam_role_policy_attachment.fleet_kinesis: Attaches the created IAM policy to the IAM role (aws_iam_role.fleet_role).
-
KMS Key:
aws_kms_key.kinesis_key: Creates a KMS key for encrypting the Kinesis Data Streams.
-
Kinesis Data Streams:
aws_kinesis_stream.fleet_log_destination: Provisions Kinesis Data Streams based on the configurations defined inlog_destinations. Each stream is created with the specified name, encryption type (using the KMS key), shard-level metrics, shard count (if the stream mode is not "ON_DEMAND"), and stream mode.
Requirements
| Name | Version |
|---|---|
| terraform | >= 1.3.7 |
| aws | >= 5.29.0 |
Providers
| Name | Version |
|---|---|
| aws | 5.51.0 |
Modules
No modules.
Resources
| Name | Type |
|---|---|
| aws_iam_policy.fleet_kinesis | resource |
| aws_iam_role.fleet_role | resource |
| aws_iam_role_policy_attachment.fleet_kinesis | resource |
| aws_kinesis_stream.fleet_log_destination | resource |
| aws_kms_key.kinesis_key | resource |
| aws_iam_policy_document.assume_role | data source |
| aws_iam_policy_document.kinesis | data source |
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| fleet_iam_role_arn | The ARN of the IAM role that will be assuming into the IAM role defined in this module to gain permissions required to write to the Kinesis Data Stream(s). | string |
n/a | yes |
| log_destinations | A map of configurations for Kinesis data streams. | map(object({ |
{ |
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 |
|---|---|
| kinesis_iam_role | n/a |
| kinesis_streams | A map of Kinesis streams with their names and ARNs. |