Files

3.1 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>
}