From ae8863ce649318d6f847514dbfb2b914375bff28 Mon Sep 17 00:00:00 2001 From: Jorge Falcon <22119513+BCTBB@users.noreply.github.com> Date: Fri, 19 Sep 2025 16:16:22 -0400 Subject: [PATCH] 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. --- README.md | 2 +- addons/cloudfront-software-installers/main.tf | 1 + .../variables.tf | 1 + addons/logging-destination-firehose/README.md | 3 +- addons/logging-destination-firehose/main.tf | 6 +- .../logging-destination-firehose/variables.tf | 5 ++ addons/osquery-perf/.header.md | 16 +++- addons/osquery-perf/README.md | 26 ++++-- addons/osquery-perf/main.tf | 13 +-- addons/osquery-perf/outputs.tf | 7 ++ addons/osquery-perf/variables.tf | 11 ++- byo-vpc/README.md | 4 +- byo-vpc/byo-db/README.md | 4 +- byo-vpc/byo-db/byo-ecs/iam.tf | 8 +- byo-vpc/byo-db/main.tf | 2 + byo-vpc/byo-db/variables.tf | 2 + byo-vpc/variables.tf | 2 + example/.header.md | 33 ++----- example/README.md | 53 ++++------- example/main.tf | 67 ++++++-------- example/mdm-secrets.tf | 90 +++++++------------ variables.tf | 2 + 22 files changed, 167 insertions(+), 191 deletions(-) create mode 100644 addons/osquery-perf/outputs.tf diff --git a/README.md b/README.md index f95c405..fac7ccd 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ No resources. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [alb\_config](#input\_alb\_config) | n/a |
object({
name = optional(string, "fleet")
security_groups = optional(list(string), [])
access_logs = optional(map(string), {})
allowed_cidrs = optional(list(string), ["0.0.0.0/0"])
allowed_ipv6_cidrs = optional(list(string), ["::/0"])
egress_cidrs = optional(list(string), ["0.0.0.0/0"])
egress_ipv6_cidrs = optional(list(string), ["::/0"])
extra_target_groups = optional(any, [])
https_listener_rules = optional(any, [])
https_overrides = optional(any, {})
xff_header_processing_mode = optional(string, null)
tls_policy = optional(string, "ELBSecurityPolicy-TLS13-1-2-2021-06")
idle_timeout = optional(number, 905)
}) | `{}` | no |
+| [alb\_config](#input\_alb\_config) | n/a | object({
name = optional(string, "fleet")
security_groups = optional(list(string), [])
access_logs = optional(map(string), {})
allowed_cidrs = optional(list(string), ["0.0.0.0/0"])
allowed_ipv6_cidrs = optional(list(string), ["::/0"])
egress_cidrs = optional(list(string), ["0.0.0.0/0"])
egress_ipv6_cidrs = optional(list(string), ["::/0"])
extra_target_groups = optional(any, [])
https_listener_rules = optional(any, [])
https_overrides = optional(any, {})
xff_header_processing_mode = optional(string, null)
tls_policy = optional(string, "ELBSecurityPolicy-TLS13-1-2-2021-06")
idle_timeout = optional(number, 905)
internal = optional(bool, false)
enable_deletion_protection = optional(bool, true)
}) | `{}` | no |
| [certificate\_arn](#input\_certificate\_arn) | n/a | `string` | n/a | yes |
| [ecs\_cluster](#input\_ecs\_cluster) | The config for the terraform-aws-modules/ecs/aws module | object({
autoscaling_capacity_providers = optional(any, {})
cluster_configuration = optional(any, {
execute_command_configuration = {
logging = "OVERRIDE"
log_configuration = {
cloud_watch_log_group_name = "/aws/ecs/aws-ec2"
}
}
})
cluster_name = optional(string, "fleet")
cluster_settings = optional(map(string), {
"name" : "containerInsights",
"value" : "enabled",
})
create = optional(bool, true)
default_capacity_provider_use_fargate = optional(bool, true)
fargate_capacity_providers = optional(any, {
FARGATE = {
default_capacity_provider_strategy = {
weight = 100
}
}
FARGATE_SPOT = {
default_capacity_provider_strategy = {
weight = 0
}
}
})
tags = optional(map(string))
}) | {
"autoscaling_capacity_providers": {},
"cluster_configuration": {
"execute_command_configuration": {
"log_configuration": {
"cloud_watch_log_group_name": "/aws/ecs/aws-ec2"
},
"logging": "OVERRIDE"
}
},
"cluster_name": "fleet",
"cluster_settings": {
"name": "containerInsights",
"value": "enabled"
},
"create": true,
"default_capacity_provider_use_fargate": true,
"fargate_capacity_providers": {
"FARGATE": {
"default_capacity_provider_strategy": {
"weight": 100
}
},
"FARGATE_SPOT": {
"default_capacity_provider_strategy": {
"weight": 0
}
}
},
"tags": {}
} | no |
| [fleet\_config](#input\_fleet\_config) | The configuration object for Fleet itself. Fields that default to null will have their respective resources created if not specified. | object({
task_mem = optional(number, null)
task_cpu = optional(number, null)
mem = optional(number, 4096)
cpu = optional(number, 512)
pid_mode = optional(string, null)
image = optional(string, "fleetdm/fleet:v4.72.1")
family = optional(string, "fleet")
sidecars = optional(list(any), [])
depends_on = optional(list(any), [])
mount_points = optional(list(any), [])
volumes = optional(list(any), [])
extra_environment_variables = optional(map(string), {})
extra_iam_policies = optional(list(string), [])
extra_execution_iam_policies = optional(list(string), [])
extra_secrets = optional(map(string), {})
security_group_name = optional(string, "fleet")
iam_role_arn = optional(string, null)
repository_credentials = optional(string, "")
private_key_secret_name = optional(string, "fleet-server-private-key")
service = optional(object({
name = optional(string, "fleet")
}), {
name = "fleet"
})
database = optional(object({
password_secret_arn = string
user = string
database = string
address = string
rr_address = optional(string, null)
}), {
password_secret_arn = null
user = null
database = null
address = null
rr_address = null
})
redis = optional(object({
address = string
use_tls = optional(bool, true)
}), {
address = null
use_tls = true
})
awslogs = optional(object({
name = optional(string, null)
region = optional(string, null)
create = optional(bool, true)
prefix = optional(string, "fleet")
retention = optional(number, 5)
}), {
name = null
region = null
prefix = "fleet"
retention = 5
})
loadbalancer = optional(object({
arn = string
}), {
arn = null
})
extra_load_balancers = optional(list(any), [])
networking = optional(object({
subnets = optional(list(string), null)
security_groups = optional(list(string), null)
ingress_sources = optional(object({
cidr_blocks = optional(list(string), [])
ipv6_cidr_blocks = optional(list(string), [])
security_groups = optional(list(string), [])
prefix_list_ids = optional(list(string), [])
}), {
cidr_blocks = []
ipv6_cidr_blocks = []
security_groups = []
prefix_list_ids = []
})
}), {
subnets = null
security_groups = null
ingress_sources = {
cidr_blocks = []
ipv6_cidr_blocks = []
security_groups = []
prefix_list_ids = []
}
})
autoscaling = optional(object({
max_capacity = optional(number, 5)
min_capacity = optional(number, 1)
memory_tracking_target_value = optional(number, 80)
cpu_tracking_target_value = optional(number, 80)
}), {
max_capacity = 5
min_capacity = 1
memory_tracking_target_value = 80
cpu_tracking_target_value = 80
})
iam = optional(object({
role = optional(object({
name = optional(string, "fleet-role")
policy_name = optional(string, "fleet-iam-policy")
}), {
name = "fleet-role"
policy_name = "fleet-iam-policy"
})
execution = optional(object({
name = optional(string, "fleet-execution-role")
policy_name = optional(string, "fleet-execution-role")
}), {
name = "fleet-execution-role"
policy_name = "fleet-iam-policy-execution"
})
}), {
name = "fleetdm-execution-role"
})
software_installers = optional(object({
create_bucket = optional(bool, true)
bucket_name = optional(string, null)
bucket_prefix = optional(string, "fleet-software-installers-")
s3_object_prefix = optional(string, "")
enable_bucket_versioning = optional(bool, false)
expire_noncurrent_versions = optional(bool, true)
noncurrent_version_expiration_days = optional(number, 30)
create_kms_key = optional(bool, false)
kms_alias = optional(string, "fleet-software-installers")
tags = optional(map(string), {})
}), {
create_bucket = true
bucket_name = null
bucket_prefix = "fleet-software-installers-"
s3_object_prefix = ""
enable_bucket_versioning = false
expire_noncurrent_versions = true
noncurrent_version_expiration_days = 30
create_kms_key = false
kms_alias = "fleet-software-installers"
tags = {}
})
}) | {
"autoscaling": {
"cpu_tracking_target_value": 80,
"max_capacity": 5,
"memory_tracking_target_value": 80,
"min_capacity": 1
},
"awslogs": {
"create": true,
"name": null,
"prefix": "fleet",
"region": null,
"retention": 5
},
"cpu": 256,
"database": {
"address": null,
"database": null,
"password_secret_arn": null,
"rr_address": null,
"user": null
},
"depends_on": [],
"extra_environment_variables": {},
"extra_execution_iam_policies": [],
"extra_iam_policies": [],
"extra_load_balancers": [],
"extra_secrets": {},
"family": "fleet",
"iam": {
"execution": {
"name": "fleet-execution-role",
"policy_name": "fleet-iam-policy-execution"
},
"role": {
"name": "fleet-role",
"policy_name": "fleet-iam-policy"
}
},
"iam_role_arn": null,
"image": "fleetdm/fleet:v4.72.1",
"loadbalancer": {
"arn": null
},
"mem": 512,
"mount_points": [],
"networking": {
"ingress_sources": {
"cidr_blocks": [],
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"security_groups": []
},
"security_groups": null,
"subnets": null
},
"pid_mode": null,
"private_key_secret_name": "fleet-server-private-key",
"redis": {
"address": null,
"use_tls": true
},
"repository_credentials": "",
"security_group_name": "fleet",
"security_groups": null,
"service": {
"name": "fleet"
},
"sidecars": [],
"software_installers": {
"bucket_name": null,
"bucket_prefix": "fleet-software-installers-",
"create_bucket": true,
"s3_object_prefix": ""
},
"task_cpu": null,
"task_mem": null,
"volumes": []
} | no |
diff --git a/addons/cloudfront-software-installers/main.tf b/addons/cloudfront-software-installers/main.tf
index bef796a..e66517b 100644
--- a/addons/cloudfront-software-installers/main.tf
+++ b/addons/cloudfront-software-installers/main.tf
@@ -53,6 +53,7 @@ data "aws_iam_policy_document" "software_installers_kms" {
}
resource "aws_kms_key_policy" "software_installers" {
+ count = var.s3_kms_key_id != null ? 1 : 0
key_id = var.s3_kms_key_id
policy = data.aws_iam_policy_document.software_installers_kms.json
}
diff --git a/addons/cloudfront-software-installers/variables.tf b/addons/cloudfront-software-installers/variables.tf
index 23895a7..bb825ed 100644
--- a/addons/cloudfront-software-installers/variables.tf
+++ b/addons/cloudfront-software-installers/variables.tf
@@ -22,6 +22,7 @@ variable "s3_bucket" {
variable "s3_kms_key_id" {
description = "KMS key id used to encrypt the s3 bucket"
type = string
+ default = null
}
variable "enable_logging" {
diff --git a/addons/logging-destination-firehose/README.md b/addons/logging-destination-firehose/README.md
index 7e02991..9ae97a8 100644
--- a/addons/logging-destination-firehose/README.md
+++ b/addons/logging-destination-firehose/README.md
@@ -9,7 +9,7 @@ No requirements.
| Name | Version |
|------|---------|
-| [aws](#provider\_aws) | 6.3.0 |
+| [aws](#provider\_aws) | 6.13.0 |
## Modules
@@ -59,6 +59,7 @@ No modules.
| [compression\_format](#input\_compression\_format) | n/a | `string` | `"UNCOMPRESSED"` | no |
| [osquery\_results\_s3\_bucket](#input\_osquery\_results\_s3\_bucket) | n/a | object({
name = optional(string, "fleet-osquery-results-archive")
expires_days = optional(number, 1)
}) | {
"expires_days": 1,
"name": "fleet-osquery-results-archive"
} | no |
| [osquery\_status\_s3\_bucket](#input\_osquery\_status\_s3\_bucket) | n/a | object({
name = optional(string, "fleet-osquery-status-archive")
expires_days = optional(number, 1)
}) | {
"expires_days": 1,
"name": "fleet-osquery-status-archive"
} | no |
+| [prefix](#input\_prefix) | n/a | `string` | `""` | no |
## Outputs
diff --git a/addons/logging-destination-firehose/main.tf b/addons/logging-destination-firehose/main.tf
index 430bd71..4d84bf1 100644
--- a/addons/logging-destination-firehose/main.tf
+++ b/addons/logging-destination-firehose/main.tf
@@ -167,17 +167,17 @@ data "aws_iam_policy_document" "audit_policy_doc" {
}
resource "aws_iam_policy" "firehose-results" {
- name = "osquery_results_firehose_policy"
+ name = var.prefix == "" ? "osquery_results_firehose_policy" : "${var.prefix}_osquery_results_firehose_policy"
policy = data.aws_iam_policy_document.osquery_results_policy_doc.json
}
resource "aws_iam_policy" "firehose-status" {
- name = "osquery_status_firehose_policy"
+ name = var.prefix == "" ? "osquery_status_firehose_policy" : "${var.prefix}_osquery_status_firehose_policy"
policy = data.aws_iam_policy_document.osquery_status_policy_doc.json
}
resource "aws_iam_policy" "firehose-audit" {
- name = "audit_firehose_policy"
+ name = var.prefix == "" ? "audit_firehose_policy" : "${var.prefix}_audit_firehose_policy"
policy = data.aws_iam_policy_document.audit_policy_doc.json
}
diff --git a/addons/logging-destination-firehose/variables.tf b/addons/logging-destination-firehose/variables.tf
index e9187eb..7371142 100644
--- a/addons/logging-destination-firehose/variables.tf
+++ b/addons/logging-destination-firehose/variables.tf
@@ -1,3 +1,8 @@
+variable "prefix" {
+ type = string
+ default = ""
+}
+
variable "osquery_results_s3_bucket" {
type = object({
name = optional(string, "fleet-osquery-results-archive")
diff --git a/addons/osquery-perf/.header.md b/addons/osquery-perf/.header.md
index 3df823a..8812542 100644
--- a/addons/osquery-perf/.header.md
+++ b/addons/osquery-perf/.header.md
@@ -2,15 +2,19 @@
This addon adds osquery-perf hosts to the Fleet installation.
These are generally used for loadtesting or other testing purposes. See https://github.com/fleetdm/fleet/tree/main/cmd/osquery-perf to learn more about osquery-perf itself.
-This addon creates an AWS Secrets Manager secret that will be used to store the enroll secret that the osquery-perf hosts use to enroll into Fleet.
+This addon:
+1. Creates an AWS Secrets Manager secret that will be used to store the enroll secret that the osquery-perf hosts use to enroll into Fleet. AND
+2. Optionally takes a string, `enroll_secret` (string), to create an AWS Secrets Manager secret version, in the AWS Secrets Manager Secret created by the addon. If not specified directly to the module, the secret will need to have its `SecretString` populated with the enroll secret manually once everything is setup in order for the osquery-perf hosts to connect. OR
+3. Optionally takes a AWS Secrets Manager secret ARN, `enroll_secret_arn` (string), for an already existing Secrets Manager secret.
-The addon additionally optionally takes an enroll secret to pass into its Secrets Manager secret. If not specified directly to the module, the secret will need to have its `SecretString` populated with the enroll secret manually once everything is setup in order for the osquery-perf hosts to connect.
+If both an `enroll_secret` and an `enroll_secret_arn` are defined, the module will prioritize the `enroll_secret_arn`.
+If neither an `enroll_secret` or an `enroll_secret_arn` are defined, the module will create a placeholder secret, you will need to add a `secret_version` manually and `terraform apply` one more time.
Below is an example implementation of the module:
```
module "osquery_perf" {
- source = "github.com/fleetdm/fleet-terraform//addons/osquery-perf?ref=tf-mod-addon-osquery-perf-v1.1.0"
+ source = "github.com/fleetdm/fleet-terraform//addons/osquery-perf?ref=tf-mod-addon-osquery-perf-v1.2.0"
customer_prefix = "fleet"
ecs_cluster = module.main.byo-vpc.byo-db.byo-ecs.service.cluster
subnets = module.main.byo-vpc.byo-db.byo-ecs.service.network_configuration[0].subnets
@@ -21,6 +25,10 @@ module "osquery_perf" {
osquery_perf_image = local.osquery_perf_image
extra_flags = ["--os_templates", "mac10.14.6,ubuntu_22.04,windows_11"]
logging_options = module.main.byo-vpc.byo-db.byo-ecs.logging_config
- enroll_secret = "mGNJvwKhs4PIa6ZNxMiXqqBfXKO67n2Y"
+ # Optional - One of enroll_secret or enroll_secret_arn can be used, but neither are required.
+ # If neither are passed in, you will need to populate the secret version manually,
+ # in the secret that is created by the addon.
+ # enroll_secret = "mGNJvwKhs4PIa6ZNxMiXqqBfXKO67n2Y"
+ # enroll_secret_arn = "arn:aws:secretsmanager:object({
awslogs-group = string
awslogs-region = string
awslogs-stream-prefix = string
}) | n/a | yes |
@@ -70,4 +79,7 @@ No modules.
## Outputs
-No outputs.
+| Name | Description |
+|------|-------------|
+| [osquery\_perf\_enroll\_secret\_id](#output\_osquery\_perf\_enroll\_secret\_id) | n/a |
+| [osquery\_perf\_enroll\_secret\_name](#output\_osquery\_perf\_enroll\_secret\_name) | n/a |
diff --git a/addons/osquery-perf/main.tf b/addons/osquery-perf/main.tf
index b2f47ec..8b6084a 100644
--- a/addons/osquery-perf/main.tf
+++ b/addons/osquery-perf/main.tf
@@ -1,26 +1,29 @@
resource "aws_kms_key" "enroll_secret" {
+ count = var.enroll_secret_arn == null ? 1 : 0
deletion_window_in_days = 10
enable_key_rotation = true
}
resource "aws_kms_alias" "enroll_secret" {
+ count = var.enroll_secret_arn == null ? 1 : 0
name_prefix = "alias/${var.customer_prefix}-enroll-secret-key"
- target_key_id = aws_kms_key.enroll_secret.key_id
+ target_key_id = aws_kms_key.enroll_secret[0].key_id
}
resource "aws_secretsmanager_secret" "enroll_secret" {
+ count = var.enroll_secret_arn == null ? 1 : 0
name_prefix = "${var.customer_prefix}-enroll-secret"
- kms_key_id = aws_kms_key.enroll_secret.arn
+ kms_key_id = aws_kms_key.enroll_secret[0].arn
}
resource "aws_secretsmanager_secret_version" "enroll_secret" {
- count = var.enroll_secret == null ? 0 : 1
- secret_id = aws_secretsmanager_secret.enroll_secret.id
+ count = var.enroll_secret == null || var.enroll_secret_arn != null ? 0 : 1 # Passing in ARN takes priority
+ secret_id = aws_secretsmanager_secret.enroll_secret[0].id
secret_string = var.enroll_secret
}
data "aws_secretsmanager_secret_version" "enroll_secret" {
- secret_id = aws_secretsmanager_secret.enroll_secret.id
+ secret_id = var.enroll_secret_arn == null ? aws_secretsmanager_secret.enroll_secret[0].id : var.enroll_secret_arn
}
resource "aws_ecs_task_definition" "osquery_perf" {
diff --git a/addons/osquery-perf/outputs.tf b/addons/osquery-perf/outputs.tf
new file mode 100644
index 0000000..32c630f
--- /dev/null
+++ b/addons/osquery-perf/outputs.tf
@@ -0,0 +1,7 @@
+output "osquery_perf_enroll_secret_name" {
+ value = var.enroll_secret_arn != null ? null : aws_secretsmanager_secret.enroll_secret[0].name
+}
+
+output "osquery_perf_enroll_secret_id" {
+ value = var.enroll_secret_arn != null ? null : aws_secretsmanager_secret.enroll_secret[0].id
+}
\ No newline at end of file
diff --git a/addons/osquery-perf/variables.tf b/addons/osquery-perf/variables.tf
index a2fc5c3..dfd9bf1 100644
--- a/addons/osquery-perf/variables.tf
+++ b/addons/osquery-perf/variables.tf
@@ -53,6 +53,13 @@ variable "subnets" {
}
variable "enroll_secret" {
- type = string
- default = null
+ type = string
+ description = "Value of the enroll secret to be created, if enroll_secret_arn is not passed in"
+ default = null
+}
+
+variable "enroll_secret_arn" {
+ type = string
+ description = "ARN of the AWS Secret Version containing the enroll secret"
+ default = null
}
diff --git a/byo-vpc/README.md b/byo-vpc/README.md
index 35eb345..45c78d3 100644
--- a/byo-vpc/README.md
+++ b/byo-vpc/README.md
@@ -6,7 +6,7 @@ No requirements.
| Name | Version |
|------|---------|
-| [aws](#provider\_aws) | 6.11.0 |
+| [aws](#provider\_aws) | 6.12.0 |
| [random](#provider\_random) | 3.7.2 |
## Modules
@@ -31,7 +31,7 @@ No requirements.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
-| [alb\_config](#input\_alb\_config) | n/a | object({
name = optional(string, "fleet")
subnets = list(string)
security_groups = optional(list(string), [])
access_logs = optional(map(string), {})
certificate_arn = string
allowed_cidrs = optional(list(string), ["0.0.0.0/0"])
allowed_ipv6_cidrs = optional(list(string), ["::/0"])
egress_cidrs = optional(list(string), ["0.0.0.0/0"])
egress_ipv6_cidrs = optional(list(string), ["::/0"])
extra_target_groups = optional(any, [])
https_listener_rules = optional(any, [])
https_overrides = optional(any, {})
xff_header_processing_mode = optional(string, null)
tls_policy = optional(string, "ELBSecurityPolicy-TLS13-1-2-2021-06")
idle_timeout = optional(number, 905)
}) | n/a | yes |
+| [alb\_config](#input\_alb\_config) | n/a | object({
name = optional(string, "fleet")
subnets = list(string)
security_groups = optional(list(string), [])
access_logs = optional(map(string), {})
certificate_arn = string
allowed_cidrs = optional(list(string), ["0.0.0.0/0"])
allowed_ipv6_cidrs = optional(list(string), ["::/0"])
egress_cidrs = optional(list(string), ["0.0.0.0/0"])
egress_ipv6_cidrs = optional(list(string), ["::/0"])
extra_target_groups = optional(any, [])
https_listener_rules = optional(any, [])
https_overrides = optional(any, {})
xff_header_processing_mode = optional(string, null)
tls_policy = optional(string, "ELBSecurityPolicy-TLS13-1-2-2021-06")
idle_timeout = optional(number, 905)
internal = optional(bool, false)
enable_deletion_protection = optional(bool, true)
}) | n/a | yes |
| [ecs\_cluster](#input\_ecs\_cluster) | The config for the terraform-aws-modules/ecs/aws module | object({
autoscaling_capacity_providers = optional(any, {})
cluster_configuration = optional(any, {
execute_command_configuration = {
logging = "OVERRIDE"
log_configuration = {
cloud_watch_log_group_name = "/aws/ecs/aws-ec2"
}
}
})
cluster_name = optional(string, "fleet")
cluster_settings = optional(map(string), {
"name" : "containerInsights",
"value" : "enabled",
})
create = optional(bool, true)
default_capacity_provider_use_fargate = optional(bool, true)
fargate_capacity_providers = optional(any, {
FARGATE = {
default_capacity_provider_strategy = {
weight = 100
}
}
FARGATE_SPOT = {
default_capacity_provider_strategy = {
weight = 0
}
}
})
tags = optional(map(string))
}) | {
"autoscaling_capacity_providers": {},
"cluster_configuration": {
"execute_command_configuration": {
"log_configuration": {
"cloud_watch_log_group_name": "/aws/ecs/aws-ec2"
},
"logging": "OVERRIDE"
}
},
"cluster_name": "fleet",
"cluster_settings": {
"name": "containerInsights",
"value": "enabled"
},
"create": true,
"default_capacity_provider_use_fargate": true,
"fargate_capacity_providers": {
"FARGATE": {
"default_capacity_provider_strategy": {
"weight": 100
}
},
"FARGATE_SPOT": {
"default_capacity_provider_strategy": {
"weight": 0
}
}
},
"tags": {}
} | no |
| [fleet\_config](#input\_fleet\_config) | The configuration object for Fleet itself. Fields that default to null will have their respective resources created if not specified. | object({
task_mem = optional(number, null)
task_cpu = optional(number, null)
mem = optional(number, 4096)
cpu = optional(number, 512)
pid_mode = optional(string, null)
image = optional(string, "fleetdm/fleet:v4.72.1")
family = optional(string, "fleet")
sidecars = optional(list(any), [])
depends_on = optional(list(any), [])
mount_points = optional(list(any), [])
volumes = optional(list(any), [])
extra_environment_variables = optional(map(string), {})
extra_iam_policies = optional(list(string), [])
extra_execution_iam_policies = optional(list(string), [])
extra_secrets = optional(map(string), {})
security_group_name = optional(string, "fleet")
iam_role_arn = optional(string, null)
repository_credentials = optional(string, "")
private_key_secret_name = optional(string, "fleet-server-private-key")
service = optional(object({
name = optional(string, "fleet")
}), {
name = "fleet"
})
database = optional(object({
password_secret_arn = string
user = string
database = string
address = string
rr_address = optional(string, null)
}), {
password_secret_arn = null
user = null
database = null
address = null
rr_address = null
})
redis = optional(object({
address = string
use_tls = optional(bool, true)
}), {
address = null
use_tls = true
})
awslogs = optional(object({
name = optional(string, null)
region = optional(string, null)
create = optional(bool, true)
prefix = optional(string, "fleet")
retention = optional(number, 5)
}), {
name = null
region = null
prefix = "fleet"
retention = 5
})
loadbalancer = optional(object({
arn = string
}), {
arn = null
})
extra_load_balancers = optional(list(any), [])
networking = optional(object({
subnets = optional(list(string), null)
security_groups = optional(list(string), null)
ingress_sources = optional(object({
cidr_blocks = optional(list(string), [])
ipv6_cidr_blocks = optional(list(string), [])
security_groups = optional(list(string), [])
prefix_list_ids = optional(list(string), [])
}), {
cidr_blocks = []
ipv6_cidr_blocks = []
security_groups = []
prefix_list_ids = []
})
}), {
subnets = null
security_groups = null
ingress_sources = {
cidr_blocks = []
ipv6_cidr_blocks = []
security_groups = []
prefix_list_ids = []
}
})
autoscaling = optional(object({
max_capacity = optional(number, 5)
min_capacity = optional(number, 1)
memory_tracking_target_value = optional(number, 80)
cpu_tracking_target_value = optional(number, 80)
}), {
max_capacity = 5
min_capacity = 1
memory_tracking_target_value = 80
cpu_tracking_target_value = 80
})
iam = optional(object({
role = optional(object({
name = optional(string, "fleet-role")
policy_name = optional(string, "fleet-iam-policy")
}), {
name = "fleet-role"
policy_name = "fleet-iam-policy"
})
execution = optional(object({
name = optional(string, "fleet-execution-role")
policy_name = optional(string, "fleet-execution-role")
}), {
name = "fleet-execution-role"
policy_name = "fleet-iam-policy-execution"
})
}), {
name = "fleetdm-execution-role"
})
software_installers = optional(object({
create_bucket = optional(bool, true)
bucket_name = optional(string, null)
bucket_prefix = optional(string, "fleet-software-installers-")
s3_object_prefix = optional(string, "")
enable_bucket_versioning = optional(bool, false)
expire_noncurrent_versions = optional(bool, true)
noncurrent_version_expiration_days = optional(number, 30)
create_kms_key = optional(bool, false)
kms_alias = optional(string, "fleet-software-installers")
tags = optional(map(string), {})
}), {
create_bucket = true
bucket_name = null
bucket_prefix = "fleet-software-installers-"
s3_object_prefix = ""
enable_bucket_versioning = false
expire_noncurrent_versions = true
noncurrent_version_expiration_days = 30
create_kms_key = false
kms_alias = "fleet-software-installers"
tags = {}
})
}) | {
"autoscaling": {
"cpu_tracking_target_value": 80,
"max_capacity": 5,
"memory_tracking_target_value": 80,
"min_capacity": 1
},
"awslogs": {
"create": true,
"name": null,
"prefix": "fleet",
"region": null,
"retention": 5
},
"cpu": 256,
"database": {
"address": null,
"database": null,
"password_secret_arn": null,
"rr_address": null,
"user": null
},
"depends_on": [],
"extra_environment_variables": {},
"extra_execution_iam_policies": [],
"extra_iam_policies": [],
"extra_load_balancers": [],
"extra_secrets": {},
"family": "fleet",
"iam": {
"execution": {
"name": "fleet-execution-role",
"policy_name": "fleet-iam-policy-execution"
},
"role": {
"name": "fleet-role",
"policy_name": "fleet-iam-policy"
}
},
"iam_role_arn": null,
"image": "fleetdm/fleet:v4.72.1",
"loadbalancer": {
"arn": null
},
"mem": 512,
"mount_points": [],
"networking": {
"ingress_sources": {
"cidr_blocks": [],
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"security_groups": []
},
"security_groups": null,
"subnets": null
},
"pid_mode": null,
"private_key_secret_name": "fleet-server-private-key",
"redis": {
"address": null,
"use_tls": true
},
"repository_credentials": "",
"security_group_name": "fleet",
"security_groups": null,
"service": {
"name": "fleet"
},
"sidecars": [],
"software_installers": {
"bucket_name": null,
"bucket_prefix": "fleet-software-installers-",
"create_bucket": true,
"s3_object_prefix": ""
},
"task_cpu": null,
"task_mem": null,
"volumes": []
} | no |
| [migration\_config](#input\_migration\_config) | The configuration object for Fleet's migration task. | object({
mem = number
cpu = number
}) | {
"cpu": 1024,
"mem": 2048
} | no |
diff --git a/byo-vpc/byo-db/README.md b/byo-vpc/byo-db/README.md
index 7aaa22d..ea0783d 100644
--- a/byo-vpc/byo-db/README.md
+++ b/byo-vpc/byo-db/README.md
@@ -6,7 +6,7 @@ No requirements.
| Name | Version |
|------|---------|
-| [aws](#provider\_aws) | 6.11.0 |
+| [aws](#provider\_aws) | 6.12.0 |
## Modules
@@ -26,7 +26,7 @@ No requirements.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
-| [alb\_config](#input\_alb\_config) | n/a | object({
name = optional(string, "fleet")
subnets = list(string)
security_groups = optional(list(string), [])
access_logs = optional(map(string), {})
certificate_arn = string
allowed_cidrs = optional(list(string), ["0.0.0.0/0"])
allowed_ipv6_cidrs = optional(list(string), ["::/0"])
egress_cidrs = optional(list(string), ["0.0.0.0/0"])
egress_ipv6_cidrs = optional(list(string), ["::/0"])
extra_target_groups = optional(any, [])
https_listener_rules = optional(any, [])
https_overrides = optional(any, {})
xff_header_processing_mode = optional(string, null)
tls_policy = optional(string, "ELBSecurityPolicy-TLS13-1-2-2021-06")
idle_timeout = optional(number, 905)
}) | n/a | yes |
+| [alb\_config](#input\_alb\_config) | n/a | object({
name = optional(string, "fleet")
subnets = list(string)
security_groups = optional(list(string), [])
access_logs = optional(map(string), {})
certificate_arn = string
allowed_cidrs = optional(list(string), ["0.0.0.0/0"])
allowed_ipv6_cidrs = optional(list(string), ["::/0"])
egress_cidrs = optional(list(string), ["0.0.0.0/0"])
egress_ipv6_cidrs = optional(list(string), ["::/0"])
extra_target_groups = optional(any, [])
https_listener_rules = optional(any, [])
https_overrides = optional(any, {})
xff_header_processing_mode = optional(string, null)
tls_policy = optional(string, "ELBSecurityPolicy-TLS13-1-2-2021-06")
idle_timeout = optional(number, 905)
internal = optional(bool, false)
enable_deletion_protection = optional(bool, true)
}) | n/a | yes |
| [ecs\_cluster](#input\_ecs\_cluster) | The config for the terraform-aws-modules/ecs/aws module | object({
autoscaling_capacity_providers = optional(any, {})
cluster_configuration = optional(any, {
execute_command_configuration = {
logging = "OVERRIDE"
log_configuration = {
cloud_watch_log_group_name = "/aws/ecs/aws-ec2"
}
}
})
cluster_name = optional(string, "fleet")
cluster_settings = optional(map(string), {
"name" : "containerInsights",
"value" : "enabled",
})
create = optional(bool, true)
default_capacity_provider_use_fargate = optional(bool, true)
fargate_capacity_providers = optional(any, {
FARGATE = {
default_capacity_provider_strategy = {
weight = 100
}
}
FARGATE_SPOT = {
default_capacity_provider_strategy = {
weight = 0
}
}
})
tags = optional(map(string))
}) | {
"autoscaling_capacity_providers": {},
"cluster_configuration": {
"execute_command_configuration": {
"log_configuration": {
"cloud_watch_log_group_name": "/aws/ecs/aws-ec2"
},
"logging": "OVERRIDE"
}
},
"cluster_name": "fleet",
"cluster_settings": {
"name": "containerInsights",
"value": "enabled"
},
"create": true,
"default_capacity_provider_use_fargate": true,
"fargate_capacity_providers": {
"FARGATE": {
"default_capacity_provider_strategy": {
"weight": 100
}
},
"FARGATE_SPOT": {
"default_capacity_provider_strategy": {
"weight": 0
}
}
},
"tags": {}
} | no |
| [fleet\_config](#input\_fleet\_config) | The configuration object for Fleet itself. Fields that default to null will have their respective resources created if not specified. | object({
task_mem = optional(number, null)
task_cpu = optional(number, null)
mem = optional(number, 4096)
cpu = optional(number, 512)
pid_mode = optional(string, null)
image = optional(string, "fleetdm/fleet:v4.72.1")
family = optional(string, "fleet")
sidecars = optional(list(any), [])
depends_on = optional(list(any), [])
mount_points = optional(list(any), [])
volumes = optional(list(any), [])
extra_environment_variables = optional(map(string), {})
extra_iam_policies = optional(list(string), [])
extra_execution_iam_policies = optional(list(string), [])
extra_secrets = optional(map(string), {})
security_group_name = optional(string, "fleet")
iam_role_arn = optional(string, null)
repository_credentials = optional(string, "")
private_key_secret_name = optional(string, "fleet-server-private-key")
service = optional(object({
name = optional(string, "fleet")
}), {
name = "fleet"
})
database = optional(object({
password_secret_arn = string
user = string
database = string
address = string
rr_address = optional(string, null)
}), {
password_secret_arn = null
user = null
database = null
address = null
rr_address = null
})
redis = optional(object({
address = string
use_tls = optional(bool, true)
}), {
address = null
use_tls = true
})
awslogs = optional(object({
name = optional(string, null)
region = optional(string, null)
create = optional(bool, true)
prefix = optional(string, "fleet")
retention = optional(number, 5)
}), {
name = null
region = null
prefix = "fleet"
retention = 5
})
loadbalancer = optional(object({
arn = string
}), {
arn = null
})
extra_load_balancers = optional(list(any), [])
networking = optional(object({
subnets = optional(list(string), null)
security_groups = optional(list(string), null)
ingress_sources = optional(object({
cidr_blocks = optional(list(string), [])
ipv6_cidr_blocks = optional(list(string), [])
security_groups = optional(list(string), [])
prefix_list_ids = optional(list(string), [])
}), {
cidr_blocks = []
ipv6_cidr_blocks = []
security_groups = []
prefix_list_ids = []
})
}), {
subnets = null
security_groups = null
ingress_sources = {
cidr_blocks = []
ipv6_cidr_blocks = []
security_groups = []
prefix_list_ids = []
}
})
autoscaling = optional(object({
max_capacity = optional(number, 5)
min_capacity = optional(number, 1)
memory_tracking_target_value = optional(number, 80)
cpu_tracking_target_value = optional(number, 80)
}), {
max_capacity = 5
min_capacity = 1
memory_tracking_target_value = 80
cpu_tracking_target_value = 80
})
iam = optional(object({
role = optional(object({
name = optional(string, "fleet-role")
policy_name = optional(string, "fleet-iam-policy")
}), {
name = "fleet-role"
policy_name = "fleet-iam-policy"
})
execution = optional(object({
name = optional(string, "fleet-execution-role")
policy_name = optional(string, "fleet-execution-role")
}), {
name = "fleet-execution-role"
policy_name = "fleet-iam-policy-execution"
})
}), {
name = "fleetdm-execution-role"
})
software_installers = optional(object({
create_bucket = optional(bool, true)
bucket_name = optional(string, null)
bucket_prefix = optional(string, "fleet-software-installers-")
s3_object_prefix = optional(string, "")
enable_bucket_versioning = optional(bool, false)
expire_noncurrent_versions = optional(bool, true)
noncurrent_version_expiration_days = optional(number, 30)
create_kms_key = optional(bool, false)
kms_alias = optional(string, "fleet-software-installers")
tags = optional(map(string), {})
}), {
create_bucket = true
bucket_name = null
bucket_prefix = "fleet-software-installers-"
s3_object_prefix = ""
enable_bucket_versioning = false
expire_noncurrent_versions = true
noncurrent_version_expiration_days = 30
create_kms_key = false
kms_alias = "fleet-software-installers"
tags = {}
})
}) | {
"autoscaling": {
"cpu_tracking_target_value": 80,
"max_capacity": 5,
"memory_tracking_target_value": 80,
"min_capacity": 1
},
"awslogs": {
"create": true,
"name": null,
"prefix": "fleet",
"region": null,
"retention": 5
},
"cpu": 256,
"database": {
"address": null,
"database": null,
"password_secret_arn": null,
"rr_address": null,
"user": null
},
"depends_on": [],
"extra_environment_variables": {},
"extra_execution_iam_policies": [],
"extra_iam_policies": [],
"extra_load_balancers": [],
"extra_secrets": {},
"family": "fleet",
"iam": {
"execution": {
"name": "fleet-execution-role",
"policy_name": "fleet-iam-policy-execution"
},
"role": {
"name": "fleet-role",
"policy_name": "fleet-iam-policy"
}
},
"iam_role_arn": null,
"image": "fleetdm/fleet:v4.72.1",
"loadbalancer": {
"arn": null
},
"mem": 512,
"mount_points": [],
"networking": {
"ingress_sources": {
"cidr_blocks": [],
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"security_groups": []
},
"security_groups": null,
"subnets": null
},
"pid_mode": null,
"private_key_secret_name": "fleet-server-private-key",
"redis": {
"address": null,
"use_tls": true
},
"repository_credentials": "",
"security_group_name": "fleet",
"security_groups": null,
"service": {
"name": "fleet"
},
"sidecars": [],
"software_installers": {
"bucket_name": null,
"bucket_prefix": "fleet-software-installers-",
"create_bucket": true,
"s3_object_prefix": ""
},
"task_cpu": null,
"task_mem": null,
"volumes": []
} | no |
| [migration\_config](#input\_migration\_config) | The configuration object for Fleet's migration task. | object({
mem = number
cpu = number
}) | {
"cpu": 1024,
"mem": 2048
} | no |
diff --git a/byo-vpc/byo-db/byo-ecs/iam.tf b/byo-vpc/byo-db/byo-ecs/iam.tf
index c0d0d46..f3f4bc3 100644
--- a/byo-vpc/byo-db/byo-ecs/iam.tf
+++ b/byo-vpc/byo-db/byo-ecs/iam.tf
@@ -119,14 +119,14 @@ resource "aws_iam_role_policy_attachment" "main" {
}
resource "aws_iam_role_policy_attachment" "extras" {
- for_each = toset(var.fleet_config.extra_iam_policies)
- policy_arn = each.value
+ count = length(var.fleet_config.extra_iam_policies)
+ policy_arn = var.fleet_config.extra_iam_policies[count.index]
role = aws_iam_role.main[0].name
}
resource "aws_iam_role_policy_attachment" "execution_extras" {
- for_each = toset(var.fleet_config.extra_execution_iam_policies)
- policy_arn = each.value
+ count = length(var.fleet_config.extra_execution_iam_policies)
+ policy_arn = var.fleet_config.extra_execution_iam_policies[count.index]
role = aws_iam_role.execution.name
}
diff --git a/byo-vpc/byo-db/main.tf b/byo-vpc/byo-db/main.tf
index c861774..c593cbc 100644
--- a/byo-vpc/byo-db/main.tf
+++ b/byo-vpc/byo-db/main.tf
@@ -73,6 +73,8 @@ module "alb" {
security_groups = concat(var.alb_config.security_groups, [aws_security_group.alb.id])
access_logs = var.alb_config.access_logs
idle_timeout = var.alb_config.idle_timeout
+ internal = var.alb_config.internal
+ enable_deletion_protection = var.alb_config.enable_deletion_protection
target_groups = local.target_groups
diff --git a/byo-vpc/byo-db/variables.tf b/byo-vpc/byo-db/variables.tf
index 7249406..406df10 100644
--- a/byo-vpc/byo-db/variables.tf
+++ b/byo-vpc/byo-db/variables.tf
@@ -324,5 +324,7 @@ variable "alb_config" {
xff_header_processing_mode = optional(string, null)
tls_policy = optional(string, "ELBSecurityPolicy-TLS13-1-2-2021-06")
idle_timeout = optional(number, 905)
+ internal = optional(bool, false)
+ enable_deletion_protection = optional(bool, true)
})
}
diff --git a/byo-vpc/variables.tf b/byo-vpc/variables.tf
index f43497c..6426ae3 100644
--- a/byo-vpc/variables.tf
+++ b/byo-vpc/variables.tf
@@ -429,5 +429,7 @@ variable "alb_config" {
xff_header_processing_mode = optional(string, null)
tls_policy = optional(string, "ELBSecurityPolicy-TLS13-1-2-2021-06")
idle_timeout = optional(number, 905)
+ internal = optional(bool, false)
+ enable_deletion_protection = optional(bool, true)
})
}
diff --git a/example/.header.md b/example/.header.md
index ecd313e..cc78259 100644
--- a/example/.header.md
+++ b/example/.header.md
@@ -4,35 +4,12 @@ This code provides some example usage of the Fleet Terraform module, including h
- domain name
- route53 zone name (may match the domain name)
- license key (if premium)
- - uncommenting the mdm module if mdm is desired
- any extra settings to be passed to Fleet via ENV var.
-Due to Terraform issues, this code requires 3 applies "from scratch":
-1. `terraform apply -target module.fleet.module.vpc`
-2. `terraform apply -target module.osquery-carve -target module.firehose-logging`
-3. If using a new route53 zone:
- - `terraform apply -target aws_route53_zone.main`
- - From the output, obtain the NS records created for the zone and add them to the parent DNS zone
-4. If enabling mdm: `terraform apply -target module.mdm`. It will need to be uncommented as well as the KMS section below it.
-5. `terraform apply -target module.fleet`
-6. `terraform apply`
-7. If enabling mdm do the following:
- - Record the KMS key from step 5 output.
- - Create the Windows MDM cert via the document at https://fleetdm.com/guides/windows-mdm-setup#step-1-generate-your-certificate-and-key, but name them as scep.key and scep.crt to follow a legacy convention of the mdm module.
- - Place the certificates in the `resources` folder with the following names based upon their function:
-```
-scep.crt
-scep.key
-```
- - Using the `encrypt.sh` script, KMS encrypt all of these secrets as follows:
-```
-cd resources
-for i in *; do ../scripts/encrypt.sh