Files
windmill/examples/deploy/aws-ecs-terraform/ecs_cluster.tf
Alexander PetricandClaude Opus 5.5 f183bd43fb chore: retire the standalone lsp and multiplayer images from examples, drop lsp/Dockerfile (#11341)
* chore: retire the standalone lsp and multiplayer images from examples, drop lsp/Dockerfile

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* chore: drop the unbuilt DockerfileMultiplayer, document running the LSP from windmill-extra

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(examples): ecs terraform destroys cleanly and gives private instances no public ip

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(examples): give windmill-extra on ecs a WINDMILL_BASE_URL for multiplayer auth, address review

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(examples): make the ecs example upgrade cleanly from the standalone lsp/multiplayer stack

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(examples): name the extra target group by prefix so create_before_destroy can replace it

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs(examples): note the brief editor-socket gap when upgrading the ecs example

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs(examples): the debugger stays off after the ecs upgrade unless enabled

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 17:13:06 +02:00

105 lines
3.0 KiB
Terraform

resource "aws_launch_template" "windmill_cluster_lt" {
name = "windmill-cluster-lt"
image_id = data.aws_ssm_parameter.amazon_linux_2023.value
instance_type = "t3.medium"
# vpc_security_group_ids = [aws_security_group.windmill_cluster_sg.id]
block_device_mappings {
device_name = "/dev/xvda"
ebs {
volume_size = 100
}
}
iam_instance_profile {
name = "ecsInstanceRole"
}
network_interfaces {
device_index = 0
delete_on_termination = true
# Private subnets: outbound traffic goes through the NAT gateways, so no public IP.
associate_public_ip_address = false
security_groups = [
aws_security_group.windmill_cluster_sg.id
]
}
user_data = filebase64("${path.module}/lt_init_script.sh")
tag_specifications {
resource_type = "instance"
tags = {
Name = "ECS Instance - windmill-cluster"
}
}
}
resource "aws_autoscaling_group" "windmill_cluster_asg" {
name = "windmill-cluster-asg"
max_size = 10
min_size = 1
vpc_zone_identifier = [
aws_subnet.windmill_cluster_subnet_private1.id,
aws_subnet.windmill_cluster_subnet_private2.id
]
launch_template {
id = aws_launch_template.windmill_cluster_lt.id
version = "$Latest"
}
health_check_type = "EC2"
tag {
key = "AmazonECSManaged"
value = true
propagate_at_launch = true
}
# The ECS agent on these instances reaches AWS through private route -> NAT gateway -> public
# route -> internet gateway. Keeping that whole path until the instances are gone lets
# `terraform destroy` drain and delete the ECS services, which otherwise hang in DRAINING.
depends_on = [
aws_route_table_association.windmill_cluster_subnet_private1__rtb_private1,
aws_route_table_association.windmill_cluster_subnet_private2__rtb_private2,
aws_route_table_association.windmill_cluster_subnet_public1__rtb_public,
aws_route_table_association.windmill_cluster_subnet_public2__rtb_public,
]
}
resource "aws_ecs_cluster" "windmill_cluster" {
name = "windmill-cluster"
}
resource "aws_ecs_capacity_provider" "windmill_cluster_capacity_provider" {
name = "windmill-cluster-capacity-provider"
auto_scaling_group_provider {
auto_scaling_group_arn = aws_autoscaling_group.windmill_cluster_asg.arn
managed_scaling {
maximum_scaling_step_size = 5
minimum_scaling_step_size = 1
status = "ENABLED"
}
}
}
resource "aws_ecs_cluster_capacity_providers" "windmill_cluster_cluster___capacity_provider" {
cluster_name = aws_ecs_cluster.windmill_cluster.name
capacity_providers = [
aws_ecs_capacity_provider.windmill_cluster_capacity_provider.name,
aws_ecs_capacity_provider.windmill_cluster_high_performance_capacity_provider.name # remove if not using high performance workers
]
default_capacity_provider_strategy {
base = 1
weight = 100
capacity_provider = aws_ecs_capacity_provider.windmill_cluster_capacity_provider.name
}
}