Skip to content

Commit

Permalink
TF config fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
klejejs committed Sep 26, 2024
1 parent 17afaa1 commit d720513
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 19 deletions.
16 changes: 13 additions & 3 deletions stun_server/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
output "stun_server_ip" {
description = "The public IP address of the stun server"
value = data.aws_network_interface.stun_server_interface.association[0].public_ip
output "stun_server_ip-us_east_1" {
description = "The public IP address of the stun server in us-east-1"
value = module.us_east_1.stun_server_ip
}

output "stun_server_ip-eu_central_1" {
description = "The public IP address of the stun server in eu-central-1"
value = module.eu_central_1.stun_server_ip
}

output "stun_server_ip-ap_southeast_1" {
description = "The public IP address of the stun server in ap-southeast-1"
value = module.ap_southeast_1.stun_server_ip
}
2 changes: 1 addition & 1 deletion stun_server/region/dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ data "cloudflare_zone" "dns_zone" {
resource "cloudflare_record" "instance_dns" {
zone_id = data.cloudflare_zone.dns_zone.id
name = join("-", [var.subdomain, data.aws_region.current.name])
content = module.stun_server.aws_network_interface.stun_server_interface.association[0].public_ip
content = data.aws_network_interface.stun_server_interface.association[0].public_ip
type = "A"
proxied = true
}
6 changes: 3 additions & 3 deletions stun_server/region/ecs.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "aws_ecs_service" "stun-server" {
name = local.service_name
cluster = data.tfe_outputs.infrastructure.values[aws_region.current.name].ecs_cluster
cluster = data.tfe_outputs.infrastructure.values[data.aws_region.current.name].ecs_cluster
task_definition = module.stun_server.task_definition
desired_count = 1
deployment_minimum_healthy_percent = 100
Expand All @@ -16,8 +16,8 @@ resource "aws_ecs_service" "stun-server" {
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.tfe_outputs.infrastructure.values[data.aws_region.current.name].public_subnets[0],
data.tfe_outputs.infrastructure.values[data.aws_region.current.name].public_subnets[1]
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion stun_server/region/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module "stun_server" {
service_name = local.service_name
container_image = "ghcr.io/home-assistant/stun"
container_version = var.image_tag
region = aws_region.current.name
region = data.aws_region.current.name
ecs_cpu = 2048
ecs_memory = 4096
container_definitions = {
Expand Down
2 changes: 1 addition & 1 deletion stun_server/region/network.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "aws_security_group" "stun_sg" {
vpc_id = data.tfe_outputs.infrastructure.values[aws_region.current.name].network_id
vpc_id = data.tfe_outputs.infrastructure.values[data.aws_region.current.name].network_id

egress {
from_port = 0
Expand Down
4 changes: 4 additions & 0 deletions stun_server/region/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "stun_server_ip" {
description = "The public IP address of the stun server"
value = data.aws_network_interface.stun_server_interface.association[0].public_ip
}
19 changes: 19 additions & 0 deletions stun_server/region/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
terraform {

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}

tfe = {
source = "hashicorp/tfe"
version = "~> 0.58.0"
}

cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 4.0"
}
}
}
10 changes: 0 additions & 10 deletions stun_server/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,5 @@ terraform {
source = "hashicorp/aws"
version = "~> 4.0"
}

tfe = {
source = "hashicorp/tfe"
version = "~> 0.58.0"
}

cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 4.0"
}
}
}

0 comments on commit d720513

Please sign in to comment.