page_title | subcategory | description |
---|---|---|
http Data Source - terraform-provider-http |
The http data source makes an HTTP GET request to the given URL and exports
information about the response.
The given URL may be either an http or https URL. At present this resource
can only retrieve data from URLs that respond with text/* or
application/json content types, and expects the result to be UTF-8 encoded
regardless of the returned content type header.
~> Important Although https URLs can be used, there is currently no
mechanism to authenticate the remote server except for general verification of
the server certificate's chain of trust. Data retrieved from servers not under
your control should be treated as untrustworthy. |
The http
data source makes an HTTP GET request to the given URL and exports
information about the response.
The given URL may be either an http
or https
URL. At present this resource
can only retrieve data from URLs that respond with text/*
or
application/json
content types, and expects the result to be UTF-8 encoded
regardless of the returned content type header.
~> Important Although https
URLs can be used, there is currently no
mechanism to authenticate the remote server except for general verification of
the server certificate's chain of trust. Data retrieved from servers not under
your control should be treated as untrustworthy.
# The following example shows how to issue an HTTP GET request supplying
# an optional request header.
data "http" "example" {
url = "https://checkpoint-api.hashicorp.com/v1/check/terraform"
# Optional request headers
request_headers = {
Accept = "application/json"
}
}
Precondition and Postcondition checks are available with Terraform v1.2.0 and later.
data "http" "example" {
url = "https://checkpoint-api.hashicorp.com/v1/check/terraform"
# Optional request headers
request_headers = {
Accept = "application/json"
}
lifecycle {
postcondition {
condition = contains([201, 204], self.status_code)
error_message = "Status code invalid"
}
}
}
Precondition and Postcondition checks are available with Terraform v1.2.0 and later.
data "http" "example" {
url = "https://checkpoint-api.hashicorp.com/v1/check/terraform"
# Optional request headers
request_headers = {
Accept = "application/json"
}
}
resource "random_uuid" "example" {
lifecycle {
precondition {
condition = contains([201, 204], data.http.example.status_code)
error_message = "Status code invalid"
}
}
}
url
(String) The URL for the request. Supported schemes arehttp
andhttps
.
request_headers
(Map of String) A map of request header field names and values.
id
(String) The ID of this resource.response_body
(String) The response body returned as a string.response_headers
(Map of String) A map of response header field names and values. Duplicate headers are concatenated according to RFC2616.status_code
(Number) The HTTP response status code.