-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to using service module, support multiple regions
- Loading branch information
Showing
11 changed files
with
151 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,4 @@ resource "aws_ecs_task_definition" "task" { | |
} | ||
}, var.container_definitions) | ||
]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
resource "aws_ecs_service" "stun-server" { | ||
name = local.service_name | ||
cluster = data.tfe_outputs.infrastructure.values[var.region].ecs_cluster | ||
task_definition = module.stun_server.task_definition | ||
desired_count = 1 | ||
deployment_minimum_healthy_percent = 100 | ||
deployment_maximum_percent = 200 | ||
health_check_grace_period_seconds = 90 | ||
launch_type = local.launch_type | ||
|
||
# Required to fetch the public IP address of the ECS service | ||
enable_ecs_managed_tags = true | ||
wait_for_steady_state = true | ||
|
||
network_configuration { | ||
assign_public_ip = true | ||
security_groups = [aws_security_group.stun_sg.id] | ||
subnets = [ | ||
data.tfe_outputs.infrastructure.values.public_subnets[0], | ||
data.tfe_outputs.infrastructure.values.public_subnets[1] | ||
] | ||
} | ||
} | ||
|
||
data "aws_network_interface" "stun_server_interface" { | ||
filter { | ||
name = "tag:aws:ecs:serviceName" | ||
values = [aws_ecs_service.stun-server.name] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
locals { | ||
service_name = "stun-server" | ||
launch_type = "FARGATE" | ||
} | ||
|
||
data "tfe_outputs" "infrastructure" { | ||
organization = "home_assistant" | ||
workspace = "infrastructure" | ||
} | ||
|
||
module "stun_server" { | ||
source = "../../.modules/service" | ||
|
||
service_name = local.service_name | ||
container_image = "ghcr.io/home-assistant/stun-server" | ||
container_version = var.image_tag | ||
launch_type = local.launch_type | ||
region = var.region | ||
ecs_cpu = 2048 | ||
ecs_memory = 4096 | ||
container_definitions = { | ||
portMappings = [ | ||
{ | ||
containerPort = 3478 | ||
hostPort = 3478 | ||
protocol = "tcp" | ||
}, | ||
{ | ||
containerPort = 3478 | ||
hostPort = 3478 | ||
protocol = "udp" | ||
} | ||
], | ||
} | ||
webservice = true | ||
rolling_updates = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
variable "region" { | ||
description = "The region to deploy the STUN server to" | ||
type = string | ||
|
||
} | ||
|
||
variable "domain_name" { | ||
description = "The base domain name" | ||
type = string | ||
} | ||
|
||
variable "subdomain" { | ||
description = "The subdomain to use for the STUN server" | ||
type = string | ||
} | ||
variable "image_tag" { | ||
description = "Version of the Stun server to deploy" | ||
type = string | ||
} |