hashicorp / terraform-plugin-framework

A next-generation framework for building Terraform providers.
https://developer.hashicorp.com/terraform/plugin/framework
Mozilla Public License 2.0
304 stars 93 forks source link

The provider "X" does not support moved operations across resource types and providers #1039

Closed grongor closed 1 month ago

grongor commented 2 months ago

I've spent several hours trying to figure out why I can't use the moved block with my provider...and I'm quite sure the reason is that nobody actually bothered to test this functionality before. I may be wrong, but...PR #1038 fixes it. Also see https://github.com/hashicorp/terraform-plugin-go/pull/432.

Module version

v1.11.0

Relevant provider source code

func (r *MyResource) MoveState(ctx context.Context) []resource.StateMover {
    panic("this never gets executed")
}

Terraform Configuration Files

moved {
  from = my_old_resource.lorem
  to   = my_resource.ipsum
}

Debug Output

I think it's not relevant

Expected Behavior

I'd expect to see a panic...or to be more precise, I'd expect that terraform plan would execute the MoveState method of my providers resource.

Actual Behavior

│ Error: Unsupported `moved` across resource types
│
│   on main.tf line 135:
│  135: moved {
│
│ The provider "X" does not support moved operations across resource types and providers.

Steps to Reproduce

Try implement the move in your provider.

References

https://github.com/hashicorp/terraform-plugin-framework/pull/1038 https://github.com/hashicorp/terraform-plugin-go/pull/432

pascal-hofmann commented 1 month ago

I just ran into the same issue. Thanks for your work @grongor.

Would be great to get this fixed or to get some documentation in case we are missing something here.

austinvalle commented 1 month ago

Hey all 👋🏻, that definitely is a bug in framework, I'll take a look at the PRs soon. Not sure how this was missed, but I'd guess there aren't a ton of usages of MoveResource outside of the major providers (aws mostly), which all rely on terraform-plugin-mux that has it's own surfacing of capabilities.

Regardless, we'll get this fixed and release a patch fix for framework + plugin-go sometime this week.

pascal-hofmann commented 1 month ago

Awesome, thanks for the quick reaction!

austinvalle commented 1 month ago

The fix has been merged (alongside additional logging that will be released in a new version of terraform-plugin-go) and will be released later this week.

For development, if you'd like to test out the changes before that:

go get -u github.com/hashicorp/terraform-plugin-go@94d8cc586c2073a1206149acde3768d35b9e77b7
go get -u github.com/hashicorp/terraform-plugin-framework@ba1098a5813d88ab817ba1c8d70a6d1b58793660

go mod tidy

Note that both Go modules will also be updated to require minimum Go 1.22, so you may also need to bump your Go version for your provider


Thanks to @grongor for the PRs! 🎸