Enforce DENY non-HTTPS requests to s3 buckets (#250)

- Enforces access over HTTPS to all Fleet-terraform created buckets.
- Fixes vpc-flow-logs log retention; now allows configuring the
retention in days.
This commit is contained in:
Jorge Falcon authored and GitHub committed 2026-06-08 18:37:48 -04:00
1 parent a276eb6a98
commit 7b381e0bbb
25 files changed
+503 -175

No files matched your search

+4
View File
@@ -13,3 +13,7 @@ When a module-created customer-managed key must trust the Fleet IAM role, Terraf
The IAM policy exported by this addon is intentionally S3-only. KMS authorization is handled in the KMS key policy for module-created keys. If `osquery_carve_s3_bucket.kms.kms_key_arn` is set, this module does not manage the referenced key policy and does not export a generic KMS IAM policy for it.
When bringing your own KMS key, it is your responsibility to ensure that key policy and any separately managed IAM permissions allow the Fleet role to perform the required KMS actions for S3 object encryption and decryption.
## S3 Bucket Policy: Deny Non-HTTPS
This module automatically attaches a bucket policy that denies any requests made over plain HTTP. No configuration is required.
+6
View File
@@ -14,6 +14,10 @@ The IAM policy exported by this addon is intentionally S3-only. KMS authorizatio
When bringing your own KMS key, it is your responsibility to ensure that key policy and any separately managed IAM permissions allow the Fleet role to perform the required KMS actions for S3 object encryption and decryption.
## S3 Bucket Policy: Deny Non-HTTPS
This module automatically attaches a bucket policy that denies any requests made over plain HTTP. No configuration is required.
## Requirements
| Name | Version |
@@ -41,9 +45,11 @@ No modules.
| [aws_kms_key_policy.osquery_carve](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key_policy) | resource |
| [aws_s3_bucket.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
| [aws_s3_bucket_lifecycle_configuration.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |
| [aws_s3_bucket_policy.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
| [aws_s3_bucket_public_access_block.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |
| [aws_s3_bucket_server_side_encryption_configuration.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_iam_policy_document.deny_insecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.osquery_carve_kms](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_role.osquery_carve_fleet](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_role) | data source |
+27
View File
@@ -205,6 +205,33 @@ resource "aws_s3_bucket_public_access_block" "main" {
restrict_public_buckets = true
}
data "aws_iam_policy_document" "deny_insecure_transport" {
statement {
sid = "DenyNonHTTPS"
effect = "Deny"
actions = ["s3:*"]
resources = [
aws_s3_bucket.main.arn,
"${aws_s3_bucket.main.arn}/*",
]
principals {
type = "*"
identifiers = ["*"]
}
condition {
test = "Bool"
variable = "aws:SecureTransport"
values = ["false"]
}
}
}
resource "aws_s3_bucket_policy" "deny_insecure_transport" {
bucket = aws_s3_bucket.main.id
policy = data.aws_iam_policy_document.deny_insecure_transport.json
}
data "aws_iam_policy_document" "main" {
statement {
actions = [