diff --git a/examples/service-ip-ranges/main.tf b/examples/service-ip-ranges/main.tf index d3af221..feb2bad 100644 --- a/examples/service-ip-ranges/main.tf +++ b/examples/service-ip-ranges/main.tf @@ -12,6 +12,10 @@ locals { service = "ATLASSIAN" category = "jira" }, + { + service = "CHECKLY" + category = "all" + }, { service = "GITHUB" category = "all" diff --git a/modules/service-ip-ranges/main.tf b/modules/service-ip-ranges/main.tf index f9094fa..f5ee29f 100644 --- a/modules/service-ip-ranges/main.tf +++ b/modules/service-ip-ranges/main.tf @@ -7,6 +7,13 @@ locals { "all" = setunion(values(local.atlassian_cidrs)...) }, {}) ) + ## Checkly + "CHECKLY" = { + "all" = setunion( + local.checkly_ipv4_cidrs, + local.checkly_ipv6_cidrs, + ) + } ## GitHub "GITHUB" = merge( local.github_cidrs, @@ -66,6 +73,42 @@ locals { } +################################################### +# IP Ranges for Checkly +################################################### + +data "http" "checkly_ipv4" { + count = var.service == "CHECKLY" ? 1 : 0 + + url = "https://api.checklyhq.com/v1/static-ips" +} + +data "http" "checkly_ipv6" { + count = var.service == "CHECKLY" ? 1 : 0 + + url = "https://api.checklyhq.com/v1/static-ipv6s" +} + +locals { + checkly_ipv4_data = (var.service == "CHECKLY" + ? jsondecode(trimspace(data.http.checkly_ipv4[0].response_body)) + : [] + ) + checkly_ipv6_data = (var.service == "CHECKLY" + ? jsondecode(trimspace(data.http.checkly_ipv6[0].response_body)) + : [] + ) + checkly_ipv4_cidrs = toset([ + for ip in local.checkly_ipv4_data : + "${ip}/32" + ]) + checkly_ipv6_cidrs = toset([ + for ip in local.checkly_ipv6_data : + ip + ]) +} + + ################################################### # IP Ranges for GitHub.com ################################################### diff --git a/modules/service-ip-ranges/variables.tf b/modules/service-ip-ranges/variables.tf index 5e99f69..a7d5473 100644 --- a/modules/service-ip-ranges/variables.tf +++ b/modules/service-ip-ranges/variables.tf @@ -6,12 +6,13 @@ variable "service" { validation { condition = contains([ "ATLASSIAN", + "CHECKLY", "GITHUB", "OKTA", "SCALR", "TERRAFORM_CLOUD", ], var.service) - error_message = "Valid values for `service` are `ATLASSIAN`, `GITHUB`, `OKTA`, `SCALR`, `TERRAFORM_CLOUD`." + error_message = "Valid values for `service` are `ATLASSIAN`, `CHECKLY`, `GITHUB`, `OKTA`, `SCALR`, `TERRAFORM_CLOUD`." } }