Allow Fleet ECS target-group protocol to be configured for https support (#184)
This commit is contained in:
1 parent
2877050841
commit
a62e432d2f
8 files changed
+124
-67
No files matched your search
@@ -112,7 +112,7 @@ resource "aws_ecs_task_definition" "vuln-processing" {
|
||||
},
|
||||
{
|
||||
name = "FLEET_SERVER_TLS"
|
||||
value = "false"
|
||||
value = tostring(try(var.fleet_config.server_tls_enabled, false))
|
||||
},
|
||||
{
|
||||
name = "FLEET_S3_SOFTWARE_INSTALLERS_BUCKET"
|
||||
@@ -163,4 +163,3 @@ resource "aws_ecs_task_definition" "vuln-processing" {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,8 +48,8 @@ resource "aws_ecs_service" "fleet" {
|
||||
}
|
||||
|
||||
network_configuration {
|
||||
subnets = var.fleet_config.networking.subnets
|
||||
security_groups = var.fleet_config.networking.security_groups == null ? aws_security_group.main.*.id : var.fleet_config.networking.security_groups
|
||||
subnets = var.fleet_config.networking.subnets
|
||||
security_groups = var.fleet_config.networking.security_groups == null ? aws_security_group.main.*.id : var.fleet_config.networking.security_groups
|
||||
assign_public_ip = var.fleet_config.networking.assign_public_ip
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ resource "aws_ecs_task_definition" "backend" {
|
||||
},
|
||||
{
|
||||
name = "FLEET_SERVER_TLS"
|
||||
value = "false"
|
||||
value = tostring(var.fleet_config.server_tls_enabled)
|
||||
},
|
||||
{
|
||||
name = "FLEET_S3_SOFTWARE_INSTALLERS_BUCKET"
|
||||
@@ -297,7 +297,7 @@ resource "aws_s3_bucket" "software_installers" { #tfsec:ignore:aws-s3-encryption
|
||||
bucket = var.fleet_config.software_installers.bucket_name
|
||||
bucket_prefix = var.fleet_config.software_installers.bucket_prefix
|
||||
tags = var.fleet_config.software_installers.tags
|
||||
|
||||
|
||||
# Allow destroy of non-empty buckets
|
||||
force_destroy = true
|
||||
}
|
||||
@@ -311,7 +311,7 @@ resource "aws_s3_bucket_versioning" "software_installers" {
|
||||
}
|
||||
|
||||
resource "aws_s3_bucket_lifecycle_configuration" "software_installers" {
|
||||
count = var.fleet_config.software_installers.enable_bucket_versioning == true && var.fleet_config.software_installers.create_bucket == true && var.fleet_config.software_installers.expire_noncurrent_versions == true? 1 : 0
|
||||
count = var.fleet_config.software_installers.enable_bucket_versioning == true && var.fleet_config.software_installers.create_bucket == true && var.fleet_config.software_installers.expire_noncurrent_versions == true ? 1 : 0
|
||||
depends_on = [aws_s3_bucket_versioning.software_installers[0]]
|
||||
bucket = aws_s3_bucket.software_installers[0].bucket
|
||||
rule {
|
||||
|
||||
@@ -30,6 +30,7 @@ variable "fleet_config" {
|
||||
iam_role_arn = optional(string, null)
|
||||
repository_credentials = optional(string, "")
|
||||
private_key_secret_name = optional(string, "fleet-server-private-key")
|
||||
server_tls_enabled = optional(bool, false)
|
||||
service = optional(object({
|
||||
name = optional(string, "fleet")
|
||||
}), {
|
||||
@@ -146,6 +147,7 @@ variable "fleet_config" {
|
||||
iam_role_arn = null
|
||||
repository_credentials = ""
|
||||
private_key_secret_name = "fleet-server-private-key"
|
||||
server_tls_enabled = false
|
||||
service = {
|
||||
name = "fleet"
|
||||
}
|
||||
|
||||
+34
-35
@@ -15,21 +15,20 @@ locals {
|
||||
assign_public_ip = var.fleet_config.networking.assign_public_ip
|
||||
})
|
||||
})
|
||||
fleet_target_group_health_check = merge(
|
||||
var.alb_config.fleet_target_group.health_check,
|
||||
{
|
||||
protocol = var.alb_config.fleet_target_group.protocol
|
||||
}
|
||||
)
|
||||
fleet_target_group = [
|
||||
{
|
||||
name = var.alb_config.name
|
||||
backend_protocol = "HTTP"
|
||||
backend_port = 80
|
||||
target_type = "ip"
|
||||
create_attachment = false
|
||||
health_check = {
|
||||
path = "/healthz"
|
||||
matcher = "200"
|
||||
timeout = 10
|
||||
interval = 15
|
||||
healthy_threshold = 5
|
||||
unhealthy_threshold = 5
|
||||
}
|
||||
protocol = var.alb_config.fleet_target_group.protocol
|
||||
port = var.alb_config.fleet_target_group.port
|
||||
target_type = var.alb_config.fleet_target_group.target_type
|
||||
create_attachment = var.alb_config.fleet_target_group.create_attachment
|
||||
health_check = local.fleet_target_group_health_check
|
||||
}
|
||||
]
|
||||
target_groups = { for idx, tg in concat(local.fleet_target_group, var.alb_config.extra_target_groups) :
|
||||
@@ -69,12 +68,12 @@ module "alb" {
|
||||
|
||||
load_balancer_type = "application"
|
||||
|
||||
vpc_id = var.vpc_id
|
||||
subnets = var.alb_config.subnets
|
||||
security_groups = concat(var.alb_config.security_groups, [aws_security_group.alb.id])
|
||||
access_logs = var.alb_config.access_logs
|
||||
idle_timeout = var.alb_config.idle_timeout
|
||||
internal = var.alb_config.internal
|
||||
vpc_id = var.vpc_id
|
||||
subnets = var.alb_config.subnets
|
||||
security_groups = concat(var.alb_config.security_groups, [aws_security_group.alb.id])
|
||||
access_logs = var.alb_config.access_logs
|
||||
idle_timeout = var.alb_config.idle_timeout
|
||||
internal = var.alb_config.internal
|
||||
enable_deletion_protection = var.alb_config.enable_deletion_protection
|
||||
|
||||
target_groups = local.target_groups
|
||||
@@ -105,28 +104,28 @@ module "alb" {
|
||||
"rule-${idx}" => merge(rule, {
|
||||
conditions = flatten([
|
||||
for condition in rule.conditions : concat(flatten([
|
||||
for key in ["host_headers", "http_request_methods", "path_patterns", "source_ips"]:
|
||||
for key in ["host_headers", "http_request_methods", "path_patterns", "source_ips"] :
|
||||
lookup(condition, key, null) != null ? [{
|
||||
"${trimsuffix(key, "s")}" = {
|
||||
values = condition[key]
|
||||
}
|
||||
}] : []
|
||||
]),
|
||||
lookup(condition, "http_headers", null) != null ? [
|
||||
for header in condition.http_headers : {
|
||||
http_header = {
|
||||
http_header_name = header.http_header_name
|
||||
values = header.values
|
||||
}
|
||||
}]: [],
|
||||
lookup(condition, "query_strings", null) != null ? [{
|
||||
query_string = [
|
||||
for qs in condition.query_strings : {
|
||||
key = qs.key
|
||||
value = qs.value
|
||||
}
|
||||
]
|
||||
}]: [],
|
||||
]),
|
||||
lookup(condition, "http_headers", null) != null ? [
|
||||
for header in condition.http_headers : {
|
||||
http_header = {
|
||||
http_header_name = header.http_header_name
|
||||
values = header.values
|
||||
}
|
||||
}] : [],
|
||||
lookup(condition, "query_strings", null) != null ? [{
|
||||
query_string = [
|
||||
for qs in condition.query_strings : {
|
||||
key = qs.key
|
||||
value = qs.value
|
||||
}
|
||||
]
|
||||
}] : [],
|
||||
)])
|
||||
actions = [for action in rule.actions : merge(action, {
|
||||
target_group_key = try(action.target_group_key, try("tg-${action.target_group_index}", null))
|
||||
|
||||
@@ -91,6 +91,7 @@ variable "fleet_config" {
|
||||
iam_role_arn = optional(string, null)
|
||||
repository_credentials = optional(string, "")
|
||||
private_key_secret_name = optional(string, "fleet-server-private-key")
|
||||
server_tls_enabled = optional(bool, false)
|
||||
service = optional(object({
|
||||
name = optional(string, "fleet")
|
||||
}), {
|
||||
@@ -234,6 +235,7 @@ variable "fleet_config" {
|
||||
iam_role_arn = null
|
||||
repository_credentials = ""
|
||||
private_key_secret_name = "fleet-server-private-key"
|
||||
server_tls_enabled = false
|
||||
service = {
|
||||
name = "fleet"
|
||||
}
|
||||
@@ -312,15 +314,30 @@ variable "migration_config" {
|
||||
|
||||
variable "alb_config" {
|
||||
type = object({
|
||||
name = optional(string, "fleet")
|
||||
subnets = list(string)
|
||||
security_groups = optional(list(string), [])
|
||||
access_logs = optional(map(string), {})
|
||||
certificate_arn = 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"])
|
||||
name = optional(string, "fleet")
|
||||
subnets = list(string)
|
||||
security_groups = optional(list(string), [])
|
||||
access_logs = optional(map(string), {})
|
||||
certificate_arn = 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, {})
|
||||
|
||||
+26
-9
@@ -200,6 +200,7 @@ variable "fleet_config" {
|
||||
iam_role_arn = optional(string, null)
|
||||
repository_credentials = optional(string, "")
|
||||
private_key_secret_name = optional(string, "fleet-server-private-key")
|
||||
server_tls_enabled = optional(bool, false)
|
||||
service = optional(object({
|
||||
name = optional(string, "fleet")
|
||||
}), {
|
||||
@@ -343,6 +344,7 @@ variable "fleet_config" {
|
||||
iam_role_arn = null
|
||||
repository_credentials = ""
|
||||
private_key_secret_name = "fleet-server-private-key"
|
||||
server_tls_enabled = false
|
||||
service = {
|
||||
name = "fleet"
|
||||
}
|
||||
@@ -421,15 +423,30 @@ variable "migration_config" {
|
||||
|
||||
variable "alb_config" {
|
||||
type = object({
|
||||
name = optional(string, "fleet")
|
||||
subnets = list(string)
|
||||
security_groups = optional(list(string), [])
|
||||
access_logs = optional(map(string), {})
|
||||
certificate_arn = 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"])
|
||||
name = optional(string, "fleet")
|
||||
subnets = list(string)
|
||||
security_groups = optional(list(string), [])
|
||||
access_logs = optional(map(string), {})
|
||||
certificate_arn = 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, {})
|
||||
|
||||
@@ -145,6 +145,12 @@ module "fleet" {
|
||||
# Script execution can run for up to 300s plus overhead.
|
||||
# Ensure the load balancer does not 5XX before we have results.
|
||||
idle_timeout = 905
|
||||
# Optionally change the primary Fleet target group from the default HTTP backend
|
||||
# to HTTPS when Fleet itself terminates TLS on the ECS task.
|
||||
# fleet_target_group = {
|
||||
# protocol = "HTTPS"
|
||||
# port = 8080
|
||||
# }
|
||||
# Optionally deploy load balancer as an internal load balancer
|
||||
# internal = true
|
||||
# optionally set deletion protection on (true) or off (false)
|
||||
|
||||
+24
-7
@@ -248,6 +248,7 @@ variable "fleet_config" {
|
||||
iam_role_arn = optional(string, null)
|
||||
repository_credentials = optional(string, "")
|
||||
private_key_secret_name = optional(string, "fleet-server-private-key")
|
||||
server_tls_enabled = optional(bool, false)
|
||||
service = optional(object({
|
||||
name = optional(string, "fleet")
|
||||
}), {
|
||||
@@ -391,6 +392,7 @@ variable "fleet_config" {
|
||||
iam_role_arn = null
|
||||
repository_credentials = ""
|
||||
private_key_secret_name = "fleet-server-private-key"
|
||||
server_tls_enabled = false
|
||||
service = {
|
||||
name = "fleet"
|
||||
}
|
||||
@@ -469,13 +471,28 @@ variable "migration_config" {
|
||||
|
||||
variable "alb_config" {
|
||||
type = 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"])
|
||||
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, {})
|
||||
|
||||
Reference in new issue
Block a user