Add configurable Fleet private key delivery, optional command override, and caller-managed private key secret ARN support (#205)
## Summary
This PR extends the Fleet ECS modules to support:
- configurable Fleet server private key delivery via ecs or iam
- optional fleet_config.command overrides for Fleet task definitions
- caller-managed Fleet server private key secrets via
fleet_config.private_key_secret_arn
It also updates the external vuln scans addon to follow the same
private-key delivery and command behavior, and refreshes the generated
module documentation.
## What changed
- Added fleet_config.private_key_delivery_method with supported values:
- ecs (default): inject the private key as FLEET_SERVER_PRIVATE_KEY
- iam: inject the secret ARN as FLEET_SERVER_PRIVATE_KEY_ARN
- Added validation so only ecs or iam are accepted
- Added fleet_config.command support so callers can override the Fleet
container command when needed
- Added fleet_config.private_key_secret_arn support so callers can
supply an existing Secrets Manager secret instead of having this module
create and populate one
- Updated IAM policy wiring so private-key secret access and private-key
KMS decrypt permissions are granted to the correct role based on the
selected delivery method
- Updated module outputs so fleet_server_private_key_secret_arn returns
the effective ARN whether the secret is module-managed or caller-managed
- Updated addons/external-vuln-scans to consume the same private-key
delivery mode and optional command behavior from the passed fleet_config
- Updated byo-ecs documentation and regenerated README files
## Behavior
### Private key delivery
- ecs mode injects the secret value into the container and uses the ECS
execution role for private-key secret access
- iam mode injects the secret ARN into the container environment and
uses the Fleet task role for private-key secret access
### Command override
- When fleet_config.command is unset, the task definition omits command
- When fleet_config.command is set, the provided command is passed
through to the Fleet container
- This behavior now applies consistently to both the main ECS service
and external vuln scans
### Caller-managed private key secret
- When fleet_config.private_key_secret_arn is unset, the module creates
and populates the Fleet private key secret
- When fleet_config.private_key_secret_arn is set, the module uses the
provided secret ARN and does not create the secret, secret version, or
generated random value
## KMS note for external secrets
If a caller-managed private-key secret uses a CMK, the caller must also
provide the existing private-key KMS ARN input so the correct role
receives decrypt permissions for the selected delivery mode.
## Validation
Validated successfully with:
- terraform validate -no-color at repo root
- terraform validate -no-color in byo-vpc
- terraform validate -no-color in byo-vpc/byo-db
- terraform validate -no-color in byo-vpc/byo-db/byo-ecs
Also verified that existing module-managed private-key resources plan as
non-destructive state-address moves when transitioning to the new
counted resources:
- 0 to add
- 0 to change
- 0 to destroy
This commit is contained in:
1 parent
a30a204b44
commit
e2681aea79
13 files changed
+414
-206
No files matched your search
@@ -517,6 +517,8 @@ variable "fleet_config" {
|
||||
mem = optional(number, 4096)
|
||||
cpu = optional(number, 512)
|
||||
pid_mode = optional(string, null)
|
||||
command = optional(list(string), null)
|
||||
private_key_delivery_method = optional(string, "ecs")
|
||||
image = optional(string, "fleetdm/fleet:v4.83.0")
|
||||
family = optional(string, "fleet")
|
||||
sidecars = optional(list(any), [])
|
||||
@@ -530,6 +532,7 @@ variable "fleet_config" {
|
||||
security_group_name = optional(string, "fleet")
|
||||
iam_role_arn = optional(string, null)
|
||||
repository_credentials = optional(string, "")
|
||||
private_key_secret_arn = optional(string, null)
|
||||
private_key_secret_name = optional(string, "fleet-server-private-key")
|
||||
private_key_secret_kms = optional(object({
|
||||
cmk_enabled = optional(bool, null)
|
||||
@@ -716,6 +719,8 @@ variable "fleet_config" {
|
||||
mem = 4096
|
||||
cpu = 512
|
||||
pid_mode = null
|
||||
command = null
|
||||
private_key_delivery_method = "ecs"
|
||||
image = "fleetdm/fleet:v4.83.0"
|
||||
family = "fleet"
|
||||
sidecars = []
|
||||
@@ -730,6 +735,7 @@ variable "fleet_config" {
|
||||
security_group_name = "fleet"
|
||||
iam_role_arn = null
|
||||
repository_credentials = ""
|
||||
private_key_secret_arn = null
|
||||
private_key_secret_name = "fleet-server-private-key"
|
||||
private_key_secret_kms = {
|
||||
cmk_enabled = null
|
||||
@@ -821,6 +827,10 @@ variable "fleet_config" {
|
||||
tags = {}
|
||||
}
|
||||
}
|
||||
validation {
|
||||
condition = contains(["ecs", "iam"], var.fleet_config.private_key_delivery_method)
|
||||
error_message = "fleet_config.private_key_delivery_method must be either \"ecs\" or \"iam\"."
|
||||
}
|
||||
description = "The configuration object for Fleet itself. Fields that default to null will have their respective resources created if not specified. For published KMS blocks, legacy `enabled` is deprecated and still accepted; prefer `cmk_enabled`."
|
||||
nullable = false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user