28 lines
605 B
HCL
28 lines
605 B
HCL
/**
|
|
* # Public IP Module
|
|
*
|
|
* Discovers the caller's public IPv4 address using an external echo-IP service.
|
|
* Used to dynamically allowlist the deployer's IP in firewall rules.
|
|
*/
|
|
|
|
terraform {
|
|
required_providers {
|
|
http = { }
|
|
}
|
|
}
|
|
|
|
data "http" "echoip" {
|
|
url = var.http_url
|
|
request_headers = var.http_request_headers
|
|
method = var.http_method
|
|
|
|
insecure = core::startswith(var.http_url, "http://")
|
|
|
|
lifecycle {
|
|
postcondition {
|
|
condition = contains([200,201,204], self.status_code)
|
|
error_message = "Status code ${self.status_code} indicates request failure."
|
|
}
|
|
}
|
|
}
|