Skip to content

Do not follow HTTP redirects #170

@relvacode

Description

@relvacode

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

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions