Skip to content

Ability to override the Host with request headers #79

@niroz89

Description

@niroz89

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions