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:
1 parent
a276eb6a98
commit
7b381e0bbb
25 files changed
+503
-175
No files matched your search
@@ -7,11 +7,15 @@ This addon configures AWS Kinesis Firehose to send Fleet's osquery logs to Datad
|
||||
3. IAM roles and policies for the Firehose streams to access the S3 bucket
|
||||
4. An IAM policy for Fleet to access the Firehose streams
|
||||
|
||||
## S3 Bucket Policy: Deny Non-HTTPS
|
||||
|
||||
This module automatically attaches a bucket policy to the failure S3 bucket that denies any requests made over plain HTTP. No configuration is required.
|
||||
|
||||
## How to use
|
||||
|
||||
```hcl
|
||||
module "datadog-logging" {
|
||||
source = "github.com/fleetdm/fleet-terraform//addons/logging-destination-datadog?ref=tf-mod-addon-datadog-logging-v1.1.2"
|
||||
source = "github.com/fleetdm/fleet-terraform//addons/logging-destination-datadog?ref=tf-mod-addon-datadog-logging-v1.2.0"
|
||||
|
||||
datadog_api_key = "your-datadog-api-key"
|
||||
|
||||
@@ -82,7 +86,7 @@ Then you can use the module's outputs in your Fleet configuration:
|
||||
|
||||
```hcl
|
||||
module "fleet" {
|
||||
source = "github.com/fleetdm/fleet-terraform?depth=1&ref=tf-mod-root-v1.27.0"
|
||||
source = "github.com/fleetdm/fleet-terraform?depth=1&ref=tf-mod-root-v1.30.0"
|
||||
certificate_arn = module.acm.acm_certificate_arn
|
||||
|
||||
vpc = {
|
||||
|
||||
@@ -7,11 +7,23 @@ This addon configures AWS Kinesis Firehose to send Fleet's osquery logs to Datad
|
||||
3. IAM roles and policies for the Firehose streams to access the S3 bucket
|
||||
4. An IAM policy for Fleet to access the Firehose streams
|
||||
|
||||
## S3 Bucket Policy: Deny Non-HTTPS
|
||||
|
||||
Set `attach_deny_insecure_transport_policy = true` to attach a bucket policy to the failure S3 bucket that denies any requests made over plain HTTP:
|
||||
|
||||
```hcl
|
||||
module "datadog-logging" {
|
||||
source = "github.com/fleetdm/fleet-terraform//addons/logging-destination-datadog?ref=<tag>"
|
||||
attach_deny_insecure_transport_policy = true
|
||||
# ... other configuration ...
|
||||
}
|
||||
```
|
||||
|
||||
## How to use
|
||||
|
||||
```hcl
|
||||
module "datadog-logging" {
|
||||
source = "github.com/fleetdm/fleet-terraform//addons/logging-destination-datadog?ref=tf-mod-addon-datadog-logging-v1.1.2"
|
||||
source = "github.com/fleetdm/fleet-terraform//addons/logging-destination-datadog?ref=tf-mod-addon-datadog-logging-v1.2.0"
|
||||
|
||||
datadog_api_key = "your-datadog-api-key"
|
||||
|
||||
@@ -82,7 +94,7 @@ Then you can use the module's outputs in your Fleet configuration:
|
||||
|
||||
```hcl
|
||||
module "fleet" {
|
||||
source = "github.com/fleetdm/fleet-terraform?depth=1&ref=tf-mod-root-v1.27.0"
|
||||
source = "github.com/fleetdm/fleet-terraform?depth=1&ref=tf-mod-root-v1.30.0"
|
||||
certificate_arn = module.acm.acm_certificate_arn
|
||||
|
||||
vpc = {
|
||||
@@ -138,8 +150,10 @@ No modules.
|
||||
| [aws_kinesis_firehose_delivery_stream.datadog](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kinesis_firehose_delivery_stream) | resource |
|
||||
| [aws_s3_bucket.datadog-failure](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
|
||||
| [aws_s3_bucket_lifecycle_configuration.datadog-failure](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.datadog-failure](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |
|
||||
| [aws_s3_bucket_server_side_encryption_configuration.datadog-failure](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource |
|
||||
| [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.firehose-logging](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
|
||||
| [aws_iam_policy_document.firehose_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
|
||||
| [aws_iam_policy_document.osquery_firehose_assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
|
||||
@@ -149,6 +163,7 @@ No modules.
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|:--------:|
|
||||
| <a name="input_attach_deny_insecure_transport_policy"></a> [attach\_deny\_insecure\_transport\_policy](#input\_attach\_deny\_insecure\_transport\_policy) | When true, attach a bucket policy to the S3 bucket that denies non-SSL requests. | `bool` | `false` | no |
|
||||
| <a name="input_compression_format"></a> [compression\_format](#input\_compression\_format) | Compression format for the Firehose delivery stream | `string` | `"UNCOMPRESSED"` | no |
|
||||
| <a name="input_datadog_api_key"></a> [datadog\_api\_key](#input\_datadog\_api\_key) | Datadog API key for authentication | `string` | n/a | yes |
|
||||
| <a name="input_datadog_url"></a> [datadog\_url](#input\_datadog\_url) | Datadog HTTP API endpoint URL | `string` | n/a | yes |
|
||||
|
||||
@@ -36,6 +36,33 @@ resource "aws_s3_bucket_public_access_block" "datadog-failure" {
|
||||
restrict_public_buckets = true
|
||||
}
|
||||
|
||||
data "aws_iam_policy_document" "deny_insecure_transport" {
|
||||
|
||||
statement {
|
||||
sid = "DenyNonHTTPS"
|
||||
effect = "Deny"
|
||||
actions = ["s3:*"]
|
||||
resources = [
|
||||
aws_s3_bucket.datadog-failure.arn,
|
||||
"${aws_s3_bucket.datadog-failure.arn}/*",
|
||||
]
|
||||
principals {
|
||||
type = "*"
|
||||
identifiers = ["*"]
|
||||
}
|
||||
condition {
|
||||
test = "Bool"
|
||||
variable = "aws:SecureTransport"
|
||||
values = ["false"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_s3_bucket_policy" "deny_insecure_transport" {
|
||||
bucket = aws_s3_bucket.datadog-failure.id
|
||||
policy = data.aws_iam_policy_document.deny_insecure_transport.json
|
||||
}
|
||||
|
||||
data "aws_iam_policy_document" "firehose_policy" {
|
||||
statement {
|
||||
effect = "Allow"
|
||||
|
||||
Reference in new issue
Block a user