HTTP 数据源

原文


类型:http

http 数据源向给定的 URL 发出 HTTP GET 请求并输出响应的信息。

基础用法

data "http" "example" {
  url = "https://checkpoint-api.hashicorp.com/v1/check/terraform"

  # Optional request headers
  request_headers = {
    Accept = "application/json"
  }
}

配置参数

有两类配置参数:必须的和可选的。在每个类别中,可用选项按英文字母顺序排列和描述。

必须

  • url (string) - ​​请求数据的 URL。此 URL 必须返回 200 OK 状态码以及 text/*application/json 作为 Content-Type。

可选

  • request_headers (map[string]string) - 表示请求中包含的额外 HTTP 标头的字符串映射。

数据源输出

该数据源的输出如下:

  • url (string) - 请求数据的 URL。
  • body (string) - HTTP 响应的原始 body
  • request_headers (map[string]string) - 表示响应 HTTP 标头的字符串映射。根据 RFC2616,重复的标头会被连接在一起。

results matching ""

    No results matching ""