diff --git a/main.tf b/main.tf index 7f57823..75ffd9a 100644 --- a/main.tf +++ b/main.tf @@ -470,8 +470,8 @@ resource "aws_ecs_service" "directus" { } network_configuration { - assign_public_ip = false - subnets = var.private_subnet_ids + assign_public_ip = var.assign_public_ip + subnets = concat(var.assign_public_ip ? [var.public_subnet_ids] : [], var.private_subnet_ids) security_groups = concat([aws_security_group.ecs_sg.id], var.ecs_security_group_ids) } diff --git a/outputs.tf b/outputs.tf index 3df9e14..b77bd88 100644 --- a/outputs.tf +++ b/outputs.tf @@ -13,6 +13,11 @@ output "load_balancer_dns_name" { description = "The DNS name of the load balancer" } +output "load_balancer_zone_id" { + value = aws_lb.directus.zone_id + description = "The DNS zone of the load balancer" +} + output "load_balancer_target_group_arn" { value = aws_lb_target_group.directus_lb_target_group.arn description = "The ARN of the load balancer target group" diff --git a/variables.tf b/variables.tf index 02f7c16..37c56e5 100644 --- a/variables.tf +++ b/variables.tf @@ -272,3 +272,9 @@ variable "tags" { type = map(string) default = {} } + +variable "assign_public_ip" { + description = "Whether to assign public ip to task" + type = bool + default = false +}