You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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 ?
Terraform CLI and Provider Versions
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 offollow_redirects
to make it obvious the default behaviour is to follow redirects, and setting the option totrue
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
ishttp://example.org
which returns HTTP 200 OKstatus_code
is200
location
ishttp://example.org
Example 2
url
ishttp://example.org
which returns HTTP 302 Found and Location of/redirected
no_follow_redirects
isfalse
<-- provider makes another request -->
status_code
is200
location
ishttp://example.org/redirected
Example 3
url
ishttp://example.org
which returns HTTP 302 Found and Location of/redirected
no_follow_redirects
istrue
status_code
is302
location
ishttp://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
The text was updated successfully, but these errors were encountered: