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
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_redirectsto explicitly disable HTTP redirection and instead return the response of the first HTTP request made.no_follow_redirectsinstead offollow_redirectsto make it obvious the default behaviour is to follow redirects, and setting the option totruedisables this behaviour.I also propose that it adds an output named
locationthat 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
locationattribute is the absolute URL of the Location header value relative to the request that made the final HTTP request.Example 1
urlishttp://example.orgwhich returns HTTP 200 OKstatus_codeis200locationishttp://example.orgExample 2
urlishttp://example.orgwhich returns HTTP 302 Found and Location of/redirectedno_follow_redirectsisfalse<-- provider makes another request -->
status_codeis200locationishttp://example.org/redirectedExample 3
urlishttp://example.orgwhich returns HTTP 302 Found and Location of/redirectedno_follow_redirectsistruestatus_codeis302locationishttp://example.org/redirectedHow 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