alekc / blog-comments

Repo for blog comments from utterance
1 stars 0 forks source link

posts/use-terraform-http-data-source-for-cluster-health-check/ #2

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Use terraform http data source to wait for cluster coming up - Alekc's Blog

Neat example of how we can use terraform http data source to wait for our kubernetes cluster to come up with a healthy state (shamelessly taken from some github repo)

https://blog.alekc.org/posts/use-terraform-http-data-source-for-cluster-health-check/

AgustinRamiroDiaz commented 1 year ago

Nice post!

I'm not able to find the "timeout" parameter though. Which terraform module version are you using?

alekc commented 1 year ago

Ok, this is weird.... You are right, there is no support currently for the timeout in the official http provider (from Hashicorp), however it's available from another one.

terraform {
    required_version    = ">= 0.13.1"

    required_providers {
        http = {
            source      = "terraform-aws-modules/http"
            version     =   ">= 2.4.1"
        }
    }
}
data "http" "example" {
  url = "https://checkpoint-api.hashicorp.com/v1/check/terraform"
  timeout = 3000

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

Also as a good news, the https://github.com/hashicorp/terraform-provider-http/issues/149 has been merged, so you should expect native support for request timeout and retry in hashicorp http starting with version 3.3.0

AgustinRamiroDiaz commented 1 year ago

Thanks a lot! You can close this one :D