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
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user