Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to override the Host with request headers #79

Open
niroz89 opened this issue Jun 23, 2024 · 0 comments
Open

Ability to override the Host with request headers #79

niroz89 opened this issue Jun 23, 2024 · 0 comments

Comments

@niroz89
Copy link

niroz89 commented Jun 23, 2024

Terraform Version

Terraform v1.7.0

Terracurl does not provide an option to override the Host using Host header, similar to curl.

Terraform Configuration Files

data "terracurl_request" "home" {
    name   = "home"
    url    = "https://d2mxderzerczer.cloudfront.net"
    method = "GET"

    headers = {
      "Host"               = "www.example.com"
    }

    response_codes = [
      200,
    ]
    max_retry      = 1
    retry_interval = 3
  }

Origin has host header checks and return 400 Bad request if wrong host is provided.

Expected Behavior

Since the header overrides Host with correct value, should return 200.

Actual Behavior

Returns 400.

Use case

My use case is, I'm adding an end to end test using terraform checks to validate the response codes and headers.

check "home_page" {
  data "terracurl_request" "home" {
    name   = "home"
    url    = "https://d2mxderzerczer.cloudfront.net"
    method = "GET"

    headers = {
      "Host"               = "www.example.com"
    }

    response_codes = [
      200,
    ]
    max_retry      = 1
    retry_interval = 3
  }

  assert {
    condition     = data.terracurl_request.home.status_code == 200
    error_message = "${data.terracurl_request.home.url} returned an unhealthy status code"
  }
}

References

This issue is similar to the http provider issue. hashicorp/terraform-provider-http#311

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant