Skip to content

Commit

Permalink
Support checkly
Browse files Browse the repository at this point in the history
  • Loading branch information
posquit0 committed May 13, 2024
1 parent 226bd9e commit 326cdac
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
4 changes: 4 additions & 0 deletions examples/service-ip-ranges/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ locals {
service = "ATLASSIAN"
category = "jira"
},
{
service = "CHECKLY"
category = "all"
},
{
service = "GITHUB"
category = "all"
Expand Down
43 changes: 43 additions & 0 deletions modules/service-ip-ranges/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
###################################################
Expand Down
3 changes: 2 additions & 1 deletion modules/service-ip-ranges/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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`."
}
}

Expand Down

0 comments on commit 326cdac

Please sign in to comment.