Support for internal load balancer and deletion protection, iam policy attachment processing, osquery perf fix, and cloudfront software installers (#105)

# Main terraform

- Modified iam `resource "aws_iam_role_policy_attachment" "extras"` from
`for_each` to `count`, which allows terraform to apply even if roles are
not yet created. In cases where role is not yet created, a second
terraform apply is required for the resource to attach the policy.
- Modified iam `resource "aws_iam_role_policy_attachment"
"execution_extras"`, which allows terraform to apply even if roles are
not yet created. In cases where role is not yet created, a second
terraform apply is required for the resource to attach the policy.
- Added support for internal load balancers to be provisioned.
- Added support for toggling deletion protection on and off on the load
balancer resource.

# Example Module

- Updated example module with changes alb changes.

# Module: Cloudfront Software Installers

- Added a count & tertiary to cloudfront software installer kms key
policy, as it's fed in as an input. In cases where the key had not yet
been created, apply would fail.
- Modified `variable "s3_kms_key_id"` to allow default value `null`

# Module: Logging Destination Firehose

- Added prefix variable to support use-cases where multiple environments
are deployed in the same account

# Module: Osquery Perf

- Added dependency on
`data.aws_secretsmanager_secret_version.enroll_secret` to fix race
condition.
This commit is contained in:
Jorge Falcon authored and GitHub committed 2025-09-19 16:16:22 -04:00
1 parent 1d8bd3007d
commit ae8863ce64
22 files changed
+167 -191

No files matched your search

+25 -42
View File
@@ -73,7 +73,7 @@ locals {
}
module "fleet" {
source = "github.com/fleetdm/fleet-terraform?depth=1&ref=tf-mod-root-v1.18.0"
source = "github.com/fleetdm/fleet-terraform?depth=1&ref=tf-mod-root-v1.18.1"
certificate_arn = module.acm.acm_certificate_arn
vpc = {
@@ -99,14 +99,17 @@ module "fleet" {
cpu = 512
extra_environment_variables = merge(
local.fleet_environment_variables,
# uncomment if using a3 carves
# uncomment if using s3 carves
# module.osquery-carve.fleet_extra_environment_variables
# uncomment if using firehose
# module.firehose-logging.fleet_extra_environment_variables
)
# Uncomment if enabling mdm module below.
# extra_secrets = module.mdm.extra_secrets
# extra_execution_iam_policies = module.mdm.extra_execution_iam_policies
extra_secrets = concat(
module.mdm.extra_secrets,
)
extra_execution_iam_policies = concat(
module.mdm.extra_execution_iam_policies,
)
# extra_iam_policies = concat(
# uncomment if using a3 carves
# module.osquery-carve.fleet_extra_iam_policies,
@@ -142,6 +145,10 @@ module "fleet" {
# Script execution can run for up to 300s plus overhead.
# Ensure the load balancer does not 5XX before we have results.
idle_timeout = 905
# Optionally deploy load balancer as an internal load balancer
# internal = true
# optionally set deletion protection on (true) or off (false)
# enable_deletion_protection = true
# Optionally Remove X-Forwarded-For header
# xff_header_processing_mode = "remove"
# See https://github.com/terraform-aws-modules/terraform-aws-alb/blob/v9.17.0/examples/complete-alb/main.tf#L383-L393.
@@ -223,7 +230,6 @@ module "fleet" {
# ]
# }]
# }], local.https_listener_rules)
}
}
@@ -242,6 +248,10 @@ module "migrations" {
ecs_service = module.fleet.byo-vpc.byo-db.byo-ecs.service.name
desired_count = module.fleet.byo-vpc.byo-db.byo-ecs.appautoscaling_target.min_capacity
min_capacity = module.fleet.byo-vpc.byo-db.byo-ecs.appautoscaling_target.min_capacity
depends_on = [
module.fleet,
]
}
# Enable if using s3 for carves
@@ -254,7 +264,7 @@ module "migrations" {
# Uncomment if using firehose logging destination
# module "firehose-logging" {
# source = "github.com/fleetdm/fleet-terraform/addons/logging-destination-firehose?depth=1&ref=tf-mod-addon-logging-destination-firehose-v1.2.1"
# source = "github.com/fleetdm/fleet-terraform/addons/logging-destination-firehose?depth=1&ref=tf-mod-addon-logging-destination-firehose-v1.2.4"
# osquery_results_s3_bucket = {
# name = local.osquery_results_bucket_name
# }
@@ -263,13 +273,6 @@ module "migrations" {
# }
# }
## MDM
# MDM Secrets must be populated with JSON data including the payload from the certs, keys, challenge, etc.
# These can be populated via terraform with a secret-version, or manually after terraform is applied.
# Note: Services will not start if the mdm module is enabled and the secrets are applied but not populated.
## MDM Secret payload
# See https://github.com/fleetdm/fleet-terraform/blob/tf-mod-addon-mdm-v2.0.0/addons/mdm/README.md#abm
@@ -277,34 +280,14 @@ module "migrations" {
# the Windows MDM secrets still use this as the all Mac MDM is managed via the Fleet UI and is therefore
# disabled in the module.
# module "mdm" {
# source = "github.com/fleetdm/fleet-terraform/addons/mdm?depth=1&ref=tf-mod-addon-mdm-v2.0.0"
# apn_secret_name = null
# scep_secret_name = "fleet-scep"
# # Set abm_secret_name = null if customer is not using dep
# abm_secret_name = null
# enable_apple_mdm = false
# enable_windows_mdm = true
# }
# If you want to supply the MDM secrets via terraform, I recommend that you do not store the secrets in the clear
# on the device that applies the terraform. For the example here, terraform will create a KMS key, which will then
# be used to encrypt the secrets. The included mdm-secrets.tf file will then use the KMS key to dercrypt the secrets
# on the filesystem to generate the
# resource "aws_kms_key" "fleet_data_key" {
# description = "key used to encrypt sensitive data stored in terraform"
# }
#
# resource "aws_kms_alias" "alias" {
# name = "alias/fleet-terraform-encrypted"
# target_key_id = aws_kms_key.fleet_data_key.id
# }
#
# output "kms_key_id" {
# value = aws_kms_key.fleet_data_key.id
# }
module "mdm" {
source = "github.com/fleetdm/fleet-terraform/addons/mdm?depth=1&ref=tf-mod-addon-mdm-v2.0.0"
apn_secret_name = null
scep_secret_name = "fleet-scep"
abm_secret_name = null
enable_apple_mdm = false
enable_windows_mdm = true
}
module "acm" {
source = "terraform-aws-modules/acm/aws"