Files
fleet-terraform/addons/mdm/README.md
T

7.5 KiB

MDM addon

Notice: Previous versions of this module referred to dep, but to reduce confusion that has been replaces with abm to match the change to the newer Apple Business Manager. For each key/value pair below, the key names have been changed from previous version to match the name of the env var for easier usability. Older unused env vars were also removed for simplification. This includes removing the need for extra_environment_variables completely.

This addon enables MDM functionality for Fleet. It does this via several secrets in AWS that stores the necessary values. The following secrets are created:

  • abm
  • scep
  • apn

To encrypt those secrets with a CMK, use secrets_kms. Supply kms_key_arn to use an existing key, or set cmk_enabled = true and leave kms_key_arn = null to have this module create a key using kms_alias.

If you are creating the MDM secrets CMK and this module's extra_execution_iam_policies output is fed back into the Fleet ECS execution role in the same stack, pass secrets_kms.fleet_execution_role_name as the stable execution role name string instead of trying to read it from a Fleet module output. That avoids introducing a cycle while still letting this module add the execution role to the CMK policy.

Note: ABM is optional. If Apple Business Manager (ABM) is not used, set the abm variable to null and it will be omitted.

Since this module cannot determine the value for the secrets at apply time, this module must be applied in 2 phases:

  1. In the first phase, just add the module without passing additional config to the main Fleet module
  2. In the second phase, after the secret values have been populated, apply while also passing the additional config to the main Fleet module.

Example KMS configuration:

module "mdm" {
  source = "github.com/fleetdm/fleet-terraform/addons/mdm?depth=1&ref=tf-mod-addon-mdm-v2.2.0"

  apn_secret_name    = null
  scep_secret_name   = "fleet-scep"
  abm_secret_name    = null
  enable_apple_mdm   = false
  enable_windows_mdm = true

  secrets_kms = {
    cmk_enabled               = true
    kms_alias                 = "fleet-mdm-secrets"
    kms_base_policy           = local.kms_base_policy_statements
    fleet_execution_role_name = "fleet-execution-role"
  }
}

The secrets should have the following layouts, note that all values are strings. If a value is a JSON object, string escape it.:

ABM

{
    "FLEET_MDM_APPLE_BM_CERT_BYTES": <ABM cert>,
    "FLEET_MDM_APPLE_BM_KEY_BYTES": <ABM key>,
    "FLEET_MDM_APPLE_BM_SERVER_TOKEN_BYTES": <ABM p7m token>
}

SCEP

{
    "FLEET_MDM_APPLE_SCEP_CERT_BYTES": <SCEP cert>,
    "FLEET_MDM_APPLE_SCEP_KEY_BYTES": <SCEP key>,
    "FLEET_MDM_APPLE_SCEP_CHALLENGE": <SCEP challenge>
}

Please note that for Windows, the same SCEP cert is used and the cert+key above will populate the following environment variables:

    "FLEET_MDM_WINDOWS_WSTEP_IDENTITY_CERT_BYTES"
    "FLEET_MDM_WINDOWS_WSTEP_IDENTITY_KEY_BYTES"

APN

{
    "FLEET_MDM_APPLE_APNS_CERT_BYTES": <APNS cert>,
    "FLEET_MDM_APPLE_APNS_KEY_BYTES ": <APNS key>
}

Requirements

Name Version
terraform >= 1.12.0
aws >= 6.37.0

Providers

Name Version
aws 6.39.0

Modules

No modules.

Resources

Name Type
aws_iam_policy.main resource
aws_kms_alias.secrets resource
aws_kms_key.secrets resource
aws_secretsmanager_secret.abm resource
aws_secretsmanager_secret.apn resource
aws_secretsmanager_secret.scep resource
aws_caller_identity.current data source
aws_iam_policy_document.main data source
aws_iam_policy_document.secrets_kms data source
aws_iam_role.fleet_execution data source
aws_kms_key.provided data source
aws_partition.current data source
aws_region.current data source

Inputs

Name Description Type Default Required
abm_secret_name n/a string "fleet-abm" no
apn_secret_name n/a string "fleet-apn" no
enable_apple_mdm n/a bool true no
enable_windows_mdm n/a bool false no
scep_secret_name n/a string "fleet-scep" no
secrets_kms Configuration for optional customer-managed KMS encryption of the MDM Secrets Manager secrets.
object({
cmk_enabled = optional(bool, false)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-mdm-secrets")
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_execution_role_name = optional(string, null)
})
{
"cmk_enabled": false,
"extra_kms_policies": [],
"fleet_execution_role_name": null,
"kms_alias": "fleet-mdm-secrets",
"kms_base_policy": null,
"kms_key_arn": null
}
no

Outputs

Name Description
abm n/a
apn n/a
extra_execution_iam_policies n/a
extra_secrets n/a
scep n/a