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.
This commit is contained in:
1 parent
1d8bd3007d
commit
ae8863ce64
22 files changed
+167
-191
No files matched your search
@@ -72,7 +72,7 @@ No resources.
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|:--------:|
|
||||
| <a name="input_alb_config"></a> [alb\_config](#input\_alb\_config) | n/a | <pre>object({<br/> name = optional(string, "fleet")<br/> security_groups = optional(list(string), [])<br/> access_logs = optional(map(string), {})<br/> allowed_cidrs = optional(list(string), ["0.0.0.0/0"])<br/> allowed_ipv6_cidrs = optional(list(string), ["::/0"])<br/> egress_cidrs = optional(list(string), ["0.0.0.0/0"])<br/> egress_ipv6_cidrs = optional(list(string), ["::/0"])<br/> extra_target_groups = optional(any, [])<br/> https_listener_rules = optional(any, [])<br/> https_overrides = optional(any, {})<br/> xff_header_processing_mode = optional(string, null)<br/> tls_policy = optional(string, "ELBSecurityPolicy-TLS13-1-2-2021-06")<br/> idle_timeout = optional(number, 905)<br/> })</pre> | `{}` | no |
|
||||
| <a name="input_alb_config"></a> [alb\_config](#input\_alb\_config) | n/a | <pre>object({<br/> name = optional(string, "fleet")<br/> security_groups = optional(list(string), [])<br/> access_logs = optional(map(string), {})<br/> allowed_cidrs = optional(list(string), ["0.0.0.0/0"])<br/> allowed_ipv6_cidrs = optional(list(string), ["::/0"])<br/> egress_cidrs = optional(list(string), ["0.0.0.0/0"])<br/> egress_ipv6_cidrs = optional(list(string), ["::/0"])<br/> extra_target_groups = optional(any, [])<br/> https_listener_rules = optional(any, [])<br/> https_overrides = optional(any, {})<br/> xff_header_processing_mode = optional(string, null)<br/> tls_policy = optional(string, "ELBSecurityPolicy-TLS13-1-2-2021-06")<br/> idle_timeout = optional(number, 905)<br/> internal = optional(bool, false)<br/> enable_deletion_protection = optional(bool, true)<br/> })</pre> | `{}` | no |
|
||||
| <a name="input_certificate_arn"></a> [certificate\_arn](#input\_certificate\_arn) | n/a | `string` | n/a | yes |
|
||||
| <a name="input_ecs_cluster"></a> [ecs\_cluster](#input\_ecs\_cluster) | The config for the terraform-aws-modules/ecs/aws module | <pre>object({<br/> autoscaling_capacity_providers = optional(any, {})<br/> cluster_configuration = optional(any, {<br/> execute_command_configuration = {<br/> logging = "OVERRIDE"<br/> log_configuration = {<br/> cloud_watch_log_group_name = "/aws/ecs/aws-ec2"<br/> }<br/> }<br/> })<br/> cluster_name = optional(string, "fleet")<br/> cluster_settings = optional(map(string), {<br/> "name" : "containerInsights",<br/> "value" : "enabled",<br/> })<br/> create = optional(bool, true)<br/> default_capacity_provider_use_fargate = optional(bool, true)<br/> fargate_capacity_providers = optional(any, {<br/> FARGATE = {<br/> default_capacity_provider_strategy = {<br/> weight = 100<br/> }<br/> }<br/> FARGATE_SPOT = {<br/> default_capacity_provider_strategy = {<br/> weight = 0<br/> }<br/> }<br/> })<br/> tags = optional(map(string))<br/> })</pre> | <pre>{<br/> "autoscaling_capacity_providers": {},<br/> "cluster_configuration": {<br/> "execute_command_configuration": {<br/> "log_configuration": {<br/> "cloud_watch_log_group_name": "/aws/ecs/aws-ec2"<br/> },<br/> "logging": "OVERRIDE"<br/> }<br/> },<br/> "cluster_name": "fleet",<br/> "cluster_settings": {<br/> "name": "containerInsights",<br/> "value": "enabled"<br/> },<br/> "create": true,<br/> "default_capacity_provider_use_fargate": true,<br/> "fargate_capacity_providers": {<br/> "FARGATE": {<br/> "default_capacity_provider_strategy": {<br/> "weight": 100<br/> }<br/> },<br/> "FARGATE_SPOT": {<br/> "default_capacity_provider_strategy": {<br/> "weight": 0<br/> }<br/> }<br/> },<br/> "tags": {}<br/>}</pre> | no |
|
||||
| <a name="input_fleet_config"></a> [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. | <pre>object({<br/> task_mem = optional(number, null)<br/> task_cpu = optional(number, null)<br/> mem = optional(number, 4096)<br/> cpu = optional(number, 512)<br/> pid_mode = optional(string, null)<br/> image = optional(string, "fleetdm/fleet:v4.72.1")<br/> family = optional(string, "fleet")<br/> sidecars = optional(list(any), [])<br/> depends_on = optional(list(any), [])<br/> mount_points = optional(list(any), [])<br/> volumes = optional(list(any), [])<br/> extra_environment_variables = optional(map(string), {})<br/> extra_iam_policies = optional(list(string), [])<br/> extra_execution_iam_policies = optional(list(string), [])<br/> extra_secrets = optional(map(string), {})<br/> security_group_name = optional(string, "fleet")<br/> iam_role_arn = optional(string, null)<br/> repository_credentials = optional(string, "")<br/> private_key_secret_name = optional(string, "fleet-server-private-key")<br/> service = optional(object({<br/> name = optional(string, "fleet")<br/> }), {<br/> name = "fleet"<br/> })<br/> database = optional(object({<br/> password_secret_arn = string<br/> user = string<br/> database = string<br/> address = string<br/> rr_address = optional(string, null)<br/> }), {<br/> password_secret_arn = null<br/> user = null<br/> database = null<br/> address = null<br/> rr_address = null<br/> })<br/> redis = optional(object({<br/> address = string<br/> use_tls = optional(bool, true)<br/> }), {<br/> address = null<br/> use_tls = true<br/> })<br/> awslogs = optional(object({<br/> name = optional(string, null)<br/> region = optional(string, null)<br/> create = optional(bool, true)<br/> prefix = optional(string, "fleet")<br/> retention = optional(number, 5)<br/> }), {<br/> name = null<br/> region = null<br/> prefix = "fleet"<br/> retention = 5<br/> })<br/> loadbalancer = optional(object({<br/> arn = string<br/> }), {<br/> arn = null<br/> })<br/> extra_load_balancers = optional(list(any), [])<br/> networking = optional(object({<br/> subnets = optional(list(string), null)<br/> security_groups = optional(list(string), null)<br/> ingress_sources = optional(object({<br/> cidr_blocks = optional(list(string), [])<br/> ipv6_cidr_blocks = optional(list(string), [])<br/> security_groups = optional(list(string), [])<br/> prefix_list_ids = optional(list(string), [])<br/> }), {<br/> cidr_blocks = []<br/> ipv6_cidr_blocks = []<br/> security_groups = []<br/> prefix_list_ids = []<br/> })<br/> }), {<br/> subnets = null<br/> security_groups = null<br/> ingress_sources = {<br/> cidr_blocks = []<br/> ipv6_cidr_blocks = []<br/> security_groups = []<br/> prefix_list_ids = []<br/> }<br/> })<br/> autoscaling = optional(object({<br/> max_capacity = optional(number, 5)<br/> min_capacity = optional(number, 1)<br/> memory_tracking_target_value = optional(number, 80)<br/> cpu_tracking_target_value = optional(number, 80)<br/> }), {<br/> max_capacity = 5<br/> min_capacity = 1<br/> memory_tracking_target_value = 80<br/> cpu_tracking_target_value = 80<br/> })<br/> iam = optional(object({<br/> role = optional(object({<br/> name = optional(string, "fleet-role")<br/> policy_name = optional(string, "fleet-iam-policy")<br/> }), {<br/> name = "fleet-role"<br/> policy_name = "fleet-iam-policy"<br/> })<br/> execution = optional(object({<br/> name = optional(string, "fleet-execution-role")<br/> policy_name = optional(string, "fleet-execution-role")<br/> }), {<br/> name = "fleet-execution-role"<br/> policy_name = "fleet-iam-policy-execution"<br/> })<br/> }), {<br/> name = "fleetdm-execution-role"<br/> })<br/> software_installers = optional(object({<br/> create_bucket = optional(bool, true)<br/> bucket_name = opLine truncated
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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" {
|
||||
|
||||
@@ -9,7 +9,7 @@ No requirements.
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.3.0 |
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.13.0 |
|
||||
|
||||
## Modules
|
||||
|
||||
@@ -59,6 +59,7 @@ No modules.
|
||||
| <a name="input_compression_format"></a> [compression\_format](#input\_compression\_format) | n/a | `string` | `"UNCOMPRESSED"` | no |
|
||||
| <a name="input_osquery_results_s3_bucket"></a> [osquery\_results\_s3\_bucket](#input\_osquery\_results\_s3\_bucket) | n/a | <pre>object({<br/> name = optional(string, "fleet-osquery-results-archive")<br/> expires_days = optional(number, 1)<br/> })</pre> | <pre>{<br/> "expires_days": 1,<br/> "name": "fleet-osquery-results-archive"<br/>}</pre> | no |
|
||||
| <a name="input_osquery_status_s3_bucket"></a> [osquery\_status\_s3\_bucket](#input\_osquery\_status\_s3\_bucket) | n/a | <pre>object({<br/> name = optional(string, "fleet-osquery-status-archive")<br/> expires_days = optional(number, 1)<br/> })</pre> | <pre>{<br/> "expires_days": 1,<br/> "name": "fleet-osquery-status-archive"<br/>}</pre> | no |
|
||||
| <a name="input_prefix"></a> [prefix](#input\_prefix) | n/a | `string` | `""` | no |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
variable "prefix" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "osquery_results_s3_bucket" {
|
||||
type = object({
|
||||
name = optional(string, "fleet-osquery-results-archive")
|
||||
|
||||
@@ -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:<region>:<account-id>:secret:<secret-name>"
|
||||
}
|
||||
```
|
||||
@@ -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,7 +25,11 @@ 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:<region>:<account-id>:secret:<secret-name>"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -33,7 +41,7 @@ No requirements.
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.2.0 |
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.12.0 |
|
||||
|
||||
## Modules
|
||||
|
||||
@@ -59,7 +67,8 @@ No modules.
|
||||
| <a name="input_ecs_cluster"></a> [ecs\_cluster](#input\_ecs\_cluster) | n/a | `string` | n/a | yes |
|
||||
| <a name="input_ecs_execution_iam_role_arn"></a> [ecs\_execution\_iam\_role\_arn](#input\_ecs\_execution\_iam\_role\_arn) | n/a | `string` | n/a | yes |
|
||||
| <a name="input_ecs_iam_role_arn"></a> [ecs\_iam\_role\_arn](#input\_ecs\_iam\_role\_arn) | n/a | `string` | n/a | yes |
|
||||
| <a name="input_enroll_secret"></a> [enroll\_secret](#input\_enroll\_secret) | n/a | `string` | `null` | no |
|
||||
| <a name="input_enroll_secret"></a> [enroll\_secret](#input\_enroll\_secret) | Value of the enroll secret to be created, if enroll\_secret\_arn is not passed in | `string` | `null` | no |
|
||||
| <a name="input_enroll_secret_arn"></a> [enroll\_secret\_arn](#input\_enroll\_secret\_arn) | ARN of the AWS Secret Version containing the enroll secret | `string` | `null` | no |
|
||||
| <a name="input_extra_flags"></a> [extra\_flags](#input\_extra\_flags) | n/a | `list(string)` | `[]` | no |
|
||||
| <a name="input_loadtest_containers"></a> [loadtest\_containers](#input\_loadtest\_containers) | n/a | `number` | `1` | no |
|
||||
| <a name="input_logging_options"></a> [logging\_options](#input\_logging\_options) | n/a | <pre>object({<br/> awslogs-group = string<br/> awslogs-region = string<br/> awslogs-stream-prefix = string<br/> })</pre> | n/a | yes |
|
||||
@@ -70,4 +79,7 @@ No modules.
|
||||
|
||||
## Outputs
|
||||
|
||||
No outputs.
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| <a name="output_osquery_perf_enroll_secret_id"></a> [osquery\_perf\_enroll\_secret\_id](#output\_osquery\_perf\_enroll\_secret\_id) | n/a |
|
||||
| <a name="output_osquery_perf_enroll_secret_name"></a> [osquery\_perf\_enroll\_secret\_name](#output\_osquery\_perf\_enroll\_secret\_name) | n/a |
|
||||
@@ -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" {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
+2
-2
@@ -6,7 +6,7 @@ No requirements.
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.11.0 |
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.12.0 |
|
||||
| <a name="provider_random"></a> [random](#provider\_random) | 3.7.2 |
|
||||
|
||||
## Modules
|
||||
@@ -31,7 +31,7 @@ No requirements.
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|:--------:|
|
||||
| <a name="input_alb_config"></a> [alb\_config](#input\_alb\_config) | n/a | <pre>object({<br/> name = optional(string, "fleet")<br/> subnets = list(string)<br/> security_groups = optional(list(string), [])<br/> access_logs = optional(map(string), {})<br/> certificate_arn = string<br/> allowed_cidrs = optional(list(string), ["0.0.0.0/0"])<br/> allowed_ipv6_cidrs = optional(list(string), ["::/0"])<br/> egress_cidrs = optional(list(string), ["0.0.0.0/0"])<br/> egress_ipv6_cidrs = optional(list(string), ["::/0"])<br/> extra_target_groups = optional(any, [])<br/> https_listener_rules = optional(any, [])<br/> https_overrides = optional(any, {})<br/> xff_header_processing_mode = optional(string, null)<br/> tls_policy = optional(string, "ELBSecurityPolicy-TLS13-1-2-2021-06")<br/> idle_timeout = optional(number, 905)<br/> })</pre> | n/a | yes |
|
||||
| <a name="input_alb_config"></a> [alb\_config](#input\_alb\_config) | n/a | <pre>object({<br/> name = optional(string, "fleet")<br/> subnets = list(string)<br/> security_groups = optional(list(string), [])<br/> access_logs = optional(map(string), {})<br/> certificate_arn = string<br/> allowed_cidrs = optional(list(string), ["0.0.0.0/0"])<br/> allowed_ipv6_cidrs = optional(list(string), ["::/0"])<br/> egress_cidrs = optional(list(string), ["0.0.0.0/0"])<br/> egress_ipv6_cidrs = optional(list(string), ["::/0"])<br/> extra_target_groups = optional(any, [])<br/> https_listener_rules = optional(any, [])<br/> https_overrides = optional(any, {})<br/> xff_header_processing_mode = optional(string, null)<br/> tls_policy = optional(string, "ELBSecurityPolicy-TLS13-1-2-2021-06")<br/> idle_timeout = optional(number, 905)<br/> internal = optional(bool, false)<br/> enable_deletion_protection = optional(bool, true)<br/> })</pre> | n/a | yes |
|
||||
| <a name="input_ecs_cluster"></a> [ecs\_cluster](#input\_ecs\_cluster) | The config for the terraform-aws-modules/ecs/aws module | <pre>object({<br/> autoscaling_capacity_providers = optional(any, {})<br/> cluster_configuration = optional(any, {<br/> execute_command_configuration = {<br/> logging = "OVERRIDE"<br/> log_configuration = {<br/> cloud_watch_log_group_name = "/aws/ecs/aws-ec2"<br/> }<br/> }<br/> })<br/> cluster_name = optional(string, "fleet")<br/> cluster_settings = optional(map(string), {<br/> "name" : "containerInsights",<br/> "value" : "enabled",<br/> })<br/> create = optional(bool, true)<br/> default_capacity_provider_use_fargate = optional(bool, true)<br/> fargate_capacity_providers = optional(any, {<br/> FARGATE = {<br/> default_capacity_provider_strategy = {<br/> weight = 100<br/> }<br/> }<br/> FARGATE_SPOT = {<br/> default_capacity_provider_strategy = {<br/> weight = 0<br/> }<br/> }<br/> })<br/> tags = optional(map(string))<br/> })</pre> | <pre>{<br/> "autoscaling_capacity_providers": {},<br/> "cluster_configuration": {<br/> "execute_command_configuration": {<br/> "log_configuration": {<br/> "cloud_watch_log_group_name": "/aws/ecs/aws-ec2"<br/> },<br/> "logging": "OVERRIDE"<br/> }<br/> },<br/> "cluster_name": "fleet",<br/> "cluster_settings": {<br/> "name": "containerInsights",<br/> "value": "enabled"<br/> },<br/> "create": true,<br/> "default_capacity_provider_use_fargate": true,<br/> "fargate_capacity_providers": {<br/> "FARGATE": {<br/> "default_capacity_provider_strategy": {<br/> "weight": 100<br/> }<br/> },<br/> "FARGATE_SPOT": {<br/> "default_capacity_provider_strategy": {<br/> "weight": 0<br/> }<br/> }<br/> },<br/> "tags": {}<br/>}</pre> | no |
|
||||
| <a name="input_fleet_config"></a> [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. | <pre>object({<br/> task_mem = optional(number, null)<br/> task_cpu = optional(number, null)<br/> mem = optional(number, 4096)<br/> cpu = optional(number, 512)<br/> pid_mode = optional(string, null)<br/> image = optional(string, "fleetdm/fleet:v4.72.1")<br/> family = optional(string, "fleet")<br/> sidecars = optional(list(any), [])<br/> depends_on = optional(list(any), [])<br/> mount_points = optional(list(any), [])<br/> volumes = optional(list(any), [])<br/> extra_environment_variables = optional(map(string), {})<br/> extra_iam_policies = optional(list(string), [])<br/> extra_execution_iam_policies = optional(list(string), [])<br/> extra_secrets = optional(map(string), {})<br/> security_group_name = optional(string, "fleet")<br/> iam_role_arn = optional(string, null)<br/> repository_credentials = optional(string, "")<br/> private_key_secret_name = optional(string, "fleet-server-private-key")<br/> service = optional(object({<br/> name = optional(string, "fleet")<br/> }), {<br/> name = "fleet"<br/> })<br/> database = optional(object({<br/> password_secret_arn = string<br/> user = string<br/> database = string<br/> address = string<br/> rr_address = optional(string, null)<br/> }), {<br/> password_secret_arn = null<br/> user = null<br/> database = null<br/> address = null<br/> rr_address = null<br/> })<br/> redis = optional(object({<br/> address = string<br/> use_tls = optional(bool, true)<br/> }), {<br/> address = null<br/> use_tls = true<br/> })<br/> awslogs = optional(object({<br/> name = optional(string, null)<br/> region = optional(string, null)<br/> create = optional(bool, true)<br/> prefix = optional(string, "fleet")<br/> retention = optional(number, 5)<br/> }), {<br/> name = null<br/> region = null<br/> prefix = "fleet"<br/> retention = 5<br/> })<br/> loadbalancer = optional(object({<br/> arn = string<br/> }), {<br/> arn = null<br/> })<br/> extra_load_balancers = optional(list(any), [])<br/> networking = optional(object({<br/> subnets = optional(list(string), null)<br/> security_groups = optional(list(string), null)<br/> ingress_sources = optional(object({<br/> cidr_blocks = optional(list(string), [])<br/> ipv6_cidr_blocks = optional(list(string), [])<br/> security_groups = optional(list(string), [])<br/> prefix_list_ids = optional(list(string), [])<br/> }), {<br/> cidr_blocks = []<br/> ipv6_cidr_blocks = []<br/> security_groups = []<br/> prefix_list_ids = []<br/> })<br/> }), {<br/> subnets = null<br/> security_groups = null<br/> ingress_sources = {<br/> cidr_blocks = []<br/> ipv6_cidr_blocks = []<br/> security_groups = []<br/> prefix_list_ids = []<br/> }<br/> })<br/> autoscaling = optional(object({<br/> max_capacity = optional(number, 5)<br/> min_capacity = optional(number, 1)<br/> memory_tracking_target_value = optional(number, 80)<br/> cpu_tracking_target_value = optional(number, 80)<br/> }), {<br/> max_capacity = 5<br/> min_capacity = 1<br/> memory_tracking_target_value = 80<br/> cpu_tracking_target_value = 80<br/> })<br/> iam = optional(object({<br/> role = optional(object({<br/> name = optional(string, "fleet-role")<br/> policy_name = optional(string, "fleet-iam-policy")<br/> }), {<br/> name = "fleet-role"<br/> policy_name = "fleet-iam-policy"<br/> })<br/> execution = optional(object({<br/> name = optional(string, "fleet-execution-role")<br/> policy_name = optional(string, "fleet-execution-role")<br/> }), {<br/> name = "fleet-execution-role"<br/> policy_name = "fleet-iam-policy-execution"<br/> })<br/> }), {<br/> name = "fleetdm-execution-role"<br/> })<br/> software_installers = optional(object({<br/> create_bucket = optional(bool, true)<br/> bucket_name = opLine truncated
|
||||
| <a name="input_migration_config"></a> [migration\_config](#input\_migration\_config) | The configuration object for Fleet's migration task. | <pre>object({<br/> mem = number<br/> cpu = number<br/> })</pre> | <pre>{<br/> "cpu": 1024,<br/> "mem": 2048<br/>}</pre> | no |
|
||||
|
||||
@@ -6,7 +6,7 @@ No requirements.
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.11.0 |
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.12.0 |
|
||||
|
||||
## Modules
|
||||
|
||||
@@ -26,7 +26,7 @@ No requirements.
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|:--------:|
|
||||
| <a name="input_alb_config"></a> [alb\_config](#input\_alb\_config) | n/a | <pre>object({<br/> name = optional(string, "fleet")<br/> subnets = list(string)<br/> security_groups = optional(list(string), [])<br/> access_logs = optional(map(string), {})<br/> certificate_arn = string<br/> allowed_cidrs = optional(list(string), ["0.0.0.0/0"])<br/> allowed_ipv6_cidrs = optional(list(string), ["::/0"])<br/> egress_cidrs = optional(list(string), ["0.0.0.0/0"])<br/> egress_ipv6_cidrs = optional(list(string), ["::/0"])<br/> extra_target_groups = optional(any, [])<br/> https_listener_rules = optional(any, [])<br/> https_overrides = optional(any, {})<br/> xff_header_processing_mode = optional(string, null)<br/> tls_policy = optional(string, "ELBSecurityPolicy-TLS13-1-2-2021-06")<br/> idle_timeout = optional(number, 905)<br/> })</pre> | n/a | yes |
|
||||
| <a name="input_alb_config"></a> [alb\_config](#input\_alb\_config) | n/a | <pre>object({<br/> name = optional(string, "fleet")<br/> subnets = list(string)<br/> security_groups = optional(list(string), [])<br/> access_logs = optional(map(string), {})<br/> certificate_arn = string<br/> allowed_cidrs = optional(list(string), ["0.0.0.0/0"])<br/> allowed_ipv6_cidrs = optional(list(string), ["::/0"])<br/> egress_cidrs = optional(list(string), ["0.0.0.0/0"])<br/> egress_ipv6_cidrs = optional(list(string), ["::/0"])<br/> extra_target_groups = optional(any, [])<br/> https_listener_rules = optional(any, [])<br/> https_overrides = optional(any, {})<br/> xff_header_processing_mode = optional(string, null)<br/> tls_policy = optional(string, "ELBSecurityPolicy-TLS13-1-2-2021-06")<br/> idle_timeout = optional(number, 905)<br/> internal = optional(bool, false)<br/> enable_deletion_protection = optional(bool, true)<br/> })</pre> | n/a | yes |
|
||||
| <a name="input_ecs_cluster"></a> [ecs\_cluster](#input\_ecs\_cluster) | The config for the terraform-aws-modules/ecs/aws module | <pre>object({<br/> autoscaling_capacity_providers = optional(any, {})<br/> cluster_configuration = optional(any, {<br/> execute_command_configuration = {<br/> logging = "OVERRIDE"<br/> log_configuration = {<br/> cloud_watch_log_group_name = "/aws/ecs/aws-ec2"<br/> }<br/> }<br/> })<br/> cluster_name = optional(string, "fleet")<br/> cluster_settings = optional(map(string), {<br/> "name" : "containerInsights",<br/> "value" : "enabled",<br/> })<br/> create = optional(bool, true)<br/> default_capacity_provider_use_fargate = optional(bool, true)<br/> fargate_capacity_providers = optional(any, {<br/> FARGATE = {<br/> default_capacity_provider_strategy = {<br/> weight = 100<br/> }<br/> }<br/> FARGATE_SPOT = {<br/> default_capacity_provider_strategy = {<br/> weight = 0<br/> }<br/> }<br/> })<br/> tags = optional(map(string))<br/> })</pre> | <pre>{<br/> "autoscaling_capacity_providers": {},<br/> "cluster_configuration": {<br/> "execute_command_configuration": {<br/> "log_configuration": {<br/> "cloud_watch_log_group_name": "/aws/ecs/aws-ec2"<br/> },<br/> "logging": "OVERRIDE"<br/> }<br/> },<br/> "cluster_name": "fleet",<br/> "cluster_settings": {<br/> "name": "containerInsights",<br/> "value": "enabled"<br/> },<br/> "create": true,<br/> "default_capacity_provider_use_fargate": true,<br/> "fargate_capacity_providers": {<br/> "FARGATE": {<br/> "default_capacity_provider_strategy": {<br/> "weight": 100<br/> }<br/> },<br/> "FARGATE_SPOT": {<br/> "default_capacity_provider_strategy": {<br/> "weight": 0<br/> }<br/> }<br/> },<br/> "tags": {}<br/>}</pre> | no |
|
||||
| <a name="input_fleet_config"></a> [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. | <pre>object({<br/> task_mem = optional(number, null)<br/> task_cpu = optional(number, null)<br/> mem = optional(number, 4096)<br/> cpu = optional(number, 512)<br/> pid_mode = optional(string, null)<br/> image = optional(string, "fleetdm/fleet:v4.72.1")<br/> family = optional(string, "fleet")<br/> sidecars = optional(list(any), [])<br/> depends_on = optional(list(any), [])<br/> mount_points = optional(list(any), [])<br/> volumes = optional(list(any), [])<br/> extra_environment_variables = optional(map(string), {})<br/> extra_iam_policies = optional(list(string), [])<br/> extra_execution_iam_policies = optional(list(string), [])<br/> extra_secrets = optional(map(string), {})<br/> security_group_name = optional(string, "fleet")<br/> iam_role_arn = optional(string, null)<br/> repository_credentials = optional(string, "")<br/> private_key_secret_name = optional(string, "fleet-server-private-key")<br/> service = optional(object({<br/> name = optional(string, "fleet")<br/> }), {<br/> name = "fleet"<br/> })<br/> database = optional(object({<br/> password_secret_arn = string<br/> user = string<br/> database = string<br/> address = string<br/> rr_address = optional(string, null)<br/> }), {<br/> password_secret_arn = null<br/> user = null<br/> database = null<br/> address = null<br/> rr_address = null<br/> })<br/> redis = optional(object({<br/> address = string<br/> use_tls = optional(bool, true)<br/> }), {<br/> address = null<br/> use_tls = true<br/> })<br/> awslogs = optional(object({<br/> name = optional(string, null)<br/> region = optional(string, null)<br/> create = optional(bool, true)<br/> prefix = optional(string, "fleet")<br/> retention = optional(number, 5)<br/> }), {<br/> name = null<br/> region = null<br/> prefix = "fleet"<br/> retention = 5<br/> })<br/> loadbalancer = optional(object({<br/> arn = string<br/> }), {<br/> arn = null<br/> })<br/> extra_load_balancers = optional(list(any), [])<br/> networking = optional(object({<br/> subnets = optional(list(string), null)<br/> security_groups = optional(list(string), null)<br/> ingress_sources = optional(object({<br/> cidr_blocks = optional(list(string), [])<br/> ipv6_cidr_blocks = optional(list(string), [])<br/> security_groups = optional(list(string), [])<br/> prefix_list_ids = optional(list(string), [])<br/> }), {<br/> cidr_blocks = []<br/> ipv6_cidr_blocks = []<br/> security_groups = []<br/> prefix_list_ids = []<br/> })<br/> }), {<br/> subnets = null<br/> security_groups = null<br/> ingress_sources = {<br/> cidr_blocks = []<br/> ipv6_cidr_blocks = []<br/> security_groups = []<br/> prefix_list_ids = []<br/> }<br/> })<br/> autoscaling = optional(object({<br/> max_capacity = optional(number, 5)<br/> min_capacity = optional(number, 1)<br/> memory_tracking_target_value = optional(number, 80)<br/> cpu_tracking_target_value = optional(number, 80)<br/> }), {<br/> max_capacity = 5<br/> min_capacity = 1<br/> memory_tracking_target_value = 80<br/> cpu_tracking_target_value = 80<br/> })<br/> iam = optional(object({<br/> role = optional(object({<br/> name = optional(string, "fleet-role")<br/> policy_name = optional(string, "fleet-iam-policy")<br/> }), {<br/> name = "fleet-role"<br/> policy_name = "fleet-iam-policy"<br/> })<br/> execution = optional(object({<br/> name = optional(string, "fleet-execution-role")<br/> policy_name = optional(string, "fleet-execution-role")<br/> }), {<br/> name = "fleet-execution-role"<br/> policy_name = "fleet-iam-policy-execution"<br/> })<br/> }), {<br/> name = "fleetdm-execution-role"<br/> })<br/> software_installers = optional(object({<br/> create_bucket = optional(bool, true)<br/> bucket_name = opLine truncated
|
||||
| <a name="input_migration_config"></a> [migration\_config](#input\_migration\_config) | The configuration object for Fleet's migration task. | <pre>object({<br/> mem = number<br/> cpu = number<br/> })</pre> | <pre>{<br/> "cpu": 1024,<br/> "mem": 2048<br/>}</pre> | no |
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
+5
-28
@@ -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 <kms-key-id-from-terraform-output> $i $i.encrypted; done
|
||||
for i in *.encrypted; do rm ${i/.encrypted/}; done
|
||||
```
|
||||
This will encrypt all of the mdm secrets and add the .encrypted extension to them. It will also remove the non-encrypted version of the secrets so that they are encrypted at rest even locally.
|
||||
To deploy:
|
||||
|
||||
- Uncomment all of the resources and data sources in `mdm-secrets.tf`.
|
||||
- Re-run `terraform apply` to populate the Secrets Manager secrets.
|
||||
- Uncomment the sections in the `fleet_config` portion of `main.tf` for mdm and run a final `terraform apply`. Services will restart with mdm enabled.
|
||||
1. `terraform apply`
|
||||
|
||||
If using a new route53 zone:
|
||||
|
||||
- From the output, obtain the NS records created for the zone and add them to the parent DNS zone
|
||||
+19
-34
@@ -4,64 +4,49 @@ 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 <kms-key-id-from-terraform-output> $i $i.encrypted; done
|
||||
for i in *.encrypted; do rm ${i/.encrypted/}; done
|
||||
```
|
||||
This will encrypt all of the mdm secrets and add the .encrypted extension to them. It will also remove the non-encrypted version of the secrets so that they are encrypted at rest even locally.
|
||||
To deploy:
|
||||
|
||||
- Uncomment all of the resources and data sources in `mdm-secrets.tf`.
|
||||
- Re-run `terraform apply` to populate the Secrets Manager secrets.
|
||||
- Uncomment the sections in the `fleet_config` portion of `main.tf` for mdm and run a final `terraform apply`. Services will restart with mdm enabled.
|
||||
1. `terraform apply`
|
||||
|
||||
If using a new route53 zone:
|
||||
|
||||
- From the output, obtain the NS records created for the zone and add them to the parent DNS zone
|
||||
|
||||
## Requirements
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | 5.36.0 |
|
||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | 6.11.0 |
|
||||
|
||||
## Providers
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.36.0 |
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.11.0 |
|
||||
| <a name="provider_random"></a> [random](#provider\_random) | 3.7.2 |
|
||||
| <a name="provider_tls"></a> [tls](#provider\_tls) | n/a |
|
||||
|
||||
## Modules
|
||||
|
||||
| Name | Source | Version |
|
||||
|------|--------|---------|
|
||||
| <a name="module_acm"></a> [acm](#module\_acm) | terraform-aws-modules/acm/aws | 4.3.1 |
|
||||
| <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 |
|
||||
| <a name="module_fleet"></a> [fleet](#module\_fleet) | github.com/fleetdm/fleet-terraform?depth=1&ref=tf-mod-root-v1.18.1 | n/a |
|
||||
| <a name="module_mdm"></a> [mdm](#module\_mdm) | github.com/fleetdm/fleet-terraform/addons/mdm?depth=1&ref=tf-mod-addon-mdm-v2.0.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.1.0 | n/a |
|
||||
|
||||
## Resources
|
||||
|
||||
| Name | Type |
|
||||
|------|------|
|
||||
| [aws_route53_record.main](https://registry.terraform.io/providers/hashicorp/aws/5.36.0/docs/resources/route53_record) | resource |
|
||||
| [aws_route53_zone.main](https://registry.terraform.io/providers/hashicorp/aws/5.36.0/docs/resources/route53_zone) | resource |
|
||||
| [aws_route53_record.main](https://registry.terraform.io/providers/hashicorp/aws/6.11.0/docs/resources/route53_record) | resource |
|
||||
| [aws_route53_zone.main](https://registry.terraform.io/providers/hashicorp/aws/6.11.0/docs/resources/route53_zone) | resource |
|
||||
| [aws_secretsmanager_secret_version.scep](https://registry.terraform.io/providers/hashicorp/aws/6.11.0/docs/resources/secretsmanager_secret_version) | resource |
|
||||
| [random_password.challenge](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
|
||||
| [tls_private_key.scep_key](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) | resource |
|
||||
| [tls_self_signed_cert.scep_cert](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/self_signed_cert) | resource |
|
||||
|
||||
## Inputs
|
||||
|
||||
|
||||
+25
-42
@@ -73,7 +73,7 @@ locals {
|
||||
}
|
||||
|
||||
module "fleet" {
|
||||
source = "github.com/fleetdm/fleet-terraform?depth=1&ref=tf-mod-root-v1.18.0"
|
||||
source = "github.com/fleetdm/fleet-terraform?depth=1&ref=tf-mod-root-v1.18.1"
|
||||
certificate_arn = module.acm.acm_certificate_arn
|
||||
|
||||
vpc = {
|
||||
@@ -99,14 +99,17 @@ module "fleet" {
|
||||
cpu = 512
|
||||
extra_environment_variables = merge(
|
||||
local.fleet_environment_variables,
|
||||
# uncomment if using a3 carves
|
||||
# uncomment if using s3 carves
|
||||
# module.osquery-carve.fleet_extra_environment_variables
|
||||
# uncomment if using firehose
|
||||
# module.firehose-logging.fleet_extra_environment_variables
|
||||
)
|
||||
# Uncomment if enabling mdm module below.
|
||||
# extra_secrets = module.mdm.extra_secrets
|
||||
# extra_execution_iam_policies = module.mdm.extra_execution_iam_policies
|
||||
extra_secrets = concat(
|
||||
module.mdm.extra_secrets,
|
||||
)
|
||||
extra_execution_iam_policies = concat(
|
||||
module.mdm.extra_execution_iam_policies,
|
||||
)
|
||||
# extra_iam_policies = concat(
|
||||
# uncomment if using a3 carves
|
||||
# module.osquery-carve.fleet_extra_iam_policies,
|
||||
@@ -142,6 +145,10 @@ module "fleet" {
|
||||
# Script execution can run for up to 300s plus overhead.
|
||||
# Ensure the load balancer does not 5XX before we have results.
|
||||
idle_timeout = 905
|
||||
# Optionally deploy load balancer as an internal load balancer
|
||||
# internal = true
|
||||
# optionally set deletion protection on (true) or off (false)
|
||||
# enable_deletion_protection = true
|
||||
# Optionally Remove X-Forwarded-For header
|
||||
# xff_header_processing_mode = "remove"
|
||||
# See https://github.com/terraform-aws-modules/terraform-aws-alb/blob/v9.17.0/examples/complete-alb/main.tf#L383-L393.
|
||||
@@ -223,7 +230,6 @@ module "fleet" {
|
||||
# ]
|
||||
# }]
|
||||
# }], local.https_listener_rules)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,6 +248,10 @@ module "migrations" {
|
||||
ecs_service = module.fleet.byo-vpc.byo-db.byo-ecs.service.name
|
||||
desired_count = module.fleet.byo-vpc.byo-db.byo-ecs.appautoscaling_target.min_capacity
|
||||
min_capacity = module.fleet.byo-vpc.byo-db.byo-ecs.appautoscaling_target.min_capacity
|
||||
|
||||
depends_on = [
|
||||
module.fleet,
|
||||
]
|
||||
}
|
||||
|
||||
# Enable if using s3 for carves
|
||||
@@ -254,7 +264,7 @@ module "migrations" {
|
||||
|
||||
# Uncomment if using firehose logging destination
|
||||
# module "firehose-logging" {
|
||||
# source = "github.com/fleetdm/fleet-terraform/addons/logging-destination-firehose?depth=1&ref=tf-mod-addon-logging-destination-firehose-v1.2.1"
|
||||
# source = "github.com/fleetdm/fleet-terraform/addons/logging-destination-firehose?depth=1&ref=tf-mod-addon-logging-destination-firehose-v1.2.4"
|
||||
# osquery_results_s3_bucket = {
|
||||
# name = local.osquery_results_bucket_name
|
||||
# }
|
||||
@@ -263,13 +273,6 @@ module "migrations" {
|
||||
# }
|
||||
# }
|
||||
|
||||
## MDM
|
||||
|
||||
# MDM Secrets must be populated with JSON data including the payload from the certs, keys, challenge, etc.
|
||||
# These can be populated via terraform with a secret-version, or manually after terraform is applied.
|
||||
# Note: Services will not start if the mdm module is enabled and the secrets are applied but not populated.
|
||||
|
||||
|
||||
## MDM Secret payload
|
||||
|
||||
# See https://github.com/fleetdm/fleet-terraform/blob/tf-mod-addon-mdm-v2.0.0/addons/mdm/README.md#abm
|
||||
@@ -277,34 +280,14 @@ module "migrations" {
|
||||
# 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"
|
||||
# apn_secret_name = null
|
||||
# scep_secret_name = "fleet-scep"
|
||||
# # Set abm_secret_name = null if customer is not using dep
|
||||
# abm_secret_name = null
|
||||
# enable_apple_mdm = false
|
||||
# enable_windows_mdm = true
|
||||
# }
|
||||
|
||||
# If you want to supply the MDM secrets via terraform, I recommend that you do not store the secrets in the clear
|
||||
# on the device that applies the terraform. For the example here, terraform will create a KMS key, which will then
|
||||
# be used to encrypt the secrets. The included mdm-secrets.tf file will then use the KMS key to dercrypt the secrets
|
||||
# on the filesystem to generate the
|
||||
|
||||
# resource "aws_kms_key" "fleet_data_key" {
|
||||
# description = "key used to encrypt sensitive data stored in terraform"
|
||||
# }
|
||||
#
|
||||
# resource "aws_kms_alias" "alias" {
|
||||
# name = "alias/fleet-terraform-encrypted"
|
||||
# target_key_id = aws_kms_key.fleet_data_key.id
|
||||
# }
|
||||
#
|
||||
# output "kms_key_id" {
|
||||
# value = aws_kms_key.fleet_data_key.id
|
||||
# }
|
||||
module "mdm" {
|
||||
source = "github.com/fleetdm/fleet-terraform/addons/mdm?depth=1&ref=tf-mod-addon-mdm-v2.0.0"
|
||||
apn_secret_name = null
|
||||
scep_secret_name = "fleet-scep"
|
||||
abm_secret_name = null
|
||||
enable_apple_mdm = false
|
||||
enable_windows_mdm = true
|
||||
}
|
||||
|
||||
module "acm" {
|
||||
source = "terraform-aws-modules/acm/aws"
|
||||
|
||||
+34
-56
@@ -1,62 +1,40 @@
|
||||
# Note: Everything is commented out here as mdm is not enabled by default.
|
||||
# Uncomment to use.
|
||||
|
||||
# This section expects all kms-encrypted secrets to live in the resources/
|
||||
# subdirectory. The list of expected filenames is as follows:
|
||||
|
||||
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"
|
||||
resource "tls_private_key" "scep_key" {
|
||||
algorithm = "RSA"
|
||||
rsa_bits = 4096
|
||||
}
|
||||
|
||||
# To ease the process of encrypting and decrypting secrets, see
|
||||
# scripts/encrypt.sh and scripts/decrypt.sh
|
||||
resource "tls_self_signed_cert" "scep_cert" {
|
||||
private_key_pem = tls_private_key.scep_key.private_key_pem
|
||||
|
||||
# Place your non-encrypted files in the resources folder and
|
||||
# run the following:
|
||||
#
|
||||
# cd resources
|
||||
# for i in *; do ../scripts/encrypt.sh <kms-key-id-from-terraform-output> $i $i.encrypted; done
|
||||
# for i in *.encrypted; do rm ${i/.encrypted/}; done
|
||||
subject {
|
||||
common_name = "Fleet Root CA"
|
||||
organization = "Fleet."
|
||||
country = "US"
|
||||
}
|
||||
|
||||
# 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. 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
|
||||
is_ca_certificate = true
|
||||
validity_period_hours = 87648
|
||||
|
||||
# resource "random_password" "challenge" {
|
||||
# length = 12
|
||||
# special = false
|
||||
# }
|
||||
#
|
||||
# resource "aws_secretsmanager_secret_version" "scep" {
|
||||
# secret_id = module.mdm.scep.id
|
||||
# secret_string = jsonencode(
|
||||
# {
|
||||
# FLEET_MDM_APPLE_SCEP_CERT_BYTES = data.aws_kms_secrets.scep_cert.plaintext["FLEET_MDM_APPLE_SCEP_CERT_BYTES"]
|
||||
# FLEET_MDM_APPLE_SCEP_KEY_BYTES = data.aws_kms_secrets.scep_key.plaintext["FLEET_MDM_APPLE_SCEP_KEY_BYTES"]
|
||||
# FLEET_MDM_APPLE_SCEP_CHALLENGE = random_password.challenge.result
|
||||
# }
|
||||
# )
|
||||
# }
|
||||
#
|
||||
#
|
||||
# data "aws_kms_secrets" "scep_cert" {
|
||||
# secret {
|
||||
# name = "FLEET_MDM_APPLE_SCEP_CERT_BYTES"
|
||||
# key_id = aws_kms_key.fleet_data_key.id
|
||||
# payload = file(local.scep_cert)
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# data "aws_kms_secrets" "scep_key" {
|
||||
# secret {
|
||||
# name = "FLEET_MDM_APPLE_SCEP_KEY_BYTES"
|
||||
# key_id = aws_kms_key.fleet_data_key.id
|
||||
# payload = file(local.scep_key)
|
||||
# }
|
||||
# }
|
||||
allowed_uses = [
|
||||
"cert_signing",
|
||||
"crl_signing",
|
||||
"key_encipherment",
|
||||
"digital_signature",
|
||||
]
|
||||
}
|
||||
|
||||
resource "random_password" "challenge" {
|
||||
length = 12
|
||||
special = false
|
||||
}
|
||||
|
||||
resource "aws_secretsmanager_secret_version" "scep" {
|
||||
secret_id = module.mdm.scep.id
|
||||
secret_string = jsonencode(
|
||||
{
|
||||
FLEET_MDM_APPLE_SCEP_CERT_BYTES = tls_self_signed_cert.scep_cert.cert_pem
|
||||
FLEET_MDM_APPLE_SCEP_KEY_BYTES = tls_private_key.scep_key.private_key_pem
|
||||
FLEET_MDM_APPLE_SCEP_CHALLENGE = random_password.challenge.result
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -475,6 +475,8 @@ 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)
|
||||
})
|
||||
default = {}
|
||||
}
|
||||
Reference in new issue
Block a user