Created
August 14, 2024 11:34
-
-
Save shalomb/eb3118f3aced60da8ef8302cb6a186bb to your computer and use it in GitHub Desktop.
Terraform DNS Lookup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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