terraform-provider-http
terraform-provider-http copied to clipboard
Do not follow HTTP redirects
Terraform CLI and Provider Versions
terraform version
Terraform v1.2.6
on darwin_amd64
Use Cases or Problem Statement
The current version of this provider does not expose an option to not implictly follow HTTP redirects.
It also does not document the behaviour of HTTP redirection, as highlighted in #60.
In my use-case, I would like to use this module to call an HTTP server with some specific headers, such as Authorization. This server will then respond with a S3 URL which I would like to pass to another module that I do not want to propagate the origin server-specific request headers to.
Proposal
I propose that the provider adds the option no_follow_redirects
to explicitly disable HTTP redirection and instead return the response of the first HTTP request made.
no_follow_redirects
instead of follow_redirects
to make it obvious the default behaviour is to follow redirects, and setting the option to true
disables this behaviour.
I also propose that it adds an output named location
that describes the absolute URL of the request that made the final response returned by the provider.
In the case that the server responds with a Location header, the location
attribute is the absolute URL of the Location header value relative to the request that made the final HTTP request.
Example 1
url
is http://example.org
which returns HTTP 200 OK
status_code
is 200
location
is http://example.org
Example 2
url
is http://example.org
which returns HTTP 302 Found and Location of /redirected
no_follow_redirects
is false
<-- provider makes another request -->
status_code
is 200
location
is http://example.org/redirected
Example 3
url
is http://example.org
which returns HTTP 302 Found and Location of /redirected
no_follow_redirects
is true
status_code
is 302
location
is http://example.org/redirected
How much impact is this issue causing?
Medium
Additional Information
I have written an implementation of this proposal at https://github.com/relvacode/terraform-provider-http/tree/feature/explicit-follow-redirects
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
I also want this, 100% a very useful feature to have!
+1 Would also love to see this merged!!
+1 to this as well - would be very useful in my use case!
I've investigated the proposal implementation provided by relvacode and tested it out. I have found that all that's really missing is a "Location" in the struct. By setting the http { METHOD = "HEAD" } and having a Location output defined, I'm receiving the "Location" response which includes the Token from the header (which is typically found in the 302 redirect).
Would it be acceptable for me to submit a PR towards these changes ?
+1