From d2cae029db9e5808687632f5e0f3a986532a89e2 Mon Sep 17 00:00:00 2001 From: Robert Fairburn <8029478+rfairburn@users.noreply.github.com> Date: Wed, 15 Jul 2026 00:37:35 -0500 Subject: [PATCH 1/7] Improve validdate (#267) --- .github/workflows/tfvalidate.yml | 46 +++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tfvalidate.yml b/.github/workflows/tfvalidate.yml index caf729c..6382c4b 100644 --- a/.github/workflows/tfvalidate.yml +++ b/.github/workflows/tfvalidate.yml @@ -72,6 +72,10 @@ jobs: uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3 with: terraform_version: 1.12.0 + - name: Check formatting ${{ matrix.terraform_dir }} + working-directory: ${{ matrix.terraform_dir }} + run: terraform fmt -check + # If we want to test more of these, consider using a matrix. With a matrix of directories, all terraform modules could be fully tested and potentially in parallel. - name: Validate ${{ matrix.terraform_dir }} module (covers all submodules) working-directory: ${{ matrix.terraform_dir }} @@ -80,7 +84,43 @@ jobs: # and fail direct `terraform validate` unless alias configs are present. # Generate a temporary provider file for any discovered aws. references. AWS_ALIASES="$(grep -RhoE 'provider[[:space:]]*=[[:space:]]*aws\.[A-Za-z0-9_]+' -- *.tf 2>/dev/null | sed -E 's/.*aws\.([A-Za-z0-9_]+)/\1/' | sort -u || true)" - if [[ -n "${AWS_ALIASES}" ]]; then + AWS_CONFIGURED_ALIASES="$(awk ' + function brace_delta(line, copy, opens, closes) { + copy = line + opens = gsub(/\{/, "", copy) + copy = line + closes = gsub(/\}/, "", copy) + return opens - closes + } + + /^[[:space:]]*provider[[:space:]]+"aws"[[:space:]]*\{/ { + in_aws_provider = 1 + depth = 0 + } + + in_aws_provider { + if ($0 ~ /^[[:space:]]*alias[[:space:]]*=[[:space:]]*"[A-Za-z0-9_]+"/) { + alias = $0 + sub(/^[^"]*"/, "", alias) + sub(/".*$/, "", alias) + print alias + } + + depth += brace_delta($0) + if (depth == 0) { + in_aws_provider = 0 + } + } + ' *.tf | sort -u)" + AWS_MISSING_ALIASES="$( + for alias in ${AWS_ALIASES}; do + if ! grep -qx "${alias}" <<< "${AWS_CONFIGURED_ALIASES}"; then + echo "${alias}" + fi + done + )" + + if [[ -n "${AWS_MISSING_ALIASES}" ]]; then # Terraform ignores dot-prefixed files, so this must not start with "." AUTO_PROVIDER_FILE="tfvalidate.providers.auto.tf" { @@ -89,7 +129,7 @@ jobs: echo } > "${AUTO_PROVIDER_FILE}" - for alias in ${AWS_ALIASES}; do + for alias in ${AWS_MISSING_ALIASES}; do { echo 'provider "aws" {' echo " alias = \"${alias}\"" @@ -99,7 +139,7 @@ jobs: } >> "${AUTO_PROVIDER_FILE}" done - echo "Generated ${AUTO_PROVIDER_FILE} for aliases: ${AWS_ALIASES}" + echo "Generated ${AUTO_PROVIDER_FILE} for missing aliases: ${AWS_MISSING_ALIASES}" fi terraform init -backend=false From 35ad999822c7bc5a043702e69f321bcbdb5cb3f2 Mon Sep 17 00:00:00 2001 From: Robert Fairburn <8029478+rfairburn@users.noreply.github.com> Date: Wed, 15 Jul 2026 07:45:23 -0500 Subject: [PATCH 2/7] S3 bucket tagging (#268) --- addons/logging-alb/README.md | 15 +++++++------ addons/logging-alb/main.tf | 4 ++++ addons/logging-alb/variables.tf | 6 +++++ addons/logging-destination-datadog/README.md | 22 ++++++------------- addons/logging-destination-datadog/main.tf | 1 + .../logging-destination-datadog/variables.tf | 6 +++++ addons/logging-destination-splunk/README.md | 11 +++++----- addons/logging-destination-splunk/main.tf | 1 + .../logging-destination-splunk/variables.tf | 6 +++++ addons/osquery-carve/README.md | 14 ++++++------ addons/osquery-carve/main.tf | 1 + addons/osquery-carve/variables.tf | 2 ++ 12 files changed, 55 insertions(+), 34 deletions(-) diff --git a/addons/logging-alb/README.md b/addons/logging-alb/README.md index 397a8b0..c383a54 100644 --- a/addons/logging-alb/README.md +++ b/addons/logging-alb/README.md @@ -89,22 +89,22 @@ No requirements. ## Providers | Name | Version | -|------|---------| -| [archive](#provider\_archive) | 2.7.1 | -| [aws](#provider\_aws) | 6.40.0 | +| ---- | ------- | +| [archive](#provider\_archive) | 2.8.0 | +| [aws](#provider\_aws) | 6.54.0 | | [terraform](#provider\_terraform) | n/a | ## Modules | Name | Source | Version | -|------|--------|---------| +| ---- | ------ | ------- | | [athena-s3-bucket](#module\_athena-s3-bucket) | terraform-aws-modules/s3-bucket/aws | 5.12.0 | | [s3\_bucket\_for\_logs](#module\_s3\_bucket\_for\_logs) | terraform-aws-modules/s3-bucket/aws | 5.12.0 | ## Resources | Name | Type | -|------|------| +| ---- | ---- | | [aws_athena_database.logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/athena_database) | resource | | [aws_athena_workgroup.logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/athena_workgroup) | resource | | [aws_cloudwatch_event_rule.sweep_reencrypt](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule) | resource | @@ -144,7 +144,7 @@ No requirements. ## Inputs | Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| +| ---- | ----------- | ---- | ------- | :------: | | [alt\_path\_prefix](#input\_alt\_path\_prefix) | Used if the prefix inside of the s3 bucket doesn't match the name of the bucket prefix | `string` | `null` | no | | [enable\_athena](#input\_enable\_athena) | n/a | `bool` | `true` | no | | [enable\_reencrypt\_sweep](#input\_enable\_reencrypt\_sweep) | Enable the sweep and re-encrypt Lambda functions, EventBridge schedule, S3 bucket notification, and associated IAM roles. | `bool` | `false` | no | @@ -155,6 +155,7 @@ No requirements. | [kms\_base\_policy](#input\_kms\_base\_policy) | Optional base KMS key-policy statements to apply to module-created CMKs before module-required service access statements are merged in. If null, the module defaults to the historical root `kms:*` statement. |
list(object({
sid = string
effect = string
principals = object({
type = string
identifiers = list(string)
})
actions = list(string)
resources = list(string)
conditions = optional(list(object({
test = string
variable = string
values = list(string)
})), [])
}))
| `null` | no | | [lambda\_log\_retention\_in\_days](#input\_lambda\_log\_retention\_in\_days) | CloudWatch log retention in days for the re-encrypt and sweep Lambda functions | `number` | `365` | no | | [prefix](#input\_prefix) | n/a | `string` | `"fleet"` | no | +| [s3\_bucket\_tags](#input\_s3\_bucket\_tags) | Additional tags to apply to all S3 buckets created by this module. | `map(string)` | `{}` | no | | [s3\_expiration\_days](#input\_s3\_expiration\_days) | n/a | `number` | `90` | no | | [s3\_newer\_noncurrent\_versions](#input\_s3\_newer\_noncurrent\_versions) | n/a | `number` | `5` | no | | [s3\_noncurrent\_version\_expiration\_days](#input\_s3\_noncurrent\_version\_expiration\_days) | n/a | `number` | `30` | no | @@ -163,5 +164,5 @@ No requirements. ## Outputs | Name | Description | -|------|-------------| +| ---- | ----------- | | [log\_s3\_bucket\_id](#output\_log\_s3\_bucket\_id) | S3 bucket used by ALB access logging (SSE-S3 on write, re-encrypted to SSE-KMS by Lambda) | diff --git a/addons/logging-alb/main.tf b/addons/logging-alb/main.tf index 308d202..70686d9 100644 --- a/addons/logging-alb/main.tf +++ b/addons/logging-alb/main.tf @@ -260,6 +260,8 @@ module "s3_bucket_for_logs" { bucket = local.landing_bucket_name + tags = var.s3_bucket_tags + # Allow deletion of non-empty bucket force_destroy = true @@ -646,6 +648,8 @@ module "athena-s3-bucket" { bucket = "${var.prefix}-alb-logs-athena" + tags = var.s3_bucket_tags + # Allow deletion of non-empty bucket force_destroy = true diff --git a/addons/logging-alb/variables.tf b/addons/logging-alb/variables.tf index c5983c0..8749b4b 100644 --- a/addons/logging-alb/variables.tf +++ b/addons/logging-alb/variables.tf @@ -86,3 +86,9 @@ variable "extra_s3_athena_policies" { type = list(any) default = [] } + +variable "s3_bucket_tags" { + description = "Additional tags to apply to all S3 buckets created by this module." + type = map(string) + default = {} +} diff --git a/addons/logging-destination-datadog/README.md b/addons/logging-destination-datadog/README.md index 5d130f4..785824e 100644 --- a/addons/logging-destination-datadog/README.md +++ b/addons/logging-destination-datadog/README.md @@ -9,15 +9,7 @@ This addon configures AWS Kinesis Firehose to send Fleet's osquery logs to Datad ## S3 Bucket Policy: Deny Non-HTTPS -Set `attach_deny_insecure_transport_policy = true` to attach a bucket policy to the failure S3 bucket that denies any requests made over plain HTTP: - -```hcl -module "datadog-logging" { - source = "github.com/fleetdm/fleet-terraform//addons/logging-destination-datadog?ref=" - attach_deny_insecure_transport_policy = true - # ... other configuration ... -} -``` +This module automatically attaches a bucket policy to the failure S3 bucket that denies any requests made over plain HTTP. No configuration is required. ## How to use @@ -132,8 +124,8 @@ No requirements. ## Providers | Name | Version | -|------|---------| -| [aws](#provider\_aws) | 6.41.0 | +| ---- | ------- | +| [aws](#provider\_aws) | n/a | ## Modules @@ -142,7 +134,7 @@ No modules. ## Resources | Name | Type | -|------|------| +| ---- | ---- | | [aws_iam_policy.firehose](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource | | [aws_iam_policy.firehose-logging](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource | | [aws_iam_role.firehose](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | @@ -162,18 +154,18 @@ No modules. ## Inputs | Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| [attach\_deny\_insecure\_transport\_policy](#input\_attach\_deny\_insecure\_transport\_policy) | When true, attach a bucket policy to the S3 bucket that denies non-SSL requests. | `bool` | `false` | no | +| ---- | ----------- | ---- | ------- | :------: | | [compression\_format](#input\_compression\_format) | Compression format for the Firehose delivery stream | `string` | `"UNCOMPRESSED"` | no | | [datadog\_api\_key](#input\_datadog\_api\_key) | Datadog API key for authentication | `string` | n/a | yes | | [datadog\_url](#input\_datadog\_url) | Datadog HTTP API endpoint URL | `string` | n/a | yes | | [log\_destinations](#input\_log\_destinations) | A map of configurations for Datadog Firehose delivery streams. |
map(object({
name = string
buffering_size = number
buffering_interval = number
s3_buffering_size = number
s3_buffering_interval = number
content_encoding = string
common_attributes = optional(list(object({
name = string
value = string
})), [])
}))
|
{
"audit": {
"buffering_interval": 60,
"buffering_size": 2,
"common_attributes": [],
"content_encoding": "NONE",
"name": "fleet-audit-datadog",
"s3_buffering_interval": 400,
"s3_buffering_size": 10
},
"results": {
"buffering_interval": 60,
"buffering_size": 2,
"common_attributes": [],
"content_encoding": "NONE",
"name": "fleet-osquery-results-datadog",
"s3_buffering_interval": 400,
"s3_buffering_size": 10
},
"status": {
"buffering_interval": 60,
"buffering_size": 2,
"common_attributes": [],
"content_encoding": "NONE",
"name": "fleet-osquery-status-datadog",
"s3_buffering_interval": 400,
"s3_buffering_size": 10
}
}
| no | | [s3\_bucket\_config](#input\_s3\_bucket\_config) | Configuration for the S3 bucket used to store failed Datadog delivery attempts |
object({
name_prefix = optional(string, "fleet-datadog-failure")
expires_days = optional(number, 1)
})
|
{
"expires_days": 1,
"name_prefix": "fleet-datadog-failure"
}
| no | +| [s3\_bucket\_tags](#input\_s3\_bucket\_tags) | Additional tags to apply to the S3 failure bucket. | `map(string)` | `{}` | no | ## Outputs | Name | Description | -|------|-------------| +| ---- | ----------- | | [fleet\_extra\_environment\_variables](#output\_fleet\_extra\_environment\_variables) | Environment variables to configure Fleet to use Datadog logging via Firehose | | [fleet\_extra\_iam\_policies](#output\_fleet\_extra\_iam\_policies) | IAM policies required for Fleet to log to Datadog via Firehose | | [fleet\_s3\_datadog\_failure\_config](#output\_fleet\_s3\_datadog\_failure\_config) | S3 bucket details - datadog-failure | diff --git a/addons/logging-destination-datadog/main.tf b/addons/logging-destination-datadog/main.tf index 0202541..05fc2e4 100644 --- a/addons/logging-destination-datadog/main.tf +++ b/addons/logging-destination-datadog/main.tf @@ -2,6 +2,7 @@ data "aws_region" "current" {} resource "aws_s3_bucket" "datadog-failure" { #tfsec:ignore:aws-s3-encryption-customer-key:exp:2022-07-01 #tfsec:ignore:aws-s3-enable-versioning #tfsec:ignore:aws-s3-enable-bucket-logging:exp:2022-06-15 bucket_prefix = var.s3_bucket_config.name_prefix + tags = var.s3_bucket_tags } resource "aws_s3_bucket_lifecycle_configuration" "datadog-failure" { diff --git a/addons/logging-destination-datadog/variables.tf b/addons/logging-destination-datadog/variables.tf index 5ba41d6..6db709c 100644 --- a/addons/logging-destination-datadog/variables.tf +++ b/addons/logging-destination-datadog/variables.tf @@ -70,3 +70,9 @@ variable "datadog_api_key" { description = "Datadog API key for authentication" sensitive = true } + +variable "s3_bucket_tags" { + description = "Additional tags to apply to the S3 failure bucket." + type = map(string) + default = {} +} diff --git a/addons/logging-destination-splunk/README.md b/addons/logging-destination-splunk/README.md index 88f2b8c..852b66b 100644 --- a/addons/logging-destination-splunk/README.md +++ b/addons/logging-destination-splunk/README.md @@ -100,8 +100,8 @@ No requirements. ## Providers | Name | Version | -|------|---------| -| [aws](#provider\_aws) | 6.41.0 | +| ---- | ------- | +| [aws](#provider\_aws) | n/a | ## Modules @@ -110,7 +110,7 @@ No modules. ## Resources | Name | Type | -|------|------| +| ---- | ---- | | [aws_iam_policy.firehose](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource | | [aws_iam_policy.firehose-logging](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource | | [aws_iam_role.firehose](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | @@ -130,16 +130,17 @@ No modules. ## Inputs | Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| +| ---- | ----------- | ---- | ------- | :------: | | [compression\_format](#input\_compression\_format) | Compression format for the Firehose delivery stream | `string` | `"UNCOMPRESSED"` | no | | [iam\_policy\_name](#input\_iam\_policy\_name) | n/a | `string` | `"splunk-firehose-policy"` | no | | [log\_destinations](#input\_log\_destinations) | A map of configurations for Splunk Firehose delivery streams. |
map(object({
# hec endpoint/token are logically optional but validated to enforce
name = string
hec_endpoint = optional(string)
hec_token = optional(string)
hec_acknowledgement_timeout = optional(number, 600)
hec_endpoint_type = optional(string, "Raw")
s3_buffering_size = optional(number, 2)
s3_buffering_interval = optional(number, 400)
s3_error_output_prefix = optional(string, null)

}))
|
{
"audit": {
"hec_acknowledgement_timeout": 600,
"hec_endpoint_type": "Raw",
"name": "fleet-audit-splunk",
"s3_buffering_interval": 400,
"s3_buffering_size": 10,
"s3_error_output_prefix": "audit/"
},
"results": {
"hec_acknowledgement_timeout": 600,
"hec_endpoint_type": "Raw",
"name": "fleet-osquery-results-splunk",
"s3_buffering_interval": 400,
"s3_buffering_size": 10,
"s3_error_output_prefix": "results/"
},
"status": {
"hec_acknowledgement_timeout": 600,
"hec_endpoint_type": "Raw",
"name": "fleet-osquery-status-splunk",
"s3_buffering_interval": 400,
"s3_buffering_size": 10,
"s3_error_output_prefix": "status/"
}
}
| no | | [s3\_bucket\_config](#input\_s3\_bucket\_config) | Configuration for the S3 bucket used to store failed Splunk delivery attempts |
object({
name_prefix = optional(string, "fleet-splunk-failure")
expires_days = optional(number, 1)
})
|
{
"expires_days": 1,
"name_prefix": "fleet-splunk-failure"
}
| no | +| [s3\_bucket\_tags](#input\_s3\_bucket\_tags) | Additional tags to apply to the S3 failure bucket. | `map(string)` | `{}` | no | ## Outputs | Name | Description | -|------|-------------| +| ---- | ----------- | | [fleet\_extra\_environment\_variables](#output\_fleet\_extra\_environment\_variables) | Environment variables to configure Fleet to use Splunk logging via Firehose | | [fleet\_extra\_iam\_policies](#output\_fleet\_extra\_iam\_policies) | IAM policies required for Fleet to log to Splunk via Firehose | | [fleet\_s3\_splunk\_failure\_config](#output\_fleet\_s3\_splunk\_failure\_config) | S3 bucket details - splunk-failure | diff --git a/addons/logging-destination-splunk/main.tf b/addons/logging-destination-splunk/main.tf index 9e8fa97..8a355de 100644 --- a/addons/logging-destination-splunk/main.tf +++ b/addons/logging-destination-splunk/main.tf @@ -3,6 +3,7 @@ data "aws_region" "current" {} resource "aws_s3_bucket" "splunk-failure" { #tfsec:ignore:aws-s3-encryption-customer-key:exp:2022-07-01 #tfsec:ignore:aws-s3-enable-versioning #tfsec:ignore:aws-s3-enable-bucket-logging:exp:2022-06-15 bucket_prefix = var.s3_bucket_config.name_prefix force_destroy = true + tags = var.s3_bucket_tags } resource "aws_s3_bucket_lifecycle_configuration" "splunk-failure" { diff --git a/addons/logging-destination-splunk/variables.tf b/addons/logging-destination-splunk/variables.tf index 3ca3c3b..eeec99b 100644 --- a/addons/logging-destination-splunk/variables.tf +++ b/addons/logging-destination-splunk/variables.tf @@ -71,3 +71,9 @@ variable "compression_format" { default = "UNCOMPRESSED" description = "Compression format for the Firehose delivery stream" } + +variable "s3_bucket_tags" { + description = "Additional tags to apply to the S3 failure bucket." + type = map(string) + default = {} +} diff --git a/addons/osquery-carve/README.md b/addons/osquery-carve/README.md index 466c944..2ae6ca0 100644 --- a/addons/osquery-carve/README.md +++ b/addons/osquery-carve/README.md @@ -21,15 +21,15 @@ This module automatically attaches a bucket policy that denies any requests made ## Requirements | Name | Version | -|------|---------| +| ---- | ------- | | [terraform](#requirement\_terraform) | >= 1.12.0 | | [aws](#requirement\_aws) | >= 6.37.0 | ## Providers | Name | Version | -|------|---------| -| [aws](#provider\_aws) | 6.41.0 | +| ---- | ------- | +| [aws](#provider\_aws) | 6.39.0 | ## Modules @@ -38,7 +38,7 @@ No modules. ## Resources | Name | Type | -|------|------| +| ---- | ---- | | [aws_iam_policy.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource | | [aws_kms_alias.osquery_carve](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_alias) | resource | | [aws_kms_key.osquery_carve](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource | @@ -59,12 +59,12 @@ No modules. ## Inputs | Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| [osquery\_carve\_s3\_bucket](#input\_osquery\_carve\_s3\_bucket) | Configuration for the osquery carve S3 bucket, including optional customer-managed KMS settings. |
object({
name = optional(string, "fleet-osquery-results-archive")
expires_days = optional(number, 1)
kms = optional(object({
kms_key_arn = optional(string, null)
create_kms_key = optional(bool, false)
kms_alias = optional(string, "osquery-carve")
kms_base_policy = optional(list(object({
sid = string
effect = string
principals = object({
type = string
identifiers = list(string)
})
actions = list(string)
resources = list(string)
conditions = optional(list(object({
test = string
variable = string
values = list(string)
})), [])
})), null)
extra_kms_policies = optional(list(any), [])
fleet_role_name = optional(string, null)
}), {
kms_key_arn = null
create_kms_key = false
kms_alias = "osquery-carve"
kms_base_policy = null
extra_kms_policies = []
fleet_role_name = null
})
})
|
{
"expires_days": 1,
"kms": {
"create_kms_key": false,
"extra_kms_policies": [],
"fleet_role_name": null,
"kms_alias": "osquery-carve",
"kms_base_policy": null,
"kms_key_arn": null
},
"name": "fleet-osquery-results-archive"
}
| no | +| ---- | ----------- | ---- | ------- | :------: | +| [osquery\_carve\_s3\_bucket](#input\_osquery\_carve\_s3\_bucket) | Configuration for the osquery carve S3 bucket, including optional customer-managed KMS settings. |
object({
name = optional(string, "fleet-osquery-results-archive")
expires_days = optional(number, 1)
tags = optional(map(string), {})
kms = optional(object({
kms_key_arn = optional(string, null)
create_kms_key = optional(bool, false)
kms_alias = optional(string, "osquery-carve")
kms_base_policy = optional(list(object({
sid = string
effect = string
principals = object({
type = string
identifiers = list(string)
})
actions = list(string)
resources = list(string)
conditions = optional(list(object({
test = string
variable = string
values = list(string)
})), [])
})), null)
extra_kms_policies = optional(list(any), [])
fleet_role_name = optional(string, null)
}), {
kms_key_arn = null
create_kms_key = false
kms_alias = "osquery-carve"
kms_base_policy = null
extra_kms_policies = []
fleet_role_name = null
})
})
|
{
"expires_days": 1,
"kms": {
"create_kms_key": false,
"extra_kms_policies": [],
"fleet_role_name": null,
"kms_alias": "osquery-carve",
"kms_base_policy": null,
"kms_key_arn": null
},
"name": "fleet-osquery-results-archive",
"tags": {}
}
| no | ## Outputs | Name | Description | -|------|-------------| +| ---- | ----------- | | [fleet\_extra\_environment\_variables](#output\_fleet\_extra\_environment\_variables) | n/a | | [fleet\_extra\_iam\_policies](#output\_fleet\_extra\_iam\_policies) | IAM policies required for Fleet to access the osquery carve S3 bucket. | diff --git a/addons/osquery-carve/main.tf b/addons/osquery-carve/main.tf index 0e143cf..66e3e88 100644 --- a/addons/osquery-carve/main.tf +++ b/addons/osquery-carve/main.tf @@ -82,6 +82,7 @@ data "aws_iam_role" "osquery_carve_fleet" { resource "aws_s3_bucket" "main" { #tfsec:ignore:aws-s3-encryption-customer-key:exp:2028-07-01 #tfsec:ignore:aws-s3-enable-versioning #tfsec:ignore:aws-s3-enable-bucket-logging:exp:2028-07-01 bucket = var.osquery_carve_s3_bucket.name + tags = var.osquery_carve_s3_bucket.tags } resource "aws_s3_bucket_lifecycle_configuration" "main" { diff --git a/addons/osquery-carve/variables.tf b/addons/osquery-carve/variables.tf index 5e17bf6..52e9cf1 100644 --- a/addons/osquery-carve/variables.tf +++ b/addons/osquery-carve/variables.tf @@ -2,6 +2,7 @@ variable "osquery_carve_s3_bucket" { type = object({ name = optional(string, "fleet-osquery-results-archive") expires_days = optional(number, 1) + tags = optional(map(string), {}) kms = optional(object({ kms_key_arn = optional(string, null) create_kms_key = optional(bool, false) @@ -36,6 +37,7 @@ variable "osquery_carve_s3_bucket" { default = { name = "fleet-osquery-results-archive" expires_days = 1 + tags = {} kms = { kms_key_arn = null create_kms_key = false From 5c22e0388ad88464f3d2c63723a701425b4dc327 Mon Sep 17 00:00:00 2001 From: Luke Heath Date: Wed, 15 Jul 2026 12:07:17 -0700 Subject: [PATCH 3/7] Bump Fleet version to v4.89.0 (#269) --- byo-vpc/byo-db/byo-ecs/variables.tf | 4 ++-- byo-vpc/byo-db/variables.tf | 4 ++-- byo-vpc/example/main.tf | 2 +- byo-vpc/variables.tf | 4 ++-- example/main.tf | 2 +- gcp/.header.md | 2 +- gcp/byo-project/variables.tf | 2 +- gcp/variables.tf | 2 +- variables.tf | 4 ++-- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/byo-vpc/byo-db/byo-ecs/variables.tf b/byo-vpc/byo-db/byo-ecs/variables.tf index becc233..2a10d79 100644 --- a/byo-vpc/byo-db/byo-ecs/variables.tf +++ b/byo-vpc/byo-db/byo-ecs/variables.tf @@ -41,7 +41,7 @@ variable "fleet_config" { pid_mode = optional(string, null) command = optional(list(string), null) private_key_delivery_method = optional(string, "ecs") - image = optional(string, "fleetdm/fleet:v4.88.1") + image = optional(string, "fleetdm/fleet:v4.89.0") family = optional(string, "fleet") sidecars = optional(list(any), []) depends_on = optional(list(any), []) @@ -203,7 +203,7 @@ variable "fleet_config" { pid_mode = null command = null private_key_delivery_method = "ecs" - image = "fleetdm/fleet:v4.88.1" + image = "fleetdm/fleet:v4.89.0" family = "fleet" sidecars = [] depends_on = [] diff --git a/byo-vpc/byo-db/variables.tf b/byo-vpc/byo-db/variables.tf index 2dcbb5a..f729081 100644 --- a/byo-vpc/byo-db/variables.tf +++ b/byo-vpc/byo-db/variables.tf @@ -162,7 +162,7 @@ variable "fleet_config" { pid_mode = optional(string, null) command = optional(list(string), null) private_key_delivery_method = optional(string, "ecs") - image = optional(string, "fleetdm/fleet:v4.88.1") + image = optional(string, "fleetdm/fleet:v4.89.0") family = optional(string, "fleet") sidecars = optional(list(any), []) depends_on = optional(list(any), []) @@ -364,7 +364,7 @@ variable "fleet_config" { pid_mode = null command = null private_key_delivery_method = "ecs" - image = "fleetdm/fleet:v4.88.1" + image = "fleetdm/fleet:v4.89.0" family = "fleet" sidecars = [] depends_on = [] diff --git a/byo-vpc/example/main.tf b/byo-vpc/example/main.tf index f7d0a3b..e98ba44 100644 --- a/byo-vpc/example/main.tf +++ b/byo-vpc/example/main.tf @@ -17,7 +17,7 @@ provider "aws" { } locals { - fleet_image = "fleetdm/fleet:v4.88.1" + fleet_image = "fleetdm/fleet:v4.89.0" domain_name = "example.com" } diff --git a/byo-vpc/variables.tf b/byo-vpc/variables.tf index 4bfc208..23155d9 100644 --- a/byo-vpc/variables.tf +++ b/byo-vpc/variables.tf @@ -433,7 +433,7 @@ variable "fleet_config" { pid_mode = optional(string, null) command = optional(list(string), null) private_key_delivery_method = optional(string, "ecs") - image = optional(string, "fleetdm/fleet:v4.88.1") + image = optional(string, "fleetdm/fleet:v4.89.0") family = optional(string, "fleet") sidecars = optional(list(any), []) depends_on = optional(list(any), []) @@ -635,7 +635,7 @@ variable "fleet_config" { pid_mode = null command = null private_key_delivery_method = "ecs" - image = "fleetdm/fleet:v4.88.1" + image = "fleetdm/fleet:v4.89.0" family = "fleet" sidecars = [] depends_on = [] diff --git a/example/main.tf b/example/main.tf index bb29fc4..1339213 100644 --- a/example/main.tf +++ b/example/main.tf @@ -89,7 +89,7 @@ module "fleet" { fleet_config = { # To avoid pull-rate limiting from dockerhub, consider using our quay.io mirror # for the Fleet image. e.g. "quay.io/fleetdm/fleet:v4.67.0" - image = "fleetdm/fleet:v4.88.1" # override default to deploy the image you desire + image = "fleetdm/fleet:v4.89.0" # override default to deploy the image you desire # See https://fleetdm.com/docs/deploy/reference-architectures#aws for appropriate scaling # memory and cpu. autoscaling = { diff --git a/gcp/.header.md b/gcp/.header.md index 289f41f..a0a86cb 100644 --- a/gcp/.header.md +++ b/gcp/.header.md @@ -89,7 +89,7 @@ This Terraform project automates the deployment of Fleet Device Management (Flee * `dns_zone_name`: The DNS zone that will be created/managed in Cloud DNS (e.g., `mydomain.com.`). **Must end with a dot.** * `dns_record_name`: The specific DNS record for Fleet (e.g., `fleet.mydomain.com.`). **Must end with a dot.** * `project_name`: A descriptive name for the project to be created. -* `fleet_config.image_tag`: The Docker image tag for the Fleet version you want to deploy (e.g., `fleetdm/fleet:v4.88.1`). +* `fleet_config.image_tag`: The Docker image tag for the Fleet version you want to deploy (e.g., `fleetdm/fleet:v4.89.0`). * `fleet_config.exec_migration`: Set to `true` when you are upgrading the `fleet_config.image_tag` to automatically run database migrations. Set to `false` if you want to manage migrations manually or if it's not an image upgrade. * `fleet_config.license_key` (Optional, inside the `fleet_config` object): Your Fleet license key if you have one. diff --git a/gcp/byo-project/variables.tf b/gcp/byo-project/variables.tf index 0f5bb98..47933de 100644 --- a/gcp/byo-project/variables.tf +++ b/gcp/byo-project/variables.tf @@ -107,7 +107,7 @@ variable "fleet_config" { }))) }) default = { - image_tag = "fleetdm/fleet:v4.88.1" + image_tag = "fleetdm/fleet:v4.89.0" installers_bucket_name = "" fleet_cpu = "1000m" fleet_memory = "4096Mi" diff --git a/gcp/variables.tf b/gcp/variables.tf index abedbfd..e358cae 100644 --- a/gcp/variables.tf +++ b/gcp/variables.tf @@ -137,7 +137,7 @@ variable "fleet_config" { }))) }) default = { - image_tag = "fleetdm/fleet:v4.88.1" + image_tag = "fleetdm/fleet:v4.89.0" installers_bucket_name = "" # Bucket names must be globally unique fleet_cpu = "1000m" fleet_memory = "4096Mi" diff --git a/variables.tf b/variables.tf index 1801d32..d454080 100644 --- a/variables.tf +++ b/variables.tf @@ -595,7 +595,7 @@ variable "fleet_config" { pid_mode = optional(string, null) command = optional(list(string), null) private_key_delivery_method = optional(string, "ecs") - image = optional(string, "fleetdm/fleet:v4.88.1") + image = optional(string, "fleetdm/fleet:v4.89.0") family = optional(string, "fleet") sidecars = optional(list(any), []) depends_on = optional(list(any), []) @@ -797,7 +797,7 @@ variable "fleet_config" { pid_mode = null command = null private_key_delivery_method = "ecs" - image = "fleetdm/fleet:v4.88.1" + image = "fleetdm/fleet:v4.89.0" family = "fleet" sidecars = [] depends_on = [] From 2837d1621fdc560fe6da0ed2a17f2844a2176cbe Mon Sep 17 00:00:00 2001 From: George Karr Date: Thu, 16 Jul 2026 12:02:40 -0700 Subject: [PATCH 4/7] bumping version (#270) --- byo-vpc/byo-db/byo-ecs/variables.tf | 4 ++-- byo-vpc/byo-db/variables.tf | 4 ++-- byo-vpc/example/main.tf | 2 +- byo-vpc/variables.tf | 4 ++-- example/main.tf | 2 +- gcp/.header.md | 2 +- gcp/byo-project/variables.tf | 2 +- gcp/variables.tf | 2 +- variables.tf | 4 ++-- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/byo-vpc/byo-db/byo-ecs/variables.tf b/byo-vpc/byo-db/byo-ecs/variables.tf index 2a10d79..9033087 100644 --- a/byo-vpc/byo-db/byo-ecs/variables.tf +++ b/byo-vpc/byo-db/byo-ecs/variables.tf @@ -41,7 +41,7 @@ variable "fleet_config" { pid_mode = optional(string, null) command = optional(list(string), null) private_key_delivery_method = optional(string, "ecs") - image = optional(string, "fleetdm/fleet:v4.89.0") + image = optional(string, "fleetdm/fleet:v4.89.1") family = optional(string, "fleet") sidecars = optional(list(any), []) depends_on = optional(list(any), []) @@ -203,7 +203,7 @@ variable "fleet_config" { pid_mode = null command = null private_key_delivery_method = "ecs" - image = "fleetdm/fleet:v4.89.0" + image = "fleetdm/fleet:v4.89.1" family = "fleet" sidecars = [] depends_on = [] diff --git a/byo-vpc/byo-db/variables.tf b/byo-vpc/byo-db/variables.tf index f729081..3708549 100644 --- a/byo-vpc/byo-db/variables.tf +++ b/byo-vpc/byo-db/variables.tf @@ -162,7 +162,7 @@ variable "fleet_config" { pid_mode = optional(string, null) command = optional(list(string), null) private_key_delivery_method = optional(string, "ecs") - image = optional(string, "fleetdm/fleet:v4.89.0") + image = optional(string, "fleetdm/fleet:v4.89.1") family = optional(string, "fleet") sidecars = optional(list(any), []) depends_on = optional(list(any), []) @@ -364,7 +364,7 @@ variable "fleet_config" { pid_mode = null command = null private_key_delivery_method = "ecs" - image = "fleetdm/fleet:v4.89.0" + image = "fleetdm/fleet:v4.89.1" family = "fleet" sidecars = [] depends_on = [] diff --git a/byo-vpc/example/main.tf b/byo-vpc/example/main.tf index e98ba44..39d640b 100644 --- a/byo-vpc/example/main.tf +++ b/byo-vpc/example/main.tf @@ -17,7 +17,7 @@ provider "aws" { } locals { - fleet_image = "fleetdm/fleet:v4.89.0" + fleet_image = "fleetdm/fleet:v4.89.1" domain_name = "example.com" } diff --git a/byo-vpc/variables.tf b/byo-vpc/variables.tf index 23155d9..e71ddba 100644 --- a/byo-vpc/variables.tf +++ b/byo-vpc/variables.tf @@ -433,7 +433,7 @@ variable "fleet_config" { pid_mode = optional(string, null) command = optional(list(string), null) private_key_delivery_method = optional(string, "ecs") - image = optional(string, "fleetdm/fleet:v4.89.0") + image = optional(string, "fleetdm/fleet:v4.89.1") family = optional(string, "fleet") sidecars = optional(list(any), []) depends_on = optional(list(any), []) @@ -635,7 +635,7 @@ variable "fleet_config" { pid_mode = null command = null private_key_delivery_method = "ecs" - image = "fleetdm/fleet:v4.89.0" + image = "fleetdm/fleet:v4.89.1" family = "fleet" sidecars = [] depends_on = [] diff --git a/example/main.tf b/example/main.tf index 1339213..448b73a 100644 --- a/example/main.tf +++ b/example/main.tf @@ -89,7 +89,7 @@ module "fleet" { fleet_config = { # To avoid pull-rate limiting from dockerhub, consider using our quay.io mirror # for the Fleet image. e.g. "quay.io/fleetdm/fleet:v4.67.0" - image = "fleetdm/fleet:v4.89.0" # override default to deploy the image you desire + image = "fleetdm/fleet:v4.89.1" # override default to deploy the image you desire # See https://fleetdm.com/docs/deploy/reference-architectures#aws for appropriate scaling # memory and cpu. autoscaling = { diff --git a/gcp/.header.md b/gcp/.header.md index a0a86cb..d6510b3 100644 --- a/gcp/.header.md +++ b/gcp/.header.md @@ -89,7 +89,7 @@ This Terraform project automates the deployment of Fleet Device Management (Flee * `dns_zone_name`: The DNS zone that will be created/managed in Cloud DNS (e.g., `mydomain.com.`). **Must end with a dot.** * `dns_record_name`: The specific DNS record for Fleet (e.g., `fleet.mydomain.com.`). **Must end with a dot.** * `project_name`: A descriptive name for the project to be created. -* `fleet_config.image_tag`: The Docker image tag for the Fleet version you want to deploy (e.g., `fleetdm/fleet:v4.89.0`). +* `fleet_config.image_tag`: The Docker image tag for the Fleet version you want to deploy (e.g., `fleetdm/fleet:v4.89.1`). * `fleet_config.exec_migration`: Set to `true` when you are upgrading the `fleet_config.image_tag` to automatically run database migrations. Set to `false` if you want to manage migrations manually or if it's not an image upgrade. * `fleet_config.license_key` (Optional, inside the `fleet_config` object): Your Fleet license key if you have one. diff --git a/gcp/byo-project/variables.tf b/gcp/byo-project/variables.tf index 47933de..057c15c 100644 --- a/gcp/byo-project/variables.tf +++ b/gcp/byo-project/variables.tf @@ -107,7 +107,7 @@ variable "fleet_config" { }))) }) default = { - image_tag = "fleetdm/fleet:v4.89.0" + image_tag = "fleetdm/fleet:v4.89.1" installers_bucket_name = "" fleet_cpu = "1000m" fleet_memory = "4096Mi" diff --git a/gcp/variables.tf b/gcp/variables.tf index e358cae..26a9d6f 100644 --- a/gcp/variables.tf +++ b/gcp/variables.tf @@ -137,7 +137,7 @@ variable "fleet_config" { }))) }) default = { - image_tag = "fleetdm/fleet:v4.89.0" + image_tag = "fleetdm/fleet:v4.89.1" installers_bucket_name = "" # Bucket names must be globally unique fleet_cpu = "1000m" fleet_memory = "4096Mi" diff --git a/variables.tf b/variables.tf index d454080..9dfa7d5 100644 --- a/variables.tf +++ b/variables.tf @@ -595,7 +595,7 @@ variable "fleet_config" { pid_mode = optional(string, null) command = optional(list(string), null) private_key_delivery_method = optional(string, "ecs") - image = optional(string, "fleetdm/fleet:v4.89.0") + image = optional(string, "fleetdm/fleet:v4.89.1") family = optional(string, "fleet") sidecars = optional(list(any), []) depends_on = optional(list(any), []) @@ -797,7 +797,7 @@ variable "fleet_config" { pid_mode = null command = null private_key_delivery_method = "ecs" - image = "fleetdm/fleet:v4.89.0" + image = "fleetdm/fleet:v4.89.1" family = "fleet" sidecars = [] depends_on = [] From 1ce4979133a7f9e6d2a6d70b5bed8257b1a3c325 Mon Sep 17 00:00:00 2001 From: Jorge Falcon <22119513+BCTBB@users.noreply.github.com> Date: Tue, 21 Jul 2026 12:02:49 -0400 Subject: [PATCH 5/7] Document Restore/Rollback Process and Tooling for Fleet deploy on AWS (#236) - Adds `tools/rds-db-restore/README.md` - Documentation for the restore process. - Adds `tools/rds-db-restore/db-restore.sh` - Script to restore and rollback Fleet to an earlier state. --- tools/rds-db-restore/README.md | 233 +++++ tools/rds-db-restore/db-restore.sh | 1406 ++++++++++++++++++++++++++++ 2 files changed, 1639 insertions(+) create mode 100644 tools/rds-db-restore/README.md create mode 100755 tools/rds-db-restore/db-restore.sh diff --git a/tools/rds-db-restore/README.md b/tools/rds-db-restore/README.md new file mode 100644 index 0000000..1e81f2b --- /dev/null +++ b/tools/rds-db-restore/README.md @@ -0,0 +1,233 @@ +# Fleet database restore on AWS + +`db-restore.sh` automates the restoration of a Fleet-managed Aurora database cluster using Terraform and AWS RDS APIs. It supports point-in-time recovery (PITR), RDS snapshot restoration, dry-runs, ECS scale-down handling, optional Fleet image rollback, RDS master username updates, and delayed cleanup of old DB resources. + +This script is designed for self-hosted Fleet deployments provisioned via `fleet-terraform`. + +> **Note:** Fleet built and tested `db-restore.sh` against the [`fleet-terraform/example`](https://github.com/fleetdm/fleet-terraform/tree/main/example) (Standard) deployment layout. If your Fleet deployment is not based on `fleet-terraform/example`, this script will not support your restore. + +## Prerequisites + +- `terraform`, `aws` CLI, `jq`, `perl`, and `python3` on your `PATH` +- AWS credentials configured with permissions to manage RDS, ECS, IAM, Secrets Manager, and EC2 security groups in the target region +- The target `fleet-terraform` environment directory checked out locally + +## Quick start + +The script does not need to live in your environment directory, but you should run it from there. It defaults to `$PWD` for Terraform state and config. `cd` into your environment directory before running it, whether the script lives inside that directory or somewhere else on disk. + +Every restore command needs exactly one restore source. Use `--restore-time ` for point-in-time recovery (PITR), or `--restore-snapshot ` to restore from an RDS DB cluster snapshot. Each step below shows both forms. + +1. **Run from inside the environment directory:** + ```bash + cd fleet-terraform/example + AWS_PROFILE= /path/to/db-restore.sh --list + ``` +2. **Dry-run the restore:** + + PITR: + ```bash + AWS_PROFILE= /path/to/db-restore.sh \ + --restore-time 2026-05-05T11:00:00Z \ + --dry-run + ``` + Snapshot: + ```bash + AWS_PROFILE= /path/to/db-restore.sh \ + --restore-snapshot arn:aws:rds:us-east-2:123456789012:cluster-snapshot:fleet-prod-manual-2026-04-06 \ + --dry-run + ``` +3. **Execute the restore:** + + PITR: + ```bash + AWS_PROFILE= /path/to/db-restore.sh \ + --restore-time 2026-05-05T11:00:00Z \ + --confirm + ``` + Snapshot: + ```bash + AWS_PROFILE= /path/to/db-restore.sh \ + --restore-snapshot arn:aws:rds:us-east-2:123456789012:cluster-snapshot:fleet-prod-manual-2026-04-06 \ + --confirm + ``` + +## Supported Terraform layouts + +The script works with `fleet-terraform` layouts by auto-detecting the parent module address from Terraform state. It searches for `module.rds.aws_rds_cluster.this` and uses the path preceding it as the base. + +| Layout | Environment Directory | Auto-detected `MODULE_ADDRESS` | +|---|---|---| +| Standard | `fleet-terraform/example` | `module.fleet.module.byo-vpc` | +| BYO-VPC *(not verified; contact Fleet customer support before use)* | `fleet-terraform/byo-vpc/example` | `module.byo-vpc.module.byo-db` | + +## Execution path + +When running a standard restore with migrations enabled, the script performs the following steps: + +1. Captures a full copy of Terraform state and resource metadata into `.db-restore-/`. +2. Optionally updates `fleet_config.image` if `--rollback` and `--fleet-image` are provided. Supports literal values and `local.*` references whose definitions are literals in the same file. `var.*` expressions are rejected. +3. Optionally adds/updates `rds_config.master_username` if `--master-username` is provided. +4. Updates the `rds_config` block to point to the restored database. +5. Scales Fleet ECS services to `0` so no tasks connect during the restore. +6. Removes old RDS resources from Terraform state. +7. Creates a new Aurora cluster from the chosen restore point. +8. Restores the original `rds_config` and re-applies monitoring/observability settings. +9. Applies ECS services and runs database migrations (`module.migrations`). +10. Scales ECS services back up. +11. Keeps old DB resources intact for safe cleanup later. + +## Configuration & flags + +| Flag | Required | Description | +|---|---|---| +| `--cleanup-only` | No | Cleanup mode. Requires `--manifest` pointing to the `manifest.json` written under `.db-restore-/` by a previous run. Deletes old DB resources from that restore. | +| `--cleanup-old-resources` | No | Delete old DB resources immediately after restore. Default keeps them for safe later cleanup. | +| `--confirm` | No | Skips the interactive typed confirmation prompt. Without it, you will be prompted to type the environment name. | +| `--config-file ` | No | Terraform file containing `rds_config`. Default: `/main.tf`. | +| `--destination-name ` | No | Override restored DB name. Default increments from current cluster name. | +| `--dry-run` | No | Print the execution path and planned mutations. Creates a manifest without applying changes. | +| `--env-dir ` | No | Root directory containing the environment. Default: `$PWD`. | +| `--fleet-image ` | No | Specifies the Fleet image version when using `--rollback`. | +| `--help` | No | Show help text. | +| `--master-username ` | No | Set `rds_config.master_username`. Adds if absent, updates if present. Requires fleet-terraform root module tag >= `tf-mod-root-v1.28.0` or byo-vpc tag >= `tf-mod-byo-vpc-v1.29.0`. | +| `--manifest ` | Yes (with `--cleanup-only`) | Path to the `manifest.json` JSON file produced by a prior restore (written under `.db-restore-/`). Accepts an absolute or relative path; absolute is convenient when invoking the script from outside the environment directory. Used by `--cleanup-only`. | +| `--module-address ` | No | Terraform address of the parent module. Auto-detected when possible. | +| `--no-ecs-apply` | No | Do not apply ECS targets or scale services back up. Services remain at `0` for manual validation. | +| `--old-final-snapshot-id ` | No | Final snapshot ID for old cluster deletion. Auto-generated if omitted, in the form `-pre-restore-retirement-`. | +| `--region ` | No | AWS region. Default: `AWS_REGION` / `AWS_DEFAULT_REGION` / `us-east-2`. | +| `--restore-snapshot ` | No | Restore from an RDS DB cluster snapshot identifier or ARN. | +| `--restore-time