Skip to content

Add variables to control creation of public IPs #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/aws_ecs/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ resource "aws_launch_configuration" "this" {
instance_type = var.instance_type # e.g. t2.medium

enable_monitoring = true
associate_public_ip_address = true
associate_public_ip_address = var.associate_public_ip_address

# This user data represents a collection of “scripts” that will be executed the first time the machine starts.
# This specific example makes sure the EC2 instance is automatically attached to the ECS cluster that we create earlier
Expand Down
1 change: 1 addition & 0 deletions modules/aws_ecs/loadbalancers.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
resource "aws_lb" "this" {
name = "${var.deployment_name}-alb"
idle_timeout = var.alb_idle_timeout
internal = var.alb_internal

security_groups = [aws_security_group.alb.id]
subnets = var.public_subnet_ids
Expand Down
6 changes: 3 additions & 3 deletions modules/aws_ecs/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ locals {
auto_create_group = "true"
log_stream_prefix = "SERVICE_RETOOL/"
}
} : {
} : {
logDriver = "awslogs"
options = {
awslogs-group = aws_cloudwatch_log_group.this.id
Expand All @@ -143,7 +143,7 @@ locals {
memory = var.launch_type == "EC2" ? var.ecs_task_resource_map["fluentbit"]["memory"] : null

firelensConfiguration = {
type = "fluentbit"
type = "fluentbit"
options = {
config-file-type = "file"
config-file-value = "/extra.conf"
Expand All @@ -152,7 +152,7 @@ locals {

logConfiguration = {
logDriver = "awslogs"
options = {
options = {
awslogs-group = aws_cloudwatch_log_group.this.id
awslogs-region = var.aws_region
awslogs-stream-prefix = "SERVICE_RETOOL"
Expand Down
29 changes: 15 additions & 14 deletions modules/aws_ecs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ resource "aws_ecs_service" "retool" {
security_groups = [
aws_security_group.containers.id
]
assign_public_ip = true
assign_public_ip = var.assign_public_ip
}
}
}
Expand Down Expand Up @@ -107,7 +107,7 @@ resource "aws_ecs_service" "jobs_runner" {
security_groups = [
aws_security_group.containers.id
]
assign_public_ip = true
assign_public_ip = var.assign_public_ip
}
}
}
Expand Down Expand Up @@ -140,7 +140,7 @@ resource "aws_ecs_service" "workflows_backend" {
security_groups = [
aws_security_group.containers.id
]
assign_public_ip = true
assign_public_ip = var.assign_public_ip
}
}
}
Expand Down Expand Up @@ -169,7 +169,7 @@ resource "aws_ecs_service" "workflows_worker" {
security_groups = [
aws_security_group.containers.id
]
assign_public_ip = true
assign_public_ip = var.assign_public_ip
}
}
}
Expand Down Expand Up @@ -201,7 +201,7 @@ resource "aws_ecs_service" "code_executor" {
security_groups = [
aws_security_group.containers.id
]
assign_public_ip = true
assign_public_ip = var.assign_public_ip
}
}
}
Expand Down Expand Up @@ -234,7 +234,7 @@ resource "aws_ecs_service" "telemetry" {
security_groups = [
aws_security_group.containers.id
]
assign_public_ip = true
assign_public_ip = var.assign_public_ip
}
}
}
Expand Down Expand Up @@ -454,12 +454,12 @@ resource "aws_ecs_task_definition" "retool_code_executor" {
local.common_containers,
[
{
name = "retool-code-executor"
essential = true
image = local.ecs_code_executor_image
cpu = var.launch_type == "EC2" ? var.ecs_task_resource_map["code_executor"]["cpu"] : null
memory = var.launch_type == "EC2" ? var.ecs_task_resource_map["code_executor"]["memory"] : null
user = var.launch_type == "EC2" ? null : "1001:1001"
name = "retool-code-executor"
essential = true
image = local.ecs_code_executor_image
cpu = var.launch_type == "EC2" ? var.ecs_task_resource_map["code_executor"]["cpu"] : null
memory = var.launch_type == "EC2" ? var.ecs_task_resource_map["code_executor"]["memory"] : null
user = var.launch_type == "EC2" ? null : "1001:1001"
# required to use nsjail sandboxing, which is required for custom libraries for JS and Python
# Learn more here: https://docs.retool.com/self-hosted/concepts/architecture#code-executor
# If not using nsjail sandboxing, update this to be false and use user = "1001:1001"
Expand All @@ -486,7 +486,7 @@ resource "aws_ecs_task_definition" "retool_code_executor" {
local.base_environment_variables,
[
{
name = "NODE_OPTIONS",
name = "NODE_OPTIONS",
value = "--max_old_space_size=1024"
}
],
Expand Down Expand Up @@ -635,7 +635,7 @@ resource "aws_service_discovery_service" "retool_code_executor_service" {

resource "aws_service_discovery_service" "retool_telemetry_service" {
count = var.telemetry_enabled ? 1 : 0
name = "telemetry"
name = "telemetry"

dns_config {
namespace_id = aws_service_discovery_private_dns_namespace.retool_namespace[0].id
Expand Down Expand Up @@ -701,5 +701,6 @@ module "temporal" {
aws_ecs_capacity_provider_name = var.launch_type == "EC2" ? aws_ecs_capacity_provider.this[0].name : null
task_propagate_tags = var.task_propagate_tags
service_discovery_namespace = local.service_discovery_namespace
assign_public_ip = var.assign_public_ip
iam_partition = var.iam_partition
}
2 changes: 1 addition & 1 deletion modules/aws_ecs/temporal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ resource "aws_ecs_service" "retool_temporal" {
security_groups = [
var.container_sg_id
]
assign_public_ip = true
assign_public_ip = var.assign_public_ip
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions modules/aws_ecs/temporal/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ variable "launch_type" {
}
}

variable "assign_public_ip" {
type = bool
description = "Whether to assign a public IP address to Temporal Fargate tasks. Defaults to false."
default = true
}

variable "temporal_aurora_username" {
type = string
default = "retool"
Expand Down
18 changes: 18 additions & 0 deletions modules/aws_ecs/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ variable "min_instance_count" {
default = 3
}

variable "associate_public_ip_address" {
type = bool
description = "Whether to associate a public IP address with an EC2 instance in a VPC. Defaults to true."
default = true
}

variable "assign_public_ip" {
type = bool
description = "Whether to assign a public IP address to Fargate tasks. Defaults to false."
default = true
}

variable "deployment_name" {
type = string
description = "Name prefix for created resources. Defaults to `retool`."
Expand Down Expand Up @@ -421,6 +433,12 @@ variable "alb_http_redirect" {
description = "Boolean for if http should redirect to https"
}

variable "alb_internal" {
type = bool
default = false
description = "Whether to create an internal load balancer. Defaults to false."
}

variable "cookie_insecure" {
type = bool
default = true
Expand Down
1 change: 1 addition & 0 deletions modules/aws_ecs_ec2/loadbalancers.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
resource "aws_lb" "this" {
name = "${var.deployment_name}-alb"
idle_timeout = var.alb_idle_timeout
internal = var.alb_internal

security_groups = [aws_security_group.alb.id]
subnets = var.subnet_ids
Expand Down
2 changes: 1 addition & 1 deletion modules/aws_ecs_ec2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ resource "aws_launch_configuration" "this" {
instance_type = var.instance_type # e.g. t2.medium

enable_monitoring = true
associate_public_ip_address = true
associate_public_ip_address = var.associate_public_ip_address

# This user data represents a collection of “scripts” that will be executed the first time the machine starts.
# This specific example makes sure the EC2 instance is automatically attached to the ECS cluster that we create earlier
Expand Down
12 changes: 12 additions & 0 deletions modules/aws_ecs_ec2/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ variable "min_instance_count" {
default = 3
}

variable "associate_public_ip_address" {
type = bool
description = "Whether to associate a public IP address with an EC2 instance in a VPC. Defaults to true."
default = true
}

variable "deployment_name" {
type = string
description = "Name prefix for created resources. Defaults to `retool`."
Expand Down Expand Up @@ -139,6 +145,12 @@ variable "cookie_insecure" {
description = "Whether to allow insecure cookies. Should be turned off when serving on HTTPS. Defaults to true."
}

variable "alb_internal" {
type = bool
default = false
description = "Whether to create an internal load balancer. Defaults to false."
}

variable "maximum_percent" {
type = number
default = 250
Expand Down