Update terraform example mdm to match current documentation (#27)

This commit is contained in:
Robert Fairburn authored and GitHub committed 2025-04-10 12:44:08 -05:00
1 parent effca06ef3
commit f3d1a07df3
6 files changed
+26 -96

No files matched your search

+1 -6
View File
@@ -18,16 +18,11 @@ Due to Terraform issues, this code requires 3 applies "from scratch":
6. `terraform apply`
7. If enabling mdm do the following:
- Record the KMS key from step 5 output.
- Use `fleetctl` to obtain all of the mdm certs. Use https://fleetdm.com/docs/using-fleet/mdm-setup#apple-push-notification-service-apns and https://fleetdm.com/docs/using-fleet/mdm-setup#apple-business-manager-abm for reference.
- 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
apns.crt
apns.key
abm.crt
abm.key
abm_token.p7m
```
- Using the `encrypt.sh` script, KMS encrypt all of these secrets as follows:
```
+3 -10
View File
@@ -18,16 +18,11 @@ Due to Terraform issues, this code requires 3 applies "from scratch":
6. `terraform apply`
7. If enabling mdm do the following:
- Record the KMS key from step 5 output.
- Use `fleetctl` to obtain all of the mdm certs. Use https://fleetdm.com/docs/using-fleet/mdm-setup#apple-push-notification-service-apns and https://fleetdm.com/docs/using-fleet/mdm-setup#apple-business-manager-abm for reference.
- 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
apns.crt
apns.key
abm.crt
abm.key
abm_token.p7m
```
- Using the `encrypt.sh` script, KMS encrypt all of these secrets as follows:
```
@@ -58,10 +53,8 @@ This will encrypt all of the mdm secrets and add the .encrypted extension to the
| Name | Source | Version |
|------|--------|---------|
| <a name="module_acm"></a> [acm](#module\_acm) | terraform-aws-modules/acm/aws | 4.3.1 |
| <a name="module_firehose-logging"></a> [firehose-logging](#module\_firehose-logging) | github.com/fleetdm/fleet-terraform/addons/logging-destination-firehose | tf-mod-addon-logging-destination-firehose-v1.1.1 |
| <a name="module_fleet"></a> [fleet](#module\_fleet) | github.com/fleetdm/fleet-terraform | tf-mod-root-v1.12.0 |
| <a name="module_migrations"></a> [migrations](#module\_migrations) | github.com/fleetdm/fleet-terraform/addons/migrations | tf-mod-addon-migrations-v2.0.1 |
| <a name="module_osquery-carve"></a> [osquery-carve](#module\_osquery-carve) | github.com/fleetdm/fleet-terraform/addons/osquery-carve | tf-mod-addon-osquery-carve-v1.1.0 |
| <a name="module_fleet"></a> [fleet](#module\_fleet) | github.com/fleetdm/fleet-terraform?depth=1&ref=tf-mod-root-v1.14.0 | n/a |
| <a name="module_migrations"></a> [migrations](#module\_migrations) | github.com/fleetdm/fleet-terraform/addons/migrations?depth=1&ref=tf-mod-addon-migrations-v2.0.1 | n/a |
## Resources
+10 -7
View File
@@ -52,7 +52,7 @@ locals {
}
module "fleet" {
source = "github.com/fleetdm/fleet-terraform?depth=1&ref=tf-mod-root-v1.13.0"
source = "github.com/fleetdm/fleet-terraform?depth=1&ref=tf-mod-root-v1.14.0"
certificate_arn = module.acm.acm_certificate_arn
vpc = {
@@ -103,6 +103,8 @@ module "fleet" {
}
# Uncomment to specify the RDS engine version
# engine_version = "8.0.mysql_aurora.3.07.1"
# Uncomment to use more or fewer replicas
# replicas = 2
}
redis_config = {
# See https://fleetdm.com/docs/deploy/reference-architectures#aws for instance types.
@@ -167,18 +169,19 @@ module "migrations" {
## MDM Secret payload
# See https://github.com/fleetdm/fleet/blob/tf-mod-addon-mdm-v2.0.0/terraform/addons/mdm/README.md#abm
# Per that document, both Windows and Mac will use the same SCEP secret under the hood.
# See https://github.com/fleetdm/fleet-terraform/blob/tf-mod-addon-mdm-v2.0.0/addons/mdm/README.md#abm
# Per that document, both Windows and Mac will use the same SCEP secret under the hood. Currently only
# 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"
# # Set apn_secret_name = null if not using mac mdm
# apn_secret_name = "fleet-apn"
# apn_secret_name = null
# scep_secret_name = "fleet-scep"
# # Set abm_secret_name = null if customer is not using dep
# abm_secret_name = "fleet-dep"
# enable_apple_mdm = true
# abm_secret_name = null
# enable_apple_mdm = false
# enable_windows_mdm = true
# }
+5 -67
View File
@@ -8,11 +8,6 @@ locals {
mdm_resource_path = "${path.module}/resources"
scep_cert = "${local.mdm_resource_path}/scep.crt.encrypted"
scep_key = "${local.mdm_resource_path}/scep.key.encrypted"
apns_cert = "${local.mdm_resource_path}/apns.crt.encrypted"
apns_key = "${local.mdm_resource_path}/apns.key.encrypted"
abm_cert = "${local.mdm_resource_path}/abm.crt.encrypted"
abm_key = "${local.mdm_resource_path}/abm.key.encrypted"
abm_token = "${local.mdm_resource_path}/abm_token.p7m.encrypted"
}
# To ease the process of encrypting and decrypting secrets, see
@@ -27,7 +22,10 @@ locals {
# The SCEP challenge will be randomly generated by terraform. We do not
# need to know what it is. For troubleshooting, it can always be found
# in the SCEP secret in AWS.
# in the SCEP secret in AWS. The SCEP cert is primarily used as the
# Windows WSTEP cert at this point as the MAC scep is generated
# automatically in the applicaton. The other MAC MDM secrets can now be
# manged via the Fleet UI
# resource "random_password" "challenge" {
# length = 12
@@ -61,64 +59,4 @@ locals {
# payload = file(local.scep_key)
# }
# }
#
# resource "aws_secretsmanager_secret_version" "apn" {
# secret_id = module.mdm.apn.id
# secret_string = jsonencode(
# {
# FLEET_MDM_APPLE_APNS_CERT_BYTES = data.aws_kms_secrets.apns_cert.plaintext["FLEET_MDM_APPLE_APNS_CERT_BYTES"]
# FLEET_MDM_APPLE_APNS_KEY_BYTES = data.aws_kms_secrets.apns_key.plaintext["FLEET_MDM_APPLE_APNS_KEY_BYTES"]
# }
# )
# }
#
# data "aws_kms_secrets" "apns_cert" {
# secret {
# name = "FLEET_MDM_APPLE_APNS_CERT_BYTES"
# key_id = aws_kms_key.fleet_data_key.id
# payload = file(local.apns_cert)
# }
# }
#
# data "aws_kms_secrets" "apns_key" {
# secret {
# name = "FLEET_MDM_APPLE_APNS_KEY_BYTES"
# key_id = aws_kms_key.fleet_data_key.id
# payload = file(local.apns_key)
# }
# }
#
# resource "aws_secretsmanager_secret_version" "abm" {
# secret_id = module.mdm.abm.id
# secret_string = jsonencode(
# {
# FLEET_MDM_APPLE_BM_CERT_BYTES = data.aws_kms_secrets.abm_cert.plaintext["FLEET_MDM_APPLE_BM_CERT_BYTES"]
# FLEET_MDM_APPLE_BM_KEY_BYTES = data.aws_kms_secrets.abm_key.plaintext["FLEET_MDM_APPLE_BM_KEY_BYTES"]
# FLEET_MDM_APPLE_BM_SERVER_TOKEN_BYTES = data.aws_kms_secrets.token.plaintext["FLEET_MDM_APPLE_BM_SERVER_TOKEN_BYTES"]
# }
# )
# }
#
# data "aws_kms_secrets" "abm_cert" {
# secret {
# name = "FLEET_MDM_APPLE_BM_CERT_BYTES"
# key_id = aws_kms_key.fleet_data_key.id
# payload = file(local.abm_cert)
# }
# }
#
# data "aws_kms_secrets" "abm_key" {
# secret {
# name = "FLEET_MDM_APPLE_BM_KEY_BYTES"
# key_id = aws_kms_key.fleet_data_key.id
# payload = file(local.abm_key)
# }
# }
#
# data "aws_kms_secrets" "token" {
# secret {
# name = "FLEET_MDM_APPLE_BM_SERVER_TOKEN_BYTES"
# key_id = aws_kms_key.fleet_data_key.id
# payload = file(local.abm_token)
# }
# }