Skip to content

Commit da33b54

Browse files
committed
test BB connecting to exernal services
1 parent ee116bb commit da33b54

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

other-providers/test/main.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
variable "api_url" {
2+
default = "https://www.google.com"
3+
}
4+
5+
resource "terraform_data" "api_call" {
6+
# This ensures the call runs whenever the URL changes
7+
triggers_replace = {
8+
url = var.api_url
9+
}
10+
11+
provisioner "local-exec" {
12+
# -o /dev/null hides the response body
13+
# -w "%%{http_code}" captures only the status code (e.g., 200)
14+
command = "curl -s -o /dev/null -w \"%%{http_code}\" ${var.api_url} > status_code.txt"
15+
}
16+
}
17+
18+
data "local_file" "status_code" {
19+
# Explicit dependency ensures we wait for the curl command to finish
20+
depends_on = [terraform_data.api_call]
21+
filename = "${path.module}/status_code.txt"
22+
}
23+
24+
output "http_response_code" {
25+
value = data.local_file.status_code.content
26+
description = "The HTTP status code returned by the API"
27+
}

0 commit comments

Comments
 (0)