-
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 Cloudflare load balancer config to Terraform
- Loading branch information
Showing
8 changed files
with
106 additions
and
16 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
resource "cloudflare_load_balancer" "stun-server" { | ||
zone_id = data.cloudflare_zone.dns_zone.id | ||
name = "stun.${var.domain_name}" | ||
default_pool_ids = [module.us_east_1.cloudflare_load_balancer_pool_id, module.eu_central_1.cloudflare_load_balancer_pool_id, module.ap_southeast_1.cloudflare_load_balancer_pool_id] | ||
fallback_pool_id = module.us_east_1.cloudflare_load_balancer_pool_id | ||
description = "Stun server load balancer using proximity steering policy" | ||
|
||
proxied = false | ||
steering_policy = "proximity" | ||
|
||
location_strategy { | ||
mode = "pop" | ||
prefer_ecs = "proximity" | ||
} | ||
} | ||
|
||
resource "cloudflare_load_balancer_monitor" "stun-server" { | ||
account_id = var.CLOUDFLARE_ACCOUNT_ID | ||
type = "tcp" | ||
port = 3478 | ||
interval = 60 | ||
timeout = 5 | ||
retries = 2 | ||
} |
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 |
---|---|---|
@@ -1,8 +1,4 @@ | ||
output "endpoints" { | ||
description = "Endpoints of the Stun server" | ||
value = { | ||
"us-east-1" = module.us_east_1.stun_server_endpoint | ||
"eu-central-1" = module.eu_central_1.stun_server_endpoint | ||
"ap-southeast-1" = module.ap_southeast_1.stun_server_endpoint | ||
} | ||
output "endpoint" { | ||
description = "Endpoint of the Stun server" | ||
value = cloudflare_load_balancer.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,18 @@ | ||
resource "cloudflare_load_balancer_pool" "stun-server" { | ||
account_id = var.cloudflare_account_id | ||
name = "stun-${data.aws_region.current.name}" | ||
description = "Stun server pool for ${data.aws_region.current.name}" | ||
latitude = var.cloudflare_load_balancer_pool_latitude | ||
longitude = var.cloudflare_load_balancer_pool_longitude | ||
monitor = var.cloudflare_load_balancer_monitor_id | ||
|
||
origins { | ||
name = "stun-${data.aws_region.current.name}-pool" | ||
address = aws_lb.main.dns_name | ||
weight = 1 | ||
} | ||
|
||
origin_steering { | ||
policy = "random" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
output "stun_server_endpoint" { | ||
description = "Endpoint of the Stun server" | ||
value = aws_lb.main.dns_name | ||
output "cloudflare_load_balancer_pool_id" { | ||
description = "The ID of the Cloudflare Load Balancer Pool" | ||
value = cloudflare_load_balancer_pool.stun-server.id | ||
} |
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