diff --git a/.header.md b/.header.md index 97506da..62e5b7e 100644 --- a/.header.md +++ b/.header.md @@ -66,6 +66,24 @@ This module also exposes Aurora MySQL backtracking through `rds_config.backtrack * Set `0` to disable backtracking explicitly. * Leave it `null` to keep the default upstream behavior. +# S3 Bucket Policy: Deny Non-HTTPS + +All S3 buckets created by this module automatically have a bucket policy that denies any requests made over plain HTTP. No configuration is required. + +When `cloudfront_distribution_arn` is set in `software_installers`, the bucket policy automatically includes an allow statement for CloudFront to read objects. This means the `cloudfront-software-installers` addon no longer manages a bucket policy — it is fully handled here. + +# VPC Flow Log Retention + +The root module now exposes `flow_log_cloudwatch_log_group_retention_in_days` on the `vpc` variable to set CloudWatch log retention for VPC flow logs. It defaults to `null` (infinite retention). + +```hcl +vpc = { + enable_flow_log = true + create_flow_log_cloudwatch_log_group = true + flow_log_cloudwatch_log_group_retention_in_days = 365 +} +``` + # Migration Notes * Existing environments remain unchanged unless you opt into new KMS or Database Insights settings. @@ -86,7 +104,7 @@ DELETE_OLD_STREAMS=false ./scripts/cloudwatch_logs_kms_migration.sh R | [alb\_config](#input\_alb\_config) | n/a |
object({
name = optional(string, "fleet")
security_groups = optional(list(string), [])
access_logs = optional(map(string), {})
allowed_cidrs = optional(list(string), ["0.0.0.0/0"])
allowed_ipv6_cidrs = optional(list(string), ["::/0"])
egress_cidrs = optional(list(string), ["0.0.0.0/0"])
egress_ipv6_cidrs = optional(list(string), ["::/0"])
fleet_target_group = optional(object({
protocol = optional(string, "HTTP")
port = optional(number, 80)
target_type = optional(string, "ip")
create_attachment = optional(bool, false)
health_check = optional(object({
path = optional(string, "/healthz")
matcher = optional(string, "200")
port = optional(string)
timeout = optional(number, 10)
interval = optional(number, 15)
healthy_threshold = optional(number, 5)
unhealthy_threshold = optional(number, 5)
}), {})
}), {})
extra_target_groups = optional(any, [])
https_listener_rules = optional(any, [])
https_overrides = optional(any, {})
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, false)
})
| `{}` | no | | [certificate\_arn](#input\_certificate\_arn) | n/a | `string` | n/a | yes | | [ecs\_cluster](#input\_ecs\_cluster) | The config for the terraform-aws-modules/ecs/aws module. For published KMS blocks, legacy `enabled` is deprecated and still accepted; prefer `cmk_enabled`. |
object({
autoscaling_capacity_providers = optional(any, {})
cluster_configuration = optional(any, {
execute_command_configuration = {
logging = "OVERRIDE"
log_configuration = {
cloud_watch_log_group_name = "/aws/ecs/aws-ec2"
}
}
})
cluster_name = optional(string, "fleet")
cloudwatch_log_group = optional(object({
create = optional(bool, true)
retention_in_days = optional(number, 90)
kms = optional(object({
cmk_enabled = optional(bool, null)
enabled = optional(bool, null)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-ecs-cluster-logs")
extra_kms_policies = optional(list(any), [])
}), {
cmk_enabled = null
enabled = null
kms_key_arn = null
kms_alias = "fleet-ecs-cluster-logs"
extra_kms_policies = []
})
}), {
create = true
retention_in_days = 90
kms = {
cmk_enabled = null
enabled = null
kms_key_arn = null
kms_alias = "fleet-ecs-cluster-logs"
}
})
cluster_settings = optional(any, {
"name" : "containerInsights",
"value" : "enabled",
})
create = optional(bool, true)
default_capacity_provider_use_fargate = optional(bool, true)
fargate_capacity_providers = optional(any, {
FARGATE = {
default_capacity_provider_strategy = {
weight = 100
}
}
FARGATE_SPOT = {
default_capacity_provider_strategy = {
weight = 0
}
}
})
tags = optional(map(string))
})
|
{
"autoscaling_capacity_providers": {},
"cloudwatch_log_group": {
"create": true,
"kms": {
"cmk_enabled": null,
"enabled": null,
"extra_kms_policies": [],
"kms_alias": "fleet-ecs-cluster-logs",
"kms_key_arn": null
},
"retention_in_days": 90
},
"cluster_configuration": {
"execute_command_configuration": {
"log_configuration": {
"cloud_watch_log_group_name": "/aws/ecs/aws-ec2"
},
"logging": "OVERRIDE"
}
},
"cluster_name": "fleet",
"cluster_settings": {
"name": "containerInsights",
"value": "enabled"
},
"create": true,
"default_capacity_provider_use_fargate": true,
"fargate_capacity_providers": {
"FARGATE": {
"default_capacity_provider_strategy": {
"weight": 100
}
},
"FARGATE_SPOT": {
"default_capacity_provider_strategy": {
"weight": 0
}
}
},
"tags": {}
}
| no | -| [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. For published KMS blocks, legacy `enabled` is deprecated and still accepted; prefer `cmk_enabled`. |
object({
task_mem = optional(number, null)
task_cpu = optional(number, null)
ephemeral_storage = optional(object({
size_in_gib = number
}), null)
mem = optional(number, 4096)
cpu = optional(number, 512)
pid_mode = optional(string, null)
command = optional(list(string), null)
private_key_delivery_method = optional(string, "ecs")
image = optional(string, "fleetdm/fleet:v4.85.0")
family = optional(string, "fleet")
sidecars = optional(list(any), [])
depends_on = optional(list(any), [])
mount_points = optional(list(any), [])
volumes = optional(list(any), [])
extra_environment_variables = optional(map(string), {})
extra_iam_policies = optional(list(string), [])
extra_execution_iam_policies = optional(list(string), [])
extra_secrets = optional(map(string), {})
security_group_name = optional(string, "fleet")
iam_role_arn = optional(string, null)
repository_credentials = optional(string, "")
private_key_secret_arn = optional(string, null)
private_key_secret_name = optional(string, "fleet-server-private-key")
private_key_secret_kms = optional(object({
cmk_enabled = optional(bool, null)
enabled = optional(bool, null)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-server-private-key")
extra_kms_policies = optional(list(any), [])
}), {
cmk_enabled = null
enabled = null
kms_key_arn = null
kms_alias = "fleet-server-private-key"
extra_kms_policies = []
})
fargate_ephemeral_storage_kms = optional(object({
cmk_enabled = optional(bool, null)
enabled = optional(bool, null)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-fargate-ephemeral-storage")
extra_kms_policies = optional(list(any), [])
}), {
cmk_enabled = null
enabled = null
kms_key_arn = null
kms_alias = "fleet-fargate-ephemeral-storage"
extra_kms_policies = []
})
server_tls_enabled = optional(bool, false)
service = optional(object({
name = optional(string, "fleet")
}), {
name = "fleet"
})
database = optional(object({
password_secret_arn = optional(string, null)
password_secret_kms_key_arn = optional(string, null)
user = optional(string, null)
database = optional(string, null)
address = optional(string, null)
rr_address = optional(string, null)
}), {
password_secret_arn = null
password_secret_kms_key_arn = null
user = null
database = null
address = null
rr_address = null
})
redis = optional(object({
address = string
use_tls = optional(bool, true)
}), {
address = null
use_tls = true
})
awslogs = optional(object({
name = optional(string, null)
region = optional(string, null)
create = optional(bool, true)
prefix = optional(string, "fleet")
retention = optional(number, 5)
kms = optional(object({
cmk_enabled = optional(bool, null)
enabled = optional(bool, null)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-application-logs")
extra_kms_policies = optional(list(any), [])
}), {
cmk_enabled = null
enabled = null
kms_key_arn = null
kms_alias = "fleet-application-logs"
extra_kms_policies = []
})
}), {
name = null
region = null
create = true
prefix = "fleet"
retention = 5
kms = {
cmk_enabled = null
enabled = null
kms_key_arn = null
kms_alias = "fleet-application-logs"
extra_kms_policies = []
}
})
loadbalancer = optional(object({
arn = string
}), {
arn = null
})
extra_load_balancers = optional(list(any), [])
networking = optional(object({
subnets = optional(list(string), null)
security_groups = optional(list(string), null)
ingress_sources = optional(object({
cidr_blocks = optional(list(string), [])
ipv6_cidr_blocks = optional(list(string), [])
security_groups = optional(list(string), [])
prefix_list_ids = optional(list(string), [])
}), {
cidr_blocks = []
ipv6_cidr_blocks = []
security_groups = []
prefix_list_ids = []
})
assign_public_ip = optional(bool, false)
}), {
subnets = null
security_groups = null
ingress_sources = {
cidr_blocks = []
ipv6_cidr_blocks = []
security_groups = []
prefix_list_ids = []
}
assign_public_ip = false
})
autoscaling = optional(object({
max_capacity = optional(number, 5)
min_capacity = optional(number, 1)
memory_tracking_target_value = optional(number, 80)
cpu_tracking_target_value = optional(number, 80)
}), {
max_capacity = 5
min_capacity = 1
memory_tracking_target_value = 80
cpu_tracking_target_value = 80
})
iam = optional(object({
role = optional(object({
name = optional(string, "fleet-role")
policy_name = optional(string, "fleet-iam-policy")
}), {
name = "fleet-role"
policy_name = "fleet-iam-policy"
})
execution = optional(object({
name = optional(string, "fleet-execution-role")
policy_name = optional(string, "fleet-execution-role")
}), {
name = "fleet-execution-role"
policy_name = "fleet-iam-policy-execution"
})
}), {
name = "fleetdm-execution-role"
})
software_installers = optional(object({
create_bucket = optional(bool, true)
bucket_name = optional(string, null)
bucket_prefix = optional(string, "fleet-software-installers-")
s3_object_prefix = optional(string, "")
cloudfront_distribution_arn = optional(string, null)
enable_bucket_versioning = optional(bool, false)
expire_noncurrent_versions = optional(bool, true)
noncurrent_version_expiration_days = optional(number, 30)
create_kms_key = optional(bool, false)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-software-installers")
extra_kms_policies = optional(list(any), [])
tags = optional(map(string), {})
}), {
create_bucket = true
bucket_name = null
bucket_prefix = "fleet-software-installers-"
s3_object_prefix = ""
cloudfront_distribution_arn = null
enable_bucket_versioning = false
expire_noncurrent_versions = true
noncurrent_version_expiration_days = 30
create_kms_key = false
kms_key_arn = null
kms_alias = "fleet-software-installers"
extra_kms_policies = []
tags = {}
})
})
|
{
"autoscaling": {
"cpu_tracking_target_value": 80,
"max_capacity": 5,
"memory_tracking_target_value": 80,
"min_capacity": 1
},
"awslogs": {
"create": true,
"kms": {
"cmk_enabled": null,
"enabled": null,
"extra_kms_policies": [],
"kms_alias": "fleet-application-logs",
"kms_key_arn": null
},
"name": null,
"prefix": "fleet",
"region": null,
"retention": 5
},
"command": null,
"cpu": 512,
"database": {
"address": null,
"database": null,
"password_secret_arn": null,
"rr_address": null,
"user": null
},
"depends_on": [],
"ephemeral_storage": null,
"extra_environment_variables": {},
"extra_execution_iam_policies": [],
"extra_iam_policies": [],
"extra_load_balancers": [],
"extra_secrets": {},
"family": "fleet",
"fargate_ephemeral_storage_kms": {
"cmk_enabled": null,
"enabled": null,
"extra_kms_policies": [],
"kms_alias": "fleet-fargate-ephemeral-storage",
"kms_key_arn": null
},
"iam": {
"execution": {
"name": "fleet-execution-role",
"policy_name": "fleet-iam-policy-execution"
},
"role": {
"name": "fleet-role",
"policy_name": "fleet-iam-policy"
}
},
"iam_role_arn": null,
"image": "fleetdm/fleet:v4.85.0",
"loadbalancer": {
"arn": null
},
"mem": 4096,
"mount_points": [],
"networking": {
"assign_public_ip": false,
"ingress_sources": {
"cidr_blocks": [],
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"security_groups": []
},
"security_groups": null,
"subnets": null
},
"pid_mode": null,
"private_key_delivery_method": "ecs",
"private_key_secret_arn": null,
"private_key_secret_kms": {
"cmk_enabled": null,
"enabled": null,
"extra_kms_policies": [],
"kms_alias": "fleet-server-private-key",
"kms_key_arn": null
},
"private_key_secret_name": "fleet-server-private-key",
"redis": {
"address": null,
"use_tls": true
},
"repository_credentials": "",
"security_group_name": "fleet",
"security_groups": null,
"server_tls_enabled": false,
"service": {
"name": "fleet"
},
"sidecars": [],
"software_installers": {
"bucket_name": null,
"bucket_prefix": "fleet-software-installers-",
"cloudfront_distribution_arn": null,
"create_bucket": true,
"create_kms_key": false,
"enable_bucket_versioning": false,
"expire_noncurrent_versions": true,
"extra_kms_policies": [],
"kms_alias": "fleet-software-installers",
"kms_key_arn": null,
"noncurrent_version_expiration_days": 30,
"s3_object_prefix": "",
"tags": {}
},
"task_cpu": null,
"task_mem": null,
"volumes": []
}
| no | +| [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. For published KMS blocks, legacy `enabled` is deprecated and still accepted; prefer `cmk_enabled`. |
object({
task_mem = optional(number, null)
task_cpu = optional(number, null)
ephemeral_storage = optional(object({
size_in_gib = number
}), null)
mem = optional(number, 4096)
cpu = optional(number, 512)
pid_mode = optional(string, null)
command = optional(list(string), null)
private_key_delivery_method = optional(string, "ecs")
image = optional(string, "fleetdm/fleet:v4.86.1")
family = optional(string, "fleet")
sidecars = optional(list(any), [])
depends_on = optional(list(any), [])
mount_points = optional(list(any), [])
volumes = optional(list(any), [])
extra_environment_variables = optional(map(string), {})
extra_iam_policies = optional(list(string), [])
extra_execution_iam_policies = optional(list(string), [])
extra_secrets = optional(map(string), {})
security_group_name = optional(string, "fleet")
iam_role_arn = optional(string, null)
repository_credentials = optional(string, "")
private_key_secret_arn = optional(string, null)
private_key_secret_name = optional(string, "fleet-server-private-key")
private_key_secret_kms = optional(object({
cmk_enabled = optional(bool, null)
enabled = optional(bool, null)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-server-private-key")
extra_kms_policies = optional(list(any), [])
}), {
cmk_enabled = null
enabled = null
kms_key_arn = null
kms_alias = "fleet-server-private-key"
extra_kms_policies = []
})
fargate_ephemeral_storage_kms = optional(object({
cmk_enabled = optional(bool, null)
enabled = optional(bool, null)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-fargate-ephemeral-storage")
extra_kms_policies = optional(list(any), [])
}), {
cmk_enabled = null
enabled = null
kms_key_arn = null
kms_alias = "fleet-fargate-ephemeral-storage"
extra_kms_policies = []
})
server_tls_enabled = optional(bool, false)
service = optional(object({
name = optional(string, "fleet")
}), {
name = "fleet"
})
database = optional(object({
password_secret_arn = optional(string, null)
password_secret_kms_key_arn = optional(string, null)
user = optional(string, null)
database = optional(string, null)
address = optional(string, null)
rr_address = optional(string, null)
}), {
password_secret_arn = null
password_secret_kms_key_arn = null
user = null
database = null
address = null
rr_address = null
})
redis = optional(object({
address = string
use_tls = optional(bool, true)
}), {
address = null
use_tls = true
})
awslogs = optional(object({
name = optional(string, null)
region = optional(string, null)
create = optional(bool, true)
prefix = optional(string, "fleet")
retention = optional(number, 5)
kms = optional(object({
cmk_enabled = optional(bool, null)
enabled = optional(bool, null)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-application-logs")
extra_kms_policies = optional(list(any), [])
}), {
cmk_enabled = null
enabled = null
kms_key_arn = null
kms_alias = "fleet-application-logs"
extra_kms_policies = []
})
}), {
name = null
region = null
create = true
prefix = "fleet"
retention = 5
kms = {
cmk_enabled = null
enabled = null
kms_key_arn = null
kms_alias = "fleet-application-logs"
extra_kms_policies = []
}
})
loadbalancer = optional(object({
arn = string
}), {
arn = null
})
extra_load_balancers = optional(list(any), [])
networking = optional(object({
subnets = optional(list(string), null)
security_groups = optional(list(string), null)
ingress_sources = optional(object({
cidr_blocks = optional(list(string), [])
ipv6_cidr_blocks = optional(list(string), [])
security_groups = optional(list(string), [])
prefix_list_ids = optional(list(string), [])
}), {
cidr_blocks = []
ipv6_cidr_blocks = []
security_groups = []
prefix_list_ids = []
})
assign_public_ip = optional(bool, false)
}), {
subnets = null
security_groups = null
ingress_sources = {
cidr_blocks = []
ipv6_cidr_blocks = []
security_groups = []
prefix_list_ids = []
}
assign_public_ip = false
})
autoscaling = optional(object({
max_capacity = optional(number, 5)
min_capacity = optional(number, 1)
memory_tracking_target_value = optional(number, 80)
cpu_tracking_target_value = optional(number, 80)
}), {
max_capacity = 5
min_capacity = 1
memory_tracking_target_value = 80
cpu_tracking_target_value = 80
})
iam = optional(object({
role = optional(object({
name = optional(string, "fleet-role")
policy_name = optional(string, "fleet-iam-policy")
}), {
name = "fleet-role"
policy_name = "fleet-iam-policy"
})
execution = optional(object({
name = optional(string, "fleet-execution-role")
policy_name = optional(string, "fleet-execution-role")
}), {
name = "fleet-execution-role"
policy_name = "fleet-iam-policy-execution"
})
}), {
name = "fleetdm-execution-role"
})
software_installers = optional(object({
create_bucket = optional(bool, true)
bucket_name = optional(string, null)
bucket_prefix = optional(string, "fleet-software-installers-")
s3_object_prefix = optional(string, "")
cloudfront_distribution_arn = optional(string, null)
enable_bucket_versioning = optional(bool, false)
expire_noncurrent_versions = optional(bool, true)
noncurrent_version_expiration_days = optional(number, 30)
create_kms_key = optional(bool, false)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-software-installers")
extra_kms_policies = optional(list(any), [])
tags = optional(map(string), {})
}), {
create_bucket = true
bucket_name = null
bucket_prefix = "fleet-software-installers-"
s3_object_prefix = ""
cloudfront_distribution_arn = null
enable_bucket_versioning = false
expire_noncurrent_versions = true
noncurrent_version_expiration_days = 30
create_kms_key = false
kms_key_arn = null
kms_alias = "fleet-software-installers"
extra_kms_policies = []
tags = {}
})
})
|
{
"autoscaling": {
"cpu_tracking_target_value": 80,
"max_capacity": 5,
"memory_tracking_target_value": 80,
"min_capacity": 1
},
"awslogs": {
"create": true,
"kms": {
"cmk_enabled": null,
"enabled": null,
"extra_kms_policies": [],
"kms_alias": "fleet-application-logs",
"kms_key_arn": null
},
"name": null,
"prefix": "fleet",
"region": null,
"retention": 5
},
"command": null,
"cpu": 512,
"database": {
"address": null,
"database": null,
"password_secret_arn": null,
"rr_address": null,
"user": null
},
"depends_on": [],
"ephemeral_storage": null,
"extra_environment_variables": {},
"extra_execution_iam_policies": [],
"extra_iam_policies": [],
"extra_load_balancers": [],
"extra_secrets": {},
"family": "fleet",
"fargate_ephemeral_storage_kms": {
"cmk_enabled": null,
"enabled": null,
"extra_kms_policies": [],
"kms_alias": "fleet-fargate-ephemeral-storage",
"kms_key_arn": null
},
"iam": {
"execution": {
"name": "fleet-execution-role",
"policy_name": "fleet-iam-policy-execution"
},
"role": {
"name": "fleet-role",
"policy_name": "fleet-iam-policy"
}
},
"iam_role_arn": null,
"image": "fleetdm/fleet:v4.86.1",
"loadbalancer": {
"arn": null
},
"mem": 4096,
"mount_points": [],
"networking": {
"assign_public_ip": false,
"ingress_sources": {
"cidr_blocks": [],
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"security_groups": []
},
"security_groups": null,
"subnets": null
},
"pid_mode": null,
"private_key_delivery_method": "ecs",
"private_key_secret_arn": null,
"private_key_secret_kms": {
"cmk_enabled": null,
"enabled": null,
"extra_kms_policies": [],
"kms_alias": "fleet-server-private-key",
"kms_key_arn": null
},
"private_key_secret_name": "fleet-server-private-key",
"redis": {
"address": null,
"use_tls": true
},
"repository_credentials": "",
"security_group_name": "fleet",
"security_groups": null,
"server_tls_enabled": false,
"service": {
"name": "fleet"
},
"sidecars": [],
"software_installers": {
"bucket_name": null,
"bucket_prefix": "fleet-software-installers-",
"cloudfront_distribution_arn": null,
"create_bucket": true,
"create_kms_key": false,
"enable_bucket_versioning": false,
"expire_noncurrent_versions": true,
"extra_kms_policies": [],
"kms_alias": "fleet-software-installers",
"kms_key_arn": null,
"noncurrent_version_expiration_days": 30,
"s3_object_prefix": "",
"tags": {}
},
"task_cpu": null,
"task_mem": null,
"volumes": []
}
| no | | [kms\_base\_policy](#input\_kms\_base\_policy) | Optional base KMS key-policy statements to apply to module-created CMKs before module-required service access statements are merged in. If null, the module defaults to the historical root `kms:*` statement. |
list(object({
sid = string
effect = string
principals = object({
type = string
identifiers = list(string)
})
actions = list(string)
resources = list(string)
conditions = optional(list(object({
test = string
variable = string
values = list(string)
})), [])
}))
| `null` | no | | [migration\_config](#input\_migration\_config) | The configuration object for Fleet's migration task. |
object({
mem = number
cpu = number
})
|
{
"cpu": 1024,
"mem": 2048
}
| no | | [rds\_config](#input\_rds\_config) | The config for the terraform-aws-modules/rds-aurora/aws module |
object({
name = optional(string, "fleet")
engine_version = optional(string, "8.0.mysql_aurora.3.08.2")
instance_class = optional(string, "db.t4g.large")
subnets = optional(list(string), [])
allowed_security_groups = optional(list(string), [])
allowed_cidr_blocks = optional(list(string), [])
apply_immediately = optional(bool, true)
monitoring_interval = optional(number, 10)
backtrack_window = optional(number, null)
db_parameter_group_name = optional(string)
db_parameters = optional(map(string), {})
db_cluster_parameter_group_name = optional(string)
db_cluster_parameters = optional(map(string), {})
enabled_cloudwatch_logs_exports = optional(list(string), [])
final_snapshot_identifier = optional(string, null)
password_secret_kms = optional(object({
cmk_enabled = optional(bool, false)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-rds-password-secret")
extra_kms_policies = optional(list(any), [])
}), {
cmk_enabled = false
kms_key_arn = null
kms_alias = "fleet-rds-password-secret"
extra_kms_policies = []
})
storage_kms = optional(object({
cmk_enabled = optional(bool, false)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-rds-storage")
extra_kms_policies = optional(list(any), [])
}), {
cmk_enabled = false
kms_key_arn = null
kms_alias = "fleet-rds-storage"
extra_kms_policies = []
})
observability = optional(object({
performance_insights_enabled = optional(bool, true)
retention_period = optional(number, null)
database_insights_mode = optional(string, null)
kms = optional(object({
cmk_enabled = optional(bool, false)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-rds-performance-insights")
extra_kms_policies = optional(list(any), [])
}), {
cmk_enabled = false
kms_key_arn = null
kms_alias = "fleet-rds-performance-insights"
extra_kms_policies = []
})
}), {
performance_insights_enabled = true
retention_period = null
database_insights_mode = null
kms = {
cmk_enabled = false
kms_key_arn = null
kms_alias = "fleet-rds-performance-insights"
extra_kms_policies = []
}
})
cloudwatch_log_group = optional(object({
retention_in_days = optional(number, null)
skip_destroy = optional(bool, false)
kms = optional(object({
cmk_enabled = optional(bool, false)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-rds-logs")
extra_kms_policies = optional(list(any), [])
}), {
cmk_enabled = false
kms_key_arn = null
kms_alias = "fleet-rds-logs"
extra_kms_policies = []
})
}), {
retention_in_days = null
skip_destroy = false
kms = {
cmk_enabled = false
kms_key_arn = null
kms_alias = "fleet-rds-logs"
extra_kms_policies = []
}
})
master_username = optional(string, "fleet")
database_name = optional(string, "fleet")
snapshot_identifier = optional(string)
cluster_tags = optional(map(string), {})
skip_final_snapshot = optional(bool, true)
backup_retention_period = optional(number, 7)
replicas = optional(number, 2)
serverless = optional(bool, false)
serverless_min_capacity = optional(number, 2)
serverless_max_capacity = optional(number, 10)
restore_to_point_in_time = optional(map(string), {})
})
|
{
"allowed_cidr_blocks": [],
"allowed_security_groups": [],
"apply_immediately": true,
"backtrack_window": null,
"backup_retention_period": 7,
"cloudwatch_log_group": {
"kms": {
"cmk_enabled": false,
"extra_kms_policies": [],
"kms_alias": "fleet-rds-logs",
"kms_key_arn": null
},
"retention_in_days": null,
"skip_destroy": false
},
"cluster_tags": {},
"database_name": "fleet",
"db_cluster_parameter_group_name": null,
"db_cluster_parameters": {},
"db_parameter_group_name": null,
"db_parameters": {},
"enabled_cloudwatch_logs_exports": [],
"engine_version": "8.0.mysql_aurora.3.08.2",
"final_snapshot_identifier": null,
"instance_class": "db.t4g.large",
"master_username": "fleet",
"monitoring_interval": 10,
"name": "fleet",
"observability": {
"database_insights_mode": null,
"kms": {
"cmk_enabled": false,
"extra_kms_policies": [],
"kms_alias": "fleet-rds-performance-insights",
"kms_key_arn": null
},
"performance_insights_enabled": true,
"retention_period": null
},
"password_secret_kms": {
"cmk_enabled": false,
"extra_kms_policies": [],
"kms_alias": "fleet-rds-password-secret",
"kms_key_arn": null
},
"replicas": 2,
"restore_to_point_in_time": {},
"serverless": false,
"serverless_max_capacity": 10,
"serverless_min_capacity": 2,
"skip_final_snapshot": true,
"snapshot_identifier": null,
"storage_kms": {
"cmk_enabled": false,
"extra_kms_policies": [],
"kms_alias": "fleet-rds-storage",
"kms_key_arn": null
},
"subnets": []
}
| no | | [redis\_config](#input\_redis\_config) | n/a |
object({
name = optional(string, "fleet")
replication_group_id = optional(string)
elasticache_subnet_group_name = optional(string)
allowed_security_group_ids = optional(list(string), [])
subnets = optional(list(string))
availability_zones = optional(list(string))
cluster_size = optional(number, 3)
instance_type = optional(string, "cache.m5.large")
apply_immediately = optional(bool, true)
automatic_failover_enabled = optional(bool, false)
engine = optional(string, "redis")
engine_version = optional(string, "7.1")
family = optional(string, "redis7")
at_rest_encryption_enabled = optional(bool, true)
at_rest_kms = optional(object({
cmk_enabled = optional(bool, false)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-redis-at-rest")
extra_kms_policies = optional(list(any), [])
}), {
cmk_enabled = false
kms_key_arn = null
kms_alias = "fleet-redis-at-rest"
extra_kms_policies = []
})
transit_encryption_enabled = optional(bool, true)
parameter = optional(list(object({
name = string
value = string
})), [])
cloudwatch_log_group = optional(object({
retention_in_days = optional(number, null)
skip_destroy = optional(bool, false)
kms = optional(object({
cmk_enabled = optional(bool, false)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-redis-logs")
extra_kms_policies = optional(list(any), [])
}), {
cmk_enabled = false
kms_key_arn = null
kms_alias = "fleet-redis-logs"
extra_kms_policies = []
})
}), {
retention_in_days = null
skip_destroy = false
kms = {
cmk_enabled = false
kms_key_arn = null
kms_alias = "fleet-redis-logs"
}
})
log_delivery_configuration = optional(list(map(any)), [])
tags = optional(map(string), {})
})
|
{
"allowed_security_group_ids": [],
"apply_immediately": true,
"at_rest_encryption_enabled": true,
"at_rest_kms": {
"cmk_enabled": false,
"extra_kms_policies": [],
"kms_alias": "fleet-redis-at-rest",
"kms_key_arn": null
},
"automatic_failover_enabled": false,
"availability_zones": null,
"cloudwatch_log_group": {
"kms": {
"cmk_enabled": false,
"extra_kms_policies": [],
"kms_alias": "fleet-redis-logs",
"kms_key_arn": null
},
"retention_in_days": null,
"skip_destroy": false
},
"cluster_size": 3,
"elasticache_subnet_group_name": null,
"engine": "redis",
"engine_version": "7.1",
"family": "redis7",
"instance_type": "cache.m5.large",
"log_delivery_configuration": [],
"name": "fleet",
"parameter": [],
"replication_group_id": null,
"subnets": null,
"tags": {},
"transit_encryption_enabled": true
}
| no | -| [vpc](#input\_vpc) | n/a |
object({
name = optional(string, "fleet")
cidr = optional(string, "10.10.0.0/16")
azs = optional(list(string), ["us-east-2a", "us-east-2b", "us-east-2c"])
private_subnets = optional(list(string), ["10.10.1.0/24", "10.10.2.0/24", "10.10.3.0/24"])
public_subnets = optional(list(string), ["10.10.11.0/24", "10.10.12.0/24", "10.10.13.0/24"])
database_subnets = optional(list(string), ["10.10.21.0/24", "10.10.22.0/24", "10.10.23.0/24"])
elasticache_subnets = optional(list(string), ["10.10.31.0/24", "10.10.32.0/24", "10.10.33.0/24"])

create_database_subnet_group = optional(bool, false)
create_database_subnet_route_table = optional(bool, true)
create_elasticache_subnet_group = optional(bool, true)
create_elasticache_subnet_route_table = optional(bool, true)
enable_vpn_gateway = optional(bool, false)
one_nat_gateway_per_az = optional(bool, false)
single_nat_gateway = optional(bool, true)
enable_nat_gateway = optional(bool, true)
enable_dns_hostnames = optional(bool, false)
enable_dns_support = optional(bool, true)
enable_flow_log = optional(bool, false)
create_flow_log_cloudwatch_log_group = optional(bool, false)
create_flow_log_cloudwatch_iam_role = optional(bool, false)
flow_log_max_aggregation_interval = optional(number, 600)
flow_log_cloudwatch_log_group_name_prefix = optional(string, "/aws/vpc-flow-log/")
flow_log_cloudwatch_log_group_name_suffix = optional(string, "")
flow_log_cloudwatch_log_group_kms = optional(object({
cmk_enabled = optional(bool, false)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-vpc-flow-logs")
extra_kms_policies = optional(list(any), [])
}), {
cmk_enabled = false
kms_key_arn = null
kms_alias = "fleet-vpc-flow-logs"
extra_kms_policies = []
})
vpc_flow_log_tags = optional(map(string), {})
})
|
{
"azs": [
"us-east-2a",
"us-east-2b",
"us-east-2c"
],
"cidr": "10.10.0.0/16",
"create_database_subnet_group": false,
"create_database_subnet_route_table": true,
"create_elasticache_subnet_group": true,
"create_elasticache_subnet_route_table": true,
"create_flow_log_cloudwatch_iam_role": false,
"create_flow_log_cloudwatch_log_group": false,
"database_subnets": [
"10.10.21.0/24",
"10.10.22.0/24",
"10.10.23.0/24"
],
"elasticache_subnets": [
"10.10.31.0/24",
"10.10.32.0/24",
"10.10.33.0/24"
],
"enable_dns_hostnames": false,
"enable_dns_support": true,
"enable_flow_log": false,
"enable_nat_gateway": true,
"enable_vpn_gateway": false,
"flow_log_cloudwatch_log_group_kms": {
"cmk_enabled": false,
"extra_kms_policies": [],
"kms_alias": "fleet-vpc-flow-logs",
"kms_key_arn": null
},
"flow_log_cloudwatch_log_group_name_prefix": "/aws/vpc-flow-log/",
"flow_log_cloudwatch_log_group_name_suffix": "",
"flow_log_max_aggregation_interval": 600,
"name": "fleet",
"one_nat_gateway_per_az": false,
"private_subnets": [
"10.10.1.0/24",
"10.10.2.0/24",
"10.10.3.0/24"
],
"public_subnets": [
"10.10.11.0/24",
"10.10.12.0/24",
"10.10.13.0/24"
],
"single_nat_gateway": true,
"vpc_flow_log_tags": {}
}
| no | +| [vpc](#input\_vpc) | n/a |
object({
name = optional(string, "fleet")
cidr = optional(string, "10.10.0.0/16")
azs = optional(list(string), ["us-east-2a", "us-east-2b", "us-east-2c"])
private_subnets = optional(list(string), ["10.10.1.0/24", "10.10.2.0/24", "10.10.3.0/24"])
public_subnets = optional(list(string), ["10.10.11.0/24", "10.10.12.0/24", "10.10.13.0/24"])
database_subnets = optional(list(string), ["10.10.21.0/24", "10.10.22.0/24", "10.10.23.0/24"])
elasticache_subnets = optional(list(string), ["10.10.31.0/24", "10.10.32.0/24", "10.10.33.0/24"])

create_database_subnet_group = optional(bool, false)
create_database_subnet_route_table = optional(bool, true)
create_elasticache_subnet_group = optional(bool, true)
create_elasticache_subnet_route_table = optional(bool, true)
enable_vpn_gateway = optional(bool, false)
one_nat_gateway_per_az = optional(bool, false)
single_nat_gateway = optional(bool, true)
enable_nat_gateway = optional(bool, true)
enable_dns_hostnames = optional(bool, false)
enable_dns_support = optional(bool, true)
enable_flow_log = optional(bool, false)
create_flow_log_cloudwatch_log_group = optional(bool, false)
create_flow_log_cloudwatch_iam_role = optional(bool, false)
flow_log_max_aggregation_interval = optional(number, 600)
flow_log_cloudwatch_log_group_name_prefix = optional(string, "/aws/vpc-flow-log/")
flow_log_cloudwatch_log_group_name_suffix = optional(string, "")
flow_log_cloudwatch_log_group_retention_in_days = optional(number, null)
flow_log_cloudwatch_log_group_kms = optional(object({
cmk_enabled = optional(bool, false)
kms_key_arn = optional(string, null)
kms_alias = optional(string, "fleet-vpc-flow-logs")
extra_kms_policies = optional(list(any), [])
}), {
cmk_enabled = false
kms_key_arn = null
kms_alias = "fleet-vpc-flow-logs"
extra_kms_policies = []
})
vpc_flow_log_tags = optional(map(string), {})

manage_default_network_acl = optional(bool, true)
default_network_acl_ingress = optional(list(map(string)), [
{
rule_no = 100
action = "allow"
from_port = 0
to_port = 0
protocol = "-1"
cidr_block = "0.0.0.0/0"
},
{
rule_no = 101
action = "allow"
from_port = 0
to_port = 0
protocol = "-1"
ipv6_cidr_block = "::/0"
}])
default_network_acl_egress = optional(list(map(string)), [
{
rule_no = 100
action = "allow"
from_port = 0
to_port = 0
protocol = "-1"
cidr_block = "0.0.0.0/0"
},
{
rule_no = 101
action = "allow"
from_port = 0
to_port = 0
protocol = "-1"
ipv6_cidr_block = "::/0"
}])
})
|
{
"azs": [
"us-east-2a",
"us-east-2b",
"us-east-2c"
],
"cidr": "10.10.0.0/16",
"create_database_subnet_group": false,
"create_database_subnet_route_table": true,
"create_elasticache_subnet_group": true,
"create_elasticache_subnet_route_table": true,
"create_flow_log_cloudwatch_iam_role": false,
"create_flow_log_cloudwatch_log_group": false,
"database_subnets": [
"10.10.21.0/24",
"10.10.22.0/24",
"10.10.23.0/24"
],
"default_network_acl_egress": [
{
"action": "allow",
"cidr_block": "0.0.0.0/0",
"from_port": 0,
"protocol": "-1",
"rule_no": 100,
"to_port": 0
},
{
"action": "allow",
"from_port": 0,
"ipv6_cidr_block": "::/0",
"protocol": "-1",
"rule_no": 101,
"to_port": 0
}
],
"default_network_acl_ingress": [
{
"action": "allow",
"cidr_block": "0.0.0.0/0",
"from_port": 0,
"protocol": "-1",
"rule_no": 100,
"to_port": 0
},
{
"action": "allow",
"from_port": 0,
"ipv6_cidr_block": "::/0",
"protocol": "-1",
"rule_no": 101,
"to_port": 0
}
],
"elasticache_subnets": [
"10.10.31.0/24",
"10.10.32.0/24",
"10.10.33.0/24"
],
"enable_dns_hostnames": false,
"enable_dns_support": true,
"enable_flow_log": false,
"enable_nat_gateway": true,
"enable_vpn_gateway": false,
"flow_log_cloudwatch_log_group_kms": {
"cmk_enabled": false,
"extra_kms_policies": [],
"kms_alias": "fleet-vpc-flow-logs",
"kms_key_arn": null
},
"flow_log_cloudwatch_log_group_name_prefix": "/aws/vpc-flow-log/",
"flow_log_cloudwatch_log_group_name_suffix": "",
"flow_log_cloudwatch_log_group_retention_in_days": null,
"flow_log_max_aggregation_interval": 600,
"manage_default_network_acl": true,
"name": "fleet",
"one_nat_gateway_per_az": false,
"private_subnets": [
"10.10.1.0/24",
"10.10.2.0/24",
"10.10.3.0/24"
],
"public_subnets": [
"10.10.11.0/24",
"10.10.12.0/24",
"10.10.13.0/24"
],
"single_nat_gateway": true,
"vpc_flow_log_tags": {}
}
| no | ## Outputs diff --git a/addons/cloudfront-software-installers/.header.md b/addons/cloudfront-software-installers/.header.md index 2cc32d3..3691bdf 100644 --- a/addons/cloudfront-software-installers/.header.md +++ b/addons/cloudfront-software-installers/.header.md @@ -14,14 +14,18 @@ The second link includes a script that can be used to test and see if signed URL This addon is intentionally out of scope for AWS GovCloud compatibility. CloudFront is not available inside the AWS GovCloud (US) partition, so using it with GovCloud-hosted resources is a cross-partition architecture that should be designed and reviewed separately. +## S3 Bucket Policy + +This addon no longer manages an S3 bucket policy on the software installers bucket. The bucket policy is now managed by the core module (`byo-ecs`), which automatically denies non-HTTPS requests and includes the CloudFront allow statement when `cloudfront_distribution_arn` is set. + ## Other module requirements These are the minimum versions of modules required if used: - - tf-mod-root-v1.13.0 - - tf-mod-byo-vpc-v1.14.0 - - tf-mod-byo-db-v1.10.0 - - tf-mod-byo-ecs-v1.9.0 + - tf-mod-root-v1.30.0 + - tf-mod-byo-vpc-v1.31.0 + - tf-mod-byo-db-v1.21.0 + - tf-mod-byo-ecs-v1.21.0 - tf-mod-addon-logging-alb-v1.3.0 Previous versions do not allow for proper interaction with both the software installers and logging s3 buckets. @@ -121,7 +125,7 @@ Now with those encrypted we could setup the module with something like the follo ``` module "cloudfront-software-installers" { - source = "github.com/fleetdm/fleet-terraform/addons/cloudfront-software-installers?ref=tf-mod-addon-cloudfront-software-installers-v1.2.0" + source = "github.com/fleetdm/fleet-terraform/addons/cloudfront-software-installers?ref=tf-mod-addon-cloudfront-software-installers-v3.0.0" customer = "fleet" s3_bucket = module.main.byo-vpc.byo-db.byo-ecs.fleet_s3_software_installers_config.bucket_name # OPTIONAL diff --git a/addons/cloudfront-software-installers/README.md b/addons/cloudfront-software-installers/README.md index 86f0af2..24ba565 100644 --- a/addons/cloudfront-software-installers/README.md +++ b/addons/cloudfront-software-installers/README.md @@ -13,14 +13,18 @@ The second link includes a script that can be used to test and see if signed URL This addon is intentionally out of scope for AWS GovCloud compatibility. CloudFront is not available inside the AWS GovCloud (US) partition, so using it with GovCloud-hosted resources is a cross-partition architecture that should be designed and reviewed separately. +## S3 Bucket Policy + +This addon no longer manages an S3 bucket policy on the software installers bucket. The bucket policy is now managed by the core module (`byo-ecs`), which automatically denies non-HTTPS requests and includes the CloudFront allow statement when `cloudfront_distribution_arn` is set. + ## Other module requirements These are the minimum versions of modules required if used: - - tf-mod-root-v1.13.0 - - tf-mod-byo-vpc-v1.14.0 - - tf-mod-byo-db-v1.10.0 - - tf-mod-byo-ecs-v1.9.0 + - tf-mod-root-v1.30.0 + - tf-mod-byo-vpc-v1.31.0 + - tf-mod-byo-db-v1.21.0 + - tf-mod-byo-ecs-v1.21.0 - tf-mod-addon-logging-alb-v1.3.0 Previous versions do not allow for proper interaction with both the software installers and logging s3 buckets. @@ -120,7 +124,7 @@ Now with those encrypted we could setup the module with something like the follo ``` module "cloudfront-software-installers" { - source = "github.com/fleetdm/fleet-terraform/addons/cloudfront-software-installers?ref=tf-mod-addon-cloudfront-software-installers-v1.2.0" + source = "github.com/fleetdm/fleet-terraform/addons/cloudfront-software-installers?ref=tf-mod-addon-cloudfront-software-installers-v3.0.0" customer = "fleet" s3_bucket = module.main.byo-vpc.byo-db.byo-ecs.fleet_s3_software_installers_config.bucket_name # OPTIONAL @@ -177,7 +181,7 @@ No requirements. | Name | Version | |------|---------| -| [aws](#provider\_aws) | 6.36.0 | +| [aws](#provider\_aws) | 6.49.0 | ## Modules @@ -192,10 +196,8 @@ No requirements. | [aws_cloudfront_key_group.software_installers](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_key_group) | resource | | [aws_cloudfront_public_key.software_installers](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_public_key) | resource | | [aws_iam_policy.software_installers_secret](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource | -| [aws_s3_bucket_policy.software_installers](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource | | [aws_secretsmanager_secret.software_installers](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret) | resource | | [aws_secretsmanager_secret_version.software_installers](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret_version) | resource | -| [aws_iam_policy_document.software_installers_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | | [aws_iam_policy_document.software_installers_secret](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | | [aws_s3_bucket.logging](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/s3_bucket) | data source | | [aws_s3_bucket.software_installers](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/s3_bucket) | data source | diff --git a/addons/cloudfront-software-installers/main.tf b/addons/cloudfront-software-installers/main.tf index 666a1cb..825dc46 100644 --- a/addons/cloudfront-software-installers/main.tf +++ b/addons/cloudfront-software-installers/main.tf @@ -1,29 +1,7 @@ -data "aws_iam_policy_document" "software_installers_bucket" { - statement { - actions = ["s3:GetObject"] - resources = ["${data.aws_s3_bucket.software_installers.arn}/*"] - effect = "Allow" - principals { - type = "Service" - identifiers = ["cloudfront.amazonaws.com"] - } - condition { - test = "StringEquals" - variable = "AWS:SourceArn" - values = [module.cloudfront_software_installers.cloudfront_distribution_arn] - } - } -} - data "aws_s3_bucket" "software_installers" { bucket = var.s3_bucket } -resource "aws_s3_bucket_policy" "software_installers" { - bucket = data.aws_s3_bucket.software_installers.bucket - policy = data.aws_iam_policy_document.software_installers_bucket.json -} - data "aws_iam_policy_document" "software_installers_secret" { statement { effect = "Allow" diff --git a/addons/logging-destination-datadog/.header.md b/addons/logging-destination-datadog/.header.md index b34bd43..fce653d 100644 --- a/addons/logging-destination-datadog/.header.md +++ b/addons/logging-destination-datadog/.header.md @@ -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 = { diff --git a/addons/logging-destination-datadog/README.md b/addons/logging-destination-datadog/README.md index 024449c..5d130f4 100644 --- a/addons/logging-destination-datadog/README.md +++ b/addons/logging-destination-datadog/README.md @@ -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=" + 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 | |------|-------------|------|---------|:--------:| +| [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 | | [compression\_format](#input\_compression\_format) | Compression format for the Firehose delivery stream | `string` | `"UNCOMPRESSED"` | no | | [datadog\_api\_key](#input\_datadog\_api\_key) | Datadog API key for authentication | `string` | n/a | yes | | [datadog\_url](#input\_datadog\_url) | Datadog HTTP API endpoint URL | `string` | n/a | yes | diff --git a/addons/logging-destination-datadog/main.tf b/addons/logging-destination-datadog/main.tf index 6a7f6d8..0202541 100644 --- a/addons/logging-destination-datadog/main.tf +++ b/addons/logging-destination-datadog/main.tf @@ -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" diff --git a/addons/logging-destination-firehose/.header.md b/addons/logging-destination-firehose/.header.md index a498396..209dc93 100644 --- a/addons/logging-destination-firehose/.header.md +++ b/addons/logging-destination-firehose/.header.md @@ -1,2 +1,6 @@ # Logging Destination: Firehose This addon provides a Kinesis Firehose logging destination for Fleet. + +## S3 Bucket Policy: Deny Non-HTTPS + +This module automatically attaches a bucket policy to each S3 bucket (osquery-results, osquery-status, audit) that denies any requests made over plain HTTP. No configuration is required. diff --git a/addons/logging-destination-firehose/README.md b/addons/logging-destination-firehose/README.md index ddaae7c..3b53a0e 100644 --- a/addons/logging-destination-firehose/README.md +++ b/addons/logging-destination-firehose/README.md @@ -1,6 +1,10 @@ # Logging Destination: Firehose This addon provides a Kinesis Firehose logging destination for Fleet. +## S3 Bucket Policy: Deny Non-HTTPS + +This module automatically attaches a bucket policy to each S3 bucket (osquery-results, osquery-status, audit) that denies any requests made over plain HTTP. No configuration is required. + ## Requirements No requirements. @@ -38,6 +42,9 @@ No modules. | [aws_s3_bucket_lifecycle_configuration.audit](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource | | [aws_s3_bucket_lifecycle_configuration.osquery-results](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource | | [aws_s3_bucket_lifecycle_configuration.osquery-status](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource | +| [aws_s3_bucket_policy.deny_insecure_transport_audit](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource | +| [aws_s3_bucket_policy.deny_insecure_transport_osquery_results](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource | +| [aws_s3_bucket_policy.deny_insecure_transport_osquery_status](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource | | [aws_s3_bucket_public_access_block.audit](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource | | [aws_s3_bucket_public_access_block.osquery-results](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource | | [aws_s3_bucket_public_access_block.osquery-status](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource | @@ -45,6 +52,9 @@ No modules. | [aws_s3_bucket_server_side_encryption_configuration.osquery-results](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource | | [aws_s3_bucket_server_side_encryption_configuration.osquery-status](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource | | [aws_iam_policy_document.audit_policy_doc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | +| [aws_iam_policy_document.deny_insecure_transport_audit](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | +| [aws_iam_policy_document.deny_insecure_transport_osquery_results](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | +| [aws_iam_policy_document.deny_insecure_transport_osquery_status](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.osquery_firehose_assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | | [aws_iam_policy_document.osquery_results_policy_doc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | diff --git a/addons/logging-destination-firehose/main.tf b/addons/logging-destination-firehose/main.tf index 962160e..40cdcdb 100644 --- a/addons/logging-destination-firehose/main.tf +++ b/addons/logging-destination-firehose/main.tf @@ -42,6 +42,34 @@ resource "aws_s3_bucket_public_access_block" "osquery-results" { restrict_public_buckets = true } +data "aws_iam_policy_document" "deny_insecure_transport_osquery_results" { + + statement { + sid = "DenyNonHTTPS" + effect = "Deny" + actions = ["s3:*"] + resources = [ + aws_s3_bucket.osquery-results.arn, + "${aws_s3_bucket.osquery-results.arn}/*", + ] + principals { + type = "*" + identifiers = ["*"] + } + condition { + test = "Bool" + variable = "aws:SecureTransport" + values = ["false"] + } + } +} + +resource "aws_s3_bucket_policy" "deny_insecure_transport_osquery_results" { + + bucket = aws_s3_bucket.osquery-results.id + policy = data.aws_iam_policy_document.deny_insecure_transport_osquery_results.json +} + // Customer keys are not supported in our Fleet Terraforms at the moment. We will evaluate the // possibility of providing this capability in the future. // No versioning on this bucket is by design. @@ -83,6 +111,34 @@ resource "aws_s3_bucket_public_access_block" "osquery-status" { restrict_public_buckets = true } +data "aws_iam_policy_document" "deny_insecure_transport_osquery_status" { + + statement { + sid = "DenyNonHTTPS" + effect = "Deny" + actions = ["s3:*"] + resources = [ + aws_s3_bucket.osquery-status.arn, + "${aws_s3_bucket.osquery-status.arn}/*", + ] + principals { + type = "*" + identifiers = ["*"] + } + condition { + test = "Bool" + variable = "aws:SecureTransport" + values = ["false"] + } + } +} + +resource "aws_s3_bucket_policy" "deny_insecure_transport_osquery_status" { + + bucket = aws_s3_bucket.osquery-status.id + policy = data.aws_iam_policy_document.deny_insecure_transport_osquery_status.json +} + // Customer keys are not supported in our Fleet Terraforms at the moment. We will evaluate the // possibility of providing this capability in the future. // No versioning on this bucket is by design. @@ -124,6 +180,34 @@ resource "aws_s3_bucket_public_access_block" "audit" { restrict_public_buckets = true } +data "aws_iam_policy_document" "deny_insecure_transport_audit" { + + statement { + sid = "DenyNonHTTPS" + effect = "Deny" + actions = ["s3:*"] + resources = [ + aws_s3_bucket.audit.arn, + "${aws_s3_bucket.audit.arn}/*", + ] + principals { + type = "*" + identifiers = ["*"] + } + condition { + test = "Bool" + variable = "aws:SecureTransport" + values = ["false"] + } + } +} + +resource "aws_s3_bucket_policy" "deny_insecure_transport_audit" { + + bucket = aws_s3_bucket.audit.id + policy = data.aws_iam_policy_document.deny_insecure_transport_audit.json +} + data "aws_iam_policy_document" "osquery_results_policy_doc" { statement { effect = "Allow" diff --git a/addons/logging-destination-snowflake/.header.md b/addons/logging-destination-snowflake/.header.md index 70717b3..b3b4b44 100644 --- a/addons/logging-destination-snowflake/.header.md +++ b/addons/logging-destination-snowflake/.header.md @@ -7,11 +7,15 @@ This addon configures AWS Kinesis Firehose to send Fleet's osquery logs to Snowf 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 "snowflake-logging" { - source = "github.com/fleetdm/fleet-terraform//addons/logging-destination-snowflake?depth=1&ref=tf-mod-addon-logging-destination-snowflake-v1.0.3" + source = "github.com/fleetdm/fleet-terraform//addons/logging-destination-snowflake?depth=1&ref=tf-mod-addon-logging-destination-snowflake-v1.1.0" s3_bucket_config = { name_prefix = "fleet-snowflake-failure" @@ -78,7 +82,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 = { diff --git a/addons/logging-destination-snowflake/README.md b/addons/logging-destination-snowflake/README.md index 575f330..31e91bd 100644 --- a/addons/logging-destination-snowflake/README.md +++ b/addons/logging-destination-snowflake/README.md @@ -7,11 +7,15 @@ This addon configures AWS Kinesis Firehose to send Fleet's osquery logs to Snowf 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 "snowflake-logging" { - source = "github.com/fleetdm/fleet-terraform//addons/logging-destination-snowflake?depth=1&ref=tf-mod-addon-logging-destination-snowflake-v1.0.3" + source = "github.com/fleetdm/fleet-terraform//addons/logging-destination-snowflake?depth=1&ref=tf-mod-addon-logging-destination-snowflake-v1.1.0" s3_bucket_config = { name_prefix = "fleet-snowflake-failure" @@ -78,7 +82,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 = { @@ -134,8 +138,10 @@ No modules. | [aws_kinesis_firehose_delivery_stream.snowflake](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kinesis_firehose_delivery_stream) | resource | | [aws_s3_bucket.snowflake-failure](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | | [aws_s3_bucket_lifecycle_configuration.snowflake-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.snowflake-failure](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource | | [aws_s3_bucket_server_side_encryption_configuration.snowflake-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 | diff --git a/addons/logging-destination-snowflake/main.tf b/addons/logging-destination-snowflake/main.tf index 73b2a14..dfc0a7e 100644 --- a/addons/logging-destination-snowflake/main.tf +++ b/addons/logging-destination-snowflake/main.tf @@ -37,6 +37,33 @@ resource "aws_s3_bucket_public_access_block" "snowflake-failure" { restrict_public_buckets = true } +data "aws_iam_policy_document" "deny_insecure_transport" { + + statement { + sid = "DenyNonHTTPS" + effect = "Deny" + actions = ["s3:*"] + resources = [ + aws_s3_bucket.snowflake-failure.arn, + "${aws_s3_bucket.snowflake-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.snowflake-failure.id + policy = data.aws_iam_policy_document.deny_insecure_transport.json +} + data "aws_iam_policy_document" "firehose_policy" { statement { effect = "Allow" diff --git a/addons/logging-destination-splunk/.header.md b/addons/logging-destination-splunk/.header.md index c900c1a..f825fc0 100644 --- a/addons/logging-destination-splunk/.header.md +++ b/addons/logging-destination-splunk/.header.md @@ -7,11 +7,15 @@ This addon configures AWS Kinesis Firehose to send Fleet's osquery logs to Splun 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 "splunk-logging" { - source = "github.com/fleetdm/fleet-terraform//addons/logging-destination-splunk?depth=1&ref=tf-mod-addon-logging-destination-splunk-v1.0.1" + source = "github.com/fleetdm/fleet-terraform//addons/logging-destination-splunk?depth=1&ref=tf-mod-addon-logging-destination-splunk-v1.1.0" s3_bucket_config = { name_prefix = "fleet-splunk-failure" @@ -58,7 +62,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 = { diff --git a/addons/logging-destination-splunk/README.md b/addons/logging-destination-splunk/README.md index e27ae11..88f2b8c 100644 --- a/addons/logging-destination-splunk/README.md +++ b/addons/logging-destination-splunk/README.md @@ -7,11 +7,15 @@ This addon configures AWS Kinesis Firehose to send Fleet's osquery logs to Splun 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 "splunk-logging" { - source = "github.com/fleetdm/fleet-terraform//addons/logging-destination-splunk?depth=1&ref=tf-mod-addon-logging-destination-splunk-v1.0.1" + source = "github.com/fleetdm/fleet-terraform//addons/logging-destination-splunk?depth=1&ref=tf-mod-addon-logging-destination-splunk-v1.1.0" s3_bucket_config = { name_prefix = "fleet-splunk-failure" @@ -58,7 +62,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 = { @@ -114,8 +118,10 @@ No modules. | [aws_kinesis_firehose_delivery_stream.splunk](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kinesis_firehose_delivery_stream) | resource | | [aws_s3_bucket.splunk-failure](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | | [aws_s3_bucket_lifecycle_configuration.splunk-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.splunk-failure](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource | | [aws_s3_bucket_server_side_encryption_configuration.splunk-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 | diff --git a/addons/logging-destination-splunk/main.tf b/addons/logging-destination-splunk/main.tf index e61221e..9e8fa97 100644 --- a/addons/logging-destination-splunk/main.tf +++ b/addons/logging-destination-splunk/main.tf @@ -37,6 +37,33 @@ resource "aws_s3_bucket_public_access_block" "splunk-failure" { restrict_public_buckets = true } +data "aws_iam_policy_document" "deny_insecure_transport" { + + statement { + sid = "DenyNonHTTPS" + effect = "Deny" + actions = ["s3:*"] + resources = [ + aws_s3_bucket.splunk-failure.arn, + "${aws_s3_bucket.splunk-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.splunk-failure.id + policy = data.aws_iam_policy_document.deny_insecure_transport.json +} + data "aws_iam_policy_document" "firehose_policy" { statement { effect = "Allow" diff --git a/addons/osquery-carve/.header.md b/addons/osquery-carve/.header.md index 3981cd7..0bba412 100644 --- a/addons/osquery-carve/.header.md +++ b/addons/osquery-carve/.header.md @@ -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. diff --git a/addons/osquery-carve/README.md b/addons/osquery-carve/README.md index 8627caf..466c944 100644 --- a/addons/osquery-carve/README.md +++ b/addons/osquery-carve/README.md @@ -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 | diff --git a/addons/osquery-carve/main.tf b/addons/osquery-carve/main.tf index 273ae87..0e143cf 100644 --- a/addons/osquery-carve/main.tf +++ b/addons/osquery-carve/main.tf @@ -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 = [ diff --git a/byo-vpc/byo-db/byo-ecs/main.tf b/byo-vpc/byo-db/byo-ecs/main.tf index c63fff2..8c342b8 100644 --- a/byo-vpc/byo-db/byo-ecs/main.tf +++ b/byo-vpc/byo-db/byo-ecs/main.tf @@ -808,3 +808,53 @@ resource "aws_s3_bucket_public_access_block" "software_installers" { ignore_public_acls = true restrict_public_buckets = true } + +data "aws_iam_policy_document" "software_installers_bucket_policy" { + count = var.fleet_config.software_installers.create_bucket == true ? 1 : 0 + + statement { + sid = "DenyNonHTTPS" + effect = "Deny" + actions = ["s3:*"] + resources = [ + aws_s3_bucket.software_installers[0].arn, + "${aws_s3_bucket.software_installers[0].arn}/*", + ] + principals { + type = "*" + identifiers = ["*"] + } + condition { + test = "Bool" + variable = "aws:SecureTransport" + values = ["false"] + } + } + + dynamic "statement" { + for_each = var.fleet_config.software_installers.cloudfront_distribution_arn != null ? [1] : [] + content { + sid = "AllowCloudFrontServicePrincipalReadOnly" + effect = "Allow" + actions = ["s3:GetObject"] + resources = [ + "${aws_s3_bucket.software_installers[0].arn}/*", + ] + principals { + type = "Service" + identifiers = ["cloudfront.amazonaws.com"] + } + condition { + test = "StringEquals" + variable = "AWS:SourceArn" + values = [var.fleet_config.software_installers.cloudfront_distribution_arn] + } + } + } +} + +resource "aws_s3_bucket_policy" "software_installers" { + count = var.fleet_config.software_installers.create_bucket == true ? 1 : 0 + bucket = aws_s3_bucket.software_installers[0].id + policy = data.aws_iam_policy_document.software_installers_bucket_policy[0].json +} diff --git a/byo-vpc/byo-db/variables.tf b/byo-vpc/byo-db/variables.tf index 18f7893..acf3ac1 100644 --- a/byo-vpc/byo-db/variables.tf +++ b/byo-vpc/byo-db/variables.tf @@ -326,33 +326,33 @@ variable "fleet_config" { name = "fleetdm-execution-role" }) software_installers = optional(object({ - create_bucket = optional(bool, true) - bucket_name = optional(string, null) - bucket_prefix = optional(string, "fleet-software-installers-") - s3_object_prefix = optional(string, "") - cloudfront_distribution_arn = optional(string, null) - enable_bucket_versioning = optional(bool, false) - expire_noncurrent_versions = optional(bool, true) - noncurrent_version_expiration_days = optional(number, 30) - create_kms_key = optional(bool, false) - kms_key_arn = optional(string, null) - kms_alias = optional(string, "fleet-software-installers") - extra_kms_policies = optional(list(any), []) - tags = optional(map(string), {}) + create_bucket = optional(bool, true) + bucket_name = optional(string, null) + bucket_prefix = optional(string, "fleet-software-installers-") + s3_object_prefix = optional(string, "") + cloudfront_distribution_arn = optional(string, null) + enable_bucket_versioning = optional(bool, false) + expire_noncurrent_versions = optional(bool, true) + noncurrent_version_expiration_days = optional(number, 30) + create_kms_key = optional(bool, false) + kms_key_arn = optional(string, null) + kms_alias = optional(string, "fleet-software-installers") + extra_kms_policies = optional(list(any), []) + tags = optional(map(string), {}) }), { - create_bucket = true - bucket_name = null - bucket_prefix = "fleet-software-installers-" - s3_object_prefix = "" - cloudfront_distribution_arn = null - enable_bucket_versioning = false - expire_noncurrent_versions = true - noncurrent_version_expiration_days = 30 - create_kms_key = false - kms_key_arn = null - kms_alias = "fleet-software-installers" - extra_kms_policies = [] - tags = {} + create_bucket = true + bucket_name = null + bucket_prefix = "fleet-software-installers-" + s3_object_prefix = "" + cloudfront_distribution_arn = null + enable_bucket_versioning = false + expire_noncurrent_versions = true + noncurrent_version_expiration_days = 30 + create_kms_key = false + kms_key_arn = null + kms_alias = "fleet-software-installers" + extra_kms_policies = [] + tags = {} }) }) default = { @@ -454,19 +454,19 @@ variable "fleet_config" { } } software_installers = { - create_bucket = true - bucket_name = null - bucket_prefix = "fleet-software-installers-" - s3_object_prefix = "" - cloudfront_distribution_arn = null - enable_bucket_versioning = false - expire_noncurrent_versions = true - noncurrent_version_expiration_days = 30 - create_kms_key = false - kms_key_arn = null - kms_alias = "fleet-software-installers" - extra_kms_policies = [] - tags = {} + create_bucket = true + bucket_name = null + bucket_prefix = "fleet-software-installers-" + s3_object_prefix = "" + cloudfront_distribution_arn = null + enable_bucket_versioning = false + expire_noncurrent_versions = true + noncurrent_version_expiration_days = 30 + create_kms_key = false + kms_key_arn = null + kms_alias = "fleet-software-installers" + extra_kms_policies = [] + tags = {} } } description = "The configuration object for Fleet itself. Fields that default to null will have their respective resources created if not specified. For published KMS blocks, legacy `enabled` is deprecated and still accepted; prefer `cmk_enabled`." diff --git a/byo-vpc/variables.tf b/byo-vpc/variables.tf index e859fdd..fb847d9 100644 --- a/byo-vpc/variables.tf +++ b/byo-vpc/variables.tf @@ -597,33 +597,33 @@ variable "fleet_config" { name = "fleetdm-execution-role" }) software_installers = optional(object({ - create_bucket = optional(bool, true) - bucket_name = optional(string, null) - bucket_prefix = optional(string, "fleet-software-installers-") - s3_object_prefix = optional(string, "") - cloudfront_distribution_arn = optional(string, null) - enable_bucket_versioning = optional(bool, false) - expire_noncurrent_versions = optional(bool, true) - noncurrent_version_expiration_days = optional(number, 30) - create_kms_key = optional(bool, false) - kms_key_arn = optional(string, null) - kms_alias = optional(string, "fleet-software-installers") - extra_kms_policies = optional(list(any), []) - tags = optional(map(string), {}) + create_bucket = optional(bool, true) + bucket_name = optional(string, null) + bucket_prefix = optional(string, "fleet-software-installers-") + s3_object_prefix = optional(string, "") + cloudfront_distribution_arn = optional(string, null) + enable_bucket_versioning = optional(bool, false) + expire_noncurrent_versions = optional(bool, true) + noncurrent_version_expiration_days = optional(number, 30) + create_kms_key = optional(bool, false) + kms_key_arn = optional(string, null) + kms_alias = optional(string, "fleet-software-installers") + extra_kms_policies = optional(list(any), []) + tags = optional(map(string), {}) }), { - create_bucket = true - bucket_name = null - bucket_prefix = "fleet-software-installers-" - s3_object_prefix = "" - cloudfront_distribution_arn = null - enable_bucket_versioning = false - expire_noncurrent_versions = true - noncurrent_version_expiration_days = 30 - create_kms_key = false - kms_key_arn = null - kms_alias = "fleet-software-installers" - extra_kms_policies = [] - tags = {} + create_bucket = true + bucket_name = null + bucket_prefix = "fleet-software-installers-" + s3_object_prefix = "" + cloudfront_distribution_arn = null + enable_bucket_versioning = false + expire_noncurrent_versions = true + noncurrent_version_expiration_days = 30 + create_kms_key = false + kms_key_arn = null + kms_alias = "fleet-software-installers" + extra_kms_policies = [] + tags = {} }) }) default = { @@ -726,19 +726,19 @@ variable "fleet_config" { } } software_installers = { - create_bucket = true - bucket_name = null - bucket_prefix = "fleet-software-installers-" - s3_object_prefix = "" - cloudfront_distribution_arn = null - enable_bucket_versioning = false - expire_noncurrent_versions = true - noncurrent_version_expiration_days = 30 - create_kms_key = false - kms_key_arn = null - kms_alias = "fleet-software-installers" - extra_kms_policies = [] - tags = {} + create_bucket = true + bucket_name = null + bucket_prefix = "fleet-software-installers-" + s3_object_prefix = "" + cloudfront_distribution_arn = null + enable_bucket_versioning = false + expire_noncurrent_versions = true + noncurrent_version_expiration_days = 30 + create_kms_key = false + kms_key_arn = null + kms_alias = "fleet-software-installers" + extra_kms_policies = [] + tags = {} } } validation { diff --git a/main.tf b/main.tf index 8804a0e..830fea3 100644 --- a/main.tf +++ b/main.tf @@ -160,9 +160,10 @@ module "vpc" { create_flow_log_cloudwatch_log_group = var.vpc.create_flow_log_cloudwatch_log_group create_flow_log_cloudwatch_iam_role = var.vpc.create_flow_log_cloudwatch_iam_role flow_log_max_aggregation_interval = var.vpc.flow_log_max_aggregation_interval - flow_log_cloudwatch_log_group_name_prefix = var.vpc.flow_log_cloudwatch_log_group_name_prefix - flow_log_cloudwatch_log_group_name_suffix = var.vpc.flow_log_cloudwatch_log_group_name_suffix - flow_log_cloudwatch_log_group_kms_key_id = local.vpc_flow_log_cloudwatch_log_group_kms_key_arn + flow_log_cloudwatch_log_group_name_prefix = var.vpc.flow_log_cloudwatch_log_group_name_prefix + flow_log_cloudwatch_log_group_name_suffix = var.vpc.flow_log_cloudwatch_log_group_name_suffix + flow_log_cloudwatch_log_group_retention_in_days = var.vpc.flow_log_cloudwatch_log_group_retention_in_days + flow_log_cloudwatch_log_group_kms_key_id = local.vpc_flow_log_cloudwatch_log_group_kms_key_arn vpc_flow_log_tags = var.vpc.vpc_flow_log_tags enable_dns_hostnames = var.vpc.enable_dns_hostnames enable_dns_support = var.vpc.enable_dns_support diff --git a/variables.tf b/variables.tf index 71e5a53..7cf35cd 100644 --- a/variables.tf +++ b/variables.tf @@ -22,8 +22,9 @@ variable "vpc" { create_flow_log_cloudwatch_log_group = optional(bool, false) create_flow_log_cloudwatch_iam_role = optional(bool, false) flow_log_max_aggregation_interval = optional(number, 600) - flow_log_cloudwatch_log_group_name_prefix = optional(string, "/aws/vpc-flow-log/") - flow_log_cloudwatch_log_group_name_suffix = optional(string, "") + flow_log_cloudwatch_log_group_name_prefix = optional(string, "/aws/vpc-flow-log/") + flow_log_cloudwatch_log_group_name_suffix = optional(string, "") + flow_log_cloudwatch_log_group_retention_in_days = optional(number, null) flow_log_cloudwatch_log_group_kms = optional(object({ cmk_enabled = optional(bool, false) kms_key_arn = optional(string, null) @@ -96,8 +97,9 @@ variable "vpc" { create_flow_log_cloudwatch_log_group = false create_flow_log_cloudwatch_iam_role = false flow_log_max_aggregation_interval = 600 - flow_log_cloudwatch_log_group_name_prefix = "/aws/vpc-flow-log/" - flow_log_cloudwatch_log_group_name_suffix = "" + flow_log_cloudwatch_log_group_name_prefix = "/aws/vpc-flow-log/" + flow_log_cloudwatch_log_group_name_suffix = "" + flow_log_cloudwatch_log_group_retention_in_days = null flow_log_cloudwatch_log_group_kms = { cmk_enabled = false kms_key_arn = null @@ -757,33 +759,33 @@ variable "fleet_config" { name = "fleetdm-execution-role" }) software_installers = optional(object({ - create_bucket = optional(bool, true) - bucket_name = optional(string, null) - bucket_prefix = optional(string, "fleet-software-installers-") - s3_object_prefix = optional(string, "") - cloudfront_distribution_arn = optional(string, null) - enable_bucket_versioning = optional(bool, false) - expire_noncurrent_versions = optional(bool, true) - noncurrent_version_expiration_days = optional(number, 30) - create_kms_key = optional(bool, false) - kms_key_arn = optional(string, null) - kms_alias = optional(string, "fleet-software-installers") - extra_kms_policies = optional(list(any), []) - tags = optional(map(string), {}) + create_bucket = optional(bool, true) + bucket_name = optional(string, null) + bucket_prefix = optional(string, "fleet-software-installers-") + s3_object_prefix = optional(string, "") + cloudfront_distribution_arn = optional(string, null) + enable_bucket_versioning = optional(bool, false) + expire_noncurrent_versions = optional(bool, true) + noncurrent_version_expiration_days = optional(number, 30) + create_kms_key = optional(bool, false) + kms_key_arn = optional(string, null) + kms_alias = optional(string, "fleet-software-installers") + extra_kms_policies = optional(list(any), []) + tags = optional(map(string), {}) }), { - create_bucket = true - bucket_name = null - bucket_prefix = "fleet-software-installers-" - s3_object_prefix = "" - cloudfront_distribution_arn = null - enable_bucket_versioning = false - expire_noncurrent_versions = true - noncurrent_version_expiration_days = 30 - create_kms_key = false - kms_key_arn = null - kms_alias = "fleet-software-installers" - extra_kms_policies = [] - tags = {} + create_bucket = true + bucket_name = null + bucket_prefix = "fleet-software-installers-" + s3_object_prefix = "" + cloudfront_distribution_arn = null + enable_bucket_versioning = false + expire_noncurrent_versions = true + noncurrent_version_expiration_days = 30 + create_kms_key = false + kms_key_arn = null + kms_alias = "fleet-software-installers" + extra_kms_policies = [] + tags = {} }) }) default = { @@ -886,19 +888,19 @@ variable "fleet_config" { } } software_installers = { - create_bucket = true - bucket_name = null - bucket_prefix = "fleet-software-installers-" - s3_object_prefix = "" - cloudfront_distribution_arn = null - enable_bucket_versioning = false - expire_noncurrent_versions = true - noncurrent_version_expiration_days = 30 - create_kms_key = false - kms_key_arn = null - kms_alias = "fleet-software-installers" - extra_kms_policies = [] - tags = {} + create_bucket = true + bucket_name = null + bucket_prefix = "fleet-software-installers-" + s3_object_prefix = "" + cloudfront_distribution_arn = null + enable_bucket_versioning = false + expire_noncurrent_versions = true + noncurrent_version_expiration_days = 30 + create_kms_key = false + kms_key_arn = null + kms_alias = "fleet-software-installers" + extra_kms_policies = [] + tags = {} } } validation {