Git Product home page Git Product logo

Comments (8)

bflad avatar bflad commented on August 24, 2024 2

This feels like a redux of this recent core issue hashicorp/terraform#30823 and pull request hashicorp/terraform#30830 -- it seems valuable to raise an issue upstream to see if Terraform core can actually ignore data source prior state in this situation, if its being consulted for plan generation.

from terraform-provider-http.

pascal-hofmann avatar pascal-hofmann commented on August 24, 2024 1

I was able to create a minimal test case for this.

It only happens if the deprecated body attribute has still been used in the last apply with terraform-provider-http 2.x.

If you then upgrade to 3.0.0, it will fail with:

╷
│ Error: Unsupported attribute
│
│   on main.tf line 15, in resource "local_file" "this":
│   15:   content  = data.http.this.body
│
│ This object has no argument, nested block, or exported attribute named "body".

Workaround: Switch to using response_body prior to upgrading to terraform-provider-http 3.

Test case:

terraform {
  required_providers {
    http = {
      source  = "hashicorp/http"
      version = "<3" # comment after first apply, run terrform init -upgrade, change body to response_body and apply again
    }
  }
}

data "http" "this" {
  url = "https://www.hashicorp.com"
}

resource "local_file" "this" {
  content  = data.http.this.body
  filename = "${path.module}/hashicorp.com.html"
}

I'll close this issue.

from terraform-provider-http.

bflad avatar bflad commented on August 24, 2024 1

By the way, there is no concept of state upgrades for data sources. There is only the UpgradeResourceState RPC that is used with managed resources. The prior data source state is only supposed to be "informative" for plan generation.

from terraform-provider-http.

pascal-hofmann avatar pascal-hofmann commented on August 24, 2024

See #140 / #142

from terraform-provider-http.

pascal-hofmann avatar pascal-hofmann commented on August 24, 2024

I'm looking into this. Will try to create a PR today.

from terraform-provider-http.

bendbennett avatar bendbennett commented on August 24, 2024

Hi @pascal-hofmann sorry you ran into trouble here.

Could you possibly post a complete example of the terraform code you are using along with the version of the http provider that you are/were using prior to upgrading to v3.0.0?

Are you trying to use the body attribute somewhere in your configuration?
Reason I ask is that the body attribute has been removed in v3.0.0 and replaced by response_body so I'm wondering if this is part of the issue?

from terraform-provider-http.

pascal-hofmann avatar pascal-hofmann commented on August 24, 2024

This is the issue. data resources are also persisted to state. When the schema changes, a state upgrader is required. I'm currently working on a PR. I'm just getting used to the new framework instead of sdk.

from terraform-provider-http.

pascal-hofmann avatar pascal-hofmann commented on August 24, 2024

@bendbennett I think currently the framework does not support state upgraders for data sources. :(

@bflad Do you have an idea, how to handle this case?

In the meantime I think I'll pin the provider version to 2. (I don't want to fix the state manually, because we have a lot of these data sources in a lot of states.)

from terraform-provider-http.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.