-
Notifications
You must be signed in to change notification settings - Fork 94
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
Document upgrade path for blocks #281
Comments
Hi @abergmeier 👋 Thank you for raising this and apologies for the lack of clarity around this. We are hoping that there will be a canonical terraform-plugin-sdk/v2 to terraform-plugin-framework migration guide created that explains some of the details of this process at a code level, we are just waiting for the framework code to solidify some more before doing so. In the meantime though, it sounds like you might be looking for Something like the following might get you close in your ResourceType GetSchema method: tfsdk.Schema{
// ... potentially other Attributes, etc. fields ...
Blocks: map[string]tfsdk.Block{
"driver": {
NestingMode: tfsdk.BlockNestingModeSet,
Required: true,
Attributes: driverAttributes,
},
},
}, Does this help in your situation? Thanks again for creating this issue. |
@abergmeier gentle ping about the above. |
Thanks for clarifying this. It indeed let me make this work. As a sidenote: |
https://github.com/hashicorp/terraform-plugin-framework/blob/main/docs/design/blocks.md describes it a little, but overall the Terraform CLI maintainers have determined that the practitioner experience is much better when working with attributes over blocks for a few reasons:
I would love to hear more about your experience here. Attributes in this framework can implement validation for any attribute type. We are hoping to have common use case validators built as part of #240. |
I would have to look into that again. IIRC it mostly failed since default support for attributes was not there/lacking. |
Personally I’d be sad to see blocks go. I get the above statements about repeatability being confusing for newcomers, but from my experience training colleagues, it’s not a big hurdle. For large configuration sets, lots of for loops tend to be broken into intermediate values using locals and then merged to create a final object/map/set which in contrast is a whole lot less cleaner than the block configuration style. |
An initial sdk/v2 to framework schema block migration guide has been published: https://www.terraform.io/plugin/framework/migrating/attributes-blocks/blocks 👍 Blocks were un-deprecated awhile ago and will have first-class support at least through version 1 of this framework. |
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. |
Module version
Use-cases
I have a provider (buildx), that I want to upgrade from SDKv2 to framework.
Now I am stuck because I cannot seem to get the following to work:
Error is:
Attempted Solutions
My naive approach was to define it as:
Proposal
I am not sure whether there is some doc that I have not found yet or whether this needs to be documented.
References
The text was updated successfully, but these errors were encountered: