Skip to content

Instantly share code, notes, and snippets.

@shalomb
Created August 14, 2024 11:34
Show Gist options
  • Save shalomb/eb3118f3aced60da8ef8302cb6a186bb to your computer and use it in GitHub Desktop.
Save shalomb/eb3118f3aced60da8ef8302cb6a186bb to your computer and use it in GitHub Desktop.
Terraform DNS Lookup
# Configure the jq provider
terraform {
required_providers {
jq = {
source = "massdriver-cloud/jq"
version = "0.2.0"
}
}
}
provider "jq" {}
data "http" "api_gw_dnsinfo" {
url = "https://networkcalc.com/api/dns/lookup/foobar.execute-api.us-east-1.amazonaws.com"
method = "GET"
# Optional request headers
request_headers = {
Accept = "application/json"
}
}
output "api_gw_dnsinfo" {
value = data.http.api_gw_dnsinfo
}
data "jq_query" "a_records" {
data = data.http.api_gw_dnsinfo.response_body
query = "[.records.A[].address]"
}
output "api_gw_a_records" {
value = data.jq_query.a_records
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment