jumppad icon indicating copy to clipboard operation
jumppad copied to clipboard

HTTP resource

Open eveld opened this issue 1 year ago • 0 comments

The HTTP resource allows you to execute HTTP requests and use the response in other resources.

resource "http" "get" {
  method = "GET"

  url = "https://httpbin.org/get"

  headers = {
    Accept = "application/json"
  }
}

resource "http" "post" {
  method = "POST"

  url = "https://httpbin.org/post"

  payload = jsonencode({
    foo = "bar"
  })

  headers = {
    Accept = "application/json"
  }
}

output "get_body" {
  value = resource.http.get.status == 200 ? resource.http.get.body : "error"
}

output "post_body" {
  value = resource.http.post.status == 200 ? resource.http.post.body : "error"
}

eveld avatar Nov 14 '23 18:11 eveld