Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Resource Object for POST/PUT Methods #241

Closed
1 task done
hikerspath opened this issue Mar 1, 2023 · 3 comments
Closed
1 task done

Feature Request: Resource Object for POST/PUT Methods #241

hikerspath opened this issue Mar 1, 2023 · 3 comments

Comments

@hikerspath
Copy link

Terraform CLI and Provider Versions

0.12+

Use Cases or Problem Statement

So datasources are read during the 'Refreshing state' phase of both plan and apply so that the data that they are given is available through the remainder of the runtime. This prevents pushing configuration into API's only during an apply phase, to build / configure something for an API that has no provider.

Proposal

Creation of a resource type object that would afford the ability to interact with virtually ANY api through paths and variables to build a resource. Given that the resource would store the json outputs in the state file then configuration could be built for any API (not just those which have a first-class provider).

How much impact is this issue causing?

Medium

Additional Information

For instance, I run a grafana instance using the kubernetes provider. It would be super cool to have a resource based trigger that would trigger the reload URL:

// Possible clean re-load of a datasource change
// https://grafana.com/docs/grafana/v8.1/http_api/admin/#reload-provisioning-configurations
data "http" "config_reload" {
  url    = "https://grafana-poc.meltwater.io/api/admin/provisioning/datasources/reload"
  method = "POST"
  
  request_headers = {
    "x-config-sha" = sha256(jsonencode(kubernetes_config_map.grafana-config.data)),
    Accept = "application/json"
  }
  
  lifecycle {
    postcondition {
      condition = contains(["config reloaded"], data.http.config_reload.response_body)
      message   = "Invalid response given during reload: ${data.http.config_reload.response_body}..."
    }
  }
}

Unfortunately, while the above does "work" it triggers before any of the changes are applied and does not help interact with the changes to the config (even though I think we found a creative way of causing the resource to "change". This type of action can only be accomplished in a resource.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@hikerspath hikerspath changed the title Resource Object for POST/PUT Methods Feature Request: Resource Object for POST/PUT Methods Mar 1, 2023
rovangju added a commit to rovangju/terraform-provider-http that referenced this issue Jul 19, 2023
rovangju added a commit to rovangju/terraform-provider-http that referenced this issue Jul 19, 2023
rovangju added a commit to rovangju/terraform-provider-http that referenced this issue Jul 19, 2023
@sean-freeman
Copy link

Link this GH Issue to fix in PR #298

@bendbennett
Copy link
Contributor

bendbennett commented Feb 20, 2024

@hikerspath thank you for opening this issue.

As described in the responses to #298, the http data source, and more broadly, the scope of the http provider is intended to be limited to operations that do not perform any mutation. Consequently, introduction of a resource, which would allow mutation of the target would be outside of this scope. Unfortunately, this means that we are unable to consider your proposal at this time. Perhaps the restapi provider might prove to be a suitable alternative, as the restapi_object resource allows POST, GET, PUT and DELETE operations.

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants